diff --git a/.gitattributes b/.gitattributes index 8d911e448..0ce94478e 100644 --- a/.gitattributes +++ b/.gitattributes @@ -4,3 +4,4 @@ .scrutinizer.yml export-ignore .travis.yml export-ignore phpunit.xml.dist export-ignore +/phpcs.xml.dist export-ignore diff --git a/.gitignore b/.gitignore index 223775c48..63764ceb8 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,5 @@ vendor/ composer.lock build/ +/phpcs.xml +/.phpcs-cache diff --git a/.travis.yml b/.travis.yml index e782cb4b0..da9a148dd 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,21 +1,44 @@ -language: php +dist: trusty sudo: false +language: php + +cache: + directories: + - $HOME/.composer/cache php: - 7.1 + - 7.2 - nightly -matrix: - fast_finish: true - before_install: - - if [[ $TRAVIS_PHP_VERSION = '7.1' ]]; then PHPUNIT_FLAGS="--coverage-clover clover.xml"; fi + - mv ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini{,.disabled} || echo "xdebug not available" + +install: + - travis_retry composer -n --prefer-source install + +script: ./vendor/bin/phpunit + +jobs: + allow_failures: + - php: nightly -before_script: - - composer -n --prefer-source install + include: + - stage: Coverage + before_script: + - mv ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini{.disabled,} + - if [[ ! $(php -m | grep -si xdebug) ]]; then echo "xdebug required for coverage"; exit 1; fi + script: + - ./vendor/bin/phpunit --coverage-clover clover.xml + after_script: + - wget https://scrutinizer-ci.com/ocular.phar + - php ocular.phar code-coverage:upload --format=php-clover clover.xml -script: - - vendor/bin/phpunit $PHPUNIT_FLAGS + - stage: Coding standard + script: + - ./vendor/bin/phpcs -after_script: - - if [ -f clover.xml ]; then wget https://scrutinizer-ci.com/ocular.phar && php ocular.phar code-coverage:upload --format=php-clover clover.xml; fi + - stage: Lint + before_script: + - travis_retry composer require --dev --prefer-dist --prefer-stable phpstan/phpstan:^0.8 + script: vendor/bin/phpstan analyse -l 3 lib diff --git a/composer.json b/composer.json index a277f3057..58e187685 100644 --- a/composer.json +++ b/composer.json @@ -16,8 +16,9 @@ "php": "^7.1" }, "require-dev": { - "phpunit/phpunit": "^5.7", - "doctrine/coding-standard": "~0.1@dev" + "phpunit/phpunit": "^6.3", + "doctrine/coding-standard": "^1.0", + "squizlabs/php_codesniffer": "^3.0" }, "autoload": { "psr-4": { "Doctrine\\Common\\Collections\\": "lib/Doctrine/Common/Collections" } diff --git a/lib/Doctrine/Common/Collections/ArrayCollection.php b/lib/Doctrine/Common/Collections/ArrayCollection.php index 0bebce200..8eb6102f8 100644 --- a/lib/Doctrine/Common/Collections/ArrayCollection.php +++ b/lib/Doctrine/Common/Collections/ArrayCollection.php @@ -405,7 +405,7 @@ public function matching(Criteria $criteria) $length = $criteria->getMaxResults(); if ($offset || $length) { - $filtered = array_slice($filtered, (int)$offset, $length); + $filtered = array_slice($filtered, (int) $offset, $length); } return $this->createFrom($filtered); diff --git a/lib/Doctrine/Common/Collections/Criteria.php b/lib/Doctrine/Common/Collections/Criteria.php index 748a08474..84ef9eb2a 100644 --- a/lib/Doctrine/Common/Collections/Criteria.php +++ b/lib/Doctrine/Common/Collections/Criteria.php @@ -33,7 +33,7 @@ class Criteria /** * @var string */ - const ASC = 'ASC'; + const ASC = 'ASC'; /** * @var string diff --git a/lib/Doctrine/Common/Collections/Expr/ClosureExpressionVisitor.php b/lib/Doctrine/Common/Collections/Expr/ClosureExpressionVisitor.php index 70b6b7ef7..0d48b5bb8 100644 --- a/lib/Doctrine/Common/Collections/Expr/ClosureExpressionVisitor.php +++ b/lib/Doctrine/Common/Collections/Expr/ClosureExpressionVisitor.php @@ -74,7 +74,9 @@ public static function getObjectFieldValue($object, $field) } // camelcase field name to support different variable naming conventions - $ccField = preg_replace_callback('/_(.?)/', function($matches) { return strtoupper($matches[1]); }, $field); + $ccField = preg_replace_callback('/_(.?)/', function ($matches) { + return strtoupper($matches[1]); + }, $field); foreach ($accessors as $accessor) { $accessor .= $ccField; @@ -102,7 +104,7 @@ public static function getObjectFieldValue($object, $field) public static function sortByField($name, $orientation = 1, \Closure $next = null) { if ( ! $next) { - $next = function() : int { + $next = function () : int { return 0; }; } @@ -176,7 +178,7 @@ public function walkComparison(Comparison $comparison) case Comparison::MEMBER_OF: return function ($object) use ($field, $value) : bool { $fieldValues = ClosureExpressionVisitor::getObjectFieldValue($object, $field); - if (!is_array($fieldValues)) { + if ( ! is_array($fieldValues)) { $fieldValues = iterator_to_array($fieldValues); } return in_array($value, $fieldValues, true); @@ -217,7 +219,7 @@ public function walkCompositeExpression(CompositeExpression $expr) $expressionList[] = $this->dispatch($child); } - switch($expr->getType()) { + switch ($expr->getType()) { case CompositeExpression::TYPE_AND: return $this->andExpressions($expressionList); diff --git a/lib/Doctrine/Common/Collections/Expr/Comparison.php b/lib/Doctrine/Common/Collections/Expr/Comparison.php index 72fa5eb75..08d91648f 100644 --- a/lib/Doctrine/Common/Collections/Expr/Comparison.php +++ b/lib/Doctrine/Common/Collections/Expr/Comparison.php @@ -27,19 +27,19 @@ */ class Comparison implements Expression { - const EQ = '='; - const NEQ = '<>'; - const LT = '<'; - const LTE = '<='; - const GT = '>'; - const GTE = '>='; - const IS = '='; // no difference with EQ - const IN = 'IN'; - const NIN = 'NIN'; - const CONTAINS = 'CONTAINS'; - const MEMBER_OF = 'MEMBER_OF'; - const STARTS_WITH = 'STARTS_WITH'; - const ENDS_WITH = 'ENDS_WITH'; + const EQ = '='; + const NEQ = '<>'; + const LT = '<'; + const LTE = '<='; + const GT = '>'; + const GTE = '>='; + const IS = '='; // no difference with EQ + const IN = 'IN'; + const NIN = 'NIN'; + const CONTAINS = 'CONTAINS'; + const MEMBER_OF = 'MEMBER_OF'; + const STARTS_WITH = 'STARTS_WITH'; + const ENDS_WITH = 'ENDS_WITH'; /** * @var string @@ -68,7 +68,7 @@ public function __construct($field, $operator, $value) } $this->field = $field; - $this->op = $operator; + $this->op = $operator; $this->value = $value; } diff --git a/lib/Doctrine/Common/Collections/Expr/CompositeExpression.php b/lib/Doctrine/Common/Collections/Expr/CompositeExpression.php index 2879754ec..6ac58b5b9 100644 --- a/lib/Doctrine/Common/Collections/Expr/CompositeExpression.php +++ b/lib/Doctrine/Common/Collections/Expr/CompositeExpression.php @@ -28,7 +28,7 @@ class CompositeExpression implements Expression { const TYPE_AND = 'AND'; - const TYPE_OR = 'OR'; + const TYPE_OR = 'OR'; /** * @var string diff --git a/lib/Doctrine/Common/Collections/ExpressionBuilder.php b/lib/Doctrine/Common/Collections/ExpressionBuilder.php index ca74f4242..60f84606c 100644 --- a/lib/Doctrine/Common/Collections/ExpressionBuilder.php +++ b/lib/Doctrine/Common/Collections/ExpressionBuilder.php @@ -195,6 +195,5 @@ public function startsWith($field, $value) public function endsWith($field, $value) { return new Comparison($field, Comparison::ENDS_WITH, new Value($value)); - } - + } } diff --git a/phpcs.xml.dist b/phpcs.xml.dist new file mode 100644 index 000000000..9de252f86 --- /dev/null +++ b/phpcs.xml.dist @@ -0,0 +1,20 @@ + + + + + + + + + + + + lib + tests + + + + + */tests/* + + diff --git a/phpunit.xml.dist b/phpunit.xml.dist index b31fbf01b..f9eb96480 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -1,13 +1,11 @@ diff --git a/tests/Doctrine/Tests/Common/Collections/AbstractLazyArrayCollectionTest.php b/tests/Doctrine/Tests/Common/Collections/AbstractLazyArrayCollectionTest.php index cadd73c1e..60ad03c3a 100644 --- a/tests/Doctrine/Tests/Common/Collections/AbstractLazyArrayCollectionTest.php +++ b/tests/Doctrine/Tests/Common/Collections/AbstractLazyArrayCollectionTest.php @@ -40,7 +40,7 @@ public function testLazyCollection() : void /** @var LazyArrayCollection $collection */ $collection = $this->buildCollection(['a', 'b', 'c']); - $this->assertFalse($collection->isInitialized()); - $this->assertCount(3, $collection); + self::assertFalse($collection->isInitialized()); + self::assertCount(3, $collection); } } diff --git a/tests/Doctrine/Tests/Common/Collections/BaseArrayCollectionTest.php b/tests/Doctrine/Tests/Common/Collections/BaseArrayCollectionTest.php index 9dbf33a1b..523e7e54b 100644 --- a/tests/Doctrine/Tests/Common/Collections/BaseArrayCollectionTest.php +++ b/tests/Doctrine/Tests/Common/Collections/BaseArrayCollectionTest.php @@ -23,7 +23,7 @@ use Doctrine\Common\Collections\Criteria; use Doctrine\Common\Collections\Selectable; -abstract class BaseArrayCollectionTest extends \PHPUnit_Framework_TestCase +abstract class BaseArrayCollectionTest extends \PHPUnit\Framework\TestCase { abstract protected function buildCollection(array $elements = []) : Collection; @@ -39,7 +39,7 @@ public function testToArray($elements) : void { $collection = $this->buildCollection($elements); - $this->assertSame($elements, $collection->toArray()); + self::assertSame($elements, $collection->toArray()); } /** @@ -48,7 +48,7 @@ public function testToArray($elements) : void public function testFirst($elements) : void { $collection = $this->buildCollection($elements); - $this->assertSame(reset($elements), $collection->first()); + self::assertSame(reset($elements), $collection->first()); } /** @@ -57,7 +57,7 @@ public function testFirst($elements) : void public function testLast($elements) : void { $collection = $this->buildCollection($elements); - $this->assertSame(end($elements), $collection->last()); + self::assertSame(end($elements), $collection->last()); } /** @@ -67,12 +67,12 @@ public function testKey($elements) : void { $collection = $this->buildCollection($elements); - $this->assertSame(key($elements), $collection->key()); + self::assertSame(key($elements), $collection->key()); next($elements); $collection->next(); - $this->assertSame(key($elements), $collection->key()); + self::assertSame(key($elements), $collection->key()); } /** @@ -84,15 +84,15 @@ public function testNext($elements) : void while (true) { $collectionNext = $collection->next(); - $arrayNext = next($elements); + $arrayNext = next($elements); - if (!$collectionNext || !$arrayNext) { + if ( ! $collectionNext || ! $arrayNext) { break; } - $this->assertSame($arrayNext, $collectionNext, 'Returned value of ArrayCollection::next() and next() not match'); - $this->assertSame(key($elements), $collection->key(), 'Keys not match'); - $this->assertSame(current($elements), $collection->current(), 'Current values not match'); + self::assertSame($arrayNext, $collectionNext, 'Returned value of ArrayCollection::next() and next() not match'); + self::assertSame(key($elements), $collection->key(), 'Keys not match'); + self::assertSame(current($elements), $collection->current(), 'Current values not match'); } } @@ -103,12 +103,12 @@ public function testCurrent($elements) : void { $collection = $this->buildCollection($elements); - $this->assertSame(current($elements), $collection->current()); + self::assertSame(current($elements), $collection->current()); next($elements); $collection->next(); - $this->assertSame(current($elements), $collection->current()); + self::assertSame(current($elements), $collection->current()); } /** @@ -118,7 +118,7 @@ public function testGetKeys($elements) : void { $collection = $this->buildCollection($elements); - $this->assertSame(array_keys($elements), $collection->getKeys()); + self::assertSame(array_keys($elements), $collection->getKeys()); } /** @@ -128,7 +128,7 @@ public function testGetValues($elements) : void { $collection = $this->buildCollection($elements); - $this->assertSame(array_values($elements), $collection->getValues()); + self::assertSame(array_values($elements), $collection->getValues()); } /** @@ -138,7 +138,7 @@ public function testCount($elements) : void { $collection = $this->buildCollection($elements); - $this->assertSame(count($elements), $collection->count()); + self::assertSame(count($elements), $collection->count()); } /** @@ -150,11 +150,11 @@ public function testIterator($elements) : void $iterations = 0; foreach ($collection->getIterator() as $key => $item) { - $this->assertSame($elements[$key], $item, "Item {$key} not match"); + self::assertSame($elements[$key], $item, "Item {$key} not match"); ++$iterations; } - $this->assertEquals(count($elements), $iterations, 'Number of iterations not match'); + self::assertEquals(count($elements), $iterations, 'Number of iterations not match'); } public function provideDifferentElements() : array @@ -168,106 +168,106 @@ public function provideDifferentElements() : array public function testRemove() : void { - $elements = [1, 'A' => 'a', 2, 'B' => 'b', 3]; + $elements = [1, 'A' => 'a', 2, 'B' => 'b', 3]; $collection = $this->buildCollection($elements); - $this->assertEquals(1, $collection->remove(0)); + self::assertEquals(1, $collection->remove(0)); unset($elements[0]); - $this->assertEquals(null, $collection->remove('non-existent')); + self::assertEquals(null, $collection->remove('non-existent')); unset($elements['non-existent']); - $this->assertEquals(2, $collection->remove(1)); + self::assertEquals(2, $collection->remove(1)); unset($elements[1]); - $this->assertEquals('a', $collection->remove('A')); + self::assertEquals('a', $collection->remove('A')); unset($elements['A']); - $this->assertEquals($elements, $collection->toArray()); + self::assertEquals($elements, $collection->toArray()); } public function testRemoveElement() : void { - $elements = [1, 'A' => 'a', 2, 'B' => 'b', 3, 'A2' => 'a', 'B2' => 'b']; + $elements = [1, 'A' => 'a', 2, 'B' => 'b', 3, 'A2' => 'a', 'B2' => 'b']; $collection = $this->buildCollection($elements); - $this->assertTrue($collection->removeElement(1)); + self::assertTrue($collection->removeElement(1)); unset($elements[0]); - $this->assertFalse($collection->removeElement('non-existent')); + self::assertFalse($collection->removeElement('non-existent')); - $this->assertTrue($collection->removeElement('a')); + self::assertTrue($collection->removeElement('a')); unset($elements['A']); - $this->assertTrue($collection->removeElement('a')); + self::assertTrue($collection->removeElement('a')); unset($elements['A2']); - $this->assertEquals($elements, $collection->toArray()); + self::assertEquals($elements, $collection->toArray()); } public function testContainsKey() : void { - $elements = [1, 'A' => 'a', 2, 'null' => null, 3, 'A2' => 'a', 'B2' => 'b']; + $elements = [1, 'A' => 'a', 2, 'null' => null, 3, 'A2' => 'a', 'B2' => 'b']; $collection = $this->buildCollection($elements); - $this->assertTrue($collection->containsKey(0), 'Contains index 0'); - $this->assertTrue($collection->containsKey('A'), 'Contains key "A"'); - $this->assertTrue($collection->containsKey('null'), 'Contains key "null", with value null'); - $this->assertFalse($collection->containsKey('non-existent'), "Doesn't contain key"); + self::assertTrue($collection->containsKey(0), 'Contains index 0'); + self::assertTrue($collection->containsKey('A'), 'Contains key "A"'); + self::assertTrue($collection->containsKey('null'), 'Contains key "null", with value null'); + self::assertFalse($collection->containsKey('non-existent'), "Doesn't contain key"); } public function testEmpty() : void { $collection = $this->buildCollection(); - $this->assertTrue($collection->isEmpty(), 'Empty collection'); + self::assertTrue($collection->isEmpty(), 'Empty collection'); $collection->add(1); - $this->assertFalse($collection->isEmpty(), 'Not empty collection'); + self::assertFalse($collection->isEmpty(), 'Not empty collection'); } public function testContains() : void { - $elements = [1, 'A' => 'a', 2, 'null' => null, 3, 'A2' => 'a', 'zero' => 0]; + $elements = [1, 'A' => 'a', 2, 'null' => null, 3, 'A2' => 'a', 'zero' => 0]; $collection = $this->buildCollection($elements); - $this->assertTrue($collection->contains(0), 'Contains Zero'); - $this->assertTrue($collection->contains('a'), 'Contains "a"'); - $this->assertTrue($collection->contains(null), 'Contains Null'); - $this->assertFalse($collection->contains('non-existent'), "Doesn't contain an element"); + self::assertTrue($collection->contains(0), 'Contains Zero'); + self::assertTrue($collection->contains('a'), 'Contains "a"'); + self::assertTrue($collection->contains(null), 'Contains Null'); + self::assertFalse($collection->contains('non-existent'), "Doesn't contain an element"); } public function testExists() : void { - $elements = [1, 'A' => 'a', 2, 'null' => null, 3, 'A2' => 'a', 'zero' => 0]; + $elements = [1, 'A' => 'a', 2, 'null' => null, 3, 'A2' => 'a', 'zero' => 0]; $collection = $this->buildCollection($elements); - $this->assertTrue($collection->exists(function ($key, $element) { + self::assertTrue($collection->exists(function ($key, $element) { return $key == 'A' && $element == 'a'; }), 'Element exists'); - $this->assertFalse($collection->exists(function ($key, $element) { + self::assertFalse($collection->exists(function ($key, $element) { return $key == 'non-existent' && $element == 'non-existent'; }), 'Element not exists'); } public function testIndexOf() : void { - $elements = [1, 'A' => 'a', 2, 'null' => null, 3, 'A2' => 'a', 'zero' => 0]; + $elements = [1, 'A' => 'a', 2, 'null' => null, 3, 'A2' => 'a', 'zero' => 0]; $collection = $this->buildCollection($elements); - $this->assertSame(array_search(2, $elements, true), $collection->indexOf(2), 'Index of 2'); - $this->assertSame(array_search(null, $elements, true), $collection->indexOf(null), 'Index of null'); - $this->assertSame(array_search('non-existent', $elements, true), $collection->indexOf('non-existent'), 'Index of non existent'); + self::assertSame(array_search(2, $elements, true), $collection->indexOf(2), 'Index of 2'); + self::assertSame(array_search(null, $elements, true), $collection->indexOf(null), 'Index of null'); + self::assertSame(array_search('non-existent', $elements, true), $collection->indexOf('non-existent'), 'Index of non existent'); } public function testGet() : void { - $elements = [1, 'A' => 'a', 2, 'null' => null, 3, 'A2' => 'a', 'zero' => 0]; + $elements = [1, 'A' => 'a', 2, 'null' => null, 3, 'A2' => 'a', 'zero' => 0]; $collection = $this->buildCollection($elements); - $this->assertSame(2, $collection->get(1), 'Get element by index'); - $this->assertSame('a', $collection->get('A'), 'Get element by name'); - $this->assertSame(null, $collection->get('non-existent'), 'Get non existent element'); + self::assertSame(2, $collection->get(1), 'Get element by index'); + self::assertSame('a', $collection->get('A'), 'Get element by name'); + self::assertSame(null, $collection->get('non-existent'), 'Get non existent element'); } public function testMatchingWithSortingPreservesyKeys() : void @@ -283,11 +283,11 @@ public function testMatchingWithSortingPreservesyKeys() : void 'object2' => $object2, ]); - if (!$this->isSelectable($collection)) { + if ( ! $this->isSelectable($collection)) { $this->markTestSkipped('Collection does not support Selectable interface'); } - $this->assertSame( + self::assertSame( [ 'object2' => $object2, 'object1' => $object1, @@ -312,11 +312,11 @@ public function testMultiColumnSortAppliesAllSorts() : void 0 => ['foo' => 1, 'bar' => 2] ]; - if (!$this->isSelectable($collection)) { + if ( ! $this->isSelectable($collection)) { $this->markTestSkipped('Collection does not support Selectable interface'); } - $this->assertSame( + self::assertSame( $expected, $collection ->matching(new Criteria(null, ['foo' => Criteria::DESC, 'bar' => Criteria::DESC])) diff --git a/tests/Doctrine/Tests/Common/Collections/BaseCollectionTest.php b/tests/Doctrine/Tests/Common/Collections/BaseCollectionTest.php index 409b0eec8..08cd9d596 100644 --- a/tests/Doctrine/Tests/Common/Collections/BaseCollectionTest.php +++ b/tests/Doctrine/Tests/Common/Collections/BaseCollectionTest.php @@ -4,7 +4,7 @@ use Doctrine\Common\Collections\Collection; -abstract class BaseCollectionTest extends \PHPUnit_Framework_TestCase +abstract class BaseCollectionTest extends \PHPUnit\Framework\TestCase { /** * @var Collection @@ -13,16 +13,16 @@ abstract class BaseCollectionTest extends \PHPUnit_Framework_TestCase public function testIssetAndUnset() : void { - $this->assertFalse(isset($this->collection[0])); + self::assertFalse(isset($this->collection[0])); $this->collection->add('testing'); - $this->assertTrue(isset($this->collection[0])); + self::assertTrue(isset($this->collection[0])); unset($this->collection[0]); - $this->assertFalse(isset($this->collection[0])); + self::assertFalse(isset($this->collection[0])); } public function testRemovingNonExistentEntryReturnsNull() : void { - $this->assertEquals(null, $this->collection->remove('testing_does_not_exist')); + self::assertEquals(null, $this->collection->remove('testing_does_not_exist')); } public function testExists() : void @@ -32,11 +32,11 @@ public function testExists() : void $exists = $this->collection->exists(function ($k, $e) { return $e == 'one'; }); - $this->assertTrue($exists); + self::assertTrue($exists); $exists = $this->collection->exists(function ($k, $e) { return $e == 'other'; }); - $this->assertFalse($exists); + self::assertFalse($exists); } public function testMap() : void @@ -46,7 +46,7 @@ public function testMap() : void $res = $this->collection->map(function ($e) { return $e * 2; }); - $this->assertEquals([2, 4], $res->toArray()); + self::assertEquals([2, 4], $res->toArray()); } public function testFilter() : void @@ -57,7 +57,7 @@ public function testFilter() : void $res = $this->collection->filter(function ($e) { return is_numeric($e); }); - $this->assertEquals([0 => 1, 2 => 3], $res->toArray()); + self::assertEquals([0 => 1, 2 => 3], $res->toArray()); } public function testFirstAndLast() : void @@ -65,8 +65,8 @@ public function testFirstAndLast() : void $this->collection->add('one'); $this->collection->add('two'); - $this->assertEquals($this->collection->first(), 'one'); - $this->assertEquals($this->collection->last(), 'two'); + self::assertEquals($this->collection->first(), 'one'); + self::assertEquals($this->collection->last(), 'two'); } public function testArrayAccess() : void @@ -74,67 +74,67 @@ public function testArrayAccess() : void $this->collection[] = 'one'; $this->collection[] = 'two'; - $this->assertEquals($this->collection[0], 'one'); - $this->assertEquals($this->collection[1], 'two'); + self::assertEquals($this->collection[0], 'one'); + self::assertEquals($this->collection[1], 'two'); unset($this->collection[0]); - $this->assertEquals($this->collection->count(), 1); + self::assertEquals($this->collection->count(), 1); } public function testContainsKey() : void { $this->collection[5] = 'five'; - $this->assertTrue($this->collection->containsKey(5)); + self::assertTrue($this->collection->containsKey(5)); } public function testContains() : void { $this->collection[0] = 'test'; - $this->assertTrue($this->collection->contains('test')); + self::assertTrue($this->collection->contains('test')); } public function testSearch() : void { $this->collection[0] = 'test'; - $this->assertEquals(0, $this->collection->indexOf('test')); + self::assertEquals(0, $this->collection->indexOf('test')); } public function testGet() : void { $this->collection[0] = 'test'; - $this->assertEquals('test', $this->collection->get(0)); + self::assertEquals('test', $this->collection->get(0)); } public function testGetKeys() : void { $this->collection[] = 'one'; $this->collection[] = 'two'; - $this->assertEquals([0, 1], $this->collection->getKeys()); + self::assertEquals([0, 1], $this->collection->getKeys()); } public function testGetValues() : void { $this->collection[] = 'one'; $this->collection[] = 'two'; - $this->assertEquals(['one', 'two'], $this->collection->getValues()); + self::assertEquals(['one', 'two'], $this->collection->getValues()); } public function testCount() : void { $this->collection[] = 'one'; $this->collection[] = 'two'; - $this->assertEquals($this->collection->count(), 2); - $this->assertEquals(count($this->collection), 2); + self::assertEquals($this->collection->count(), 2); + self::assertEquals(count($this->collection), 2); } public function testForAll() : void { $this->collection[] = 'one'; $this->collection[] = 'two'; - $this->assertEquals($this->collection->forAll(function ($k, $e) { + self::assertEquals($this->collection->forAll(function ($k, $e) { return is_string($e); }), true); - $this->assertEquals($this->collection->forAll(function ($k, $e) { + self::assertEquals($this->collection->forAll(function ($k, $e) { return is_array($e); }), false); } @@ -143,11 +143,11 @@ public function testPartition() : void { $this->collection[] = true; $this->collection[] = false; - $partition = $this->collection->partition(function ($k, $e) { + $partition = $this->collection->partition(function ($k, $e) { return $e == true; }); - $this->assertEquals($partition[0][0], true); - $this->assertEquals($partition[1][0], false); + self::assertEquals($partition[0][0], true); + self::assertEquals($partition[1][0], false); } public function testClear() : void @@ -155,18 +155,18 @@ public function testClear() : void $this->collection[] = 'one'; $this->collection[] = 'two'; $this->collection->clear(); - $this->assertEquals($this->collection->isEmpty(), true); + self::assertEquals($this->collection->isEmpty(), true); } public function testRemove() : void { $this->collection[] = 'one'; $this->collection[] = 'two'; - $el = $this->collection->remove(0); + $el = $this->collection->remove(0); - $this->assertEquals('one', $el); - $this->assertEquals($this->collection->contains('one'), false); - $this->assertNull($this->collection->remove(0)); + self::assertEquals('one', $el); + self::assertEquals($this->collection->contains('one'), false); + self::assertNull($this->collection->remove(0)); } public function testRemoveElement() : void @@ -174,9 +174,9 @@ public function testRemoveElement() : void $this->collection[] = 'one'; $this->collection[] = 'two'; - $this->assertTrue($this->collection->removeElement('two')); - $this->assertFalse($this->collection->contains('two')); - $this->assertFalse($this->collection->removeElement('two')); + self::assertTrue($this->collection->removeElement('two')); + self::assertFalse($this->collection->contains('two')); + self::assertFalse($this->collection->removeElement('two')); } public function testSlice() : void @@ -186,24 +186,24 @@ public function testSlice() : void $this->collection[] = 'three'; $slice = $this->collection->slice(0, 1); - $this->assertInternalType('array', $slice); - $this->assertEquals(['one'], $slice); + self::assertInternalType('array', $slice); + self::assertEquals(['one'], $slice); $slice = $this->collection->slice(1); - $this->assertEquals([1 => 'two', 2 => 'three'], $slice); + self::assertEquals([1 => 'two', 2 => 'three'], $slice); $slice = $this->collection->slice(1, 1); - $this->assertEquals([1 => 'two'], $slice); + self::assertEquals([1 => 'two'], $slice); } protected function fillMatchingFixture() : void { - $std1 = new \stdClass(); - $std1->foo = 'bar'; + $std1 = new \stdClass(); + $std1->foo = 'bar'; $this->collection[] = $std1; - $std2 = new \stdClass(); - $std2->foo = 'baz'; + $std2 = new \stdClass(); + $std2->foo = 'baz'; $this->collection[] = $std2; } @@ -211,12 +211,12 @@ public function testCanRemoveNullValuesByKey() : void { $this->collection->add(null); $this->collection->remove(0); - $this->assertTrue($this->collection->isEmpty()); + self::assertTrue($this->collection->isEmpty()); } public function testCanVerifyExistingKeysWithNullValues() : void { $this->collection->set('key', null); - $this->assertTrue($this->collection->containsKey('key')); + self::assertTrue($this->collection->containsKey('key')); } } diff --git a/tests/Doctrine/Tests/Common/Collections/ClosureExpressionVisitorTest.php b/tests/Doctrine/Tests/Common/Collections/ClosureExpressionVisitorTest.php index 931f0d14a..2bbf027d8 100644 --- a/tests/Doctrine/Tests/Common/Collections/ClosureExpressionVisitorTest.php +++ b/tests/Doctrine/Tests/Common/Collections/ClosureExpressionVisitorTest.php @@ -25,7 +25,7 @@ /** * @group DDC-1637 */ -class ClosureExpressionVisitorTest extends \PHPUnit_Framework_TestCase +class ClosureExpressionVisitorTest extends \PHPUnit\Framework\TestCase { /** * @var ClosureExpressionVisitor @@ -47,157 +47,157 @@ public function testGetObjectFieldValueIsAccessor() : void { $object = new TestObject(1, 2, true); - $this->assertTrue($this->visitor->getObjectFieldValue($object, 'baz')); + self::assertTrue($this->visitor->getObjectFieldValue($object, 'baz')); } public function testGetObjectFieldValueIsAccessorCamelCase() : void { $object = new TestObjectNotCamelCase(1); - $this->assertEquals(1, $this->visitor->getObjectFieldValue($object, 'foo_bar')); - $this->assertEquals(1, $this->visitor->getObjectFieldValue($object, 'foobar')); - $this->assertEquals(1, $this->visitor->getObjectFieldValue($object, 'fooBar')); + self::assertEquals(1, $this->visitor->getObjectFieldValue($object, 'foo_bar')); + self::assertEquals(1, $this->visitor->getObjectFieldValue($object, 'foobar')); + self::assertEquals(1, $this->visitor->getObjectFieldValue($object, 'fooBar')); } public function testGetObjectFieldValueIsAccessorBoth() : void { $object = new TestObjectBothCamelCaseAndUnderscore(1, 2); - $this->assertEquals(2, $this->visitor->getObjectFieldValue($object, 'foo_bar')); - $this->assertEquals(2, $this->visitor->getObjectFieldValue($object, 'foobar')); - $this->assertEquals(2, $this->visitor->getObjectFieldValue($object, 'fooBar')); + self::assertEquals(2, $this->visitor->getObjectFieldValue($object, 'foo_bar')); + self::assertEquals(2, $this->visitor->getObjectFieldValue($object, 'foobar')); + self::assertEquals(2, $this->visitor->getObjectFieldValue($object, 'fooBar')); } public function testGetObjectFieldValueIsAccessorOnePublic() : void { $object = new TestObjectPublicCamelCaseAndPrivateUnderscore(1, 2); - $this->assertEquals(2, $this->visitor->getObjectFieldValue($object, 'foo_bar')); - $this->assertEquals(2, $this->visitor->getObjectFieldValue($object, 'foobar')); - $this->assertEquals(2, $this->visitor->getObjectFieldValue($object, 'fooBar')); + self::assertEquals(2, $this->visitor->getObjectFieldValue($object, 'foo_bar')); + self::assertEquals(2, $this->visitor->getObjectFieldValue($object, 'foobar')); + self::assertEquals(2, $this->visitor->getObjectFieldValue($object, 'fooBar')); } public function testGetObjectFieldValueIsAccessorBothPublic() : void { $object = new TestObjectPublicCamelCaseAndPrivateUnderscore(1, 2); - $this->assertEquals(2, $this->visitor->getObjectFieldValue($object, 'foo_bar')); - $this->assertEquals(2, $this->visitor->getObjectFieldValue($object, 'foobar')); - $this->assertEquals(2, $this->visitor->getObjectFieldValue($object, 'fooBar')); + self::assertEquals(2, $this->visitor->getObjectFieldValue($object, 'foo_bar')); + self::assertEquals(2, $this->visitor->getObjectFieldValue($object, 'foobar')); + self::assertEquals(2, $this->visitor->getObjectFieldValue($object, 'fooBar')); } public function testGetObjectFieldValueMagicCallMethod() : void { $object = new TestObject(1, 2, true, 3); - $this->assertEquals(3, $this->visitor->getObjectFieldValue($object, 'qux')); + self::assertEquals(3, $this->visitor->getObjectFieldValue($object, 'qux')); } public function testWalkEqualsComparison() : void { $closure = $this->visitor->walkComparison($this->builder->eq("foo", 1)); - $this->assertTrue($closure(new TestObject(1))); - $this->assertFalse($closure(new TestObject(2))); + self::assertTrue($closure(new TestObject(1))); + self::assertFalse($closure(new TestObject(2))); } public function testWalkNotEqualsComparison() : void { $closure = $this->visitor->walkComparison($this->builder->neq("foo", 1)); - $this->assertFalse($closure(new TestObject(1))); - $this->assertTrue($closure(new TestObject(2))); + self::assertFalse($closure(new TestObject(1))); + self::assertTrue($closure(new TestObject(2))); } public function testWalkLessThanComparison() : void { $closure = $this->visitor->walkComparison($this->builder->lt("foo", 1)); - $this->assertFalse($closure(new TestObject(1))); - $this->assertTrue($closure(new TestObject(0))); + self::assertFalse($closure(new TestObject(1))); + self::assertTrue($closure(new TestObject(0))); } public function testWalkLessThanEqualsComparison() : void { $closure = $this->visitor->walkComparison($this->builder->lte("foo", 1)); - $this->assertFalse($closure(new TestObject(2))); - $this->assertTrue($closure(new TestObject(1))); - $this->assertTrue($closure(new TestObject(0))); + self::assertFalse($closure(new TestObject(2))); + self::assertTrue($closure(new TestObject(1))); + self::assertTrue($closure(new TestObject(0))); } public function testWalkGreaterThanEqualsComparison() : void { $closure = $this->visitor->walkComparison($this->builder->gte("foo", 1)); - $this->assertTrue($closure(new TestObject(2))); - $this->assertTrue($closure(new TestObject(1))); - $this->assertFalse($closure(new TestObject(0))); + self::assertTrue($closure(new TestObject(2))); + self::assertTrue($closure(new TestObject(1))); + self::assertFalse($closure(new TestObject(0))); } public function testWalkGreaterThanComparison() : void { $closure = $this->visitor->walkComparison($this->builder->gt("foo", 1)); - $this->assertTrue($closure(new TestObject(2))); - $this->assertFalse($closure(new TestObject(1))); - $this->assertFalse($closure(new TestObject(0))); + self::assertTrue($closure(new TestObject(2))); + self::assertFalse($closure(new TestObject(1))); + self::assertFalse($closure(new TestObject(0))); } public function testWalkInComparison() : void { $closure = $this->visitor->walkComparison($this->builder->in("foo", [1, 2, 3, '04'])); - $this->assertTrue($closure(new TestObject(2))); - $this->assertTrue($closure(new TestObject(1))); - $this->assertFalse($closure(new TestObject(0))); - $this->assertFalse($closure(new TestObject(4))); - $this->assertTrue($closure(new TestObject('04'))); + self::assertTrue($closure(new TestObject(2))); + self::assertTrue($closure(new TestObject(1))); + self::assertFalse($closure(new TestObject(0))); + self::assertFalse($closure(new TestObject(4))); + self::assertTrue($closure(new TestObject('04'))); } public function testWalkNotInComparison() : void { $closure = $this->visitor->walkComparison($this->builder->notIn("foo", [1, 2, 3, '04'])); - $this->assertFalse($closure(new TestObject(1))); - $this->assertFalse($closure(new TestObject(2))); - $this->assertTrue($closure(new TestObject(0))); - $this->assertTrue($closure(new TestObject(4))); - $this->assertFalse($closure(new TestObject('04'))); + self::assertFalse($closure(new TestObject(1))); + self::assertFalse($closure(new TestObject(2))); + self::assertTrue($closure(new TestObject(0))); + self::assertTrue($closure(new TestObject(4))); + self::assertFalse($closure(new TestObject('04'))); } public function testWalkContainsComparison() : void { $closure = $this->visitor->walkComparison($this->builder->contains('foo', 'hello')); - $this->assertTrue($closure(new TestObject('hello world'))); - $this->assertFalse($closure(new TestObject('world'))); + self::assertTrue($closure(new TestObject('hello world'))); + self::assertFalse($closure(new TestObject('world'))); } public function testWalkMemberOfComparisonWithObject() : void { $closure = $this->visitor->walkComparison($this->builder->memberof("foo", 2)); - $this->assertTrue($closure(new TestObject([1,2,3]))); - $this->assertTrue($closure(new TestObject([2]))); - $this->assertFalse($closure(new TestObject([1,3,5]))); - $this->assertFalse($closure(new TestObject(array(1,'02')))); + self::assertTrue($closure(new TestObject([1,2,3]))); + self::assertTrue($closure(new TestObject([2]))); + self::assertFalse($closure(new TestObject([1,3,5]))); + self::assertFalse($closure(new TestObject(array(1,'02')))); } public function testWalkStartsWithComparison() : void { $closure = $this->visitor->walkComparison($this->builder->startsWith('foo', 'hello')); - $this->assertTrue($closure(new TestObject('hello world'))); - $this->assertFalse($closure(new TestObject('world'))); + self::assertTrue($closure(new TestObject('hello world'))); + self::assertFalse($closure(new TestObject('world'))); } public function testWalkEndsWithComparison() : void { $closure = $this->visitor->walkComparison($this->builder->endsWith('foo', 'world')); - $this->assertTrue($closure(new TestObject('hello world'))); - $this->assertFalse($closure(new TestObject('hello'))); + self::assertTrue($closure(new TestObject('hello world'))); + self::assertFalse($closure(new TestObject('hello'))); } public function testWalkAndCompositeExpression() : void @@ -209,10 +209,10 @@ public function testWalkAndCompositeExpression() : void ) ); - $this->assertTrue($closure(new TestObject(1, 1))); - $this->assertFalse($closure(new TestObject(1, 0))); - $this->assertFalse($closure(new TestObject(0, 1))); - $this->assertFalse($closure(new TestObject(0, 0))); + self::assertTrue($closure(new TestObject(1, 1))); + self::assertFalse($closure(new TestObject(1, 0))); + self::assertFalse($closure(new TestObject(0, 1))); + self::assertFalse($closure(new TestObject(0, 0))); } public function testWalkOrCompositeExpression() : void @@ -224,54 +224,54 @@ public function testWalkOrCompositeExpression() : void ) ); - $this->assertTrue($closure(new TestObject(1, 1))); - $this->assertTrue($closure(new TestObject(1, 0))); - $this->assertTrue($closure(new TestObject(0, 1))); - $this->assertFalse($closure(new TestObject(0, 0))); + self::assertTrue($closure(new TestObject(1, 1))); + self::assertTrue($closure(new TestObject(1, 0))); + self::assertTrue($closure(new TestObject(0, 1))); + self::assertFalse($closure(new TestObject(0, 0))); } public function testSortByFieldAscending() : void { $objects = [new TestObject("b"), new TestObject("a"), new TestObject("c")]; - $sort = ClosureExpressionVisitor::sortByField("foo"); + $sort = ClosureExpressionVisitor::sortByField("foo"); usort($objects, $sort); - $this->assertEquals("a", $objects[0]->getFoo()); - $this->assertEquals("b", $objects[1]->getFoo()); - $this->assertEquals("c", $objects[2]->getFoo()); + self::assertEquals("a", $objects[0]->getFoo()); + self::assertEquals("b", $objects[1]->getFoo()); + self::assertEquals("c", $objects[2]->getFoo()); } public function testSortByFieldDescending() : void { $objects = [new TestObject("b"), new TestObject("a"), new TestObject("c")]; - $sort = ClosureExpressionVisitor::sortByField("foo", -1); + $sort = ClosureExpressionVisitor::sortByField("foo", -1); usort($objects, $sort); - $this->assertEquals("c", $objects[0]->getFoo()); - $this->assertEquals("b", $objects[1]->getFoo()); - $this->assertEquals("a", $objects[2]->getFoo()); + self::assertEquals("c", $objects[0]->getFoo()); + self::assertEquals("b", $objects[1]->getFoo()); + self::assertEquals("a", $objects[2]->getFoo()); } public function testSortDelegate() : void { $objects = [new TestObject("a", "c"), new TestObject("a", "b"), new TestObject("a", "a")]; - $sort = ClosureExpressionVisitor::sortByField("bar", 1); - $sort = ClosureExpressionVisitor::sortByField("foo", 1, $sort); + $sort = ClosureExpressionVisitor::sortByField("bar", 1); + $sort = ClosureExpressionVisitor::sortByField("foo", 1, $sort); usort($objects, $sort); - $this->assertEquals("a", $objects[0]->getBar()); - $this->assertEquals("b", $objects[1]->getBar()); - $this->assertEquals("c", $objects[2]->getBar()); + self::assertEquals("a", $objects[0]->getBar()); + self::assertEquals("b", $objects[1]->getBar()); + self::assertEquals("c", $objects[2]->getBar()); } public function testArrayComparison() : void { $closure = $this->visitor->walkComparison($this->builder->eq("foo", 42)); - $this->assertTrue($closure(['foo' => 42])); + self::assertTrue($closure(['foo' => 42])); } } @@ -336,7 +336,7 @@ class TestObjectBothCamelCaseAndUnderscore public function __construct(int $foo_bar = null, int $fooBar = null) { $this->foo_bar = $foo_bar; - $this->fooBar = $fooBar; + $this->fooBar = $fooBar; } public function getFooBar() : ?int @@ -353,7 +353,7 @@ class TestObjectPublicCamelCaseAndPrivateUnderscore public function __construct(int $foo_bar = null, int $fooBar = null) { $this->foo_bar = $foo_bar; - $this->fooBar = $fooBar; + $this->fooBar = $fooBar; } public function getFooBar() : ?int @@ -370,7 +370,7 @@ class TestObjectBothPublic public function __construct($foo_bar = null, $fooBar = null) { $this->foo_bar = $foo_bar; - $this->fooBar = $fooBar; + $this->fooBar = $fooBar; } public function getFooBar() diff --git a/tests/Doctrine/Tests/Common/Collections/CollectionTest.php b/tests/Doctrine/Tests/Common/Collections/CollectionTest.php index 5611b805f..3cb59a5cc 100644 --- a/tests/Doctrine/Tests/Common/Collections/CollectionTest.php +++ b/tests/Doctrine/Tests/Common/Collections/CollectionTest.php @@ -16,7 +16,7 @@ protected function setUp() : void public function testToString() : void { $this->collection->add('testing'); - $this->assertTrue(is_string((string) $this->collection)); + self::assertTrue(is_string((string) $this->collection)); } /** @@ -27,9 +27,9 @@ public function testMatching() : void $this->fillMatchingFixture(); $col = $this->collection->matching(new Criteria(Criteria::expr()->eq('foo', 'bar'))); - $this->assertInstanceOf(Collection::class, $col); - $this->assertNotSame($col, $this->collection); - $this->assertEquals(1, count($col)); + self::assertInstanceOf(Collection::class, $col); + self::assertNotSame($col, $this->collection); + self::assertEquals(1, count($col)); } /** @@ -41,11 +41,11 @@ public function testMatchingOrdering() : void $col = $this->collection->matching(new Criteria(null, ['foo' => 'DESC'])); - $this->assertInstanceOf(Collection::class, $col); - $this->assertNotSame($col, $this->collection); - $this->assertEquals(2, count($col)); - $this->assertEquals('baz', $col->first()->foo); - $this->assertEquals('bar', $col->last()->foo); + self::assertInstanceOf(Collection::class, $col); + self::assertNotSame($col, $this->collection); + self::assertEquals(2, count($col)); + self::assertEquals('baz', $col->first()->foo); + self::assertEquals('bar', $col->last()->foo); } /** @@ -57,9 +57,9 @@ public function testMatchingSlice() : void $col = $this->collection->matching(new Criteria(null, null, 1, 1)); - $this->assertInstanceOf(Collection::class, $col); - $this->assertNotSame($col, $this->collection); - $this->assertEquals(1, count($col)); - $this->assertEquals('baz', $col[0]->foo); + self::assertInstanceOf(Collection::class, $col); + self::assertNotSame($col, $this->collection); + self::assertEquals(1, count($col)); + self::assertEquals('baz', $col[0]->foo); } } diff --git a/tests/Doctrine/Tests/Common/Collections/CriteriaTest.php b/tests/Doctrine/Tests/Common/Collections/CriteriaTest.php index 548dbfecc..88057e486 100644 --- a/tests/Doctrine/Tests/Common/Collections/CriteriaTest.php +++ b/tests/Doctrine/Tests/Common/Collections/CriteriaTest.php @@ -7,13 +7,13 @@ use Doctrine\Common\Collections\Expr\CompositeExpression; use Doctrine\Common\Collections\ExpressionBuilder; -class CriteriaTest extends \PHPUnit_Framework_TestCase +class CriteriaTest extends \PHPUnit\Framework\TestCase { public function testCreate() : void { $criteria = Criteria::create(); - $this->assertInstanceOf(Criteria::class, $criteria); + self::assertInstanceOf(Criteria::class, $criteria); } public function testConstructor() : void @@ -21,10 +21,10 @@ public function testConstructor() : void $expr = new Comparison("field", "=", "value"); $criteria = new Criteria($expr, ["foo" => "ASC"], 10, 20); - $this->assertSame($expr, $criteria->getWhereExpression()); - $this->assertEquals(["foo" => "ASC"], $criteria->getOrderings()); - $this->assertEquals(10, $criteria->getFirstResult()); - $this->assertEquals(20, $criteria->getMaxResults()); + self::assertSame($expr, $criteria->getWhereExpression()); + self::assertEquals(["foo" => "ASC"], $criteria->getOrderings()); + self::assertEquals(10, $criteria->getFirstResult()); + self::assertEquals(20, $criteria->getMaxResults()); } public function testWhere() : void @@ -34,7 +34,7 @@ public function testWhere() : void $criteria->where($expr); - $this->assertSame($expr, $criteria->getWhereExpression()); + self::assertSame($expr, $criteria->getWhereExpression()); } public function testAndWhere() : void @@ -47,10 +47,10 @@ public function testAndWhere() : void $criteria->andWhere($expr); $where = $criteria->getWhereExpression(); - $this->assertInstanceOf(CompositeExpression::class, $where); + self::assertInstanceOf(CompositeExpression::class, $where); - $this->assertEquals(CompositeExpression::TYPE_AND, $where->getType()); - $this->assertSame([$expr, $expr], $where->getExpressionList()); + self::assertEquals(CompositeExpression::TYPE_AND, $where->getType()); + self::assertSame([$expr, $expr], $where->getExpressionList()); } public function testAndWhereWithoutWhere() : void @@ -60,7 +60,7 @@ public function testAndWhereWithoutWhere() : void $criteria->andWhere($expr); - $this->assertSame($expr, $criteria->getWhereExpression()); + self::assertSame($expr, $criteria->getWhereExpression()); } public function testOrWhere() : void @@ -73,10 +73,10 @@ public function testOrWhere() : void $criteria->orWhere($expr); $where = $criteria->getWhereExpression(); - $this->assertInstanceOf(CompositeExpression::class, $where); + self::assertInstanceOf(CompositeExpression::class, $where); - $this->assertEquals(CompositeExpression::TYPE_OR, $where->getType()); - $this->assertSame([$expr, $expr], $where->getExpressionList()); + self::assertEquals(CompositeExpression::TYPE_OR, $where->getType()); + self::assertSame([$expr, $expr], $where->getExpressionList()); } public function testOrWhereWithoutWhere() : void @@ -86,7 +86,7 @@ public function testOrWhereWithoutWhere() : void $criteria->orWhere($expr); - $this->assertSame($expr, $criteria->getWhereExpression()); + self::assertSame($expr, $criteria->getWhereExpression()); } public function testOrderings() : void @@ -94,11 +94,11 @@ public function testOrderings() : void $criteria = Criteria::create() ->orderBy(["foo" => "ASC"]); - $this->assertEquals(["foo" => "ASC"], $criteria->getOrderings()); + self::assertEquals(["foo" => "ASC"], $criteria->getOrderings()); } public function testExpr() : void { - $this->assertInstanceOf(ExpressionBuilder::class, Criteria::expr()); + self::assertInstanceOf(ExpressionBuilder::class, Criteria::expr()); } } diff --git a/tests/Doctrine/Tests/Common/Collections/DerivedCollectionTest.php b/tests/Doctrine/Tests/Common/Collections/DerivedCollectionTest.php index 540f439aa..fba6d1975 100644 --- a/tests/Doctrine/Tests/Common/Collections/DerivedCollectionTest.php +++ b/tests/Doctrine/Tests/Common/Collections/DerivedCollectionTest.php @@ -25,7 +25,7 @@ /** * @author Alexander Golovnya */ -class DerivedCollectionTest extends \PHPUnit_Framework_TestCase +class DerivedCollectionTest extends \PHPUnit\Framework\TestCase { /** * Tests that methods that create a new instance can be called in a derived @@ -34,7 +34,7 @@ class DerivedCollectionTest extends \PHPUnit_Framework_TestCase public function testDerivedClassCreation() : void { $collection = new DerivedArrayCollection(new \stdClass()); - $closure = function () { + $closure = function () { return $allMatches = false; }; diff --git a/tests/Doctrine/Tests/Common/Collections/Expr/CompositeExpressionTest.php b/tests/Doctrine/Tests/Common/Collections/Expr/CompositeExpressionTest.php index b4addc629..40bd35608 100644 --- a/tests/Doctrine/Tests/Common/Collections/Expr/CompositeExpressionTest.php +++ b/tests/Doctrine/Tests/Common/Collections/Expr/CompositeExpressionTest.php @@ -27,7 +27,7 @@ public function invalidDataProvider() : array */ public function testExceptions($expression) : void { - $type = CompositeExpression::TYPE_AND; + $type = CompositeExpression::TYPE_AND; $expressions = [ $expression, ]; @@ -41,9 +41,9 @@ public function testGetType() : void $compositeExpression = $this->createCompositeExpression(); $expectedType = CompositeExpression::TYPE_AND; - $actualType = $compositeExpression->getType(); + $actualType = $compositeExpression->getType(); - $this->assertSame($expectedType, $actualType); + self::assertSame($expectedType, $actualType); } protected function createCompositeExpression() : CompositeExpression @@ -60,7 +60,7 @@ public function testGetExpressionList() : void $expectedExpressionList = [$this->createMock(Expression::class)]; $actualExpressionList = $compositeExpression->getExpressionList(); - $this->assertEquals($expectedExpressionList, $actualExpressionList); + self::assertEquals($expectedExpressionList, $actualExpressionList); } public function testVisitor() : void diff --git a/tests/Doctrine/Tests/Common/Collections/Expr/ValueTest.php b/tests/Doctrine/Tests/Common/Collections/Expr/ValueTest.php index ccf49f6b6..142e20127 100644 --- a/tests/Doctrine/Tests/Common/Collections/Expr/ValueTest.php +++ b/tests/Doctrine/Tests/Common/Collections/Expr/ValueTest.php @@ -4,7 +4,7 @@ use Doctrine\Common\Collections\Expr\ExpressionVisitor; use Doctrine\Common\Collections\Expr\Value; -use PHPUnit_Framework_TestCase as TestCase; +use PHPUnit\Framework\TestCase as TestCase; /** * @author Tobias Oberrauch @@ -14,12 +14,12 @@ class ValueTest extends TestCase { public function testGetter() : void { - $value = 'foo'; + $value = 'foo'; $valueExpression = new Value($value); $actualValue = $valueExpression->getValue(); - $this->assertEquals($value, $actualValue); + self::assertEquals($value, $actualValue); } public function testVisitor() : void @@ -30,7 +30,7 @@ public function testVisitor() : void ->method('walkValue'); /** @var ExpressionVisitor $visitor */ - $value = 'foo'; + $value = 'foo'; $valueExpression = new Value($value); $valueExpression->visit($visitor); } diff --git a/tests/Doctrine/Tests/Common/Collections/ExpressionBuilderTest.php b/tests/Doctrine/Tests/Common/Collections/ExpressionBuilderTest.php index 4688cc0d4..e7c9e736a 100644 --- a/tests/Doctrine/Tests/Common/Collections/ExpressionBuilderTest.php +++ b/tests/Doctrine/Tests/Common/Collections/ExpressionBuilderTest.php @@ -9,7 +9,7 @@ /** * @group DDC-1637 */ -class ExpressionBuilderTest extends \PHPUnit_Framework_TestCase +class ExpressionBuilderTest extends \PHPUnit\Framework\TestCase { /** * @var ExpressionBuilder @@ -25,16 +25,16 @@ public function testAndX() : void { $expr = $this->builder->andX($this->builder->eq("a", "b")); - $this->assertInstanceOf(CompositeExpression::class, $expr); - $this->assertEquals(CompositeExpression::TYPE_AND, $expr->getType()); + self::assertInstanceOf(CompositeExpression::class, $expr); + self::assertEquals(CompositeExpression::TYPE_AND, $expr->getType()); } public function testOrX() : void { $expr = $this->builder->orX($this->builder->eq("a", "b")); - $this->assertInstanceOf(CompositeExpression::class, $expr); - $this->assertEquals(CompositeExpression::TYPE_OR, $expr->getType()); + self::assertInstanceOf(CompositeExpression::class, $expr); + self::assertEquals(CompositeExpression::TYPE_OR, $expr->getType()); } public function testInvalidAndXArgument() : void @@ -47,103 +47,103 @@ public function testEq() : void { $expr = $this->builder->eq("a", "b"); - $this->assertInstanceOf(Comparison::class, $expr); - $this->assertEquals(Comparison::EQ, $expr->getOperator()); + self::assertInstanceOf(Comparison::class, $expr); + self::assertEquals(Comparison::EQ, $expr->getOperator()); } public function testNeq() : void { $expr = $this->builder->neq("a", "b"); - $this->assertInstanceOf(Comparison::class, $expr); - $this->assertEquals(Comparison::NEQ, $expr->getOperator()); + self::assertInstanceOf(Comparison::class, $expr); + self::assertEquals(Comparison::NEQ, $expr->getOperator()); } public function testLt() : void { $expr = $this->builder->lt("a", "b"); - $this->assertInstanceOf(Comparison::class, $expr); - $this->assertEquals(Comparison::LT, $expr->getOperator()); + self::assertInstanceOf(Comparison::class, $expr); + self::assertEquals(Comparison::LT, $expr->getOperator()); } public function testGt() : void { $expr = $this->builder->gt("a", "b"); - $this->assertInstanceOf(Comparison::class, $expr); - $this->assertEquals(Comparison::GT, $expr->getOperator()); + self::assertInstanceOf(Comparison::class, $expr); + self::assertEquals(Comparison::GT, $expr->getOperator()); } public function testGte() : void { $expr = $this->builder->gte("a", "b"); - $this->assertInstanceOf(Comparison::class, $expr); - $this->assertEquals(Comparison::GTE, $expr->getOperator()); + self::assertInstanceOf(Comparison::class, $expr); + self::assertEquals(Comparison::GTE, $expr->getOperator()); } public function testLte() : void { $expr = $this->builder->lte("a", "b"); - $this->assertInstanceOf(Comparison::class, $expr); - $this->assertEquals(Comparison::LTE, $expr->getOperator()); + self::assertInstanceOf(Comparison::class, $expr); + self::assertEquals(Comparison::LTE, $expr->getOperator()); } public function testIn() : void { $expr = $this->builder->in("a", ["b"]); - $this->assertInstanceOf(Comparison::class, $expr); - $this->assertEquals(Comparison::IN, $expr->getOperator()); + self::assertInstanceOf(Comparison::class, $expr); + self::assertEquals(Comparison::IN, $expr->getOperator()); } public function testNotIn() : void { $expr = $this->builder->notIn("a", ["b"]); - $this->assertInstanceOf(Comparison::class, $expr); - $this->assertEquals(Comparison::NIN, $expr->getOperator()); + self::assertInstanceOf(Comparison::class, $expr); + self::assertEquals(Comparison::NIN, $expr->getOperator()); } public function testIsNull() : void { $expr = $this->builder->isNull("a"); - $this->assertInstanceOf(Comparison::class, $expr); - $this->assertEquals(Comparison::EQ, $expr->getOperator()); + self::assertInstanceOf(Comparison::class, $expr); + self::assertEquals(Comparison::EQ, $expr->getOperator()); } public function testContains() : void { $expr = $this->builder->contains("a", "b"); - $this->assertInstanceOf(Comparison::class, $expr); - $this->assertEquals(Comparison::CONTAINS, $expr->getOperator()); + self::assertInstanceOf(Comparison::class, $expr); + self::assertEquals(Comparison::CONTAINS, $expr->getOperator()); } public function testMemberOf() : void { $expr = $this->builder->memberOf("b", ["a"]); - $this->assertInstanceOf(Comparison::class, $expr); - $this->assertEquals(Comparison::MEMBER_OF, $expr->getOperator()); + self::assertInstanceOf(Comparison::class, $expr); + self::assertEquals(Comparison::MEMBER_OF, $expr->getOperator()); } public function testStartsWith() : void { $expr = $this->builder->startsWith("a", "b"); - $this->assertInstanceOf(Comparison::class, $expr); - $this->assertEquals(Comparison::STARTS_WITH, $expr->getOperator()); + self::assertInstanceOf(Comparison::class, $expr); + self::assertEquals(Comparison::STARTS_WITH, $expr->getOperator()); } public function testEndsWith() : void { $expr = $this->builder->endsWith("a", "b"); - $this->assertInstanceOf(Comparison::class, $expr); - $this->assertEquals(Comparison::ENDS_WITH, $expr->getOperator()); + self::assertInstanceOf(Comparison::class, $expr); + self::assertEquals(Comparison::ENDS_WITH, $expr->getOperator()); } }