mirror of
https://github.com/wiosna-dev/common-library.git
synced 2026-03-12 09:31:51 +01:00
PHP Coding Standards Fixer > fix coding standard
This commit is contained in:
@@ -19,6 +19,9 @@ use Meritoo\Common\Type\OopVisibilityType;
|
||||
*
|
||||
* @author Meritoo <github@meritoo.pl>
|
||||
* @copyright Meritoo <http://www.meritoo.pl>
|
||||
*
|
||||
* @internal
|
||||
* @covers \Meritoo\Common\Collection\Collection
|
||||
*/
|
||||
class CollectionTest extends BaseTestCase
|
||||
{
|
||||
@@ -43,6 +46,24 @@ class CollectionTest extends BaseTestCase
|
||||
*/
|
||||
private $simpleElements;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
$this->simpleElements = [
|
||||
'lorem',
|
||||
'ipsum',
|
||||
123 => 'dolor',
|
||||
345 => 'sit',
|
||||
];
|
||||
|
||||
$this->emptyCollection = new Collection();
|
||||
$this->simpleCollection = new Collection($this->simpleElements);
|
||||
}
|
||||
|
||||
public function testEmptyCollection()
|
||||
{
|
||||
static::assertSame(0, $this->emptyCollection->count());
|
||||
@@ -502,22 +523,4 @@ class CollectionTest extends BaseTestCase
|
||||
new \DateTime('2001-01-01'),
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
$this->simpleElements = [
|
||||
'lorem',
|
||||
'ipsum',
|
||||
123 => 'dolor',
|
||||
345 => 'sit',
|
||||
];
|
||||
|
||||
$this->emptyCollection = new Collection();
|
||||
$this->simpleCollection = new Collection($this->simpleElements);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,12 +18,15 @@ use Meritoo\Common\Type\OopVisibilityType;
|
||||
*
|
||||
* @author Meritoo <github@meritoo.pl>
|
||||
* @copyright Meritoo <http://www.meritoo.pl>
|
||||
*
|
||||
* @internal
|
||||
* @covers \Meritoo\Common\Exception\Base\UnknownTypeException
|
||||
*/
|
||||
class UnknownTypeExceptionTest extends BaseTestCase
|
||||
{
|
||||
public function testConstructorVisibilityAndArguments()
|
||||
{
|
||||
static::assertConstructorVisibilityAndArguments(UnknownTestTypeException::class, OopVisibilityType::IS_PUBLIC, 3);
|
||||
static::assertConstructorVisibilityAndArguments(UnknownTypeException::class, OopVisibilityType::IS_PUBLIC, 3);
|
||||
}
|
||||
|
||||
public function testWithoutException()
|
||||
@@ -46,9 +49,9 @@ class UnknownTypeExceptionTest extends BaseTestCase
|
||||
*/
|
||||
class TestType extends BaseType
|
||||
{
|
||||
const TEST_1 = 'test_1';
|
||||
public const TEST_1 = 'test_1';
|
||||
|
||||
const TEST_2 = 'test_2';
|
||||
public const TEST_2 = 'test_2';
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -56,6 +59,9 @@ class TestType extends BaseType
|
||||
*
|
||||
* @author Meritoo <github@meritoo.pl>
|
||||
* @copyright Meritoo <http://www.meritoo.pl>
|
||||
*
|
||||
* @internal
|
||||
* @covers \Meritoo\Common\Exception\Base\UnknownTypeException
|
||||
*/
|
||||
class UnknownTestTypeException extends UnknownTypeException
|
||||
{
|
||||
@@ -67,10 +73,7 @@ class UnknownTestTypeException extends UnknownTypeException
|
||||
*/
|
||||
public static function createException($unknownType)
|
||||
{
|
||||
/* @var UnknownTestTypeException $exception */
|
||||
$exception = parent::create($unknownType, new TestType(), 'type of something used for testing');
|
||||
|
||||
return $exception;
|
||||
return parent::create($unknownType, new TestType(), 'type of something used for testing');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -17,6 +17,9 @@ use Meritoo\Common\Type\OopVisibilityType;
|
||||
*
|
||||
* @author Meritoo <github@meritoo.pl>
|
||||
* @copyright Meritoo <http://www.meritoo.pl>
|
||||
*
|
||||
* @internal
|
||||
* @covers \Meritoo\Common\Exception\Bundle\IncorrectBundleNameException
|
||||
*/
|
||||
class IncorrectBundleNameExceptionTest extends BaseTestCase
|
||||
{
|
||||
|
||||
@@ -19,6 +19,9 @@ use Meritoo\Common\Type\OopVisibilityType;
|
||||
*
|
||||
* @author Meritoo <github@meritoo.pl>
|
||||
* @copyright Meritoo <http://www.meritoo.pl>
|
||||
*
|
||||
* @internal
|
||||
* @covers \Meritoo\Common\Exception\Type\UnknownDatePartTypeException
|
||||
*/
|
||||
class UnknownDatePartTypeExceptionTest extends BaseTestCase
|
||||
{
|
||||
|
||||
@@ -18,6 +18,9 @@ use Meritoo\Common\Type\OopVisibilityType;
|
||||
*
|
||||
* @author Meritoo <github@meritoo.pl>
|
||||
* @copyright Meritoo <http://www.meritoo.pl>
|
||||
*
|
||||
* @internal
|
||||
* @covers \Meritoo\Common\Exception\File\EmptyFileException
|
||||
*/
|
||||
class EmptyFileExceptionTest extends BaseTestCase
|
||||
{
|
||||
|
||||
@@ -17,6 +17,9 @@ use Meritoo\Common\Type\OopVisibilityType;
|
||||
*
|
||||
* @author Meritoo <github@meritoo.pl>
|
||||
* @copyright Meritoo <http://www.meritoo.pl>
|
||||
*
|
||||
* @internal
|
||||
* @covers \Meritoo\Common\Exception\File\EmptyFilePathException
|
||||
*/
|
||||
class EmptyFilePathExceptionTest extends BaseTestCase
|
||||
{
|
||||
|
||||
@@ -18,6 +18,9 @@ use Meritoo\Common\Type\OopVisibilityType;
|
||||
*
|
||||
* @author Meritoo <github@meritoo.pl>
|
||||
* @copyright Meritoo <http://www.meritoo.pl>
|
||||
*
|
||||
* @internal
|
||||
* @covers \Meritoo\Common\Exception\File\NotExistingFileException
|
||||
*/
|
||||
class NotExistingFileExceptionTest extends BaseTestCase
|
||||
{
|
||||
|
||||
@@ -18,6 +18,9 @@ use Meritoo\Common\Type\OopVisibilityType;
|
||||
*
|
||||
* @author Meritoo <github@meritoo.pl>
|
||||
* @copyright Meritoo <http://www.meritoo.pl>
|
||||
*
|
||||
* @internal
|
||||
* @covers \Meritoo\Common\Exception\Method\DisabledMethodException
|
||||
*/
|
||||
class DisabledMethodExceptionTest extends BaseTestCase
|
||||
{
|
||||
|
||||
@@ -18,6 +18,9 @@ use Meritoo\Common\Type\OopVisibilityType;
|
||||
*
|
||||
* @author Meritoo <github@meritoo.pl>
|
||||
* @copyright Meritoo <http://www.meritoo.pl>
|
||||
*
|
||||
* @internal
|
||||
* @covers \Meritoo\Common\Exception\Reflection\CannotResolveClassNameException
|
||||
*/
|
||||
class CannotResolveClassNameExceptionTest extends BaseTestCase
|
||||
{
|
||||
|
||||
@@ -18,6 +18,9 @@ use Meritoo\Common\Type\OopVisibilityType;
|
||||
*
|
||||
* @author Meritoo <github@meritoo.pl>
|
||||
* @copyright Meritoo <http://www.meritoo.pl>
|
||||
*
|
||||
* @internal
|
||||
* @covers \Meritoo\Common\Exception\Reflection\MissingChildClassesException
|
||||
*/
|
||||
class MissingChildClassesExceptionTest extends BaseTestCase
|
||||
{
|
||||
|
||||
@@ -17,6 +17,9 @@ use Meritoo\Common\Type\OopVisibilityType;
|
||||
*
|
||||
* @author Meritoo <github@meritoo.pl>
|
||||
* @copyright Meritoo <http://www.meritoo.pl>
|
||||
*
|
||||
* @internal
|
||||
* @covers \Meritoo\Common\Exception\Reflection\NotExistingPropertyException
|
||||
*/
|
||||
class NotExistingPropertyExceptionTest extends BaseTestCase
|
||||
{
|
||||
|
||||
@@ -18,6 +18,9 @@ use Meritoo\Common\Type\OopVisibilityType;
|
||||
*
|
||||
* @author Meritoo <github@meritoo.pl>
|
||||
* @copyright Meritoo <http://www.meritoo.pl>
|
||||
*
|
||||
* @internal
|
||||
* @covers \Meritoo\Common\Exception\Reflection\TooManyChildClassesException
|
||||
*/
|
||||
class TooManyChildClassesExceptionTest extends BaseTestCase
|
||||
{
|
||||
|
||||
@@ -18,6 +18,9 @@ use Meritoo\Common\Type\OopVisibilityType;
|
||||
*
|
||||
* @author Meritoo <github@meritoo.pl>
|
||||
* @copyright Meritoo <http://www.meritoo.pl>
|
||||
*
|
||||
* @internal
|
||||
* @covers \Meritoo\Common\Exception\Regex\IncorrectColorHexLengthException
|
||||
*/
|
||||
class IncorrectColorHexLengthExceptionTest extends BaseTestCase
|
||||
{
|
||||
|
||||
@@ -18,6 +18,9 @@ use Meritoo\Common\Type\OopVisibilityType;
|
||||
*
|
||||
* @author Meritoo <github@meritoo.pl>
|
||||
* @copyright Meritoo <http://www.meritoo.pl>
|
||||
*
|
||||
* @internal
|
||||
* @covers \Meritoo\Common\Exception\Regex\InvalidColorHexValueException
|
||||
*/
|
||||
class InvalidColorHexValueExceptionTest extends BaseTestCase
|
||||
{
|
||||
|
||||
@@ -18,6 +18,9 @@ use Meritoo\Common\Type\OopVisibilityType;
|
||||
*
|
||||
* @author Meritoo <github@meritoo.pl>
|
||||
* @copyright Meritoo <http://www.meritoo.pl>
|
||||
*
|
||||
* @internal
|
||||
* @covers \Meritoo\Common\Exception\Regex\InvalidHtmlAttributesException
|
||||
*/
|
||||
class InvalidHtmlAttributesExceptionTest extends BaseTestCase
|
||||
{
|
||||
|
||||
@@ -18,6 +18,9 @@ use Meritoo\Common\Type\OopVisibilityType;
|
||||
*
|
||||
* @author Meritoo <github@meritoo.pl>
|
||||
* @copyright Meritoo <http://www.meritoo.pl>
|
||||
*
|
||||
* @internal
|
||||
* @covers \Meritoo\Common\Exception\Regex\InvalidUrlException
|
||||
*/
|
||||
class InvalidUrlExceptionTest extends BaseTestCase
|
||||
{
|
||||
|
||||
@@ -19,6 +19,9 @@ use Meritoo\Common\Type\OopVisibilityType;
|
||||
*
|
||||
* @author Meritoo <github@meritoo.pl>
|
||||
* @copyright Meritoo <http://www.meritoo.pl>
|
||||
*
|
||||
* @internal
|
||||
* @covers \Meritoo\Common\Exception\Type\UnknownOopVisibilityTypeException
|
||||
*/
|
||||
class UnknownOopVisibilityTypeExceptionTest extends BaseTestCase
|
||||
{
|
||||
|
||||
@@ -17,6 +17,9 @@ use Meritoo\Common\Type\OopVisibilityType;
|
||||
*
|
||||
* @author Meritoo <github@meritoo.pl>
|
||||
* @copyright Meritoo <http://www.meritoo.pl>
|
||||
*
|
||||
* @internal
|
||||
* @covers \Meritoo\Common\Exception\ValueObject\InvalidSizeDimensionsException
|
||||
*/
|
||||
class InvalidSizeDimensionsExceptionTest extends BaseTestCase
|
||||
{
|
||||
|
||||
@@ -19,6 +19,9 @@ use Meritoo\Common\Utilities\GeneratorUtility;
|
||||
*
|
||||
* @author Meritoo <github@meritoo.pl>
|
||||
* @copyright Meritoo <http://www.meritoo.pl>
|
||||
*
|
||||
* @internal
|
||||
* @covers \Meritoo\Common\Test\Base\BaseTestCase
|
||||
*/
|
||||
class BaseTestCaseTest extends BaseTestCase
|
||||
{
|
||||
@@ -67,16 +70,16 @@ class BaseTestCaseTest extends BaseTestCase
|
||||
$generator = (new SimpleTestCase())->provideDateTimeInstance();
|
||||
$generatedElements = GeneratorUtility::getGeneratorElements($generator);
|
||||
|
||||
/* @var DateTime $instance1 */
|
||||
/** @var DateTime $instance1 */
|
||||
$instance1 = $generatedElements[0][0];
|
||||
|
||||
/* @var DateTime $instance2 */
|
||||
/** @var DateTime $instance2 */
|
||||
$instance2 = $generatedElements[1][0];
|
||||
|
||||
/* @var DateTime $instance3 */
|
||||
/** @var DateTime $instance3 */
|
||||
$instance3 = $generatedElements[2][0];
|
||||
|
||||
/* @var DateTime $instance4 */
|
||||
/** @var DateTime $instance4 */
|
||||
$instance4 = $generatedElements[3][0];
|
||||
|
||||
self::assertCount(count($expectedElements), $generatedElements);
|
||||
@@ -170,6 +173,9 @@ class BaseTestCaseTest extends BaseTestCase
|
||||
*
|
||||
* @author Meritoo <github@meritoo.pl>
|
||||
* @copyright Meritoo <http://www.meritoo.pl>
|
||||
*
|
||||
* @internal
|
||||
* @coversNothing
|
||||
*/
|
||||
class SimpleTestCase extends BaseTestCase
|
||||
{
|
||||
|
||||
@@ -17,6 +17,9 @@ use Meritoo\Common\Type\Base\BaseType;
|
||||
*
|
||||
* @author Meritoo <github@meritoo.pl>
|
||||
* @copyright Meritoo <http://www.meritoo.pl>
|
||||
*
|
||||
* @internal
|
||||
* @covers \Meritoo\Common\Type\Base\BaseType
|
||||
*/
|
||||
class BaseTypeTest extends BaseTestCase
|
||||
{
|
||||
@@ -199,7 +202,7 @@ class TestEmptyType extends BaseType
|
||||
*/
|
||||
class TestType extends BaseType
|
||||
{
|
||||
const TEST_1 = 'test_1';
|
||||
public const TEST_1 = 'test_1';
|
||||
|
||||
const TEST_2 = 'test_2';
|
||||
public const TEST_2 = 'test_2';
|
||||
}
|
||||
|
||||
@@ -16,6 +16,9 @@ use Meritoo\Common\Type\DatePartType;
|
||||
*
|
||||
* @author Meritoo <github@meritoo.pl>
|
||||
* @copyright Meritoo <http://www.meritoo.pl>
|
||||
*
|
||||
* @internal
|
||||
* @covers \Meritoo\Common\Type\DatePartType
|
||||
*/
|
||||
class DatePartTypeTest extends BaseTypeTestCase
|
||||
{
|
||||
|
||||
@@ -19,6 +19,9 @@ use Meritoo\Common\Type\OopVisibilityType;
|
||||
*
|
||||
* @author Meritoo <github@meritoo.pl>
|
||||
* @copyright Meritoo <http://www.meritoo.pl>
|
||||
*
|
||||
* @internal
|
||||
* @covers \Meritoo\Common\Type\DatePeriod
|
||||
*/
|
||||
class DatePeriodTest extends BaseTypeTestCase
|
||||
{
|
||||
@@ -151,9 +154,7 @@ class DatePeriodTest extends BaseTypeTestCase
|
||||
$startDate = new DateTime('2001-01-01');
|
||||
$endDate = new DateTime('2002-02-02');
|
||||
|
||||
/*
|
||||
* For start date
|
||||
*/
|
||||
// For start date
|
||||
yield[
|
||||
new DatePeriod($startDate, $endDate),
|
||||
'Y',
|
||||
@@ -182,9 +183,7 @@ class DatePeriodTest extends BaseTypeTestCase
|
||||
'2001-01-01 00:00',
|
||||
];
|
||||
|
||||
/*
|
||||
* For end date
|
||||
*/
|
||||
// For end date
|
||||
yield[
|
||||
new DatePeriod($startDate, $endDate),
|
||||
'Y',
|
||||
|
||||
@@ -18,6 +18,9 @@ use Meritoo\Test\Common\Utilities\Arrays\SimpleToString;
|
||||
*
|
||||
* @author Meritoo <github@meritoo.pl>
|
||||
* @copyright Meritoo <http://www.meritoo.pl>
|
||||
*
|
||||
* @internal
|
||||
* @covers \Meritoo\Common\Utilities\Arrays
|
||||
*/
|
||||
class ArraysTest extends BaseTestCase
|
||||
{
|
||||
@@ -27,6 +30,132 @@ class ArraysTest extends BaseTestCase
|
||||
private $complexArray;
|
||||
private $superComplexArray;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
$this->simpleArray = [
|
||||
'Lorem',
|
||||
'ipsum',
|
||||
'dolor',
|
||||
'sit',
|
||||
'amet',
|
||||
];
|
||||
|
||||
$this->simpleArrayWithKeys = [
|
||||
'Lorem' => 'ipsum',
|
||||
'dolor' => 'sit',
|
||||
'amet' => 'consectetur',
|
||||
];
|
||||
|
||||
$this->twoDimensionsArray = [
|
||||
[
|
||||
'lorem',
|
||||
'ipsum',
|
||||
'dolor',
|
||||
'sit',
|
||||
'amet',
|
||||
],
|
||||
[
|
||||
'consectetur',
|
||||
'adipiscing',
|
||||
'elit',
|
||||
],
|
||||
[
|
||||
'donec',
|
||||
'sagittis',
|
||||
'fringilla',
|
||||
'eleifend',
|
||||
],
|
||||
];
|
||||
|
||||
$this->complexArray = [
|
||||
'lorem' => [
|
||||
'ipsum' => [
|
||||
'dolor' => 'sit',
|
||||
'diam' => [
|
||||
'non' => 'egestas',
|
||||
],
|
||||
],
|
||||
],
|
||||
'consectetur' => 'adipiscing',
|
||||
'mollis' => 1234,
|
||||
2 => [],
|
||||
'sit' => [
|
||||
'nullam' => 'donec',
|
||||
'aliquet' => [
|
||||
'vitae' => [
|
||||
'ligula' => 'quis',
|
||||
],
|
||||
],
|
||||
'elit',
|
||||
],
|
||||
'amet' => [
|
||||
'iaculis',
|
||||
'primis',
|
||||
],
|
||||
];
|
||||
|
||||
$this->superComplexArray = [
|
||||
'ipsum' => [
|
||||
'quis' => [
|
||||
'vestibulum' => [
|
||||
'porta-1' => [
|
||||
'turpis',
|
||||
'urna',
|
||||
],
|
||||
'porta-2' => [
|
||||
'tortor' => [
|
||||
'in' => [
|
||||
'dui',
|
||||
'dolor' => [
|
||||
'aliquam',
|
||||
],
|
||||
],
|
||||
],
|
||||
],
|
||||
'porta-3' => [
|
||||
1,
|
||||
2,
|
||||
3,
|
||||
],
|
||||
],
|
||||
],
|
||||
],
|
||||
'primis' => [
|
||||
[
|
||||
'in',
|
||||
'faucibus',
|
||||
'orci',
|
||||
],
|
||||
[
|
||||
'luctus',
|
||||
'et',
|
||||
'ultrices',
|
||||
],
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function tearDown(): void
|
||||
{
|
||||
parent::tearDown();
|
||||
|
||||
unset(
|
||||
$this->simpleArray,
|
||||
$this->simpleArrayWithKeys,
|
||||
$this->twoDimensionsArray,
|
||||
$this->complexArray,
|
||||
$this->superComplexArray
|
||||
);
|
||||
}
|
||||
|
||||
public function testConstructor()
|
||||
{
|
||||
static::assertHasNoConstructor(Arrays::class);
|
||||
@@ -136,7 +265,8 @@ class ArraysTest extends BaseTestCase
|
||||
self::assertSame($expected, Arrays::values2csv($array, $separator), $description);
|
||||
self::assertSame('', Arrays::values2csv($this->simpleArray), 'Simple array');
|
||||
|
||||
self::assertSame("lorem,ipsum,dolor,sit,amet\n"
|
||||
self::assertSame(
|
||||
"lorem,ipsum,dolor,sit,amet\n"
|
||||
. "consectetur,adipiscing,elit\n"
|
||||
. 'donec,sagittis,fringilla,eleifend',
|
||||
Arrays::values2csv($this->twoDimensionsArray),
|
||||
@@ -146,14 +276,10 @@ class ArraysTest extends BaseTestCase
|
||||
|
||||
public function testGetFirstKey()
|
||||
{
|
||||
/*
|
||||
* Negative cases
|
||||
*/
|
||||
// Negative cases
|
||||
self::assertNull(Arrays::getFirstKey([]));
|
||||
|
||||
/*
|
||||
* Positive cases
|
||||
*/
|
||||
// Positive cases
|
||||
self::assertEquals(0, Arrays::getFirstKey($this->simpleArray));
|
||||
self::assertEquals('lorem', Arrays::getFirstKey($this->complexArray));
|
||||
}
|
||||
@@ -167,14 +293,10 @@ class ArraysTest extends BaseTestCase
|
||||
|
||||
public function testGetFirstElement()
|
||||
{
|
||||
/*
|
||||
* Negative cases
|
||||
*/
|
||||
// Negative cases
|
||||
self::assertNull(Arrays::getFirstElement([]));
|
||||
|
||||
/*
|
||||
* Positive cases
|
||||
*/
|
||||
// Positive cases
|
||||
self::assertEquals('Lorem', Arrays::getFirstElement($this->simpleArray));
|
||||
self::assertEquals('Lorem', Arrays::getFirstElement($this->simpleArray));
|
||||
self::assertEquals('lorem', Arrays::getFirstElement($this->twoDimensionsArray, false));
|
||||
@@ -191,14 +313,10 @@ class ArraysTest extends BaseTestCase
|
||||
|
||||
public function testGetLastElement()
|
||||
{
|
||||
/*
|
||||
* Negative cases
|
||||
*/
|
||||
// Negative cases
|
||||
self::assertNull(Arrays::getLastElement([]));
|
||||
|
||||
/*
|
||||
* Positive cases
|
||||
*/
|
||||
// Positive cases
|
||||
self::assertEquals('amet', Arrays::getLastElement($this->simpleArray));
|
||||
self::assertEquals('eleifend', Arrays::getLastElement($this->twoDimensionsArray, false));
|
||||
self::assertEquals('primis', Arrays::getLastElement($this->complexArray, false));
|
||||
@@ -222,14 +340,10 @@ class ArraysTest extends BaseTestCase
|
||||
|
||||
public function testGetLastRow()
|
||||
{
|
||||
/*
|
||||
* Negative cases
|
||||
*/
|
||||
// Negative cases
|
||||
self::assertNull(Arrays::getLastRow([]));
|
||||
|
||||
/*
|
||||
* Positive cases
|
||||
*/
|
||||
// Positive cases
|
||||
self::assertEquals([], Arrays::getLastRow($this->simpleArray));
|
||||
self::assertEquals([], Arrays::getLastRow($this->simpleArrayWithKeys));
|
||||
|
||||
@@ -275,14 +389,10 @@ class ArraysTest extends BaseTestCase
|
||||
|
||||
public function testArray2JavaScript()
|
||||
{
|
||||
/*
|
||||
* Negative cases
|
||||
*/
|
||||
// Negative cases
|
||||
self::assertNull(Arrays::array2JavaScript([]));
|
||||
|
||||
/*
|
||||
* Positive cases
|
||||
*/
|
||||
// Positive cases
|
||||
self::assertEquals('new Array(\'Lorem\', \'ipsum\', \'dolor\', \'sit\', \'amet\');', Arrays::array2JavaScript($this->simpleArray));
|
||||
self::assertEquals('var letsTest = new Array(\'Lorem\', \'ipsum\', \'dolor\', \'sit\', \'amet\');', Arrays::array2JavaScript($this->simpleArray, 'letsTest'));
|
||||
|
||||
@@ -350,7 +460,7 @@ letsTest[2] = value_2;';
|
||||
|
||||
/**
|
||||
* @param string $description Description of test case
|
||||
* @param array|null $expected Expected new array (with quoted elements)
|
||||
* @param null|array $expected Expected new array (with quoted elements)
|
||||
* @param array $array The array to check for string values
|
||||
*
|
||||
* @dataProvider provideArrayToQuoteStrings
|
||||
@@ -365,9 +475,7 @@ letsTest[2] = value_2;';
|
||||
$array = $this->simpleArray;
|
||||
$string = 'Lorem ipsum';
|
||||
|
||||
/*
|
||||
* Removing first element
|
||||
*/
|
||||
// Removing first element
|
||||
self::assertSame([
|
||||
0 => 'Lorem',
|
||||
1 => 'ipsum',
|
||||
@@ -376,9 +484,7 @@ letsTest[2] = value_2;';
|
||||
], Arrays::removeMarginalElement($array));
|
||||
self::assertEquals('Lorem ipsu', Arrays::removeMarginalElement($string));
|
||||
|
||||
/*
|
||||
* Removing last element
|
||||
*/
|
||||
// Removing last element
|
||||
self::assertSame([
|
||||
1 => 'ipsum',
|
||||
2 => 'dolor',
|
||||
@@ -489,14 +595,10 @@ letsTest[2] = value_2;';
|
||||
|
||||
public function testGetNonArrayElementsCount()
|
||||
{
|
||||
/*
|
||||
* Negative cases
|
||||
*/
|
||||
// Negative cases
|
||||
self::assertNull(Arrays::getNonArrayElementsCount([]));
|
||||
|
||||
/*
|
||||
* Positive cases
|
||||
*/
|
||||
// Positive cases
|
||||
self::assertEquals(5, Arrays::getNonArrayElementsCount($this->simpleArray));
|
||||
self::assertEquals(3, Arrays::getNonArrayElementsCount($this->simpleArrayWithKeys));
|
||||
self::assertEquals(12, Arrays::getNonArrayElementsCount($this->twoDimensionsArray));
|
||||
@@ -504,15 +606,11 @@ letsTest[2] = value_2;';
|
||||
|
||||
public function testString2array()
|
||||
{
|
||||
/*
|
||||
* Negative cases
|
||||
*/
|
||||
// Negative cases
|
||||
self::assertNull(Arrays::string2array(''));
|
||||
self::assertNull(Arrays::string2array(null));
|
||||
|
||||
/*
|
||||
* Positive cases
|
||||
*/
|
||||
// Positive cases
|
||||
$array = [
|
||||
'light' => '#fff',
|
||||
'dark' => '#000',
|
||||
@@ -534,9 +632,7 @@ letsTest[2] = value_2;';
|
||||
|
||||
public function testAreKeysInArray()
|
||||
{
|
||||
/*
|
||||
* Negative cases
|
||||
*/
|
||||
// Negative cases
|
||||
self::assertFalse(Arrays::areKeysInArray([], []));
|
||||
self::assertFalse(Arrays::areKeysInArray([null], $this->simpleArray));
|
||||
self::assertFalse(Arrays::areKeysInArray([''], $this->simpleArray));
|
||||
@@ -552,9 +648,7 @@ letsTest[2] = value_2;';
|
||||
self::assertFalse(Arrays::areKeysInArray($keys1, $this->complexArray));
|
||||
self::assertFalse(Arrays::areKeysInArray($keys1, $this->complexArray, false));
|
||||
|
||||
/*
|
||||
* Positive cases
|
||||
*/
|
||||
// Positive cases
|
||||
$keys12 = [
|
||||
2,
|
||||
'mollis',
|
||||
@@ -607,9 +701,7 @@ letsTest[2] = value_2;';
|
||||
|
||||
public function testGetLastElementsPathsUsingDefaults()
|
||||
{
|
||||
/*
|
||||
* Using default separator and other default arguments
|
||||
*/
|
||||
// Using default separator and other default arguments
|
||||
$expected = [
|
||||
'lorem.ipsum.dolor' => 'sit',
|
||||
'lorem.ipsum.diam.non' => 'egestas',
|
||||
@@ -628,9 +720,7 @@ letsTest[2] = value_2;';
|
||||
|
||||
public function testGetLastElementsPathsUsingCustomSeparator()
|
||||
{
|
||||
/*
|
||||
* Using custom separator
|
||||
*/
|
||||
// Using custom separator
|
||||
$separator = ' -> ';
|
||||
$expected = [
|
||||
sprintf('lorem%sipsum%sdolor', $separator, $separator) => 'sit',
|
||||
@@ -649,7 +739,7 @@ letsTest[2] = value_2;';
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string|array $stopIfMatchedBy Patterns of keys or paths that matched will stop the process of path
|
||||
* @param array|string $stopIfMatchedBy Patterns of keys or paths that matched will stop the process of path
|
||||
* building and including children of those keys or paths (recursive will
|
||||
* not be used for keys in lower level of given array)
|
||||
* @param string $separator Separator used in resultant strings. Default: ".".
|
||||
@@ -666,19 +756,13 @@ letsTest[2] = value_2;';
|
||||
{
|
||||
$pattern = '\d+';
|
||||
|
||||
/*
|
||||
* Empty array
|
||||
*/
|
||||
// Empty array
|
||||
self::assertFalse(Arrays::areAllKeysMatchedByPattern([], $pattern));
|
||||
|
||||
/*
|
||||
* Simple array with integers as keys only
|
||||
*/
|
||||
// Simple array with integers as keys only
|
||||
self::assertTrue(Arrays::areAllKeysMatchedByPattern($this->simpleArray, $pattern));
|
||||
|
||||
/*
|
||||
* Complex array with strings and integers as keys
|
||||
*/
|
||||
// Complex array with strings and integers as keys
|
||||
self::assertFalse(Arrays::areAllKeysMatchedByPattern($this->complexArray, $pattern));
|
||||
|
||||
$array = [
|
||||
@@ -686,33 +770,23 @@ letsTest[2] = value_2;';
|
||||
'c' => 'd',
|
||||
];
|
||||
|
||||
/*
|
||||
* Yet another simple array, but with strings as keys
|
||||
*/
|
||||
// Yet another simple array, but with strings as keys
|
||||
self::assertFalse(Arrays::areAllKeysMatchedByPattern($array, $pattern));
|
||||
|
||||
/*
|
||||
* The same array with another pattern
|
||||
*/
|
||||
// The same array with another pattern
|
||||
$pattern = '\w+';
|
||||
self::assertTrue(Arrays::areAllKeysMatchedByPattern($array, $pattern));
|
||||
|
||||
/*
|
||||
* The same array with mixed keys (strings and integers as keys)
|
||||
*/
|
||||
// The same array with mixed keys (strings and integers as keys)
|
||||
$array[1] = 'x';
|
||||
$pattern = '\d+';
|
||||
self::assertFalse(Arrays::areAllKeysMatchedByPattern($array, $pattern));
|
||||
|
||||
/*
|
||||
* Multidimensional array - negative case
|
||||
*/
|
||||
// Multidimensional array - negative case
|
||||
$array['e'] = ['f' => 'g'];
|
||||
self::assertFalse(Arrays::areAllKeysMatchedByPattern($array, $pattern));
|
||||
|
||||
/*
|
||||
* Multidimensional array - positive case
|
||||
*/
|
||||
// Multidimensional array - positive case
|
||||
unset($array[1]);
|
||||
$pattern = '\w+';
|
||||
self::assertTrue(Arrays::areAllKeysMatchedByPattern($array, $pattern));
|
||||
@@ -728,14 +802,10 @@ letsTest[2] = value_2;';
|
||||
|
||||
public function testIssetRecursive()
|
||||
{
|
||||
/*
|
||||
* Negative cases
|
||||
*/
|
||||
// Negative cases
|
||||
self::assertFalse(Arrays::issetRecursive([], []));
|
||||
|
||||
/*
|
||||
* Positive cases
|
||||
*/
|
||||
// Positive cases
|
||||
$unExistingKeys = [
|
||||
'a',
|
||||
'b',
|
||||
@@ -778,14 +848,10 @@ letsTest[2] = value_2;';
|
||||
|
||||
public function testGetValueByKeysPath()
|
||||
{
|
||||
/*
|
||||
* Negative cases
|
||||
*/
|
||||
// Negative cases
|
||||
self::assertNull(Arrays::getValueByKeysPath([], []));
|
||||
|
||||
/*
|
||||
* Positive cases
|
||||
*/
|
||||
// Positive cases
|
||||
self::assertNull(Arrays::getValueByKeysPath($this->simpleArray, []));
|
||||
self::assertEquals('ipsum', Arrays::getValueByKeysPath($this->simpleArray, [1]));
|
||||
self::assertEquals('sit', Arrays::getValueByKeysPath($this->simpleArray, [3]));
|
||||
@@ -839,14 +905,10 @@ letsTest[2] = value_2;';
|
||||
|
||||
public function testGetAllValuesOfKey()
|
||||
{
|
||||
/*
|
||||
* Positive case - 1-dimension array
|
||||
*/
|
||||
// Positive case - 1-dimension array
|
||||
self::assertEquals(['ipsum'], Arrays::getAllValuesOfKey($this->simpleArray, 1));
|
||||
|
||||
/*
|
||||
* Positive case - 2-dimensions array
|
||||
*/
|
||||
// Positive case - 2-dimensions array
|
||||
$effect = [
|
||||
[
|
||||
'lorem',
|
||||
@@ -861,14 +923,10 @@ letsTest[2] = value_2;';
|
||||
|
||||
self::assertEquals($effect, Arrays::getAllValuesOfKey($this->twoDimensionsArray, 0));
|
||||
|
||||
/*
|
||||
* Positive case - multi-dimensions array
|
||||
*/
|
||||
// Positive case - multi-dimensions array
|
||||
self::assertEquals(['primis'], Arrays::getAllValuesOfKey($this->complexArray, 1));
|
||||
|
||||
/*
|
||||
* Positive case - multi-dimensions array
|
||||
*/
|
||||
// Positive case - multi-dimensions array
|
||||
$effect = [
|
||||
0 => [
|
||||
'in' => [
|
||||
@@ -885,22 +943,16 @@ letsTest[2] = value_2;';
|
||||
|
||||
public function testKsortRecursive()
|
||||
{
|
||||
/*
|
||||
* Negative cases
|
||||
*/
|
||||
// Negative cases
|
||||
$array = [];
|
||||
self::assertNull(Arrays::ksortRecursive($array));
|
||||
|
||||
/*
|
||||
* Positive cases
|
||||
*/
|
||||
// Positive cases
|
||||
self::assertEquals($this->simpleArray, Arrays::ksortRecursive($this->simpleArray));
|
||||
self::assertEquals($this->simpleArray, Arrays::ksortRecursive($this->simpleArray, SORT_NUMERIC));
|
||||
self::assertEquals($this->twoDimensionsArray, Arrays::ksortRecursive($this->twoDimensionsArray));
|
||||
|
||||
/*
|
||||
* Positive case - multi-dimensions array
|
||||
*/
|
||||
// Positive case - multi-dimensions array
|
||||
$effect = [
|
||||
'amet' => [
|
||||
'iaculis',
|
||||
@@ -930,9 +982,7 @@ letsTest[2] = value_2;';
|
||||
|
||||
self::assertEquals($effect, Arrays::ksortRecursive($this->complexArray));
|
||||
|
||||
/*
|
||||
* Positive case - multi-dimensions array - with options of ksort() function
|
||||
*/
|
||||
// Positive case - multi-dimensions array - with options of ksort() function
|
||||
$effect = [
|
||||
2 => [],
|
||||
'amet' => [
|
||||
@@ -965,23 +1015,17 @@ letsTest[2] = value_2;';
|
||||
|
||||
public function testSetPositions()
|
||||
{
|
||||
/*
|
||||
* Negative cases
|
||||
*/
|
||||
// Negative cases
|
||||
self::assertNull(Arrays::setPositions([]));
|
||||
|
||||
/*
|
||||
* Positive case - 1-dimension array
|
||||
*/
|
||||
// Positive case - 1-dimension array
|
||||
$array = [
|
||||
'abc',
|
||||
];
|
||||
|
||||
self::assertEquals($array, Arrays::setPositions($array));
|
||||
|
||||
/*
|
||||
* Positive case - 2-dimensions array
|
||||
*/
|
||||
// Positive case - 2-dimensions array
|
||||
$effect = $this->twoDimensionsArray;
|
||||
$effect[0][Arrays::POSITION_KEY_NAME] = 1;
|
||||
$effect[1][Arrays::POSITION_KEY_NAME] = 2;
|
||||
@@ -989,9 +1033,7 @@ letsTest[2] = value_2;';
|
||||
|
||||
self::assertEquals($effect, Arrays::setPositions($this->twoDimensionsArray));
|
||||
|
||||
/*
|
||||
* Positive case - multi-level array
|
||||
*/
|
||||
// Positive case - multi-level array
|
||||
$array = [
|
||||
'lorem',
|
||||
'ipsum' => [
|
||||
@@ -1034,9 +1076,7 @@ letsTest[2] = value_2;';
|
||||
|
||||
self::assertEquals($effect, Arrays::setPositions($array));
|
||||
|
||||
/*
|
||||
* Positive case - non-default name of key with position value & 2-dimensions array
|
||||
*/
|
||||
// Positive case - non-default name of key with position value & 2-dimensions array
|
||||
$keyName = 'level';
|
||||
$effect = $this->twoDimensionsArray;
|
||||
|
||||
@@ -1046,9 +1086,7 @@ letsTest[2] = value_2;';
|
||||
|
||||
self::assertEquals($effect, Arrays::setPositions($this->twoDimensionsArray, $keyName));
|
||||
|
||||
/*
|
||||
* Positive case - non-default start value of position & 2-dimensions array
|
||||
*/
|
||||
// Positive case - non-default start value of position & 2-dimensions array
|
||||
$startPosition = 5;
|
||||
$effect = $this->twoDimensionsArray;
|
||||
|
||||
@@ -1062,14 +1100,10 @@ letsTest[2] = value_2;';
|
||||
|
||||
public function testTrimRecursive()
|
||||
{
|
||||
/*
|
||||
* Negative cases
|
||||
*/
|
||||
// Negative cases
|
||||
self::assertSame([], Arrays::trimRecursive([]));
|
||||
|
||||
/*
|
||||
* Positive cases
|
||||
*/
|
||||
// Positive cases
|
||||
self::assertEquals(['a'], Arrays::trimRecursive([' a ']));
|
||||
self::assertEquals([
|
||||
'a',
|
||||
@@ -1126,14 +1160,10 @@ letsTest[2] = value_2;';
|
||||
|
||||
public function testSortByCustomKeysOrder()
|
||||
{
|
||||
/*
|
||||
* Negative cases
|
||||
*/
|
||||
// Negative cases
|
||||
self::assertNull(Arrays::sortByCustomKeysOrder([], []));
|
||||
|
||||
/*
|
||||
* Positive cases
|
||||
*/
|
||||
// Positive cases
|
||||
self::assertEquals([0], Arrays::sortByCustomKeysOrder([0], []));
|
||||
self::assertEquals($this->simpleArray, Arrays::sortByCustomKeysOrder($this->simpleArray, []));
|
||||
|
||||
@@ -1204,19 +1234,13 @@ letsTest[2] = value_2;';
|
||||
{
|
||||
$separator = '/';
|
||||
|
||||
/*
|
||||
* Empty array
|
||||
*/
|
||||
// Empty array
|
||||
self::assertNull(Arrays::implodeSmart([], $separator));
|
||||
|
||||
/*
|
||||
* Simple, one-dimension array
|
||||
*/
|
||||
// Simple, one-dimension array
|
||||
self::assertEquals(implode($separator, $this->simpleArray), Arrays::implodeSmart($this->simpleArray, $separator));
|
||||
|
||||
/*
|
||||
* An array with elements that contain separator
|
||||
*/
|
||||
// An array with elements that contain separator
|
||||
$array = [
|
||||
'lorem' . $separator,
|
||||
'ipsum',
|
||||
@@ -1229,9 +1253,7 @@ letsTest[2] = value_2;';
|
||||
'dolor',
|
||||
]), Arrays::implodeSmart($array, $separator));
|
||||
|
||||
/*
|
||||
* Complex array
|
||||
*/
|
||||
// Complex array
|
||||
self::assertEquals(implode($separator, [
|
||||
'donec',
|
||||
'quis',
|
||||
@@ -1241,51 +1263,39 @@ letsTest[2] = value_2;';
|
||||
|
||||
public function testGetNextElement()
|
||||
{
|
||||
/*
|
||||
* Negative cases
|
||||
*/
|
||||
// Negative cases
|
||||
self::assertNull(Arrays::getNextElement($this->simpleArray, 'amet'));
|
||||
self::assertNull(Arrays::getNextElement($this->simpleArray, 'xyz'));
|
||||
self::assertNull(Arrays::getNextElement($this->simpleArray, 0));
|
||||
self::assertNull(Arrays::getNextElement([], ''));
|
||||
self::assertNull(Arrays::getNextElement([], null));
|
||||
|
||||
/*
|
||||
* Positive cases
|
||||
*/
|
||||
// Positive cases
|
||||
self::assertEquals('ipsum', Arrays::getNextElement($this->simpleArray, 'Lorem'));
|
||||
self::assertEquals('sit', Arrays::getNextElement($this->simpleArray, 'dolor'));
|
||||
}
|
||||
|
||||
public function testGetPreviousElement()
|
||||
{
|
||||
/*
|
||||
* Negative cases
|
||||
*/
|
||||
// Negative cases
|
||||
self::assertNull(Arrays::getPreviousElement($this->simpleArray, 'Lorem'));
|
||||
self::assertNull(Arrays::getPreviousElement($this->simpleArray, 'xyz'));
|
||||
self::assertNull(Arrays::getPreviousElement($this->simpleArray, 0));
|
||||
self::assertNull(Arrays::getPreviousElement([], ''));
|
||||
self::assertNull(Arrays::getPreviousElement([], null));
|
||||
|
||||
/*
|
||||
* Positive cases
|
||||
*/
|
||||
// Positive cases
|
||||
self::assertEquals('ipsum', Arrays::getPreviousElement($this->simpleArray, 'dolor'));
|
||||
self::assertEquals('sit', Arrays::getPreviousElement($this->simpleArray, 'amet'));
|
||||
}
|
||||
|
||||
public function testGetIndexOf()
|
||||
{
|
||||
/*
|
||||
* Negative cases
|
||||
*/
|
||||
// Negative cases
|
||||
self::assertFalse(Arrays::getIndexOf([], 'a'));
|
||||
self::assertNull(Arrays::getIndexOf($this->simpleArray, 'loremmm'));
|
||||
|
||||
/*
|
||||
* Positive cases
|
||||
*/
|
||||
// Positive cases
|
||||
self::assertEquals(1, Arrays::getIndexOf($this->simpleArray, 'ipsum'));
|
||||
self::assertEquals('dolor', Arrays::getIndexOf($this->simpleArrayWithKeys, 'sit'));
|
||||
self::assertEquals('mollis', Arrays::getIndexOf($this->complexArray, 1234));
|
||||
@@ -1293,14 +1303,10 @@ letsTest[2] = value_2;';
|
||||
|
||||
public function testIncrementIndexes()
|
||||
{
|
||||
/*
|
||||
* Negative cases
|
||||
*/
|
||||
// Negative cases
|
||||
self::assertNull(Arrays::incrementIndexes([]));
|
||||
|
||||
/*
|
||||
* Positive cases
|
||||
*/
|
||||
// Positive cases
|
||||
$array = [
|
||||
1 => 'Lorem',
|
||||
2 => 'ipsum',
|
||||
@@ -1331,9 +1337,7 @@ letsTest[2] = value_2;';
|
||||
|
||||
public function testAreAllValuesEmpty()
|
||||
{
|
||||
/*
|
||||
* Negative cases
|
||||
*/
|
||||
// Negative cases
|
||||
self::assertFalse(Arrays::areAllValuesEmpty([]));
|
||||
self::assertFalse(Arrays::areAllValuesEmpty([], true));
|
||||
self::assertFalse(Arrays::areAllValuesEmpty($this->simpleArray));
|
||||
@@ -1353,9 +1357,7 @@ letsTest[2] = value_2;';
|
||||
];
|
||||
self::assertFalse(Arrays::areAllValuesEmpty($array, true));
|
||||
|
||||
/*
|
||||
* Positive cases
|
||||
*/
|
||||
// Positive cases
|
||||
$array = [
|
||||
'',
|
||||
0,
|
||||
@@ -1371,15 +1373,11 @@ letsTest[2] = value_2;';
|
||||
|
||||
public function testDiffRecursive()
|
||||
{
|
||||
/*
|
||||
* Negative cases
|
||||
*/
|
||||
// Negative cases
|
||||
self::assertEquals([], Arrays::arrayDiffRecursive([], []));
|
||||
self::assertEquals([], Arrays::arrayDiffRecursive([], [], true));
|
||||
|
||||
/*
|
||||
* Positive cases - full comparison (keys and values)
|
||||
*/
|
||||
// Positive cases - full comparison (keys and values)
|
||||
self::assertEquals(['a'], Arrays::arrayDiffRecursive(['a'], []));
|
||||
self::assertEquals([], Arrays::arrayDiffRecursive([], ['a']));
|
||||
self::assertEquals([], Arrays::arrayDiffRecursive($this->simpleArray, $this->simpleArray));
|
||||
@@ -1432,9 +1430,7 @@ letsTest[2] = value_2;';
|
||||
|
||||
self::assertEquals($this->twoDimensionsArray[1], Arrays::arrayDiffRecursive($this->twoDimensionsArray[1], $this->twoDimensionsArray));
|
||||
|
||||
/*
|
||||
* Positive cases - simple comparison (values only)
|
||||
*/
|
||||
// Positive cases - simple comparison (values only)
|
||||
self::assertEquals(['a'], Arrays::arrayDiffRecursive(['a'], [], true));
|
||||
|
||||
$array = [
|
||||
@@ -1533,35 +1529,25 @@ letsTest[2] = value_2;';
|
||||
|
||||
public function testGetDimensionsCount()
|
||||
{
|
||||
/*
|
||||
* Basic cases
|
||||
*/
|
||||
// Basic cases
|
||||
self::assertEquals(0, Arrays::getDimensionsCount([]));
|
||||
self::assertEquals(1, Arrays::getDimensionsCount(['']));
|
||||
|
||||
/*
|
||||
* Simple cases
|
||||
*/
|
||||
// Simple cases
|
||||
self::assertEquals(1, Arrays::getDimensionsCount($this->simpleArray));
|
||||
self::assertEquals(1, Arrays::getDimensionsCount($this->simpleArrayWithKeys));
|
||||
|
||||
/*
|
||||
* Complex cases
|
||||
*/
|
||||
// Complex cases
|
||||
self::assertEquals(2, Arrays::getDimensionsCount($this->twoDimensionsArray));
|
||||
self::assertEquals(4, Arrays::getDimensionsCount($this->complexArray));
|
||||
}
|
||||
|
||||
public function testIsMultiDimensional()
|
||||
{
|
||||
/*
|
||||
* Negative cases
|
||||
*/
|
||||
// Negative cases
|
||||
self::assertNull(Arrays::isMultiDimensional([]));
|
||||
|
||||
/*
|
||||
* Positive cases
|
||||
*/
|
||||
// Positive cases
|
||||
self::assertFalse(Arrays::isMultiDimensional($this->simpleArray));
|
||||
self::assertFalse(Arrays::isMultiDimensional($this->simpleArrayWithKeys));
|
||||
|
||||
@@ -1717,9 +1703,7 @@ letsTest[2] = value_2;';
|
||||
*/
|
||||
public function provideStopIfMatchedByForGetLastElementsPaths()
|
||||
{
|
||||
/*
|
||||
* Special exception: do not use, stop recursive on the "diam" key
|
||||
*/
|
||||
// Special exception: do not use, stop recursive on the "diam" key
|
||||
yield[
|
||||
'diam',
|
||||
'.',
|
||||
@@ -1780,9 +1764,7 @@ letsTest[2] = value_2;';
|
||||
],
|
||||
];
|
||||
|
||||
/*
|
||||
* Stop building of paths on more sophisticated keys
|
||||
*/
|
||||
// Stop building of paths on more sophisticated keys
|
||||
yield[
|
||||
[
|
||||
'porta\-\d+',
|
||||
@@ -1857,9 +1839,7 @@ letsTest[2] = value_2;';
|
||||
],
|
||||
];
|
||||
|
||||
/*
|
||||
* Stop building of paths on these paths (verify paths only)
|
||||
*/
|
||||
// Stop building of paths on these paths (verify paths only)
|
||||
yield[
|
||||
[
|
||||
'ipsum > quis > vestibulum > porta-1',
|
||||
@@ -1894,9 +1874,7 @@ letsTest[2] = value_2;';
|
||||
],
|
||||
];
|
||||
|
||||
/*
|
||||
* Stop building of paths if path contains any of these part (verify part of paths only)
|
||||
*/
|
||||
// Stop building of paths if path contains any of these part (verify part of paths only)
|
||||
yield[
|
||||
[
|
||||
'vestibulum > porta-1',
|
||||
@@ -2701,130 +2679,4 @@ letsTest[2] = value_2;';
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
$this->simpleArray = [
|
||||
'Lorem',
|
||||
'ipsum',
|
||||
'dolor',
|
||||
'sit',
|
||||
'amet',
|
||||
];
|
||||
|
||||
$this->simpleArrayWithKeys = [
|
||||
'Lorem' => 'ipsum',
|
||||
'dolor' => 'sit',
|
||||
'amet' => 'consectetur',
|
||||
];
|
||||
|
||||
$this->twoDimensionsArray = [
|
||||
[
|
||||
'lorem',
|
||||
'ipsum',
|
||||
'dolor',
|
||||
'sit',
|
||||
'amet',
|
||||
],
|
||||
[
|
||||
'consectetur',
|
||||
'adipiscing',
|
||||
'elit',
|
||||
],
|
||||
[
|
||||
'donec',
|
||||
'sagittis',
|
||||
'fringilla',
|
||||
'eleifend',
|
||||
],
|
||||
];
|
||||
|
||||
$this->complexArray = [
|
||||
'lorem' => [
|
||||
'ipsum' => [
|
||||
'dolor' => 'sit',
|
||||
'diam' => [
|
||||
'non' => 'egestas',
|
||||
],
|
||||
],
|
||||
],
|
||||
'consectetur' => 'adipiscing',
|
||||
'mollis' => 1234,
|
||||
2 => [],
|
||||
'sit' => [
|
||||
'nullam' => 'donec',
|
||||
'aliquet' => [
|
||||
'vitae' => [
|
||||
'ligula' => 'quis',
|
||||
],
|
||||
],
|
||||
'elit',
|
||||
],
|
||||
'amet' => [
|
||||
'iaculis',
|
||||
'primis',
|
||||
],
|
||||
];
|
||||
|
||||
$this->superComplexArray = [
|
||||
'ipsum' => [
|
||||
'quis' => [
|
||||
'vestibulum' => [
|
||||
'porta-1' => [
|
||||
'turpis',
|
||||
'urna',
|
||||
],
|
||||
'porta-2' => [
|
||||
'tortor' => [
|
||||
'in' => [
|
||||
'dui',
|
||||
'dolor' => [
|
||||
'aliquam',
|
||||
],
|
||||
],
|
||||
],
|
||||
],
|
||||
'porta-3' => [
|
||||
1,
|
||||
2,
|
||||
3,
|
||||
],
|
||||
],
|
||||
],
|
||||
],
|
||||
'primis' => [
|
||||
[
|
||||
'in',
|
||||
'faucibus',
|
||||
'orci',
|
||||
],
|
||||
[
|
||||
'luctus',
|
||||
'et',
|
||||
'ultrices',
|
||||
],
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function tearDown(): void
|
||||
{
|
||||
parent::tearDown();
|
||||
|
||||
unset(
|
||||
$this->simpleArray,
|
||||
$this->simpleArrayWithKeys,
|
||||
$this->twoDimensionsArray,
|
||||
$this->complexArray,
|
||||
$this->superComplexArray
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,6 +16,9 @@ use Meritoo\Common\Utilities\Bootstrap4CssSelector;
|
||||
*
|
||||
* @author Meritoo <github@meritoo.pl>
|
||||
* @copyright Meritoo <http://www.meritoo.pl>
|
||||
*
|
||||
* @internal
|
||||
* @covers \Meritoo\Common\Utilities\Bootstrap4CssSelector
|
||||
*/
|
||||
class Bootstrap4CssSelectorTest extends BaseTestCase
|
||||
{
|
||||
|
||||
@@ -18,6 +18,9 @@ use Meritoo\Common\Utilities\Bundle;
|
||||
*
|
||||
* @author Meritoo <github@meritoo.pl>
|
||||
* @copyright Meritoo <http://www.meritoo.pl>
|
||||
*
|
||||
* @internal
|
||||
* @covers \Meritoo\Common\Utilities\Bundle
|
||||
*/
|
||||
class BundleTest extends BaseTestCase
|
||||
{
|
||||
|
||||
@@ -17,6 +17,9 @@ use Meritoo\Common\Utilities\Composer;
|
||||
*
|
||||
* @author Meritoo <github@meritoo.pl>
|
||||
* @copyright Meritoo <http://www.meritoo.pl>
|
||||
*
|
||||
* @internal
|
||||
* @covers \Meritoo\Common\Utilities\Composer
|
||||
*/
|
||||
class ComposerTest extends BaseTestCase
|
||||
{
|
||||
@@ -27,6 +30,16 @@ class ComposerTest extends BaseTestCase
|
||||
*/
|
||||
private $composerJsonPath;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
$this->composerJsonPath = $this->getFilePathForTesting(Composer::FILE_NAME_MAIN);
|
||||
}
|
||||
|
||||
public function testConstructor()
|
||||
{
|
||||
static::assertHasNoConstructor(Composer::class);
|
||||
@@ -80,14 +93,4 @@ class ComposerTest extends BaseTestCase
|
||||
'1.0.2',
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
$this->composerJsonPath = $this->getFilePathForTesting(Composer::FILE_NAME_MAIN);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,6 +16,9 @@ use Meritoo\Common\Utilities\CssSelector;
|
||||
*
|
||||
* @author Meritoo <github@meritoo.pl>
|
||||
* @copyright Meritoo <http://www.meritoo.pl>
|
||||
*
|
||||
* @internal
|
||||
* @covers \Meritoo\Common\Utilities\CssSelector
|
||||
*/
|
||||
class CssSelectorTest extends BaseTestCase
|
||||
{
|
||||
|
||||
@@ -22,6 +22,9 @@ use Meritoo\Common\Utilities\Locale;
|
||||
*
|
||||
* @author Meritoo <github@meritoo.pl>
|
||||
* @copyright Meritoo <http://www.meritoo.pl>
|
||||
*
|
||||
* @internal
|
||||
* @covers \Meritoo\Common\Utilities\Date
|
||||
*/
|
||||
class DateTest extends BaseTestCase
|
||||
{
|
||||
@@ -89,14 +92,10 @@ class DateTest extends BaseTestCase
|
||||
|
||||
public function testGetDateTimeConcreteDates()
|
||||
{
|
||||
/*
|
||||
* Using the standard date format provided by the tested method
|
||||
*/
|
||||
// Using the standard date format provided by the tested method
|
||||
self::assertInstanceOf(DateTime::class, Date::getDateTime('2015-03-20'));
|
||||
|
||||
/*
|
||||
* Using custom date format
|
||||
*/
|
||||
// Using custom date format
|
||||
self::assertInstanceOf(DateTime::class, Date::getDateTime('2015-03-20 11:30', false, 'Y-m-d H:i'));
|
||||
self::assertInstanceOf(DateTime::class, Date::getDateTime('20.03.2015', false, 'd.m.Y'));
|
||||
}
|
||||
@@ -248,8 +247,8 @@ class DateTest extends BaseTestCase
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string|DateTime $dateStart The start date
|
||||
* @param string|DateTime $dateEnd The end date
|
||||
* @param DateTime|string $dateStart The start date
|
||||
* @param DateTime|string $dateEnd The end date
|
||||
*
|
||||
* @dataProvider provideEmptyDatesForDateDifference
|
||||
*/
|
||||
@@ -266,9 +265,7 @@ class DateTest extends BaseTestCase
|
||||
|
||||
public function testGetDateDifferenceOneDay()
|
||||
{
|
||||
/*
|
||||
* Difference of 1 day
|
||||
*/
|
||||
// Difference of 1 day
|
||||
$dateStart = '2017-01-01';
|
||||
$dateEnd = '2017-01-02';
|
||||
|
||||
@@ -298,9 +295,7 @@ class DateTest extends BaseTestCase
|
||||
self::assertEquals(0, Date::getDateDifference($dateStart, $dateEnd, Date::DATE_DIFFERENCE_UNIT_MINUTES));
|
||||
self::assertEquals(0, Date::getDateDifference(new DateTime($dateStart), new DateTime($dateEnd), Date::DATE_DIFFERENCE_UNIT_MINUTES));
|
||||
|
||||
/*
|
||||
* Difference of 1 day (using the relative date format)
|
||||
*/
|
||||
// Difference of 1 day (using the relative date format)
|
||||
$effect = [
|
||||
Date::DATE_DIFFERENCE_UNIT_YEARS => 0,
|
||||
Date::DATE_DIFFERENCE_UNIT_MONTHS => 0,
|
||||
@@ -318,9 +313,7 @@ class DateTest extends BaseTestCase
|
||||
|
||||
public function testGetDateDifferenceOneDayTwoHours()
|
||||
{
|
||||
/*
|
||||
* Difference of 1 day, 2 hours and 15 minutes
|
||||
*/
|
||||
// Difference of 1 day, 2 hours and 15 minutes
|
||||
$dateStart = '2017-01-01 12:00';
|
||||
$dateEnd = '2017-01-02 14:15';
|
||||
|
||||
@@ -353,9 +346,7 @@ class DateTest extends BaseTestCase
|
||||
|
||||
public function testGetDateDifferenceOneMonthFortyOneDays()
|
||||
{
|
||||
/*
|
||||
* Difference of 1 month, 41 days, 4 hours and 30 minutes
|
||||
*/
|
||||
// Difference of 1 month, 41 days, 4 hours and 30 minutes
|
||||
$dateStart = '2017-01-01 12:00';
|
||||
$dateEnd = '2017-02-11 16:30';
|
||||
|
||||
@@ -516,9 +507,7 @@ class DateTest extends BaseTestCase
|
||||
|
||||
public function testGetDateDifferenceNoDifference()
|
||||
{
|
||||
/*
|
||||
* No difference
|
||||
*/
|
||||
// No difference
|
||||
$dateStart = '2017-01-01 12:00';
|
||||
$dateEnd = $dateStart;
|
||||
|
||||
@@ -572,18 +561,14 @@ class DateTest extends BaseTestCase
|
||||
|
||||
public function testGetDatesCollection()
|
||||
{
|
||||
/*
|
||||
* 1 date only
|
||||
*/
|
||||
// 1 date only
|
||||
$effect = [
|
||||
1 => new DateTime('2017-01-02'),
|
||||
];
|
||||
|
||||
self::assertEquals($effect, Date::getDatesCollection(new DateTime('2017-01-01'), 1));
|
||||
|
||||
/*
|
||||
* 3 dates with default date interval (days)
|
||||
*/
|
||||
// 3 dates with default date interval (days)
|
||||
$effect = [
|
||||
1 => new DateTime('2017-01-02'),
|
||||
2 => new DateTime('2017-01-03'),
|
||||
@@ -592,9 +577,7 @@ class DateTest extends BaseTestCase
|
||||
|
||||
self::assertEquals($effect, Date::getDatesCollection(new DateTime('2017-01-01'), 3));
|
||||
|
||||
/*
|
||||
* 3 dates with custom date interval (hours)
|
||||
*/
|
||||
// 3 dates with custom date interval (hours)
|
||||
$effect = [
|
||||
1 => new DateTime('2017-01-01 10:30'),
|
||||
2 => new DateTime('2017-01-01 11:30'),
|
||||
@@ -603,9 +586,7 @@ class DateTest extends BaseTestCase
|
||||
|
||||
self::assertEquals($effect, Date::getDatesCollection(new DateTime('2017-01-01 09:30'), 3, 'PT%dH'));
|
||||
|
||||
/*
|
||||
* 3 dates with custom date interval (months)
|
||||
*/
|
||||
// 3 dates with custom date interval (months)
|
||||
$effect = [
|
||||
1 => new DateTime('2017-02-01'),
|
||||
2 => new DateTime('2017-03-01'),
|
||||
@@ -705,42 +686,32 @@ class DateTest extends BaseTestCase
|
||||
*/
|
||||
public function provideIncorrectDateTimeValue()
|
||||
{
|
||||
/*
|
||||
* Incorrect one-character values
|
||||
*/
|
||||
// Incorrect one-character values
|
||||
yield['a'];
|
||||
yield['m'];
|
||||
|
||||
/*
|
||||
* Incorrect strings
|
||||
*/
|
||||
// Incorrect strings
|
||||
yield['ss'];
|
||||
yield['sss'];
|
||||
yield['mm'];
|
||||
yield['yy'];
|
||||
yield['yyyy'];
|
||||
|
||||
/*
|
||||
* Incorrect integer values
|
||||
*/
|
||||
// Incorrect integer values
|
||||
yield[1];
|
||||
yield[10];
|
||||
yield[15];
|
||||
yield[100];
|
||||
yield[1000];
|
||||
|
||||
/*
|
||||
* Incorrect string / numeric values
|
||||
*/
|
||||
// Incorrect string / numeric values
|
||||
yield['1'];
|
||||
yield['10'];
|
||||
yield['15'];
|
||||
yield['100'];
|
||||
yield['1000'];
|
||||
|
||||
/*
|
||||
* Incorrect dates
|
||||
*/
|
||||
// Incorrect dates
|
||||
yield['0-0-0'];
|
||||
yield['20-01-01'];
|
||||
yield['2015-0-0'];
|
||||
|
||||
@@ -16,6 +16,9 @@ use Meritoo\Common\Utilities\GeneratorUtility;
|
||||
*
|
||||
* @author Meritoo <github@meritoo.pl>
|
||||
* @copyright Meritoo <http://www.meritoo.pl>
|
||||
*
|
||||
* @internal
|
||||
* @covers \Meritoo\Common\Utilities\GeneratorUtility
|
||||
*/
|
||||
class GeneratorUtilityTest extends BaseTestCase
|
||||
{
|
||||
@@ -26,9 +29,7 @@ class GeneratorUtilityTest extends BaseTestCase
|
||||
|
||||
public function testGetGeneratorElements()
|
||||
{
|
||||
/*
|
||||
* Generator that provides boolean value
|
||||
*/
|
||||
// Generator that provides boolean value
|
||||
$elements = [
|
||||
[false],
|
||||
[true],
|
||||
@@ -46,15 +47,11 @@ class GeneratorUtilityTest extends BaseTestCase
|
||||
[[]],
|
||||
];
|
||||
|
||||
/*
|
||||
* Generator that provides an empty value
|
||||
*/
|
||||
// Generator that provides an empty value
|
||||
$generator = $this->provideEmptyValue();
|
||||
self::assertEquals($elements, GeneratorUtility::getGeneratorElements($generator));
|
||||
|
||||
/*
|
||||
* Generator that provides instance of DateTime class
|
||||
*/
|
||||
// Generator that provides instance of DateTime class
|
||||
$generator = $this->provideDateTimeInstance();
|
||||
self::assertCount(4, GeneratorUtility::getGeneratorElements($generator));
|
||||
}
|
||||
|
||||
@@ -18,6 +18,9 @@ use ReflectionException;
|
||||
*
|
||||
* @author Meritoo <github@meritoo.pl>
|
||||
* @copyright Meritoo <http://www.meritoo.pl>
|
||||
*
|
||||
* @internal
|
||||
* @covers \Meritoo\Common\Utilities\Locale
|
||||
*/
|
||||
class LocaleTest extends BaseTestCase
|
||||
{
|
||||
|
||||
@@ -17,6 +17,9 @@ use Meritoo\Common\Utilities\MimeTypes;
|
||||
*
|
||||
* @author Meritoo <github@meritoo.pl>
|
||||
* @copyright Meritoo <http://www.meritoo.pl>
|
||||
*
|
||||
* @internal
|
||||
* @covers \Meritoo\Common\Utilities\MimeTypes
|
||||
*/
|
||||
class MimeTypesTest extends BaseTestCase
|
||||
{
|
||||
|
||||
@@ -21,6 +21,9 @@ use stdClass;
|
||||
*
|
||||
* @author Meritoo <github@meritoo.pl>
|
||||
* @copyright Meritoo <http://www.meritoo.pl>
|
||||
*
|
||||
* @internal
|
||||
* @covers \Meritoo\Common\Utilities\Miscellaneous
|
||||
*/
|
||||
class MiscellaneousTest extends BaseTestCase
|
||||
{
|
||||
@@ -29,6 +32,28 @@ class MiscellaneousTest extends BaseTestCase
|
||||
private $stringDotSeparated;
|
||||
private $stringWithoutSpaces;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
$this->stringSmall = 'Lorem ipsum dolor sit amet.';
|
||||
$this->stringCommaSeparated = 'Lorem ipsum dolor sit amet, consectetur adipiscing elit';
|
||||
$this->stringDotSeparated = 'Etiam ullamcorper. Suspendisse a pellentesque dui, non felis.';
|
||||
$this->stringWithoutSpaces = 'LoremIpsumDolorSitAmetConsecteturAdipiscingElit';
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function tearDown(): void
|
||||
{
|
||||
parent::tearDown();
|
||||
unset($this->stringSmall, $this->stringCommaSeparated, $this->stringDotSeparated, $this->stringWithoutSpaces);
|
||||
}
|
||||
|
||||
public function testConstructor()
|
||||
{
|
||||
static::assertHasNoConstructor(Miscellaneous::class);
|
||||
@@ -93,24 +118,16 @@ class MiscellaneousTest extends BaseTestCase
|
||||
|
||||
public function testGetFileNameFromPath()
|
||||
{
|
||||
/*
|
||||
* Path with file
|
||||
*/
|
||||
// Path with file
|
||||
self::assertEquals('sit.amet.JPG', Miscellaneous::getFileNameFromPath('lorem/ipsum-dolor/sit.amet.JPG'));
|
||||
|
||||
/*
|
||||
* Path without file
|
||||
*/
|
||||
// Path without file
|
||||
self::assertEquals('', Miscellaneous::getFileNameFromPath('lorem/ipsum-dolor/sit-amet'));
|
||||
|
||||
/*
|
||||
* Path with a dot "." in name of directory
|
||||
*/
|
||||
// Path with a dot "." in name of directory
|
||||
self::assertEquals('sit.amet.JPG', Miscellaneous::getFileNameFromPath('lorem/ipsum.dolor/sit.amet.JPG'));
|
||||
|
||||
/*
|
||||
* Relative path
|
||||
*/
|
||||
// Relative path
|
||||
self::assertEquals('sit.amet.JPG', Miscellaneous::getFileNameFromPath('lorem/ipsum/../dolor/sit.amet.JPG'));
|
||||
}
|
||||
|
||||
@@ -119,14 +136,10 @@ class MiscellaneousTest extends BaseTestCase
|
||||
$originalFileName = 'Lorem.ipsum-dolor.sit.JPG';
|
||||
$pattern = '|^lorem\-ipsum\-dolor\-sit\-[a-z0-9.-]+\.jpg$|';
|
||||
|
||||
/*
|
||||
* With object ID
|
||||
*/
|
||||
// With object ID
|
||||
$uniqueFileName1 = Miscellaneous::getUniqueFileName($originalFileName, 123);
|
||||
|
||||
/*
|
||||
* Without object ID
|
||||
*/
|
||||
// Without object ID
|
||||
$uniqueFileName2 = Miscellaneous::getUniqueFileName($originalFileName);
|
||||
|
||||
$isCorrect1 = (bool)preg_match($pattern, $uniqueFileName1);
|
||||
@@ -200,7 +213,7 @@ class MiscellaneousTest extends BaseTestCase
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string|array $search An empty value to find
|
||||
* @param array|string $search An empty value to find
|
||||
* @dataProvider provideEmptyValue
|
||||
*/
|
||||
public function testReplaceEmptyValue($search)
|
||||
@@ -224,10 +237,10 @@ class MiscellaneousTest extends BaseTestCase
|
||||
|
||||
/**
|
||||
* @param string $description Description of test
|
||||
* @param string|array $subject The string or an array of strings to search and replace
|
||||
* @param string|array $search String or pattern or array of patterns to find. It may be: string, an array
|
||||
* @param array|string $subject The string or an array of strings to search and replace
|
||||
* @param array|string $search String or pattern or array of patterns to find. It may be: string, an array
|
||||
* of strings or an array of patterns.
|
||||
* @param string|array $replacement The string or an array of strings to replace. It may be: string or an array
|
||||
* @param array|string $replacement The string or an array of strings to replace. It may be: string or an array
|
||||
* of strings.
|
||||
* @param mixed $result Result of replacing
|
||||
*
|
||||
@@ -328,9 +341,7 @@ class MiscellaneousTest extends BaseTestCase
|
||||
|
||||
public function testGetOperatingSystemNameServer()
|
||||
{
|
||||
/*
|
||||
* While running Docker OS is a Linux
|
||||
*/
|
||||
// While running Docker OS is a Linux
|
||||
self::assertEquals('Linux', Miscellaneous::getOperatingSystemNameServer());
|
||||
}
|
||||
|
||||
@@ -531,9 +542,7 @@ class MiscellaneousTest extends BaseTestCase
|
||||
|
||||
public function testConcatenatePathsInNixOs()
|
||||
{
|
||||
/*
|
||||
* For *nix operating system
|
||||
*/
|
||||
// For *nix operating system
|
||||
$paths1 = [
|
||||
'first/directory',
|
||||
'second/one',
|
||||
@@ -546,9 +555,7 @@ class MiscellaneousTest extends BaseTestCase
|
||||
|
||||
public function testConcatenatePathsInWindowsOs()
|
||||
{
|
||||
/*
|
||||
* For Windows operating system
|
||||
*/
|
||||
// For Windows operating system
|
||||
$paths2 = [
|
||||
'C:\first\directory',
|
||||
'second\one',
|
||||
@@ -597,18 +604,14 @@ class MiscellaneousTest extends BaseTestCase
|
||||
|
||||
public function testIsBetween()
|
||||
{
|
||||
/*
|
||||
* Negative cases
|
||||
*/
|
||||
// Negative cases
|
||||
self::assertFalse(Miscellaneous::isBetween(0, 0, 0));
|
||||
self::assertFalse(Miscellaneous::isBetween('0', '0', '0'));
|
||||
self::assertFalse(Miscellaneous::isBetween(0, 0, 1));
|
||||
self::assertFalse(Miscellaneous::isBetween(-1, -1, -1));
|
||||
self::assertFalse(Miscellaneous::isBetween(1.2, 0.1, 1.1));
|
||||
|
||||
/*
|
||||
* Positive cases
|
||||
*/
|
||||
// Positive cases
|
||||
self::assertTrue(Miscellaneous::isBetween(1, 0, 2));
|
||||
self::assertTrue(Miscellaneous::isBetween('1', '0', '2'));
|
||||
self::assertTrue(Miscellaneous::isBetween(-1, -2, 2));
|
||||
@@ -628,9 +631,7 @@ class MiscellaneousTest extends BaseTestCase
|
||||
|
||||
public function testGetValidColorComponent()
|
||||
{
|
||||
/*
|
||||
* Negative cases
|
||||
*/
|
||||
// Negative cases
|
||||
self::assertEquals(0, Miscellaneous::getValidColorComponent(null));
|
||||
self::assertEquals(0, Miscellaneous::getValidColorComponent(''));
|
||||
self::assertEquals(0, Miscellaneous::getValidColorComponent('0'));
|
||||
@@ -638,18 +639,14 @@ class MiscellaneousTest extends BaseTestCase
|
||||
self::assertEquals(0, Miscellaneous::getValidColorComponent(256));
|
||||
self::assertEquals(0, Miscellaneous::getValidColorComponent(256, false));
|
||||
|
||||
/*
|
||||
* Positive cases - part 1
|
||||
*/
|
||||
// Positive cases - part 1
|
||||
self::assertEquals(1, Miscellaneous::getValidColorComponent(1));
|
||||
self::assertEquals('0a', Miscellaneous::getValidColorComponent(10));
|
||||
self::assertEquals('0f', Miscellaneous::getValidColorComponent(15));
|
||||
self::assertEquals(64, Miscellaneous::getValidColorComponent(100));
|
||||
self::assertEquals('ff', Miscellaneous::getValidColorComponent(255));
|
||||
|
||||
/*
|
||||
* Positive cases - part 2
|
||||
*/
|
||||
// Positive cases - part 2
|
||||
self::assertEquals(1, Miscellaneous::getValidColorComponent(1, false));
|
||||
self::assertEquals(10, Miscellaneous::getValidColorComponent(10, false));
|
||||
self::assertEquals(15, Miscellaneous::getValidColorComponent(15, false));
|
||||
@@ -684,9 +681,7 @@ class MiscellaneousTest extends BaseTestCase
|
||||
|
||||
public function testGetInvertedColor()
|
||||
{
|
||||
/*
|
||||
* Simple cases
|
||||
*/
|
||||
// Simple cases
|
||||
self::assertEquals('000000', Miscellaneous::getInvertedColor('fff'));
|
||||
self::assertEquals('ffffff', Miscellaneous::getInvertedColor('000'));
|
||||
self::assertEquals('000000', Miscellaneous::getInvertedColor('ffffff'));
|
||||
@@ -694,18 +689,14 @@ class MiscellaneousTest extends BaseTestCase
|
||||
self::assertEquals('#000000', Miscellaneous::getInvertedColor('#ffffff'));
|
||||
self::assertEquals('#ffffff', Miscellaneous::getInvertedColor('#000000'));
|
||||
|
||||
/*
|
||||
* Advanced cases - part 1
|
||||
*/
|
||||
// Advanced cases - part 1
|
||||
self::assertEquals('ffffee', Miscellaneous::getInvertedColor('001'));
|
||||
self::assertEquals('ffeeff', Miscellaneous::getInvertedColor('010'));
|
||||
self::assertEquals('eeffff', Miscellaneous::getInvertedColor('100'));
|
||||
self::assertEquals('333333', Miscellaneous::getInvertedColor('ccc'));
|
||||
self::assertEquals('333333', Miscellaneous::getInvertedColor('CCC'));
|
||||
|
||||
/*
|
||||
* Advanced cases - part 2
|
||||
*/
|
||||
// Advanced cases - part 2
|
||||
self::assertEquals('3e3e3e', Miscellaneous::getInvertedColor('c1c1c1'));
|
||||
self::assertEquals('3e3e3e', Miscellaneous::getInvertedColor('C1C1C1'));
|
||||
self::assertEquals('#dd5a01', Miscellaneous::getInvertedColor('#22a5fe'));
|
||||
@@ -713,9 +704,7 @@ class MiscellaneousTest extends BaseTestCase
|
||||
self::assertEquals('#464646', Miscellaneous::getInvertedColor('#b9b9b9'));
|
||||
self::assertEquals('#080808', Miscellaneous::getInvertedColor('#f7f7f7'));
|
||||
|
||||
/*
|
||||
* Advanced cases - verification
|
||||
*/
|
||||
// Advanced cases - verification
|
||||
self::assertEquals('000011', Miscellaneous::getInvertedColor('ffffee'));
|
||||
self::assertEquals('cccccc', Miscellaneous::getInvertedColor('333333'));
|
||||
self::assertEquals('#22a5fe', Miscellaneous::getInvertedColor('#dd5a01'));
|
||||
@@ -1475,26 +1464,4 @@ class MiscellaneousTest extends BaseTestCase
|
||||
'Lorem \'commodo\' dolor sit \'egestas\'',
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
$this->stringSmall = 'Lorem ipsum dolor sit amet.';
|
||||
$this->stringCommaSeparated = 'Lorem ipsum dolor sit amet, consectetur adipiscing elit';
|
||||
$this->stringDotSeparated = 'Etiam ullamcorper. Suspendisse a pellentesque dui, non felis.';
|
||||
$this->stringWithoutSpaces = 'LoremIpsumDolorSitAmetConsecteturAdipiscingElit';
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function tearDown(): void
|
||||
{
|
||||
parent::tearDown();
|
||||
unset($this->stringSmall, $this->stringCommaSeparated, $this->stringDotSeparated, $this->stringWithoutSpaces);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,6 +23,9 @@ use Meritoo\Common\Utilities\QueryBuilderUtility;
|
||||
*
|
||||
* @author Meritoo <github@meritoo.pl>
|
||||
* @copyright Meritoo <http://www.meritoo.pl>
|
||||
*
|
||||
* @internal
|
||||
* @covers \Meritoo\Common\Utilities\QueryBuilderUtility
|
||||
*/
|
||||
class QueryBuilderUtilityTest extends BaseTestCase
|
||||
{
|
||||
@@ -33,7 +36,7 @@ class QueryBuilderUtilityTest extends BaseTestCase
|
||||
|
||||
/**
|
||||
* @param QueryBuilder $queryBuilder The query builder to retrieve root alias
|
||||
* @param string|null $rootAlias Expected root alias of given query builder
|
||||
* @param null|string $rootAlias Expected root alias of given query builder
|
||||
*
|
||||
* @dataProvider provideQueryBuilderAndRootAlias
|
||||
*/
|
||||
@@ -45,7 +48,7 @@ class QueryBuilderUtilityTest extends BaseTestCase
|
||||
/**
|
||||
* @param QueryBuilder $queryBuilder The query builder to verify
|
||||
* @param string $propertyName Name of property that maybe is joined
|
||||
* @param string|null $propertyAlias Expected alias of given property joined in given query builder
|
||||
* @param null|string $propertyAlias Expected alias of given property joined in given query builder
|
||||
*
|
||||
* @dataProvider provideQueryBuilderAndPropertyAlias
|
||||
*/
|
||||
@@ -93,9 +96,7 @@ class QueryBuilderUtilityTest extends BaseTestCase
|
||||
$criteriaCount = count($criteria);
|
||||
$nullsCount = 0;
|
||||
|
||||
/*
|
||||
* I have to verify count/amount of NULLs and decrease $criteriaCount, because for null parameter is not added
|
||||
*/
|
||||
// I have to verify count/amount of NULLs and decrease $criteriaCount, because for null parameter is not added
|
||||
array_walk($criteria, function ($value) use (&$nullsCount) {
|
||||
if (null === $value) {
|
||||
++$nullsCount;
|
||||
|
||||
@@ -31,9 +31,7 @@ class F
|
||||
$this->username = $username;
|
||||
$this->gInstance = new G($firstName, $lastName);
|
||||
|
||||
/*
|
||||
* Called to avoid "Unused private method getAccountBalance" warning only
|
||||
*/
|
||||
// Called to avoid "Unused private method getAccountBalance" warning only
|
||||
$this->getAccountBalance();
|
||||
}
|
||||
|
||||
|
||||
@@ -17,11 +17,11 @@ namespace Meritoo\Test\Common\Utilities\Reflection;
|
||||
*/
|
||||
class H
|
||||
{
|
||||
const DOLOR = 'sit';
|
||||
public const DOLOR = 'sit';
|
||||
|
||||
const LOREM = 'ipsum';
|
||||
public const LOREM = 'ipsum';
|
||||
|
||||
const MAX_USERS = 5;
|
||||
public const MAX_USERS = 5;
|
||||
|
||||
const MIN_USERS = 2;
|
||||
public const MIN_USERS = 2;
|
||||
}
|
||||
|
||||
@@ -33,6 +33,9 @@ use ReflectionProperty;
|
||||
*
|
||||
* @author Meritoo <github@meritoo.pl>
|
||||
* @copyright Meritoo <http://www.meritoo.pl>
|
||||
*
|
||||
* @internal
|
||||
* @covers \Meritoo\Common\Utilities\Reflection
|
||||
*/
|
||||
class ReflectionTest extends BaseTestCase
|
||||
{
|
||||
@@ -53,18 +56,14 @@ class ReflectionTest extends BaseTestCase
|
||||
|
||||
public function testGetClassNameNotExistingClass()
|
||||
{
|
||||
/*
|
||||
* Not existing class
|
||||
*/
|
||||
// Not existing class
|
||||
self::assertEquals('', Reflection::getClassName('xyz'));
|
||||
self::assertEquals('', Reflection::getClassName('xyz', true));
|
||||
}
|
||||
|
||||
public function testGetClassNameExistingClass()
|
||||
{
|
||||
/*
|
||||
* Existing class
|
||||
*/
|
||||
// Existing class
|
||||
self::assertEquals(self::class, Reflection::getClassName(self::class));
|
||||
self::assertEquals('ReflectionTest', Reflection::getClassName(self::class, true));
|
||||
self::assertEquals(DateTime::class, Reflection::getClassName(new DateTime()));
|
||||
@@ -94,17 +93,13 @@ class ReflectionTest extends BaseTestCase
|
||||
|
||||
public function testGetClassNamespaceNotExistingClass()
|
||||
{
|
||||
/*
|
||||
* Not existing class
|
||||
*/
|
||||
// Not existing class
|
||||
self::assertEquals('', Reflection::getClassNamespace('xyz'));
|
||||
}
|
||||
|
||||
public function testGetClassNamespaceExistingClass()
|
||||
{
|
||||
/*
|
||||
* Existing class
|
||||
*/
|
||||
// Existing class
|
||||
self::assertEquals('Meritoo\Test\Common\Utilities', Reflection::getClassNamespace(self::class));
|
||||
self::assertEquals(DateTime::class, Reflection::getClassNamespace(new DateTime()));
|
||||
|
||||
|
||||
@@ -6,24 +6,49 @@
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Meritoo\Common\Utilities;
|
||||
namespace Meritoo\Test\Common\Utilities;
|
||||
|
||||
use Generator;
|
||||
use Meritoo\Common\Exception\Regex\IncorrectColorHexLengthException;
|
||||
use Meritoo\Common\Exception\Regex\InvalidColorHexValueException;
|
||||
use Meritoo\Common\Test\Base\BaseTestCase;
|
||||
use Meritoo\Common\Utilities\Regex;
|
||||
|
||||
/**
|
||||
* Test case of the useful regular expressions methods
|
||||
*
|
||||
* @author Meritoo <github@meritoo.pl>
|
||||
* @copyright Meritoo <http://www.meritoo.pl>
|
||||
*
|
||||
* @internal
|
||||
* @covers \Meritoo\Common\Utilities\Regex
|
||||
*/
|
||||
class RegexTest extends BaseTestCase
|
||||
{
|
||||
private $simpleText;
|
||||
private $camelCaseText;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
$this->simpleText = 'lorem ipsum dolor sit';
|
||||
$simpleUppercase = ucwords($this->simpleText);
|
||||
$this->camelCaseText = str_replace(' ', '', lcfirst($simpleUppercase)); // 'loremIpsumDolorSit'
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function tearDown(): void
|
||||
{
|
||||
parent::tearDown();
|
||||
unset($this->simpleText, $this->camelCaseText);
|
||||
}
|
||||
|
||||
public function testConstructor()
|
||||
{
|
||||
static::assertHasNoConstructor(Regex::class);
|
||||
@@ -171,23 +196,17 @@ class RegexTest extends BaseTestCase
|
||||
|
||||
public function testStartsWithDirectorySeparator()
|
||||
{
|
||||
/*
|
||||
* Not provided, default separator
|
||||
*/
|
||||
// Not provided, default separator
|
||||
self::assertTrue(Regex::startsWithDirectorySeparator('/my/extra/directory'));
|
||||
self::assertFalse(Regex::startsWithDirectorySeparator('my/extra/directory'));
|
||||
|
||||
/*
|
||||
* Slash as separator
|
||||
*/
|
||||
// Slash as separator
|
||||
$separatorSlash = '/';
|
||||
|
||||
self::assertTrue(Regex::startsWithDirectorySeparator('/my/extra/directory', $separatorSlash));
|
||||
self::assertFalse(Regex::startsWithDirectorySeparator('my/extra/directory', $separatorSlash));
|
||||
|
||||
/*
|
||||
* Backslash as separator
|
||||
*/
|
||||
// Backslash as separator
|
||||
$separatorBackslash = '\\';
|
||||
|
||||
self::assertTrue(Regex::startsWithDirectorySeparator('\my\extra\directory', $separatorBackslash));
|
||||
@@ -196,23 +215,17 @@ class RegexTest extends BaseTestCase
|
||||
|
||||
public function testEndsWithDirectorySeparator()
|
||||
{
|
||||
/*
|
||||
* Not provided, default separator
|
||||
*/
|
||||
// Not provided, default separator
|
||||
self::assertTrue(Regex::endsWithDirectorySeparator('my simple text/'));
|
||||
self::assertFalse(Regex::endsWithDirectorySeparator('my simple text'));
|
||||
|
||||
/*
|
||||
* Slash as separator
|
||||
*/
|
||||
// Slash as separator
|
||||
$separatorSlash = '/';
|
||||
|
||||
self::assertTrue(Regex::endsWithDirectorySeparator('my simple text/', $separatorSlash));
|
||||
self::assertFalse(Regex::endsWithDirectorySeparator('my simple text', $separatorSlash));
|
||||
|
||||
/*
|
||||
* Backslash as separator
|
||||
*/
|
||||
// Backslash as separator
|
||||
$separatorBackslash = '\\';
|
||||
|
||||
self::assertTrue(Regex::endsWithDirectorySeparator('my simple text\\', $separatorBackslash));
|
||||
@@ -912,17 +925,13 @@ class RegexTest extends BaseTestCase
|
||||
false,
|
||||
];
|
||||
|
||||
/*
|
||||
* Microsoft sp. z o.o.
|
||||
*/
|
||||
// Microsoft sp. z o.o.
|
||||
yield[
|
||||
'5270103391',
|
||||
true,
|
||||
];
|
||||
|
||||
/*
|
||||
* Onet S.A.
|
||||
*/
|
||||
// Onet S.A.
|
||||
yield[
|
||||
'7340009469',
|
||||
true,
|
||||
@@ -1994,25 +2003,4 @@ class RegexTest extends BaseTestCase
|
||||
true,
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
$this->simpleText = 'lorem ipsum dolor sit';
|
||||
$simpleUppercase = ucwords($this->simpleText);
|
||||
$this->camelCaseText = str_replace(' ', '', lcfirst($simpleUppercase)); // 'loremIpsumDolorSit'
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function tearDown(): void
|
||||
{
|
||||
parent::tearDown();
|
||||
unset($this->simpleText, $this->camelCaseText);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -34,6 +34,16 @@ class Sortable
|
||||
$this->position = $position;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns representation of object as string
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function __toString()
|
||||
{
|
||||
return sprintf('%s (position: %d)', self::class, $this->getPosition());
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns position used while sorting
|
||||
*
|
||||
@@ -53,14 +63,4 @@ class Sortable
|
||||
{
|
||||
$this->position = $position;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns representation of object as string
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function __toString()
|
||||
{
|
||||
return sprintf('%s (position: %d)', self::class, $this->getPosition());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,7 +10,6 @@ namespace Meritoo\Test\Common\Utilities;
|
||||
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use Doctrine\ORM\EntityRepository;
|
||||
use Doctrine\ORM\Query\Expr\OrderBy;
|
||||
use Doctrine\ORM\QueryBuilder;
|
||||
use Generator;
|
||||
use Meritoo\Common\Test\Base\BaseTestCase;
|
||||
@@ -23,6 +22,9 @@ use stdClass;
|
||||
*
|
||||
* @author Meritoo <github@meritoo.pl>
|
||||
* @copyright Meritoo <http://www.meritoo.pl>
|
||||
*
|
||||
* @internal
|
||||
* @covers \Meritoo\Common\Utilities\Repository
|
||||
*/
|
||||
class RepositoryTest extends BaseTestCase
|
||||
{
|
||||
@@ -53,27 +55,19 @@ class RepositoryTest extends BaseTestCase
|
||||
new stdClass(),
|
||||
];
|
||||
|
||||
/*
|
||||
* Using defaults
|
||||
*/
|
||||
// Using defaults
|
||||
Repository::replenishPositions($before);
|
||||
static::assertEquals($before, $after);
|
||||
|
||||
/*
|
||||
* Place items at the top
|
||||
*/
|
||||
// Place items at the top
|
||||
Repository::replenishPositions($before, false);
|
||||
static::assertEquals($before, $after);
|
||||
|
||||
/*
|
||||
* Set positions even there is no extreme position (at the end)
|
||||
*/
|
||||
// Set positions even there is no extreme position (at the end)
|
||||
Repository::replenishPositions($before, true, true);
|
||||
static::assertEquals($before, $after);
|
||||
|
||||
/*
|
||||
* Set positions even there is no extreme position (at the top)
|
||||
*/
|
||||
// Set positions even there is no extreme position (at the top)
|
||||
Repository::replenishPositions($before, false, true);
|
||||
static::assertEquals($before, $after);
|
||||
}
|
||||
@@ -238,7 +232,7 @@ class RepositoryTest extends BaseTestCase
|
||||
$orderDQLPart = $queryBuilder->getDQLPart('orderBy');
|
||||
$rootAliases = $queryBuilder->getRootAliases();
|
||||
|
||||
/* @var OrderBy $orderBy */
|
||||
/** @var OrderBy $orderBy */
|
||||
$orderBy = $orderDQLPart[0];
|
||||
|
||||
static::assertInstanceOf(QueryBuilder::class, $queryBuilder);
|
||||
@@ -293,7 +287,7 @@ class RepositoryTest extends BaseTestCase
|
||||
if (empty($property)) {
|
||||
static::assertSame([], $orderDQLPart);
|
||||
} else {
|
||||
/* @var OrderBy $orderBy */
|
||||
/** @var OrderBy $orderBy */
|
||||
$orderBy = $orderDQLPart[0];
|
||||
|
||||
static::assertSame([$expectedOrderBy], $orderBy->getParts());
|
||||
|
||||
@@ -17,6 +17,9 @@ use Meritoo\Common\Utilities\Uri;
|
||||
*
|
||||
* @author Meritoo <github@meritoo.pl>
|
||||
* @copyright Meritoo <http://www.meritoo.pl>
|
||||
*
|
||||
* @internal
|
||||
* @covers \Meritoo\Common\Utilities\Uri
|
||||
*/
|
||||
class UriTest extends BaseTestCase
|
||||
{
|
||||
|
||||
@@ -17,38 +17,15 @@ use SimpleXMLElement;
|
||||
*
|
||||
* @author Meritoo <github@meritoo.pl>
|
||||
* @copyright Meritoo <http://www.meritoo.pl>
|
||||
*
|
||||
* @internal
|
||||
* @covers \Meritoo\Common\Utilities\Xml
|
||||
*/
|
||||
class XmlTest extends BaseTestCase
|
||||
{
|
||||
private $simpleXml;
|
||||
private $advancedXml;
|
||||
|
||||
public function testConstructor()
|
||||
{
|
||||
static::assertHasNoConstructor(Xml::class);
|
||||
}
|
||||
|
||||
public function testMergeNodes()
|
||||
{
|
||||
/*
|
||||
* An empty XMLs
|
||||
*/
|
||||
$element1 = new SimpleXMLElement('<?xml version="1.0" encoding="UTF-8"?><cars />');
|
||||
$element2 = new SimpleXMLElement('<?xml version="1.0" encoding="UTF-8"?><employees />');
|
||||
|
||||
$merged = Xml::mergeNodes($element1, $element2);
|
||||
self::assertEquals('', (string)$merged);
|
||||
|
||||
/*
|
||||
* XMLs with data
|
||||
*/
|
||||
$element1 = new SimpleXMLElement($this->simpleXml);
|
||||
$element2 = new SimpleXMLElement($this->advancedXml);
|
||||
|
||||
$merged = Xml::mergeNodes($element1, $element2);
|
||||
self::assertEquals('John', (string)$merged->author[0]->first_name);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
@@ -90,7 +67,28 @@ class XmlTest extends BaseTestCase
|
||||
{
|
||||
parent::tearDown();
|
||||
|
||||
unset($this->simpleXml);
|
||||
unset($this->advancedXml);
|
||||
unset($this->simpleXml, $this->advancedXml);
|
||||
}
|
||||
|
||||
public function testConstructor()
|
||||
{
|
||||
static::assertHasNoConstructor(Xml::class);
|
||||
}
|
||||
|
||||
public function testMergeNodes()
|
||||
{
|
||||
// An empty XMLs
|
||||
$element1 = new SimpleXMLElement('<?xml version="1.0" encoding="UTF-8"?><cars />');
|
||||
$element2 = new SimpleXMLElement('<?xml version="1.0" encoding="UTF-8"?><employees />');
|
||||
|
||||
$merged = Xml::mergeNodes($element1, $element2);
|
||||
self::assertEquals('', (string)$merged);
|
||||
|
||||
// XMLs with data
|
||||
$element1 = new SimpleXMLElement($this->simpleXml);
|
||||
$element2 = new SimpleXMLElement($this->advancedXml);
|
||||
|
||||
$merged = Xml::mergeNodes($element1, $element2);
|
||||
self::assertEquals('John', (string)$merged->author[0]->first_name);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,6 +17,9 @@ use Meritoo\Common\ValueObject\Address;
|
||||
*
|
||||
* @author Meritoo <github@meritoo.pl>
|
||||
* @copyright Meritoo <http://www.meritoo.pl>
|
||||
*
|
||||
* @internal
|
||||
* @covers \Meritoo\Common\ValueObject\Address
|
||||
*/
|
||||
class AddressTest extends BaseTestCase
|
||||
{
|
||||
@@ -35,6 +38,15 @@ class AddressTest extends BaseTestCase
|
||||
*/
|
||||
private $addressWithoutStreet;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
$this->address = new Address('New York', '00123', '4th Avenue', '10', '200');
|
||||
$this->addressWithoutFlat = new Address('San Francisco', '00456', 'Green Street', '22');
|
||||
$this->addressWithoutStreet = new Address('Saint Louis', '00111', '', '1', '300');
|
||||
}
|
||||
|
||||
public function testConstructor()
|
||||
{
|
||||
static::assertConstructorVisibilityAndArguments(
|
||||
@@ -93,13 +105,4 @@ class AddressTest extends BaseTestCase
|
||||
static::assertSame('Green Street 22, 00456, San Francisco', (string)$this->addressWithoutFlat);
|
||||
static::assertSame('00111, Saint Louis', (string)$this->addressWithoutStreet);
|
||||
}
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
$this->address = new Address('New York', '00123', '4th Avenue', '10', '200');
|
||||
$this->addressWithoutFlat = new Address('San Francisco', '00456', 'Green Street', '22');
|
||||
$this->addressWithoutStreet = new Address('Saint Louis', '00111', '', '1', '300');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,6 +17,9 @@ use Meritoo\Common\ValueObject\BankAccount;
|
||||
*
|
||||
* @author Meritoo <github@meritoo.pl>
|
||||
* @copyright Meritoo <http://www.meritoo.pl>
|
||||
*
|
||||
* @internal
|
||||
* @covers \Meritoo\Common\ValueObject\BankAccount
|
||||
*/
|
||||
class BankAccountTest extends BaseTestCase
|
||||
{
|
||||
@@ -30,6 +33,17 @@ class BankAccountTest extends BaseTestCase
|
||||
*/
|
||||
private $bankAccount;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
$this->emptyBankAccount = new BankAccount('', '');
|
||||
$this->bankAccount = new BankAccount('Bank of America', '1234567890');
|
||||
}
|
||||
|
||||
public function testConstructor()
|
||||
{
|
||||
static::assertConstructorVisibilityAndArguments(
|
||||
@@ -57,15 +71,4 @@ class BankAccountTest extends BaseTestCase
|
||||
static::assertSame('', (string)$this->emptyBankAccount);
|
||||
static::assertSame('Bank of America, 1234567890', (string)$this->bankAccount);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
$this->emptyBankAccount = new BankAccount('', '');
|
||||
$this->bankAccount = new BankAccount('Bank of America', '1234567890');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,6 +19,9 @@ use Meritoo\Common\ValueObject\Company;
|
||||
*
|
||||
* @author Meritoo <github@meritoo.pl>
|
||||
* @copyright Meritoo <http://www.meritoo.pl>
|
||||
*
|
||||
* @internal
|
||||
* @covers \Meritoo\Common\ValueObject\Company
|
||||
*/
|
||||
class CompanyTest extends BaseTestCase
|
||||
{
|
||||
@@ -32,6 +35,25 @@ class CompanyTest extends BaseTestCase
|
||||
*/
|
||||
private $companyWithoutBankAccount;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
$this->company = new Company(
|
||||
'Test 1',
|
||||
new Address('New York', '00123', '4th Avenue', '10', '200'),
|
||||
new BankAccount('Bank 1', '12345')
|
||||
);
|
||||
|
||||
$this->companyWithoutBankAccount = new Company(
|
||||
'Test 2',
|
||||
new Address('San Francisco', '00456', 'Green Street', '22')
|
||||
);
|
||||
}
|
||||
|
||||
public function testConstructor()
|
||||
{
|
||||
static::assertConstructorVisibilityAndArguments(
|
||||
@@ -76,23 +98,4 @@ class CompanyTest extends BaseTestCase
|
||||
static::assertSame('Test 1, 4th Avenue 10/200, 00123, New York, Bank 1, 12345', (string)$this->company);
|
||||
static::assertSame('Test 2, Green Street 22, 00456, San Francisco', (string)$this->companyWithoutBankAccount);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
$this->company = new Company(
|
||||
'Test 1',
|
||||
new Address('New York', '00123', '4th Avenue', '10', '200'),
|
||||
new BankAccount('Bank 1', '12345')
|
||||
);
|
||||
|
||||
$this->companyWithoutBankAccount = new Company(
|
||||
'Test 2',
|
||||
new Address('San Francisco', '00456', 'Green Street', '22')
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,6 +17,9 @@ use Meritoo\Common\ValueObject\Human;
|
||||
*
|
||||
* @author Meritoo <github@meritoo.pl>
|
||||
* @copyright Meritoo <http://www.meritoo.pl>
|
||||
*
|
||||
* @internal
|
||||
* @covers \Meritoo\Common\ValueObject\Human
|
||||
*/
|
||||
class HumanTest extends BaseTestCase
|
||||
{
|
||||
|
||||
@@ -18,6 +18,9 @@ use Meritoo\Common\ValueObject\Size;
|
||||
*
|
||||
* @author Meritoo <github@meritoo.pl>
|
||||
* @copyright Meritoo <http://www.meritoo.pl>
|
||||
*
|
||||
* @internal
|
||||
* @covers \Meritoo\Common\ValueObject\Size
|
||||
*/
|
||||
class SizeTest extends BaseTestCase
|
||||
{
|
||||
@@ -32,12 +35,12 @@ class SizeTest extends BaseTestCase
|
||||
|
||||
/**
|
||||
* @param string $description Description of test
|
||||
* @param Size|null $size Size to convert
|
||||
* @param null|Size $size Size to convert
|
||||
* @param string $expected Expected result
|
||||
*
|
||||
* @dataProvider provideSizeForConvertingToString
|
||||
*/
|
||||
public function test__toString($description, $size, $expected)
|
||||
public function testToStringConverting($description, $size, $expected)
|
||||
{
|
||||
static::assertEquals($expected, (string)$size, $description);
|
||||
}
|
||||
@@ -57,7 +60,7 @@ class SizeTest extends BaseTestCase
|
||||
* @param string $description Description of test
|
||||
* @param Size $size Size to get width
|
||||
* @param bool $withUnit If is set to true, width is returned with unit ("px"). Otherwise - without.
|
||||
* @param string|int $expected Expected width
|
||||
* @param int|string $expected Expected width
|
||||
*
|
||||
* @dataProvider provideSizeToGetWidth
|
||||
*/
|
||||
@@ -70,7 +73,7 @@ class SizeTest extends BaseTestCase
|
||||
* @param string $description Description of test
|
||||
* @param Size $size Size to set width
|
||||
* @param int|string $width The width
|
||||
* @param string|int $expected Expected width
|
||||
* @param int|string $expected Expected width
|
||||
*
|
||||
* @dataProvider provideSizeToSetWidth
|
||||
*/
|
||||
@@ -86,7 +89,7 @@ class SizeTest extends BaseTestCase
|
||||
* @param string $description Description of test
|
||||
* @param Size $size Size to get width
|
||||
* @param bool $withUnit If is set to true, width is returned with unit ("px"). Otherwise - without.
|
||||
* @param string|int $expected Expected width
|
||||
* @param int|string $expected Expected width
|
||||
*
|
||||
* @dataProvider provideSizeToGetHeight
|
||||
*/
|
||||
@@ -99,7 +102,7 @@ class SizeTest extends BaseTestCase
|
||||
* @param string $description Description of test
|
||||
* @param Size $size Size to set height
|
||||
* @param int|string $height The height
|
||||
* @param string|int $expected Expected height
|
||||
* @param int|string $expected Expected height
|
||||
*
|
||||
* @dataProvider provideSizeToSetHeight
|
||||
*/
|
||||
@@ -167,7 +170,7 @@ class SizeTest extends BaseTestCase
|
||||
* @param string $size The size represented as string (width and height separated by "x")
|
||||
* @param string $unit Unit used when width or height should be returned with unit
|
||||
* @param string $separator Separator used to split width and height
|
||||
* @param Size|null $expected Expected result
|
||||
* @param null|Size $expected Expected result
|
||||
*
|
||||
* @dataProvider provideSizeForFromString
|
||||
*/
|
||||
|
||||
@@ -19,6 +19,9 @@ use Meritoo\Common\ValueObject\Version;
|
||||
*
|
||||
* @author Meritoo <github@meritoo.pl>
|
||||
* @copyright Meritoo <http://www.meritoo.pl>
|
||||
*
|
||||
* @internal
|
||||
* @covers \Meritoo\Common\ValueObject\Version
|
||||
*/
|
||||
class VersionTest extends BaseTestCase
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user