diff --git a/tests/Doctrine/Tests/Mapping/UnderscoreNamingStrategyTest.php b/tests/Doctrine/Tests/Mapping/UnderscoreNamingStrategyTest.php index 6b8f81ff4fa..e585ff01582 100644 --- a/tests/Doctrine/Tests/Mapping/UnderscoreNamingStrategyTest.php +++ b/tests/Doctrine/Tests/Mapping/UnderscoreNamingStrategyTest.php @@ -32,6 +32,6 @@ public function checkNoDeprecationMessageWhenNumberAwareEnabled(): void $after = Deprecation::getTriggeredDeprecations()['https://github.com/doctrine/orm/pull/7908'] ?? 0; - $this->assertSame($before, $after); + self::assertSame($before, $after); } } diff --git a/tests/Doctrine/Tests/ORM/Cache/AbstractRegionTest.php b/tests/Doctrine/Tests/ORM/Cache/AbstractRegionTest.php index 41a25befe49..4e357d24862 100644 --- a/tests/Doctrine/Tests/ORM/Cache/AbstractRegionTest.php +++ b/tests/Doctrine/Tests/ORM/Cache/AbstractRegionTest.php @@ -46,19 +46,19 @@ public static function dataProviderCacheValues(): array */ public function testPutGetContainsEvict($key, $value): void { - $this->assertFalse($this->region->contains($key)); + self::assertFalse($this->region->contains($key)); $this->region->put($key, $value); - $this->assertTrue($this->region->contains($key)); + self::assertTrue($this->region->contains($key)); $actual = $this->region->get($key); - $this->assertEquals($value, $actual); + self::assertEquals($value, $actual); $this->region->evict($key); - $this->assertFalse($this->region->contains($key)); + self::assertFalse($this->region->contains($key)); } public function testEvictAll(): void @@ -66,18 +66,18 @@ public function testEvictAll(): void $key1 = new CacheKeyMock('key.1'); $key2 = new CacheKeyMock('key.2'); - $this->assertFalse($this->region->contains($key1)); - $this->assertFalse($this->region->contains($key2)); + self::assertFalse($this->region->contains($key1)); + self::assertFalse($this->region->contains($key2)); $this->region->put($key1, new CacheEntryMock(['value' => 'foo'])); $this->region->put($key2, new CacheEntryMock(['value' => 'bar'])); - $this->assertTrue($this->region->contains($key1)); - $this->assertTrue($this->region->contains($key2)); + self::assertTrue($this->region->contains($key1)); + self::assertTrue($this->region->contains($key2)); $this->region->evictAll(); - $this->assertFalse($this->region->contains($key1)); - $this->assertFalse($this->region->contains($key2)); + self::assertFalse($this->region->contains($key1)); + self::assertFalse($this->region->contains($key2)); } } diff --git a/tests/Doctrine/Tests/ORM/Cache/CacheConfigTest.php b/tests/Doctrine/Tests/ORM/Cache/CacheConfigTest.php index d160e544553..041da75629a 100644 --- a/tests/Doctrine/Tests/ORM/Cache/CacheConfigTest.php +++ b/tests/Doctrine/Tests/ORM/Cache/CacheConfigTest.php @@ -34,33 +34,33 @@ public function testSetGetRegionLifetime(): void $config->setDefaultLifetime(111); - $this->assertEquals($config->getDefaultLifetime(), $config->getLifetime('foo_region')); + self::assertEquals($config->getDefaultLifetime(), $config->getLifetime('foo_region')); $config->setLifetime('foo_region', 222); - $this->assertEquals(222, $config->getLifetime('foo_region')); + self::assertEquals(222, $config->getLifetime('foo_region')); } public function testSetGetCacheLogger(): void { $logger = $this->createMock(CacheLogger::class); - $this->assertNull($this->config->getCacheLogger()); + self::assertNull($this->config->getCacheLogger()); $this->config->setCacheLogger($logger); - $this->assertEquals($logger, $this->config->getCacheLogger()); + self::assertEquals($logger, $this->config->getCacheLogger()); } public function testSetGetCacheFactory(): void { $factory = $this->createMock(CacheFactory::class); - $this->assertNull($this->config->getCacheFactory()); + self::assertNull($this->config->getCacheFactory()); $this->config->setCacheFactory($factory); - $this->assertEquals($factory, $this->config->getCacheFactory()); + self::assertEquals($factory, $this->config->getCacheFactory()); } public function testSetGetQueryValidator(): void @@ -72,10 +72,10 @@ public function testSetGetQueryValidator(): void $validator = $this->createMock(QueryCacheValidator::class); - $this->assertInstanceOf(TimestampQueryCacheValidator::class, $this->config->getQueryValidator()); + self::assertInstanceOf(TimestampQueryCacheValidator::class, $this->config->getQueryValidator()); $this->config->setQueryValidator($validator); - $this->assertEquals($validator, $this->config->getQueryValidator()); + self::assertEquals($validator, $this->config->getQueryValidator()); } } diff --git a/tests/Doctrine/Tests/ORM/Cache/CacheKeyTest.php b/tests/Doctrine/Tests/ORM/Cache/CacheKeyTest.php index 7e30ca5aa74..90c576ac4d7 100644 --- a/tests/Doctrine/Tests/ORM/Cache/CacheKeyTest.php +++ b/tests/Doctrine/Tests/ORM/Cache/CacheKeyTest.php @@ -18,7 +18,7 @@ public function testEntityCacheKeyIdentifierCollision(): void $key1 = new EntityCacheKey('Foo', ['id' => 1]); $key2 = new EntityCacheKey('Bar', ['id' => 1]); - $this->assertNotEquals($key1->hash, $key2->hash); + self::assertNotEquals($key1->hash, $key2->hash); } public function testEntityCacheKeyIdentifierType(): void @@ -26,7 +26,7 @@ public function testEntityCacheKeyIdentifierType(): void $key1 = new EntityCacheKey('Foo', ['id' => 1]); $key2 = new EntityCacheKey('Foo', ['id' => '1']); - $this->assertEquals($key1->hash, $key2->hash); + self::assertEquals($key1->hash, $key2->hash); } public function testEntityCacheKeyIdentifierOrder(): void @@ -34,7 +34,7 @@ public function testEntityCacheKeyIdentifierOrder(): void $key1 = new EntityCacheKey('Foo', ['foo_bar' => 1, 'bar_foo' => 2]); $key2 = new EntityCacheKey('Foo', ['bar_foo' => 2, 'foo_bar' => 1]); - $this->assertEquals($key1->hash, $key2->hash); + self::assertEquals($key1->hash, $key2->hash); } public function testCollectionCacheKeyIdentifierType(): void @@ -42,7 +42,7 @@ public function testCollectionCacheKeyIdentifierType(): void $key1 = new CollectionCacheKey('Foo', 'assoc', ['id' => 1]); $key2 = new CollectionCacheKey('Foo', 'assoc', ['id' => '1']); - $this->assertEquals($key1->hash, $key2->hash); + self::assertEquals($key1->hash, $key2->hash); } public function testCollectionCacheKeyIdentifierOrder(): void @@ -50,7 +50,7 @@ public function testCollectionCacheKeyIdentifierOrder(): void $key1 = new CollectionCacheKey('Foo', 'assoc', ['foo_bar' => 1, 'bar_foo' => 2]); $key2 = new CollectionCacheKey('Foo', 'assoc', ['bar_foo' => 2, 'foo_bar' => 1]); - $this->assertEquals($key1->hash, $key2->hash); + self::assertEquals($key1->hash, $key2->hash); } public function testCollectionCacheKeyIdentifierCollision(): void @@ -58,7 +58,7 @@ public function testCollectionCacheKeyIdentifierCollision(): void $key1 = new CollectionCacheKey('Foo', 'assoc', ['id' => 1]); $key2 = new CollectionCacheKey('Bar', 'assoc', ['id' => 1]); - $this->assertNotEquals($key1->hash, $key2->hash); + self::assertNotEquals($key1->hash, $key2->hash); } public function testCollectionCacheKeyAssociationCollision(): void @@ -66,6 +66,6 @@ public function testCollectionCacheKeyAssociationCollision(): void $key1 = new CollectionCacheKey('Foo', 'assoc1', ['id' => 1]); $key2 = new CollectionCacheKey('Foo', 'assoc2', ['id' => 1]); - $this->assertNotEquals($key1->hash, $key2->hash); + self::assertNotEquals($key1->hash, $key2->hash); } } diff --git a/tests/Doctrine/Tests/ORM/Cache/CacheLoggerChainTest.php b/tests/Doctrine/Tests/ORM/Cache/CacheLoggerChainTest.php index 42d21819164..3ee350e15a0 100644 --- a/tests/Doctrine/Tests/ORM/Cache/CacheLoggerChainTest.php +++ b/tests/Doctrine/Tests/ORM/Cache/CacheLoggerChainTest.php @@ -34,14 +34,14 @@ protected function setUp(): void public function testGetAndSetLogger(): void { - $this->assertEmpty($this->logger->getLoggers()); + self::assertEmpty($this->logger->getLoggers()); - $this->assertNull($this->logger->getLogger('mock')); + self::assertNull($this->logger->getLogger('mock')); $this->logger->setLogger('mock', $this->mock); - $this->assertSame($this->mock, $this->logger->getLogger('mock')); - $this->assertEquals(['mock' => $this->mock], $this->logger->getLoggers()); + self::assertSame($this->mock, $this->logger->getLogger('mock')); + self::assertEquals(['mock' => $this->mock], $this->logger->getLoggers()); } public function testEntityCacheChain(): void @@ -51,17 +51,17 @@ public function testEntityCacheChain(): void $this->logger->setLogger('mock', $this->mock); - $this->mock->expects($this->once()) + $this->mock->expects(self::once()) ->method('entityCacheHit') - ->with($this->equalTo($name), $this->equalTo($key)); + ->with(self::equalTo($name), self::equalTo($key)); - $this->mock->expects($this->once()) + $this->mock->expects(self::once()) ->method('entityCachePut') - ->with($this->equalTo($name), $this->equalTo($key)); + ->with(self::equalTo($name), self::equalTo($key)); - $this->mock->expects($this->once()) + $this->mock->expects(self::once()) ->method('entityCacheMiss') - ->with($this->equalTo($name), $this->equalTo($key)); + ->with(self::equalTo($name), self::equalTo($key)); $this->logger->entityCacheHit($name, $key); $this->logger->entityCachePut($name, $key); @@ -75,17 +75,17 @@ public function testCollectionCacheChain(): void $this->logger->setLogger('mock', $this->mock); - $this->mock->expects($this->once()) + $this->mock->expects(self::once()) ->method('collectionCacheHit') - ->with($this->equalTo($name), $this->equalTo($key)); + ->with(self::equalTo($name), self::equalTo($key)); - $this->mock->expects($this->once()) + $this->mock->expects(self::once()) ->method('collectionCachePut') - ->with($this->equalTo($name), $this->equalTo($key)); + ->with(self::equalTo($name), self::equalTo($key)); - $this->mock->expects($this->once()) + $this->mock->expects(self::once()) ->method('collectionCacheMiss') - ->with($this->equalTo($name), $this->equalTo($key)); + ->with(self::equalTo($name), self::equalTo($key)); $this->logger->collectionCacheHit($name, $key); $this->logger->collectionCachePut($name, $key); @@ -99,17 +99,17 @@ public function testQueryCacheChain(): void $this->logger->setLogger('mock', $this->mock); - $this->mock->expects($this->once()) + $this->mock->expects(self::once()) ->method('queryCacheHit') - ->with($this->equalTo($name), $this->equalTo($key)); + ->with(self::equalTo($name), self::equalTo($key)); - $this->mock->expects($this->once()) + $this->mock->expects(self::once()) ->method('queryCachePut') - ->with($this->equalTo($name), $this->equalTo($key)); + ->with(self::equalTo($name), self::equalTo($key)); - $this->mock->expects($this->once()) + $this->mock->expects(self::once()) ->method('queryCacheMiss') - ->with($this->equalTo($name), $this->equalTo($key)); + ->with(self::equalTo($name), self::equalTo($key)); $this->logger->queryCacheHit($name, $key); $this->logger->queryCachePut($name, $key); diff --git a/tests/Doctrine/Tests/ORM/Cache/DefaultCacheFactoryTest.php b/tests/Doctrine/Tests/ORM/Cache/DefaultCacheFactoryTest.php index 8dfd025206c..accad3ce3f3 100644 --- a/tests/Doctrine/Tests/ORM/Cache/DefaultCacheFactoryTest.php +++ b/tests/Doctrine/Tests/ORM/Cache/DefaultCacheFactoryTest.php @@ -64,7 +64,7 @@ protected function setUp(): void public function testImplementsCacheFactory(): void { - $this->assertInstanceOf(CacheFactory::class, $this->factory); + self::assertInstanceOf(CacheFactory::class, $this->factory); } public function testBuildCachedEntityPersisterReadOnly(): void @@ -76,15 +76,15 @@ public function testBuildCachedEntityPersisterReadOnly(): void $metadata->cache['usage'] = ClassMetadata::CACHE_USAGE_READ_ONLY; - $this->factory->expects($this->once()) + $this->factory->expects(self::once()) ->method('getRegion') - ->with($this->equalTo($metadata->cache)) - ->will($this->returnValue($region)); + ->with(self::equalTo($metadata->cache)) + ->will(self::returnValue($region)); $cachedPersister = $this->factory->buildCachedEntityPersister($em, $persister, $metadata); - $this->assertInstanceOf(CachedEntityPersister::class, $cachedPersister); - $this->assertInstanceOf(ReadOnlyCachedEntityPersister::class, $cachedPersister); + self::assertInstanceOf(CachedEntityPersister::class, $cachedPersister); + self::assertInstanceOf(ReadOnlyCachedEntityPersister::class, $cachedPersister); } public function testBuildCachedEntityPersisterReadWrite(): void @@ -96,15 +96,15 @@ public function testBuildCachedEntityPersisterReadWrite(): void $metadata->cache['usage'] = ClassMetadata::CACHE_USAGE_READ_WRITE; - $this->factory->expects($this->once()) + $this->factory->expects(self::once()) ->method('getRegion') - ->with($this->equalTo($metadata->cache)) - ->will($this->returnValue($region)); + ->with(self::equalTo($metadata->cache)) + ->will(self::returnValue($region)); $cachedPersister = $this->factory->buildCachedEntityPersister($em, $persister, $metadata); - $this->assertInstanceOf(CachedEntityPersister::class, $cachedPersister); - $this->assertInstanceOf(ReadWriteCachedEntityPersister::class, $cachedPersister); + self::assertInstanceOf(CachedEntityPersister::class, $cachedPersister); + self::assertInstanceOf(ReadWriteCachedEntityPersister::class, $cachedPersister); } public function testBuildCachedEntityPersisterNonStrictReadWrite(): void @@ -116,15 +116,15 @@ public function testBuildCachedEntityPersisterNonStrictReadWrite(): void $metadata->cache['usage'] = ClassMetadata::CACHE_USAGE_NONSTRICT_READ_WRITE; - $this->factory->expects($this->once()) + $this->factory->expects(self::once()) ->method('getRegion') - ->with($this->equalTo($metadata->cache)) - ->will($this->returnValue($region)); + ->with(self::equalTo($metadata->cache)) + ->will(self::returnValue($region)); $cachedPersister = $this->factory->buildCachedEntityPersister($em, $persister, $metadata); - $this->assertInstanceOf(CachedEntityPersister::class, $cachedPersister); - $this->assertInstanceOf(NonStrictReadWriteCachedEntityPersister::class, $cachedPersister); + self::assertInstanceOf(CachedEntityPersister::class, $cachedPersister); + self::assertInstanceOf(NonStrictReadWriteCachedEntityPersister::class, $cachedPersister); } public function testBuildCachedCollectionPersisterReadOnly(): void @@ -137,15 +137,15 @@ public function testBuildCachedCollectionPersisterReadOnly(): void $mapping['cache']['usage'] = ClassMetadata::CACHE_USAGE_READ_ONLY; - $this->factory->expects($this->once()) + $this->factory->expects(self::once()) ->method('getRegion') - ->with($this->equalTo($mapping['cache'])) - ->will($this->returnValue($region)); + ->with(self::equalTo($mapping['cache'])) + ->will(self::returnValue($region)); $cachedPersister = $this->factory->buildCachedCollectionPersister($em, $persister, $mapping); - $this->assertInstanceOf(CachedCollectionPersister::class, $cachedPersister); - $this->assertInstanceOf(ReadOnlyCachedCollectionPersister::class, $cachedPersister); + self::assertInstanceOf(CachedCollectionPersister::class, $cachedPersister); + self::assertInstanceOf(ReadOnlyCachedCollectionPersister::class, $cachedPersister); } public function testBuildCachedCollectionPersisterReadWrite(): void @@ -158,15 +158,15 @@ public function testBuildCachedCollectionPersisterReadWrite(): void $mapping['cache']['usage'] = ClassMetadata::CACHE_USAGE_READ_WRITE; - $this->factory->expects($this->once()) + $this->factory->expects(self::once()) ->method('getRegion') - ->with($this->equalTo($mapping['cache'])) - ->will($this->returnValue($region)); + ->with(self::equalTo($mapping['cache'])) + ->will(self::returnValue($region)); $cachedPersister = $this->factory->buildCachedCollectionPersister($em, $persister, $mapping); - $this->assertInstanceOf(CachedCollectionPersister::class, $cachedPersister); - $this->assertInstanceOf(ReadWriteCachedCollectionPersister::class, $cachedPersister); + self::assertInstanceOf(CachedCollectionPersister::class, $cachedPersister); + self::assertInstanceOf(ReadWriteCachedCollectionPersister::class, $cachedPersister); } public function testBuildCachedCollectionPersisterNonStrictReadWrite(): void @@ -179,15 +179,15 @@ public function testBuildCachedCollectionPersisterNonStrictReadWrite(): void $mapping['cache']['usage'] = ClassMetadata::CACHE_USAGE_NONSTRICT_READ_WRITE; - $this->factory->expects($this->once()) + $this->factory->expects(self::once()) ->method('getRegion') - ->with($this->equalTo($mapping['cache'])) - ->will($this->returnValue($region)); + ->with(self::equalTo($mapping['cache'])) + ->will(self::returnValue($region)); $cachedPersister = $this->factory->buildCachedCollectionPersister($em, $persister, $mapping); - $this->assertInstanceOf(CachedCollectionPersister::class, $cachedPersister); - $this->assertInstanceOf(NonStrictReadWriteCachedCollectionPersister::class, $cachedPersister); + self::assertInstanceOf(CachedCollectionPersister::class, $cachedPersister); + self::assertInstanceOf(NonStrictReadWriteCachedCollectionPersister::class, $cachedPersister); } public function testInheritedEntityCacheRegion(): void @@ -202,11 +202,11 @@ public function testInheritedEntityCacheRegion(): void $cachedPersister1 = $factory->buildCachedEntityPersister($em, $persister1, $metadata1); $cachedPersister2 = $factory->buildCachedEntityPersister($em, $persister2, $metadata2); - $this->assertInstanceOf(CachedEntityPersister::class, $cachedPersister1); - $this->assertInstanceOf(CachedEntityPersister::class, $cachedPersister2); + self::assertInstanceOf(CachedEntityPersister::class, $cachedPersister1); + self::assertInstanceOf(CachedEntityPersister::class, $cachedPersister2); - $this->assertNotSame($cachedPersister1, $cachedPersister2); - $this->assertSame($cachedPersister1->getCacheRegion(), $cachedPersister2->getCacheRegion()); + self::assertNotSame($cachedPersister1, $cachedPersister2); + self::assertSame($cachedPersister1->getCacheRegion(), $cachedPersister2->getCacheRegion()); } public function testCreateNewCacheDriver(): void @@ -221,11 +221,11 @@ public function testCreateNewCacheDriver(): void $cachedPersister1 = $factory->buildCachedEntityPersister($em, $persister1, $metadata1); $cachedPersister2 = $factory->buildCachedEntityPersister($em, $persister2, $metadata2); - $this->assertInstanceOf(CachedEntityPersister::class, $cachedPersister1); - $this->assertInstanceOf(CachedEntityPersister::class, $cachedPersister2); + self::assertInstanceOf(CachedEntityPersister::class, $cachedPersister1); + self::assertInstanceOf(CachedEntityPersister::class, $cachedPersister2); - $this->assertNotSame($cachedPersister1, $cachedPersister2); - $this->assertNotSame($cachedPersister1->getCacheRegion(), $cachedPersister2->getCacheRegion()); + self::assertNotSame($cachedPersister1, $cachedPersister2); + self::assertNotSame($cachedPersister1->getCacheRegion(), $cachedPersister2->getCacheRegion()); } public function testBuildCachedEntityPersisterNonStrictException(): void @@ -314,8 +314,8 @@ public function testBuildsNewNamespacedCacheInstancePerRegionInstance(): void ] ); - $this->assertSame('foo', $fooRegion->getCache()->getNamespace()); - $this->assertSame('bar', $barRegion->getCache()->getNamespace()); + self::assertSame('foo', $fooRegion->getCache()->getNamespace()); + self::assertSame('bar', $barRegion->getCache()->getNamespace()); } public function testAppendsNamespacedCacheInstancePerRegionInstanceWhenItsAlreadySet(): void @@ -338,8 +338,8 @@ public function testAppendsNamespacedCacheInstancePerRegionInstanceWhenItsAlread ] ); - $this->assertSame('testing:foo', $fooRegion->getCache()->getNamespace()); - $this->assertSame('testing:bar', $barRegion->getCache()->getNamespace()); + self::assertSame('testing:foo', $fooRegion->getCache()->getNamespace()); + self::assertSame('testing:bar', $barRegion->getCache()->getNamespace()); } public function testBuildsDefaultCacheRegionFromGenericCacheRegion(): void @@ -349,7 +349,7 @@ public function testBuildsDefaultCacheRegionFromGenericCacheRegion(): void $factory = new DefaultCacheFactory($this->regionsConfig, $cache); - $this->assertInstanceOf( + self::assertInstanceOf( DefaultRegion::class, $factory->getRegion( [ @@ -367,7 +367,7 @@ public function testBuildsMultiGetCacheRegionFromGenericCacheRegion(): void $factory = new DefaultCacheFactory($this->regionsConfig, $cache); - $this->assertInstanceOf( + self::assertInstanceOf( DefaultMultiGetRegion::class, $factory->getRegion( [ diff --git a/tests/Doctrine/Tests/ORM/Cache/DefaultCacheTest.php b/tests/Doctrine/Tests/ORM/Cache/DefaultCacheTest.php index 5a8b509e744..3fc8a2b2422 100644 --- a/tests/Doctrine/Tests/ORM/Cache/DefaultCacheTest.php +++ b/tests/Doctrine/Tests/ORM/Cache/DefaultCacheTest.php @@ -62,19 +62,19 @@ private function putCollectionCacheEntry(string $className, string $association, public function testImplementsCache(): void { - $this->assertInstanceOf(Cache::class, $this->cache); + self::assertInstanceOf(Cache::class, $this->cache); } public function testGetEntityCacheRegionAccess(): void { - $this->assertInstanceOf(Cache\Region::class, $this->cache->getEntityCacheRegion(State::class)); - $this->assertNull($this->cache->getEntityCacheRegion(CmsUser::class)); + self::assertInstanceOf(Cache\Region::class, $this->cache->getEntityCacheRegion(State::class)); + self::assertNull($this->cache->getEntityCacheRegion(CmsUser::class)); } public function testGetCollectionCacheRegionAccess(): void { - $this->assertInstanceOf(Cache\Region::class, $this->cache->getCollectionCacheRegion(State::class, 'cities')); - $this->assertNull($this->cache->getCollectionCacheRegion(CmsUser::class, 'phonenumbers')); + self::assertInstanceOf(Cache\Region::class, $this->cache->getCollectionCacheRegion(State::class, 'cities')); + self::assertNull($this->cache->getCollectionCacheRegion(CmsUser::class, 'phonenumbers')); } public function testContainsEntity(): void @@ -83,12 +83,12 @@ public function testContainsEntity(): void $className = Country::class; $cacheEntry = array_merge($identifier, ['name' => 'Brazil']); - $this->assertFalse($this->cache->containsEntity(Country::class, 1)); + self::assertFalse($this->cache->containsEntity(Country::class, 1)); $this->putEntityCacheEntry($className, $identifier, $cacheEntry); - $this->assertTrue($this->cache->containsEntity(Country::class, 1)); - $this->assertFalse($this->cache->containsEntity(CmsUser::class, 1)); + self::assertTrue($this->cache->containsEntity(Country::class, 1)); + self::assertFalse($this->cache->containsEntity(CmsUser::class, 1)); } public function testEvictEntity(): void @@ -99,12 +99,12 @@ public function testEvictEntity(): void $this->putEntityCacheEntry($className, $identifier, $cacheEntry); - $this->assertTrue($this->cache->containsEntity(Country::class, 1)); + self::assertTrue($this->cache->containsEntity(Country::class, 1)); $this->cache->evictEntity(Country::class, 1); $this->cache->evictEntity(CmsUser::class, 1); - $this->assertFalse($this->cache->containsEntity(Country::class, 1)); + self::assertFalse($this->cache->containsEntity(Country::class, 1)); } public function testEvictEntityRegion(): void @@ -115,12 +115,12 @@ public function testEvictEntityRegion(): void $this->putEntityCacheEntry($className, $identifier, $cacheEntry); - $this->assertTrue($this->cache->containsEntity(Country::class, 1)); + self::assertTrue($this->cache->containsEntity(Country::class, 1)); $this->cache->evictEntityRegion(Country::class); $this->cache->evictEntityRegion(CmsUser::class); - $this->assertFalse($this->cache->containsEntity(Country::class, 1)); + self::assertFalse($this->cache->containsEntity(Country::class, 1)); } public function testEvictEntityRegions(): void @@ -131,11 +131,11 @@ public function testEvictEntityRegions(): void $this->putEntityCacheEntry($className, $identifier, $cacheEntry); - $this->assertTrue($this->cache->containsEntity(Country::class, 1)); + self::assertTrue($this->cache->containsEntity(Country::class, 1)); $this->cache->evictEntityRegions(); - $this->assertFalse($this->cache->containsEntity(Country::class, 1)); + self::assertFalse($this->cache->containsEntity(Country::class, 1)); } public function testContainsCollection(): void @@ -148,12 +148,12 @@ public function testContainsCollection(): void ['id' => 12], ]; - $this->assertFalse($this->cache->containsCollection(State::class, $association, 1)); + self::assertFalse($this->cache->containsCollection(State::class, $association, 1)); $this->putCollectionCacheEntry($className, $association, $ownerId, $cacheEntry); - $this->assertTrue($this->cache->containsCollection(State::class, $association, 1)); - $this->assertFalse($this->cache->containsCollection(CmsUser::class, 'phonenumbers', 1)); + self::assertTrue($this->cache->containsCollection(State::class, $association, 1)); + self::assertFalse($this->cache->containsCollection(CmsUser::class, 'phonenumbers', 1)); } public function testEvictCollection(): void @@ -168,12 +168,12 @@ public function testEvictCollection(): void $this->putCollectionCacheEntry($className, $association, $ownerId, $cacheEntry); - $this->assertTrue($this->cache->containsCollection(State::class, $association, 1)); + self::assertTrue($this->cache->containsCollection(State::class, $association, 1)); $this->cache->evictCollection($className, $association, $ownerId); $this->cache->evictCollection(CmsUser::class, 'phonenumbers', 1); - $this->assertFalse($this->cache->containsCollection(State::class, $association, 1)); + self::assertFalse($this->cache->containsCollection(State::class, $association, 1)); } public function testEvictCollectionRegion(): void @@ -188,12 +188,12 @@ public function testEvictCollectionRegion(): void $this->putCollectionCacheEntry($className, $association, $ownerId, $cacheEntry); - $this->assertTrue($this->cache->containsCollection(State::class, $association, 1)); + self::assertTrue($this->cache->containsCollection(State::class, $association, 1)); $this->cache->evictCollectionRegion($className, $association); $this->cache->evictCollectionRegion(CmsUser::class, 'phonenumbers'); - $this->assertFalse($this->cache->containsCollection(State::class, $association, 1)); + self::assertFalse($this->cache->containsCollection(State::class, $association, 1)); } public function testEvictCollectionRegions(): void @@ -208,33 +208,33 @@ public function testEvictCollectionRegions(): void $this->putCollectionCacheEntry($className, $association, $ownerId, $cacheEntry); - $this->assertTrue($this->cache->containsCollection(State::class, $association, 1)); + self::assertTrue($this->cache->containsCollection(State::class, $association, 1)); $this->cache->evictCollectionRegions(); - $this->assertFalse($this->cache->containsCollection(State::class, $association, 1)); + self::assertFalse($this->cache->containsCollection(State::class, $association, 1)); } public function testQueryCache(): void { - $this->assertFalse($this->cache->containsQuery('foo')); + self::assertFalse($this->cache->containsQuery('foo')); $defaultQueryCache = $this->cache->getQueryCache(); $fooQueryCache = $this->cache->getQueryCache('foo'); - $this->assertInstanceOf(Cache\QueryCache::class, $defaultQueryCache); - $this->assertInstanceOf(Cache\QueryCache::class, $fooQueryCache); - $this->assertSame($defaultQueryCache, $this->cache->getQueryCache()); - $this->assertSame($fooQueryCache, $this->cache->getQueryCache('foo')); + self::assertInstanceOf(Cache\QueryCache::class, $defaultQueryCache); + self::assertInstanceOf(Cache\QueryCache::class, $fooQueryCache); + self::assertSame($defaultQueryCache, $this->cache->getQueryCache()); + self::assertSame($fooQueryCache, $this->cache->getQueryCache('foo')); $this->cache->evictQueryRegion(); $this->cache->evictQueryRegion('foo'); $this->cache->evictQueryRegions(); - $this->assertTrue($this->cache->containsQuery('foo')); + self::assertTrue($this->cache->containsQuery('foo')); - $this->assertSame($defaultQueryCache, $this->cache->getQueryCache()); - $this->assertSame($fooQueryCache, $this->cache->getQueryCache('foo')); + self::assertSame($defaultQueryCache, $this->cache->getQueryCache()); + self::assertSame($fooQueryCache, $this->cache->getQueryCache('foo')); } public function testToIdentifierArrayShouldLookupForEntityIdentifier(): void @@ -249,6 +249,6 @@ public function testToIdentifierArrayShouldLookupForEntityIdentifier(): void $method->setAccessible(true); $property->setValue($entity, $identifier); - $this->assertEquals(['id' => $identifier], $method->invoke($this->cache, $metadata, $identifier)); + self::assertEquals(['id' => $identifier], $method->invoke($this->cache, $metadata, $identifier)); } } diff --git a/tests/Doctrine/Tests/ORM/Cache/DefaultCollectionHydratorTest.php b/tests/Doctrine/Tests/ORM/Cache/DefaultCollectionHydratorTest.php index 164dd09c599..4c366f280be 100644 --- a/tests/Doctrine/Tests/ORM/Cache/DefaultCollectionHydratorTest.php +++ b/tests/Doctrine/Tests/ORM/Cache/DefaultCollectionHydratorTest.php @@ -36,7 +36,7 @@ protected function setUp(): void public function testImplementsCollectionEntryStructure(): void { - $this->assertInstanceOf(DefaultCollectionHydrator::class, $this->structure); + self::assertInstanceOf(DefaultCollectionHydrator::class, $this->structure); } public function testLoadCacheCollection(): void @@ -58,23 +58,23 @@ public function testLoadCacheCollection(): void $collection = new PersistentCollection($this->_em, $targetClass, new ArrayCollection()); $list = $this->structure->loadCacheEntry($sourceClass, $key, $entry, $collection); - $this->assertNotNull($list); - $this->assertCount(2, $list); - $this->assertCount(2, $collection); + self::assertNotNull($list); + self::assertCount(2, $list); + self::assertCount(2, $collection); - $this->assertInstanceOf($targetClass->name, $list[0]); - $this->assertInstanceOf($targetClass->name, $list[1]); - $this->assertInstanceOf($targetClass->name, $collection[0]); - $this->assertInstanceOf($targetClass->name, $collection[1]); + self::assertInstanceOf($targetClass->name, $list[0]); + self::assertInstanceOf($targetClass->name, $list[1]); + self::assertInstanceOf($targetClass->name, $collection[0]); + self::assertInstanceOf($targetClass->name, $collection[1]); - $this->assertSame($list[0], $collection[0]); - $this->assertSame($list[1], $collection[1]); + self::assertSame($list[0], $collection[0]); + self::assertSame($list[1], $collection[1]); - $this->assertEquals(31, $list[0]->getId()); - $this->assertEquals(32, $list[1]->getId()); - $this->assertEquals($list[0]->getId(), $collection[0]->getId()); - $this->assertEquals($list[1]->getId(), $collection[1]->getId()); - $this->assertEquals(UnitOfWork::STATE_MANAGED, $this->_em->getUnitOfWork()->getEntityState($collection[0])); - $this->assertEquals(UnitOfWork::STATE_MANAGED, $this->_em->getUnitOfWork()->getEntityState($collection[1])); + self::assertEquals(31, $list[0]->getId()); + self::assertEquals(32, $list[1]->getId()); + self::assertEquals($list[0]->getId(), $collection[0]->getId()); + self::assertEquals($list[1]->getId(), $collection[1]->getId()); + self::assertEquals(UnitOfWork::STATE_MANAGED, $this->_em->getUnitOfWork()->getEntityState($collection[0])); + self::assertEquals(UnitOfWork::STATE_MANAGED, $this->_em->getUnitOfWork()->getEntityState($collection[1])); } } diff --git a/tests/Doctrine/Tests/ORM/Cache/DefaultEntityHydratorTest.php b/tests/Doctrine/Tests/ORM/Cache/DefaultEntityHydratorTest.php index 144bec3db15..bd5eaeac4dd 100644 --- a/tests/Doctrine/Tests/ORM/Cache/DefaultEntityHydratorTest.php +++ b/tests/Doctrine/Tests/ORM/Cache/DefaultEntityHydratorTest.php @@ -37,7 +37,7 @@ protected function setUp(): void public function testImplementsEntityEntryStructure(): void { - $this->assertInstanceOf('\Doctrine\ORM\Cache\EntityHydrator', $this->structure); + self::assertInstanceOf('\Doctrine\ORM\Cache\EntityHydrator', $this->structure); } public function testCreateEntity(): void @@ -47,11 +47,11 @@ public function testCreateEntity(): void $entry = new EntityCacheEntry($metadata->name, ['id' => 1, 'name' => 'Foo']); $entity = $this->structure->loadCacheEntry($metadata, $key, $entry); - $this->assertInstanceOf($metadata->name, $entity); + self::assertInstanceOf($metadata->name, $entity); - $this->assertEquals(1, $entity->getId()); - $this->assertEquals('Foo', $entity->getName()); - $this->assertEquals(UnitOfWork::STATE_MANAGED, $this->em->getUnitOfWork()->getEntityState($entity)); + self::assertEquals(1, $entity->getId()); + self::assertEquals('Foo', $entity->getName()); + self::assertEquals(UnitOfWork::STATE_MANAGED, $this->em->getUnitOfWork()->getEntityState($entity)); } public function testLoadProxy(): void @@ -62,12 +62,12 @@ public function testLoadProxy(): void $proxy = $this->em->getReference($metadata->name, $key->identifier); $entity = $this->structure->loadCacheEntry($metadata, $key, $entry, $proxy); - $this->assertInstanceOf($metadata->name, $entity); - $this->assertSame($proxy, $entity); + self::assertInstanceOf($metadata->name, $entity); + self::assertSame($proxy, $entity); - $this->assertEquals(1, $entity->getId()); - $this->assertEquals('Foo', $entity->getName()); - $this->assertEquals(UnitOfWork::STATE_MANAGED, $this->em->getUnitOfWork()->getEntityState($proxy)); + self::assertEquals(1, $entity->getId()); + self::assertEquals('Foo', $entity->getName()); + self::assertEquals(UnitOfWork::STATE_MANAGED, $this->em->getUnitOfWork()->getEntityState($proxy)); } public function testBuildCacheEntry(): void @@ -83,12 +83,12 @@ public function testBuildCacheEntry(): void $cache = $this->structure->buildCacheEntry($metadata, $key, $entity); - $this->assertInstanceOf(CacheEntry::class, $cache); - $this->assertInstanceOf(EntityCacheEntry::class, $cache); + self::assertInstanceOf(CacheEntry::class, $cache); + self::assertInstanceOf(EntityCacheEntry::class, $cache); - $this->assertArrayHasKey('id', $cache->data); - $this->assertArrayHasKey('name', $cache->data); - $this->assertEquals( + self::assertArrayHasKey('id', $cache->data); + self::assertArrayHasKey('name', $cache->data); + self::assertEquals( [ 'id' => 1, 'name' => 'Foo', @@ -115,13 +115,13 @@ public function testBuildCacheEntryAssociation(): void $cache = $this->structure->buildCacheEntry($metadata, $key, $state); - $this->assertInstanceOf(CacheEntry::class, $cache); - $this->assertInstanceOf(EntityCacheEntry::class, $cache); + self::assertInstanceOf(CacheEntry::class, $cache); + self::assertInstanceOf(EntityCacheEntry::class, $cache); - $this->assertArrayHasKey('id', $cache->data); - $this->assertArrayHasKey('name', $cache->data); - $this->assertArrayHasKey('country', $cache->data); - $this->assertEquals( + self::assertArrayHasKey('id', $cache->data); + self::assertArrayHasKey('name', $cache->data); + self::assertArrayHasKey('country', $cache->data); + self::assertEquals( [ 'id' => 12, 'name' => 'Bar', @@ -146,13 +146,13 @@ public function testBuildCacheEntryNonInitializedAssocProxy(): void $cache = $this->structure->buildCacheEntry($metadata, $key, $entity); - $this->assertInstanceOf(CacheEntry::class, $cache); - $this->assertInstanceOf(EntityCacheEntry::class, $cache); + self::assertInstanceOf(CacheEntry::class, $cache); + self::assertInstanceOf(EntityCacheEntry::class, $cache); - $this->assertArrayHasKey('id', $cache->data); - $this->assertArrayHasKey('name', $cache->data); - $this->assertArrayHasKey('country', $cache->data); - $this->assertEquals( + self::assertArrayHasKey('id', $cache->data); + self::assertArrayHasKey('name', $cache->data); + self::assertArrayHasKey('country', $cache->data); + self::assertEquals( [ 'id' => 12, 'name' => 'Bar', @@ -177,14 +177,14 @@ public function testCacheEntryWithWrongIdentifierType(): void $cache = $this->structure->buildCacheEntry($metadata, $key, $entity); - $this->assertInstanceOf(CacheEntry::class, $cache); - $this->assertInstanceOf(EntityCacheEntry::class, $cache); + self::assertInstanceOf(CacheEntry::class, $cache); + self::assertInstanceOf(EntityCacheEntry::class, $cache); - $this->assertArrayHasKey('id', $cache->data); - $this->assertArrayHasKey('name', $cache->data); - $this->assertArrayHasKey('country', $cache->data); - $this->assertSame($entity->getId(), $cache->data['id']); - $this->assertEquals( + self::assertArrayHasKey('id', $cache->data); + self::assertArrayHasKey('name', $cache->data); + self::assertArrayHasKey('country', $cache->data); + self::assertSame($entity->getId(), $cache->data['id']); + self::assertEquals( [ 'id' => 12, 'name' => 'Bar', diff --git a/tests/Doctrine/Tests/ORM/Cache/DefaultQueryCacheTest.php b/tests/Doctrine/Tests/ORM/Cache/DefaultQueryCacheTest.php index 8e8b2989ed7..1768a181e03 100644 --- a/tests/Doctrine/Tests/ORM/Cache/DefaultQueryCacheTest.php +++ b/tests/Doctrine/Tests/ORM/Cache/DefaultQueryCacheTest.php @@ -65,20 +65,20 @@ protected function setUp(): void public function testImplementQueryCache(): void { - $this->assertInstanceOf(QueryCache::class, $this->queryCache); + self::assertInstanceOf(QueryCache::class, $this->queryCache); } public function testGetRegion(): void { - $this->assertSame($this->region, $this->queryCache->getRegion()); + self::assertSame($this->region, $this->queryCache->getRegion()); } public function testClearShouldEvictRegion(): void { $this->queryCache->clear(); - $this->assertArrayHasKey('evictAll', $this->region->calls); - $this->assertCount(1, $this->region->calls['evictAll']); + self::assertArrayHasKey('evictAll', $this->region->calls); + self::assertCount(1, $this->region->calls['evictAll']); } public function testPutBasicQueryResult(): void @@ -99,21 +99,21 @@ public function testPutBasicQueryResult(): void $this->em->getUnitOfWork()->registerManaged($entity, ['id' => $i], ['name' => $name]); } - $this->assertTrue($this->queryCache->put($key, $rsm, $result)); - $this->assertArrayHasKey('put', $this->region->calls); - $this->assertCount(5, $this->region->calls['put']); - - $this->assertInstanceOf(EntityCacheKey::class, $this->region->calls['put'][0]['key']); - $this->assertInstanceOf(EntityCacheKey::class, $this->region->calls['put'][1]['key']); - $this->assertInstanceOf(EntityCacheKey::class, $this->region->calls['put'][2]['key']); - $this->assertInstanceOf(EntityCacheKey::class, $this->region->calls['put'][3]['key']); - $this->assertInstanceOf(QueryCacheKey::class, $this->region->calls['put'][4]['key']); - - $this->assertInstanceOf(EntityCacheEntry::class, $this->region->calls['put'][0]['entry']); - $this->assertInstanceOf(EntityCacheEntry::class, $this->region->calls['put'][1]['entry']); - $this->assertInstanceOf(EntityCacheEntry::class, $this->region->calls['put'][2]['entry']); - $this->assertInstanceOf(EntityCacheEntry::class, $this->region->calls['put'][3]['entry']); - $this->assertInstanceOf(QueryCacheEntry::class, $this->region->calls['put'][4]['entry']); + self::assertTrue($this->queryCache->put($key, $rsm, $result)); + self::assertArrayHasKey('put', $this->region->calls); + self::assertCount(5, $this->region->calls['put']); + + self::assertInstanceOf(EntityCacheKey::class, $this->region->calls['put'][0]['key']); + self::assertInstanceOf(EntityCacheKey::class, $this->region->calls['put'][1]['key']); + self::assertInstanceOf(EntityCacheKey::class, $this->region->calls['put'][2]['key']); + self::assertInstanceOf(EntityCacheKey::class, $this->region->calls['put'][3]['key']); + self::assertInstanceOf(QueryCacheKey::class, $this->region->calls['put'][4]['key']); + + self::assertInstanceOf(EntityCacheEntry::class, $this->region->calls['put'][0]['entry']); + self::assertInstanceOf(EntityCacheEntry::class, $this->region->calls['put'][1]['entry']); + self::assertInstanceOf(EntityCacheEntry::class, $this->region->calls['put'][2]['entry']); + self::assertInstanceOf(EntityCacheEntry::class, $this->region->calls['put'][3]['entry']); + self::assertInstanceOf(QueryCacheEntry::class, $this->region->calls['put'][4]['entry']); } public function testPutToOneAssociationQueryResult(): void @@ -140,19 +140,19 @@ public function testPutToOneAssociationQueryResult(): void $uow->registerManaged($city, ['id' => $city->getId()], ['name' => $city->getName(), 'state' => $state]); } - $this->assertTrue($this->queryCache->put($key, $rsm, $result)); - $this->assertArrayHasKey('put', $this->region->calls); - $this->assertCount(9, $this->region->calls['put']); - - $this->assertInstanceOf(EntityCacheKey::class, $this->region->calls['put'][0]['key']); - $this->assertInstanceOf(EntityCacheKey::class, $this->region->calls['put'][1]['key']); - $this->assertInstanceOf(EntityCacheKey::class, $this->region->calls['put'][2]['key']); - $this->assertInstanceOf(EntityCacheKey::class, $this->region->calls['put'][3]['key']); - $this->assertInstanceOf(EntityCacheKey::class, $this->region->calls['put'][4]['key']); - $this->assertInstanceOf(EntityCacheKey::class, $this->region->calls['put'][5]['key']); - $this->assertInstanceOf(EntityCacheKey::class, $this->region->calls['put'][6]['key']); - $this->assertInstanceOf(EntityCacheKey::class, $this->region->calls['put'][7]['key']); - $this->assertInstanceOf(QueryCacheKey::class, $this->region->calls['put'][8]['key']); + self::assertTrue($this->queryCache->put($key, $rsm, $result)); + self::assertArrayHasKey('put', $this->region->calls); + self::assertCount(9, $this->region->calls['put']); + + self::assertInstanceOf(EntityCacheKey::class, $this->region->calls['put'][0]['key']); + self::assertInstanceOf(EntityCacheKey::class, $this->region->calls['put'][1]['key']); + self::assertInstanceOf(EntityCacheKey::class, $this->region->calls['put'][2]['key']); + self::assertInstanceOf(EntityCacheKey::class, $this->region->calls['put'][3]['key']); + self::assertInstanceOf(EntityCacheKey::class, $this->region->calls['put'][4]['key']); + self::assertInstanceOf(EntityCacheKey::class, $this->region->calls['put'][5]['key']); + self::assertInstanceOf(EntityCacheKey::class, $this->region->calls['put'][6]['key']); + self::assertInstanceOf(EntityCacheKey::class, $this->region->calls['put'][7]['key']); + self::assertInstanceOf(QueryCacheKey::class, $this->region->calls['put'][8]['key']); } public function testPutToOneAssociation2LevelsQueryResult(): void @@ -185,23 +185,23 @@ public function testPutToOneAssociation2LevelsQueryResult(): void $uow->registerManaged($city, ['id' => $city->getId()], ['name' => $city->getName(), 'state' => $state]); } - $this->assertTrue($this->queryCache->put($key, $rsm, $result)); - $this->assertArrayHasKey('put', $this->region->calls); - $this->assertCount(13, $this->region->calls['put']); - - $this->assertInstanceOf(EntityCacheKey::class, $this->region->calls['put'][0]['key']); - $this->assertInstanceOf(EntityCacheKey::class, $this->region->calls['put'][1]['key']); - $this->assertInstanceOf(EntityCacheKey::class, $this->region->calls['put'][2]['key']); - $this->assertInstanceOf(EntityCacheKey::class, $this->region->calls['put'][3]['key']); - $this->assertInstanceOf(EntityCacheKey::class, $this->region->calls['put'][4]['key']); - $this->assertInstanceOf(EntityCacheKey::class, $this->region->calls['put'][5]['key']); - $this->assertInstanceOf(EntityCacheKey::class, $this->region->calls['put'][6]['key']); - $this->assertInstanceOf(EntityCacheKey::class, $this->region->calls['put'][7]['key']); - $this->assertInstanceOf(EntityCacheKey::class, $this->region->calls['put'][8]['key']); - $this->assertInstanceOf(EntityCacheKey::class, $this->region->calls['put'][9]['key']); - $this->assertInstanceOf(EntityCacheKey::class, $this->region->calls['put'][10]['key']); - $this->assertInstanceOf(EntityCacheKey::class, $this->region->calls['put'][11]['key']); - $this->assertInstanceOf(QueryCacheKey::class, $this->region->calls['put'][12]['key']); + self::assertTrue($this->queryCache->put($key, $rsm, $result)); + self::assertArrayHasKey('put', $this->region->calls); + self::assertCount(13, $this->region->calls['put']); + + self::assertInstanceOf(EntityCacheKey::class, $this->region->calls['put'][0]['key']); + self::assertInstanceOf(EntityCacheKey::class, $this->region->calls['put'][1]['key']); + self::assertInstanceOf(EntityCacheKey::class, $this->region->calls['put'][2]['key']); + self::assertInstanceOf(EntityCacheKey::class, $this->region->calls['put'][3]['key']); + self::assertInstanceOf(EntityCacheKey::class, $this->region->calls['put'][4]['key']); + self::assertInstanceOf(EntityCacheKey::class, $this->region->calls['put'][5]['key']); + self::assertInstanceOf(EntityCacheKey::class, $this->region->calls['put'][6]['key']); + self::assertInstanceOf(EntityCacheKey::class, $this->region->calls['put'][7]['key']); + self::assertInstanceOf(EntityCacheKey::class, $this->region->calls['put'][8]['key']); + self::assertInstanceOf(EntityCacheKey::class, $this->region->calls['put'][9]['key']); + self::assertInstanceOf(EntityCacheKey::class, $this->region->calls['put'][10]['key']); + self::assertInstanceOf(EntityCacheKey::class, $this->region->calls['put'][11]['key']); + self::assertInstanceOf(QueryCacheKey::class, $this->region->calls['put'][12]['key']); } public function testPutToOneAssociationNullQueryResult(): void @@ -224,15 +224,15 @@ public function testPutToOneAssociationNullQueryResult(): void $uow->registerManaged($city, ['id' => $city->getId()], ['name' => $city->getName(), 'state' => null]); } - $this->assertTrue($this->queryCache->put($key, $rsm, $result)); - $this->assertArrayHasKey('put', $this->region->calls); - $this->assertCount(5, $this->region->calls['put']); + self::assertTrue($this->queryCache->put($key, $rsm, $result)); + self::assertArrayHasKey('put', $this->region->calls); + self::assertCount(5, $this->region->calls['put']); - $this->assertInstanceOf(EntityCacheKey::class, $this->region->calls['put'][0]['key']); - $this->assertInstanceOf(EntityCacheKey::class, $this->region->calls['put'][1]['key']); - $this->assertInstanceOf(EntityCacheKey::class, $this->region->calls['put'][2]['key']); - $this->assertInstanceOf(EntityCacheKey::class, $this->region->calls['put'][3]['key']); - $this->assertInstanceOf(QueryCacheKey::class, $this->region->calls['put'][4]['key']); + self::assertInstanceOf(EntityCacheKey::class, $this->region->calls['put'][0]['key']); + self::assertInstanceOf(EntityCacheKey::class, $this->region->calls['put'][1]['key']); + self::assertInstanceOf(EntityCacheKey::class, $this->region->calls['put'][2]['key']); + self::assertInstanceOf(EntityCacheKey::class, $this->region->calls['put'][3]['key']); + self::assertInstanceOf(QueryCacheKey::class, $this->region->calls['put'][4]['key']); } public function testPutToManyAssociationQueryResult(): void @@ -265,9 +265,9 @@ public function testPutToManyAssociationQueryResult(): void $uow->registerManaged($state, ['id' => $state->getId()], ['name' => $state->getName(), 'cities' => $state->getCities()]); } - $this->assertTrue($this->queryCache->put($key, $rsm, $result)); - $this->assertArrayHasKey('put', $this->region->calls); - $this->assertCount(13, $this->region->calls['put']); + self::assertTrue($this->queryCache->put($key, $rsm, $result)); + self::assertArrayHasKey('put', $this->region->calls); + self::assertCount(13, $this->region->calls['put']); } public function testGetBasicQueryResult(): void @@ -300,13 +300,13 @@ public function testGetBasicQueryResult(): void $result = $this->queryCache->get($key, $rsm); - $this->assertCount(2, $result); - $this->assertInstanceOf(Country::class, $result[0]); - $this->assertInstanceOf(Country::class, $result[1]); - $this->assertEquals(1, $result[0]->getId()); - $this->assertEquals(2, $result[1]->getId()); - $this->assertEquals('Foo', $result[0]->getName()); - $this->assertEquals('Bar', $result[1]->getName()); + self::assertCount(2, $result); + self::assertInstanceOf(Country::class, $result[0]); + self::assertInstanceOf(Country::class, $result[1]); + self::assertEquals(1, $result[0]->getId()); + self::assertEquals(2, $result[1]->getId()); + self::assertEquals('Foo', $result[0]->getName()); + self::assertEquals('Bar', $result[1]->getName()); } public function testGetWithAssociation(): void @@ -339,13 +339,13 @@ public function testGetWithAssociation(): void $result = $this->queryCache->get($key, $rsm); - $this->assertCount(2, $result); - $this->assertInstanceOf(Country::class, $result[0]); - $this->assertInstanceOf(Country::class, $result[1]); - $this->assertEquals(1, $result[0]->getId()); - $this->assertEquals(2, $result[1]->getId()); - $this->assertEquals('Foo', $result[0]->getName()); - $this->assertEquals('Bar', $result[1]->getName()); + self::assertCount(2, $result); + self::assertInstanceOf(Country::class, $result[0]); + self::assertInstanceOf(Country::class, $result[1]); + self::assertEquals(1, $result[0]->getId()); + self::assertEquals(2, $result[1]->getId()); + self::assertEquals('Foo', $result[0]->getName()); + self::assertEquals('Bar', $result[1]->getName()); } public function testGetWithAssociationCacheMiss(): void @@ -396,9 +396,9 @@ public function testCancelPutResultIfEntityPutFails(): void $this->region->addReturn('put', false); - $this->assertFalse($this->queryCache->put($key, $rsm, $result)); - $this->assertArrayHasKey('put', $this->region->calls); - $this->assertCount(1, $this->region->calls['put']); + self::assertFalse($this->queryCache->put($key, $rsm, $result)); + self::assertArrayHasKey('put', $this->region->calls); + self::assertCount(1, $this->region->calls['put']); } public function testCancelPutResultIfAssociationEntityPutFails(): void @@ -426,7 +426,7 @@ public function testCancelPutResultIfAssociationEntityPutFails(): void $this->region->addReturn('put', true); // put root entity $this->region->addReturn('put', false); // association fails - $this->assertFalse($this->queryCache->put($key, $rsm, $result)); + self::assertFalse($this->queryCache->put($key, $rsm, $result)); } public function testCancelPutToManyAssociationQueryResult(): void @@ -460,9 +460,9 @@ public function testCancelPutToManyAssociationQueryResult(): void $this->region->addReturn('put', true); // put root entity $this->region->addReturn('put', false); // collection association fails - $this->assertFalse($this->queryCache->put($key, $rsm, $result)); - $this->assertArrayHasKey('put', $this->region->calls); - $this->assertCount(2, $this->region->calls['put']); + self::assertFalse($this->queryCache->put($key, $rsm, $result)); + self::assertArrayHasKey('put', $this->region->calls); + self::assertCount(2, $this->region->calls['put']); } public function testIgnoreCacheNonGetMode(): void @@ -480,7 +480,7 @@ public function testIgnoreCacheNonGetMode(): void $this->region->addReturn('get', $entry); - $this->assertNull($this->queryCache->get($key, $rsm)); + self::assertNull($this->queryCache->get($key, $rsm)); } public function testIgnoreCacheNonPutMode(): void @@ -501,7 +501,7 @@ public function testIgnoreCacheNonPutMode(): void $this->em->getUnitOfWork()->registerManaged($entity, ['id' => $i], ['name' => $name]); } - $this->assertFalse($this->queryCache->put($key, $rsm, $result)); + self::assertFalse($this->queryCache->put($key, $rsm, $result)); } public function testGetShouldIgnoreOldQueryCacheEntryResult(): void @@ -533,7 +533,7 @@ public function testGetShouldIgnoreOldQueryCacheEntryResult(): void $rsm->addRootEntityFromClassMetadata(Country::class, 'c'); - $this->assertNull($this->queryCache->get($key, $rsm)); + self::assertNull($this->queryCache->get($key, $rsm)); } public function testGetShouldIgnoreNonQueryCacheEntryResult(): void @@ -564,7 +564,7 @@ public function testGetShouldIgnoreNonQueryCacheEntryResult(): void $rsm->addRootEntityFromClassMetadata(Country::class, 'c'); - $this->assertNull($this->queryCache->get($key, $rsm)); + self::assertNull($this->queryCache->get($key, $rsm)); } public function testGetShouldIgnoreMissingEntityQueryCacheEntry(): void @@ -583,7 +583,7 @@ public function testGetShouldIgnoreMissingEntityQueryCacheEntry(): void $rsm->addRootEntityFromClassMetadata(Country::class, 'c'); - $this->assertNull($this->queryCache->get($key, $rsm)); + self::assertNull($this->queryCache->get($key, $rsm)); } public function testGetAssociationValue(): void @@ -619,15 +619,15 @@ public function testGetAssociationValue(): void $cities = $reflection->invoke($this->queryCache, $rsm, 'c', $bavaria); $attractions = $reflection->invoke($this->queryCache, $rsm, 'a', $bavaria); - $this->assertCount(2, $cities); - $this->assertCount(2, $attractions); + self::assertCount(2, $cities); + self::assertCount(2, $attractions); - $this->assertInstanceOf(Collection::class, $cities); - $this->assertInstanceOf(Collection::class, $attractions[0]); - $this->assertInstanceOf(Collection::class, $attractions[1]); + self::assertInstanceOf(Collection::class, $cities); + self::assertInstanceOf(Collection::class, $attractions[0]); + self::assertInstanceOf(Collection::class, $attractions[1]); - $this->assertCount(2, $attractions[0]); - $this->assertCount(1, $attractions[1]); + self::assertCount(2, $attractions[0]); + self::assertCount(1, $attractions[1]); } public function testScalarResultException(): void @@ -677,7 +677,7 @@ public function testNotCacheableEntityException(): void $this->em->getUnitOfWork()->registerManaged($entity, ['id' => $i], ['booleanField' => $boolean]); } - $this->assertFalse($this->queryCache->put($key, $rsm, $result)); + self::assertFalse($this->queryCache->put($key, $rsm, $result)); } } diff --git a/tests/Doctrine/Tests/ORM/Cache/DefaultRegionTest.php b/tests/Doctrine/Tests/ORM/Cache/DefaultRegionTest.php index a30d2a54c81..cb43e08ae54 100644 --- a/tests/Doctrine/Tests/ORM/Cache/DefaultRegionTest.php +++ b/tests/Doctrine/Tests/ORM/Cache/DefaultRegionTest.php @@ -30,14 +30,14 @@ protected function createRegion(): Region public function testGetters(): void { - $this->assertEquals('default.region.test', $this->region->getName()); - $this->assertSame($this->cache, $this->region->getCache()); + self::assertEquals('default.region.test', $this->region->getName()); + self::assertSame($this->cache, $this->region->getCache()); } public function testSharedRegion(): void { if (! class_exists(ArrayCache::class)) { - $this->markTestSkipped('Test only applies with doctrine/cache 1.x'); + self::markTestSkipped('Test only applies with doctrine/cache 1.x'); } $cache = new SharedArrayCache(); @@ -46,19 +46,19 @@ public function testSharedRegion(): void $region1 = new DefaultRegion('region1', $cache->createChild()); $region2 = new DefaultRegion('region2', $cache->createChild()); - $this->assertFalse($region1->contains($key)); - $this->assertFalse($region2->contains($key)); + self::assertFalse($region1->contains($key)); + self::assertFalse($region2->contains($key)); $region1->put($key, $entry); $region2->put($key, $entry); - $this->assertTrue($region1->contains($key)); - $this->assertTrue($region2->contains($key)); + self::assertTrue($region1->contains($key)); + self::assertTrue($region2->contains($key)); $region1->evictAll(); - $this->assertFalse($region1->contains($key)); - $this->assertTrue($region2->contains($key)); + self::assertFalse($region1->contains($key)); + self::assertTrue($region2->contains($key)); } public function testDoesNotModifyCacheNamespace(): void @@ -70,7 +70,7 @@ public function testDoesNotModifyCacheNamespace(): void new DefaultRegion('bar', $cache); new DefaultRegion('baz', $cache); - $this->assertSame('foo', $cache->getNamespace()); + self::assertSame('foo', $cache->getNamespace()); } public function testEvictAllWithGenericCacheThrowsUnsupportedException(): void @@ -93,19 +93,19 @@ public function testGetMulti(): void $key2 = new CacheKeyMock('key.2'); $value2 = new CacheEntryMock(['id' => 2, 'name' => 'bar']); - $this->assertFalse($this->region->contains($key1)); - $this->assertFalse($this->region->contains($key2)); + self::assertFalse($this->region->contains($key1)); + self::assertFalse($this->region->contains($key2)); $this->region->put($key1, $value1); $this->region->put($key2, $value2); - $this->assertTrue($this->region->contains($key1)); - $this->assertTrue($this->region->contains($key2)); + self::assertTrue($this->region->contains($key1)); + self::assertTrue($this->region->contains($key2)); $actual = $this->region->getMultiple(new CollectionCacheEntry([$key1, $key2])); - $this->assertEquals($value1, $actual[0]); - $this->assertEquals($value2, $actual[1]); + self::assertEquals($value1, $actual[0]); + self::assertEquals($value2, $actual[1]); } /** diff --git a/tests/Doctrine/Tests/ORM/Cache/FileLockRegionTest.php b/tests/Doctrine/Tests/ORM/Cache/FileLockRegionTest.php index 17e28209cdc..d6f2e7998a9 100644 --- a/tests/Doctrine/Tests/ORM/Cache/FileLockRegionTest.php +++ b/tests/Doctrine/Tests/ORM/Cache/FileLockRegionTest.php @@ -66,7 +66,7 @@ protected function createRegion(): Region public function testGetRegionName(): void { - $this->assertEquals('concurren_region_test', $this->region->getName()); + self::assertEquals('concurren_region_test', $this->region->getName()); } public function testLockAndUnlock(): void @@ -75,22 +75,22 @@ public function testLockAndUnlock(): void $entry = new CacheEntryMock(['foo' => 'bar']); $file = $this->getFileName($this->region, $key); - $this->assertFalse($this->region->contains($key)); - $this->assertTrue($this->region->put($key, $entry)); - $this->assertTrue($this->region->contains($key)); + self::assertFalse($this->region->contains($key)); + self::assertTrue($this->region->put($key, $entry)); + self::assertTrue($this->region->contains($key)); $lock = $this->region->lock($key); - $this->assertFileExists($file); - $this->assertInstanceOf(Lock::class, $lock); - $this->assertEquals($lock->value, file_get_contents($file)); + self::assertFileExists($file); + self::assertInstanceOf(Lock::class, $lock); + self::assertEquals($lock->value, file_get_contents($file)); // should be not available after lock - $this->assertFalse($this->region->contains($key)); - $this->assertNull($this->region->get($key)); + self::assertFalse($this->region->contains($key)); + self::assertNull($this->region->get($key)); - $this->assertTrue($this->region->unlock($key, $lock)); - $this->assertFileDoesNotExist($file); + self::assertTrue($this->region->unlock($key, $lock)); + self::assertFileDoesNotExist($file); } public function testLockWithExistingLock(): void @@ -99,21 +99,21 @@ public function testLockWithExistingLock(): void $entry = new CacheEntryMock(['foo' => 'bar']); $file = $this->getFileName($this->region, $key); - $this->assertFalse($this->region->contains($key)); - $this->assertTrue($this->region->put($key, $entry)); - $this->assertTrue($this->region->contains($key)); + self::assertFalse($this->region->contains($key)); + self::assertTrue($this->region->put($key, $entry)); + self::assertTrue($this->region->contains($key)); file_put_contents($file, 'foo'); - $this->assertFileExists($file); - $this->assertEquals('foo', file_get_contents($file)); + self::assertFileExists($file); + self::assertEquals('foo', file_get_contents($file)); - $this->assertNull($this->region->lock($key)); - $this->assertEquals('foo', file_get_contents($file)); - $this->assertFileExists($file); + self::assertNull($this->region->lock($key)); + self::assertEquals('foo', file_get_contents($file)); + self::assertFileExists($file); // should be not available - $this->assertFalse($this->region->contains($key)); - $this->assertNull($this->region->get($key)); + self::assertFalse($this->region->contains($key)); + self::assertNull($this->region->get($key)); } public function testUnlockWithExistingLock(): void @@ -122,27 +122,27 @@ public function testUnlockWithExistingLock(): void $entry = new CacheEntryMock(['foo' => 'bar']); $file = $this->getFileName($this->region, $key); - $this->assertFalse($this->region->contains($key)); - $this->assertTrue($this->region->put($key, $entry)); - $this->assertTrue($this->region->contains($key)); + self::assertFalse($this->region->contains($key)); + self::assertTrue($this->region->put($key, $entry)); + self::assertTrue($this->region->contains($key)); - $this->assertInstanceOf(Lock::class, $lock = $this->region->lock($key)); - $this->assertEquals($lock->value, file_get_contents($file)); - $this->assertFileExists($file); + self::assertInstanceOf(Lock::class, $lock = $this->region->lock($key)); + self::assertEquals($lock->value, file_get_contents($file)); + self::assertFileExists($file); // change the lock file_put_contents($file, 'foo'); - $this->assertFileExists($file); - $this->assertEquals('foo', file_get_contents($file)); + self::assertFileExists($file); + self::assertEquals('foo', file_get_contents($file)); //try to unlock - $this->assertFalse($this->region->unlock($key, $lock)); - $this->assertEquals('foo', file_get_contents($file)); - $this->assertFileExists($file); + self::assertFalse($this->region->unlock($key, $lock)); + self::assertEquals('foo', file_get_contents($file)); + self::assertFileExists($file); // should be not available - $this->assertFalse($this->region->contains($key)); - $this->assertNull($this->region->get($key)); + self::assertFalse($this->region->contains($key)); + self::assertNull($this->region->get($key)); } public function testPutWithExistingLock(): void @@ -151,21 +151,21 @@ public function testPutWithExistingLock(): void $entry = new CacheEntryMock(['foo' => 'bar']); $file = $this->getFileName($this->region, $key); - $this->assertFalse($this->region->contains($key)); - $this->assertTrue($this->region->put($key, $entry)); - $this->assertTrue($this->region->contains($key)); + self::assertFalse($this->region->contains($key)); + self::assertTrue($this->region->put($key, $entry)); + self::assertTrue($this->region->contains($key)); // create lock file_put_contents($file, 'foo'); - $this->assertFileExists($file); - $this->assertEquals('foo', file_get_contents($file)); + self::assertFileExists($file); + self::assertEquals('foo', file_get_contents($file)); - $this->assertFalse($this->region->contains($key)); - $this->assertFalse($this->region->put($key, $entry)); - $this->assertFalse($this->region->contains($key)); + self::assertFalse($this->region->contains($key)); + self::assertFalse($this->region->put($key, $entry)); + self::assertFalse($this->region->contains($key)); - $this->assertFileExists($file); - $this->assertEquals('foo', file_get_contents($file)); + self::assertFileExists($file); + self::assertEquals('foo', file_get_contents($file)); } public function testLockedEvict(): void @@ -174,18 +174,18 @@ public function testLockedEvict(): void $entry = new CacheEntryMock(['foo' => 'bar']); $file = $this->getFileName($this->region, $key); - $this->assertFalse($this->region->contains($key)); - $this->assertTrue($this->region->put($key, $entry)); - $this->assertTrue($this->region->contains($key)); + self::assertFalse($this->region->contains($key)); + self::assertTrue($this->region->put($key, $entry)); + self::assertTrue($this->region->contains($key)); - $this->assertInstanceOf(Lock::class, $lock = $this->region->lock($key)); - $this->assertEquals($lock->value, file_get_contents($file)); - $this->assertFileExists($file); + self::assertInstanceOf(Lock::class, $lock = $this->region->lock($key)); + self::assertEquals($lock->value, file_get_contents($file)); + self::assertFileExists($file); - $this->assertFalse($this->region->contains($key)); - $this->assertTrue($this->region->evict($key)); - $this->assertFalse($this->region->contains($key)); - $this->assertFileDoesNotExist($file); + self::assertFalse($this->region->contains($key)); + self::assertTrue($this->region->evict($key)); + self::assertFalse($this->region->contains($key)); + self::assertFileDoesNotExist($file); } public function testLockedEvictAll(): void @@ -198,30 +198,30 @@ public function testLockedEvictAll(): void $entry2 = new CacheEntryMock(['foo2' => 'bar2']); $file2 = $this->getFileName($this->region, $key2); - $this->assertFalse($this->region->contains($key1)); - $this->assertTrue($this->region->put($key1, $entry1)); - $this->assertTrue($this->region->contains($key1)); + self::assertFalse($this->region->contains($key1)); + self::assertTrue($this->region->put($key1, $entry1)); + self::assertTrue($this->region->contains($key1)); - $this->assertFalse($this->region->contains($key2)); - $this->assertTrue($this->region->put($key2, $entry2)); - $this->assertTrue($this->region->contains($key2)); + self::assertFalse($this->region->contains($key2)); + self::assertTrue($this->region->put($key2, $entry2)); + self::assertTrue($this->region->contains($key2)); - $this->assertInstanceOf(Lock::class, $lock1 = $this->region->lock($key1)); - $this->assertInstanceOf(Lock::class, $lock2 = $this->region->lock($key2)); + self::assertInstanceOf(Lock::class, $lock1 = $this->region->lock($key1)); + self::assertInstanceOf(Lock::class, $lock2 = $this->region->lock($key2)); - $this->assertEquals($lock2->value, file_get_contents($file2)); - $this->assertEquals($lock1->value, file_get_contents($file1)); + self::assertEquals($lock2->value, file_get_contents($file2)); + self::assertEquals($lock1->value, file_get_contents($file1)); - $this->assertFileExists($file1); - $this->assertFileExists($file2); + self::assertFileExists($file1); + self::assertFileExists($file2); - $this->assertTrue($this->region->evictAll()); + self::assertTrue($this->region->evictAll()); - $this->assertFileDoesNotExist($file1); - $this->assertFileDoesNotExist($file2); + self::assertFileDoesNotExist($file1); + self::assertFileDoesNotExist($file2); - $this->assertFalse($this->region->contains($key1)); - $this->assertFalse($this->region->contains($key2)); + self::assertFalse($this->region->contains($key1)); + self::assertFalse($this->region->contains($key2)); } public function testLockLifetime(): void @@ -234,18 +234,18 @@ public function testLockLifetime(): void $property->setAccessible(true); $property->setValue($this->region, -10); - $this->assertFalse($this->region->contains($key)); - $this->assertTrue($this->region->put($key, $entry)); - $this->assertTrue($this->region->contains($key)); + self::assertFalse($this->region->contains($key)); + self::assertTrue($this->region->put($key, $entry)); + self::assertTrue($this->region->contains($key)); - $this->assertInstanceOf(Lock::class, $lock = $this->region->lock($key)); - $this->assertEquals($lock->value, file_get_contents($file)); - $this->assertFileExists($file); + self::assertInstanceOf(Lock::class, $lock = $this->region->lock($key)); + self::assertEquals($lock->value, file_get_contents($file)); + self::assertFileExists($file); // outdated lock should be removed - $this->assertTrue($this->region->contains($key)); - $this->assertNotNull($this->region->get($key)); - $this->assertFileDoesNotExist($file); + self::assertTrue($this->region->contains($key)); + self::assertNotNull($this->region->get($key)); + self::assertFileDoesNotExist($file); } /** @@ -262,7 +262,7 @@ public function testHandlesScanErrorsGracefullyOnEvictAll(): void set_error_handler(static function (): void { }, E_WARNING); - $this->assertTrue($region->evictAll()); + self::assertTrue($region->evictAll()); restore_error_handler(); } diff --git a/tests/Doctrine/Tests/ORM/Cache/MultiGetRegionTest.php b/tests/Doctrine/Tests/ORM/Cache/MultiGetRegionTest.php index 0228ce6b846..3f10d9652c8 100644 --- a/tests/Doctrine/Tests/ORM/Cache/MultiGetRegionTest.php +++ b/tests/Doctrine/Tests/ORM/Cache/MultiGetRegionTest.php @@ -25,19 +25,19 @@ public function testGetMulti(): void $key2 = new CacheKeyMock('key.2'); $value2 = new CacheEntryMock(['id' => 2, 'name' => 'bar']); - $this->assertFalse($this->region->contains($key1)); - $this->assertFalse($this->region->contains($key2)); + self::assertFalse($this->region->contains($key1)); + self::assertFalse($this->region->contains($key2)); $this->region->put($key1, $value1); $this->region->put($key2, $value2); - $this->assertTrue($this->region->contains($key1)); - $this->assertTrue($this->region->contains($key2)); + self::assertTrue($this->region->contains($key1)); + self::assertTrue($this->region->contains($key2)); $actual = $this->region->getMultiple(new CollectionCacheEntry([$key1, $key2])); - $this->assertEquals($value1, $actual[0]); - $this->assertEquals($value2, $actual[1]); + self::assertEquals($value1, $actual[0]); + self::assertEquals($value2, $actual[1]); } /** diff --git a/tests/Doctrine/Tests/ORM/Cache/Persister/Collection/AbstractCollectionPersisterTest.php b/tests/Doctrine/Tests/ORM/Cache/Persister/Collection/AbstractCollectionPersisterTest.php index 92120834df3..59d8178cd06 100644 --- a/tests/Doctrine/Tests/ORM/Cache/Persister/Collection/AbstractCollectionPersisterTest.php +++ b/tests/Doctrine/Tests/ORM/Cache/Persister/Collection/AbstractCollectionPersisterTest.php @@ -101,9 +101,9 @@ public function testImplementsEntityPersister(): void { $persister = $this->createPersisterDefault(); - $this->assertInstanceOf(CollectionPersister::class, $persister); - $this->assertInstanceOf(CachedPersister::class, $persister); - $this->assertInstanceOf(CachedCollectionPersister::class, $persister); + self::assertInstanceOf(CollectionPersister::class, $persister); + self::assertInstanceOf(CachedPersister::class, $persister); + self::assertInstanceOf(CachedCollectionPersister::class, $persister); } public function testInvokeDelete(): void @@ -114,11 +114,11 @@ public function testInvokeDelete(): void $this->em->getUnitOfWork()->registerManaged($entity, ['id' => 1], ['id' => 1, 'name' => 'Foo']); - $this->collectionPersister->expects($this->once()) + $this->collectionPersister->expects(self::once()) ->method('delete') - ->with($this->equalTo($collection)); + ->with(self::equalTo($collection)); - $this->assertNull($persister->delete($collection)); + self::assertNull($persister->delete($collection)); } public function testInvokeUpdate(): void @@ -131,11 +131,11 @@ public function testInvokeUpdate(): void $this->em->getUnitOfWork()->registerManaged($entity, ['id' => 1], ['id' => 1, 'name' => 'Foo']); - $this->collectionPersister->expects($this->once()) + $this->collectionPersister->expects(self::once()) ->method('update') - ->with($this->equalTo($collection)); + ->with(self::equalTo($collection)); - $this->assertNull($persister->update($collection)); + self::assertNull($persister->update($collection)); } public function testInvokeCount(): void @@ -146,12 +146,12 @@ public function testInvokeCount(): void $this->em->getUnitOfWork()->registerManaged($entity, ['id' => 1], ['id' => 1, 'name' => 'Foo']); - $this->collectionPersister->expects($this->once()) + $this->collectionPersister->expects(self::once()) ->method('count') - ->with($this->equalTo($collection)) - ->will($this->returnValue(0)); + ->with(self::equalTo($collection)) + ->will(self::returnValue(0)); - $this->assertEquals(0, $persister->count($collection)); + self::assertEquals(0, $persister->count($collection)); } public function testInvokeSlice(): void @@ -163,12 +163,12 @@ public function testInvokeSlice(): void $this->em->getUnitOfWork()->registerManaged($entity, ['id' => 1], ['id' => 1, 'name' => 'Foo']); - $this->collectionPersister->expects($this->once()) + $this->collectionPersister->expects(self::once()) ->method('slice') - ->with($this->equalTo($collection), $this->equalTo(1), $this->equalTo(2)) - ->will($this->returnValue($slice)); + ->with(self::equalTo($collection), self::equalTo(1), self::equalTo(2)) + ->will(self::returnValue($slice)); - $this->assertEquals($slice, $persister->slice($collection, 1, 2)); + self::assertEquals($slice, $persister->slice($collection, 1, 2)); } public function testInvokeContains(): void @@ -180,12 +180,12 @@ public function testInvokeContains(): void $this->em->getUnitOfWork()->registerManaged($entity, ['id' => 1], ['id' => 1, 'name' => 'Foo']); - $this->collectionPersister->expects($this->once()) + $this->collectionPersister->expects(self::once()) ->method('contains') - ->with($this->equalTo($collection), $this->equalTo($element)) - ->will($this->returnValue(false)); + ->with(self::equalTo($collection), self::equalTo($element)) + ->will(self::returnValue(false)); - $this->assertFalse($persister->contains($collection, $element)); + self::assertFalse($persister->contains($collection, $element)); } public function testInvokeContainsKey(): void @@ -196,12 +196,12 @@ public function testInvokeContainsKey(): void $this->em->getUnitOfWork()->registerManaged($entity, ['id' => 1], ['id' => 1, 'name' => 'Foo']); - $this->collectionPersister->expects($this->once()) + $this->collectionPersister->expects(self::once()) ->method('containsKey') - ->with($this->equalTo($collection), $this->equalTo(0)) - ->will($this->returnValue(false)); + ->with(self::equalTo($collection), self::equalTo(0)) + ->will(self::returnValue(false)); - $this->assertFalse($persister->containsKey($collection, 0)); + self::assertFalse($persister->containsKey($collection, 0)); } public function testInvokeGet(): void @@ -213,11 +213,11 @@ public function testInvokeGet(): void $this->em->getUnitOfWork()->registerManaged($entity, ['id' => 1], ['id' => 1, 'name' => 'Foo']); - $this->collectionPersister->expects($this->once()) + $this->collectionPersister->expects(self::once()) ->method('get') - ->with($this->equalTo($collection), $this->equalTo(0)) - ->will($this->returnValue($element)); + ->with(self::equalTo($collection), self::equalTo(0)) + ->will(self::returnValue($element)); - $this->assertEquals($element, $persister->get($collection, 0)); + self::assertEquals($element, $persister->get($collection, 0)); } } diff --git a/tests/Doctrine/Tests/ORM/Cache/Persister/Collection/ReadWriteCachedCollectionPersisterTest.php b/tests/Doctrine/Tests/ORM/Cache/Persister/Collection/ReadWriteCachedCollectionPersisterTest.php index d839107c907..60a95fa0297 100644 --- a/tests/Doctrine/Tests/ORM/Cache/Persister/Collection/ReadWriteCachedCollectionPersisterTest.php +++ b/tests/Doctrine/Tests/ORM/Cache/Persister/Collection/ReadWriteCachedCollectionPersisterTest.php @@ -53,10 +53,10 @@ public function testDeleteShouldLockItem(): void $collection = $this->createCollection($entity); $key = new CollectionCacheKey(State::class, 'cities', ['id' => 1]); - $this->region->expects($this->once()) + $this->region->expects(self::once()) ->method('lock') - ->with($this->equalTo($key)) - ->will($this->returnValue($lock)); + ->with(self::equalTo($key)) + ->will(self::returnValue($lock)); $this->em->getUnitOfWork()->registerManaged($entity, ['id' => 1], ['id' => 1, 'name' => 'Foo']); @@ -71,10 +71,10 @@ public function testUpdateShouldLockItem(): void $collection = $this->createCollection($entity); $key = new CollectionCacheKey(State::class, 'cities', ['id' => 1]); - $this->region->expects($this->once()) + $this->region->expects(self::once()) ->method('lock') - ->with($this->equalTo($key)) - ->will($this->returnValue($lock)); + ->with(self::equalTo($key)) + ->will(self::returnValue($lock)); $this->em->getUnitOfWork()->registerManaged($entity, ['id' => 1], ['id' => 1, 'name' => 'Foo']); @@ -89,15 +89,15 @@ public function testUpdateTransactionRollBackShouldEvictItem(): void $collection = $this->createCollection($entity); $key = new CollectionCacheKey(State::class, 'cities', ['id' => 1]); - $this->region->expects($this->once()) + $this->region->expects(self::once()) ->method('lock') - ->with($this->equalTo($key)) - ->will($this->returnValue($lock)); + ->with(self::equalTo($key)) + ->will(self::returnValue($lock)); - $this->region->expects($this->once()) + $this->region->expects(self::once()) ->method('evict') - ->with($this->equalTo($key)) - ->will($this->returnValue($lock)); + ->with(self::equalTo($key)) + ->will(self::returnValue($lock)); $this->em->getUnitOfWork()->registerManaged($entity, ['id' => 1], ['id' => 1, 'name' => 'Foo']); @@ -113,14 +113,14 @@ public function testDeleteTransactionRollBackShouldEvictItem(): void $collection = $this->createCollection($entity); $key = new CollectionCacheKey(State::class, 'cities', ['id' => 1]); - $this->region->expects($this->once()) + $this->region->expects(self::once()) ->method('lock') - ->with($this->equalTo($key)) - ->will($this->returnValue($lock)); + ->with(self::equalTo($key)) + ->will(self::returnValue($lock)); - $this->region->expects($this->once()) + $this->region->expects(self::once()) ->method('evict') - ->with($this->equalTo($key)); + ->with(self::equalTo($key)); $this->em->getUnitOfWork()->registerManaged($entity, ['id' => 1], ['id' => 1, 'name' => 'Foo']); @@ -139,24 +139,24 @@ public function testTransactionRollBackDeleteShouldClearQueue(): void $property->setAccessible(true); - $this->region->expects($this->once()) + $this->region->expects(self::once()) ->method('lock') - ->with($this->equalTo($key)) - ->will($this->returnValue($lock)); + ->with(self::equalTo($key)) + ->will(self::returnValue($lock)); - $this->region->expects($this->once()) + $this->region->expects(self::once()) ->method('evict') - ->with($this->equalTo($key)); + ->with(self::equalTo($key)); $this->em->getUnitOfWork()->registerManaged($entity, ['id' => 1], ['id' => 1, 'name' => 'Foo']); $persister->delete($collection); - $this->assertCount(1, $property->getValue($persister)); + self::assertCount(1, $property->getValue($persister)); $persister->afterTransactionRolledBack(); - $this->assertCount(0, $property->getValue($persister)); + self::assertCount(0, $property->getValue($persister)); } public function testTransactionRollBackUpdateShouldClearQueue(): void @@ -170,24 +170,24 @@ public function testTransactionRollBackUpdateShouldClearQueue(): void $property->setAccessible(true); - $this->region->expects($this->once()) + $this->region->expects(self::once()) ->method('lock') - ->with($this->equalTo($key)) - ->will($this->returnValue($lock)); + ->with(self::equalTo($key)) + ->will(self::returnValue($lock)); - $this->region->expects($this->once()) + $this->region->expects(self::once()) ->method('evict') - ->with($this->equalTo($key)); + ->with(self::equalTo($key)); $this->em->getUnitOfWork()->registerManaged($entity, ['id' => 1], ['id' => 1, 'name' => 'Foo']); $persister->update($collection); - $this->assertCount(1, $property->getValue($persister)); + self::assertCount(1, $property->getValue($persister)); $persister->afterTransactionRolledBack(); - $this->assertCount(0, $property->getValue($persister)); + self::assertCount(0, $property->getValue($persister)); } public function testTransactionRollCommitDeleteShouldClearQueue(): void @@ -201,24 +201,24 @@ public function testTransactionRollCommitDeleteShouldClearQueue(): void $property->setAccessible(true); - $this->region->expects($this->once()) + $this->region->expects(self::once()) ->method('lock') - ->with($this->equalTo($key)) - ->will($this->returnValue($lock)); + ->with(self::equalTo($key)) + ->will(self::returnValue($lock)); - $this->region->expects($this->once()) + $this->region->expects(self::once()) ->method('evict') - ->with($this->equalTo($key)); + ->with(self::equalTo($key)); $this->em->getUnitOfWork()->registerManaged($entity, ['id' => 1], ['id' => 1, 'name' => 'Foo']); $persister->delete($collection); - $this->assertCount(1, $property->getValue($persister)); + self::assertCount(1, $property->getValue($persister)); $persister->afterTransactionComplete(); - $this->assertCount(0, $property->getValue($persister)); + self::assertCount(0, $property->getValue($persister)); } public function testTransactionRollCommitUpdateShouldClearQueue(): void @@ -232,24 +232,24 @@ public function testTransactionRollCommitUpdateShouldClearQueue(): void $property->setAccessible(true); - $this->region->expects($this->once()) + $this->region->expects(self::once()) ->method('lock') - ->with($this->equalTo($key)) - ->will($this->returnValue($lock)); + ->with(self::equalTo($key)) + ->will(self::returnValue($lock)); - $this->region->expects($this->once()) + $this->region->expects(self::once()) ->method('evict') - ->with($this->equalTo($key)); + ->with(self::equalTo($key)); $this->em->getUnitOfWork()->registerManaged($entity, ['id' => 1], ['id' => 1, 'name' => 'Foo']); $persister->update($collection); - $this->assertCount(1, $property->getValue($persister)); + self::assertCount(1, $property->getValue($persister)); $persister->afterTransactionComplete(); - $this->assertCount(0, $property->getValue($persister)); + self::assertCount(0, $property->getValue($persister)); } public function testDeleteLockFailureShouldIgnoreQueue(): void @@ -262,19 +262,19 @@ public function testDeleteLockFailureShouldIgnoreQueue(): void $property->setAccessible(true); - $this->region->expects($this->once()) + $this->region->expects(self::once()) ->method('lock') - ->with($this->equalTo($key)) - ->will($this->returnValue(null)); + ->with(self::equalTo($key)) + ->will(self::returnValue(null)); - $this->collectionPersister->expects($this->once()) + $this->collectionPersister->expects(self::once()) ->method('delete') - ->with($this->equalTo($collection)); + ->with(self::equalTo($collection)); $this->em->getUnitOfWork()->registerManaged($entity, ['id' => 1], ['id' => 1, 'name' => 'Foo']); $persister->delete($collection); - $this->assertCount(0, $property->getValue($persister)); + self::assertCount(0, $property->getValue($persister)); } public function testUpdateLockFailureShouldIgnoreQueue(): void @@ -287,18 +287,18 @@ public function testUpdateLockFailureShouldIgnoreQueue(): void $property->setAccessible(true); - $this->region->expects($this->once()) + $this->region->expects(self::once()) ->method('lock') - ->with($this->equalTo($key)) - ->will($this->returnValue(null)); + ->with(self::equalTo($key)) + ->will(self::returnValue(null)); - $this->collectionPersister->expects($this->once()) + $this->collectionPersister->expects(self::once()) ->method('update') - ->with($this->equalTo($collection)); + ->with(self::equalTo($collection)); $this->em->getUnitOfWork()->registerManaged($entity, ['id' => 1], ['id' => 1, 'name' => 'Foo']); $persister->update($collection); - $this->assertCount(0, $property->getValue($persister)); + self::assertCount(0, $property->getValue($persister)); } } diff --git a/tests/Doctrine/Tests/ORM/Cache/Persister/Entity/AbstractEntityPersisterTest.php b/tests/Doctrine/Tests/ORM/Cache/Persister/Entity/AbstractEntityPersisterTest.php index f6069ab9f4d..44c20d30489 100644 --- a/tests/Doctrine/Tests/ORM/Cache/Persister/Entity/AbstractEntityPersisterTest.php +++ b/tests/Doctrine/Tests/ORM/Cache/Persister/Entity/AbstractEntityPersisterTest.php @@ -59,9 +59,9 @@ public function testImplementsEntityPersister(): void { $persister = $this->createPersisterDefault(); - $this->assertInstanceOf(EntityPersister::class, $persister); - $this->assertInstanceOf(CachedPersister::class, $persister); - $this->assertInstanceOf(CachedEntityPersister::class, $persister); + self::assertInstanceOf(EntityPersister::class, $persister); + self::assertInstanceOf(CachedPersister::class, $persister); + self::assertInstanceOf(CachedEntityPersister::class, $persister); } public function testInvokeAddInsert(): void @@ -69,11 +69,11 @@ public function testInvokeAddInsert(): void $persister = $this->createPersisterDefault(); $entity = new Country('Foo'); - $this->entityPersister->expects($this->once()) + $this->entityPersister->expects(self::once()) ->method('addInsert') - ->with($this->equalTo($entity)); + ->with(self::equalTo($entity)); - $this->assertNull($persister->addInsert($entity)); + self::assertNull($persister->addInsert($entity)); } public function testInvokeGetInserts(): void @@ -81,25 +81,25 @@ public function testInvokeGetInserts(): void $persister = $this->createPersisterDefault(); $entity = new Country('Foo'); - $this->entityPersister->expects($this->once()) + $this->entityPersister->expects(self::once()) ->method('getInserts') - ->will($this->returnValue([$entity])); + ->will(self::returnValue([$entity])); - $this->assertEquals([$entity], $persister->getInserts()); + self::assertEquals([$entity], $persister->getInserts()); } public function testInvokeGetSelectSQL(): void { $persister = $this->createPersisterDefault(); - $this->entityPersister->expects($this->once()) + $this->entityPersister->expects(self::once()) ->method('getSelectSQL') - ->with($this->equalTo(['name' => 'Foo']), $this->equalTo([0]), $this->equalTo(1), $this->equalTo(2), $this->equalTo(3), $this->equalTo( + ->with(self::equalTo(['name' => 'Foo']), self::equalTo([0]), self::equalTo(1), self::equalTo(2), self::equalTo(3), self::equalTo( [4] )) - ->will($this->returnValue('SELECT * FROM foo WERE name = ?')); + ->will(self::returnValue('SELECT * FROM foo WERE name = ?')); - $this->assertEquals('SELECT * FROM foo WERE name = ?', $persister->getSelectSQL( + self::assertEquals('SELECT * FROM foo WERE name = ?', $persister->getSelectSQL( ['name' => 'Foo'], [0], 1, @@ -113,23 +113,23 @@ public function testInvokeGetInsertSQL(): void { $persister = $this->createPersisterDefault(); - $this->entityPersister->expects($this->once()) + $this->entityPersister->expects(self::once()) ->method('getInsertSQL') - ->will($this->returnValue('INSERT INTO foo (?)')); + ->will(self::returnValue('INSERT INTO foo (?)')); - $this->assertEquals('INSERT INTO foo (?)', $persister->getInsertSQL()); + self::assertEquals('INSERT INTO foo (?)', $persister->getInsertSQL()); } public function testInvokeExpandParameters(): void { $persister = $this->createPersisterDefault(); - $this->entityPersister->expects($this->once()) + $this->entityPersister->expects(self::once()) ->method('expandParameters') - ->with($this->equalTo(['name' => 'Foo'])) - ->will($this->returnValue(['name' => 'Foo'])); + ->with(self::equalTo(['name' => 'Foo'])) + ->will(self::returnValue(['name' => 'Foo'])); - $this->assertEquals(['name' => 'Foo'], $persister->expandParameters(['name' => 'Foo'])); + self::assertEquals(['name' => 'Foo'], $persister->expandParameters(['name' => 'Foo'])); } public function testInvokeExpandCriteriaParameters(): void @@ -137,35 +137,35 @@ public function testInvokeExpandCriteriaParameters(): void $persister = $this->createPersisterDefault(); $criteria = new Criteria(); - $this->entityPersister->expects($this->once()) + $this->entityPersister->expects(self::once()) ->method('expandCriteriaParameters') - ->with($this->equalTo($criteria)) - ->will($this->returnValue(['name' => 'Foo'])); + ->with(self::equalTo($criteria)) + ->will(self::returnValue(['name' => 'Foo'])); - $this->assertEquals(['name' => 'Foo'], $persister->expandCriteriaParameters($criteria)); + self::assertEquals(['name' => 'Foo'], $persister->expandCriteriaParameters($criteria)); } public function testInvokeSelectConditionStatementSQL(): void { $persister = $this->createPersisterDefault(); - $this->entityPersister->expects($this->once()) + $this->entityPersister->expects(self::once()) ->method('getSelectConditionStatementSQL') - ->with($this->equalTo('id'), $this->equalTo(1), $this->equalTo([]), $this->equalTo('=')) - ->will($this->returnValue('name = 1')); + ->with(self::equalTo('id'), self::equalTo(1), self::equalTo([]), self::equalTo('=')) + ->will(self::returnValue('name = 1')); - $this->assertEquals('name = 1', $persister->getSelectConditionStatementSQL('id', 1, [], '=')); + self::assertEquals('name = 1', $persister->getSelectConditionStatementSQL('id', 1, [], '=')); } public function testInvokeExecuteInserts(): void { $persister = $this->createPersisterDefault(); - $this->entityPersister->expects($this->once()) + $this->entityPersister->expects(self::once()) ->method('executeInserts') - ->will($this->returnValue(['id' => 1])); + ->will(self::returnValue(['id' => 1])); - $this->assertEquals(['id' => 1], $persister->executeInserts()); + self::assertEquals(['id' => 1], $persister->executeInserts()); } public function testInvokeUpdate(): void @@ -173,13 +173,13 @@ public function testInvokeUpdate(): void $persister = $this->createPersisterDefault(); $entity = new Country('Foo'); - $this->entityPersister->expects($this->once()) + $this->entityPersister->expects(self::once()) ->method('update') - ->with($this->equalTo($entity)); + ->with(self::equalTo($entity)); $this->em->getUnitOfWork()->registerManaged($entity, ['id' => 1], ['id' => 1, 'name' => 'Foo']); - $this->assertNull($persister->update($entity)); + self::assertNull($persister->update($entity)); } public function testInvokeDelete(): void @@ -187,25 +187,25 @@ public function testInvokeDelete(): void $persister = $this->createPersisterDefault(); $entity = new Country('Foo'); - $this->entityPersister->expects($this->once()) + $this->entityPersister->expects(self::once()) ->method('delete') - ->with($this->equalTo($entity)); + ->with(self::equalTo($entity)); $this->em->getUnitOfWork()->registerManaged($entity, ['id' => 1], ['id' => 1, 'name' => 'Foo']); - $this->assertNull($persister->delete($entity)); + self::assertNull($persister->delete($entity)); } public function testInvokeGetOwningTable(): void { $persister = $this->createPersisterDefault(); - $this->entityPersister->expects($this->once()) + $this->entityPersister->expects(self::once()) ->method('getOwningTable') - ->with($this->equalTo('name')) - ->will($this->returnValue('t')); + ->with(self::equalTo('name')) + ->will(self::returnValue('t')); - $this->assertEquals('t', $persister->getOwningTable('name')); + self::assertEquals('t', $persister->getOwningTable('name')); } public function testInvokeLoad(): void @@ -213,16 +213,16 @@ public function testInvokeLoad(): void $persister = $this->createPersisterDefault(); $entity = new Country('Foo'); - $this->entityPersister->expects($this->once()) + $this->entityPersister->expects(self::once()) ->method('load') - ->with($this->equalTo(['id' => 1]), $this->equalTo($entity), $this->equalTo([0]), $this->equalTo( + ->with(self::equalTo(['id' => 1]), self::equalTo($entity), self::equalTo([0]), self::equalTo( [1] - ), $this->equalTo(2), $this->equalTo(3), $this->equalTo( + ), self::equalTo(2), self::equalTo(3), self::equalTo( [4] )) - ->will($this->returnValue($entity)); + ->will(self::returnValue($entity)); - $this->assertEquals($entity, $persister->load(['id' => 1], $entity, [0], [1], 2, 3, [4])); + self::assertEquals($entity, $persister->load(['id' => 1], $entity, [0], [1], 2, 3, [4])); } public function testInvokeLoadAll(): void @@ -235,16 +235,16 @@ public function testInvokeLoadAll(): void $this->em->getUnitOfWork()->registerManaged($entity, ['id' => 1], ['id' => 1, 'name' => 'Foo']); - $this->entityPersister->expects($this->once()) + $this->entityPersister->expects(self::once()) ->method('loadAll') - ->with($this->equalTo(['id' => 1]), $this->equalTo([0]), $this->equalTo(1), $this->equalTo(2)) - ->will($this->returnValue([$entity])); + ->with(self::equalTo(['id' => 1]), self::equalTo([0]), self::equalTo(1), self::equalTo(2)) + ->will(self::returnValue([$entity])); - $this->entityPersister->expects($this->once()) + $this->entityPersister->expects(self::once()) ->method('getResultSetMapping') - ->will($this->returnValue($rsm)); + ->will(self::returnValue($rsm)); - $this->assertEquals([$entity], $persister->loadAll(['id' => 1], [0], 1, 2)); + self::assertEquals([$entity], $persister->loadAll(['id' => 1], [0], 1, 2)); } public function testInvokeLoadById(): void @@ -252,12 +252,12 @@ public function testInvokeLoadById(): void $persister = $this->createPersisterDefault(); $entity = new Country('Foo'); - $this->entityPersister->expects($this->once()) + $this->entityPersister->expects(self::once()) ->method('loadById') - ->with($this->equalTo(['id' => 1]), $this->equalTo($entity)) - ->will($this->returnValue($entity)); + ->with(self::equalTo(['id' => 1]), self::equalTo($entity)) + ->will(self::returnValue($entity)); - $this->assertEquals($entity, $persister->loadById(['id' => 1], $entity)); + self::assertEquals($entity, $persister->loadById(['id' => 1], $entity)); } public function testInvokeLoadOneToOneEntity(): void @@ -265,12 +265,12 @@ public function testInvokeLoadOneToOneEntity(): void $persister = $this->createPersisterDefault(); $entity = new Country('Foo'); - $this->entityPersister->expects($this->once()) + $this->entityPersister->expects(self::once()) ->method('loadOneToOneEntity') - ->with($this->equalTo([]), $this->equalTo('foo'), $this->equalTo(['id' => 11])) - ->will($this->returnValue($entity)); + ->with(self::equalTo([]), self::equalTo('foo'), self::equalTo(['id' => 11])) + ->will(self::returnValue($entity)); - $this->assertEquals($entity, $persister->loadOneToOneEntity([], 'foo', ['id' => 11])); + self::assertEquals($entity, $persister->loadOneToOneEntity([], 'foo', ['id' => 11])); } public function testInvokeRefresh(): void @@ -278,12 +278,12 @@ public function testInvokeRefresh(): void $persister = $this->createPersisterDefault(); $entity = new Country('Foo'); - $this->entityPersister->expects($this->once()) + $this->entityPersister->expects(self::once()) ->method('refresh') - ->with($this->equalTo(['id' => 1]), $this->equalTo($entity), $this->equalTo(0)) - ->will($this->returnValue($entity)); + ->with(self::equalTo(['id' => 1]), self::equalTo($entity), self::equalTo(0)) + ->will(self::returnValue($entity)); - $this->assertNull($persister->refresh(['id' => 1], $entity)); + self::assertNull($persister->refresh(['id' => 1], $entity)); } public function testInvokeLoadCriteria(): void @@ -296,16 +296,16 @@ public function testInvokeLoadCriteria(): void $this->em->getUnitOfWork()->registerManaged($entity, ['id' => 1], ['id' => 1, 'name' => 'Foo']); $rsm->addEntityResult(Country::class, 'c'); - $this->entityPersister->expects($this->once()) + $this->entityPersister->expects(self::once()) ->method('getResultSetMapping') - ->will($this->returnValue($rsm)); + ->will(self::returnValue($rsm)); - $this->entityPersister->expects($this->once()) + $this->entityPersister->expects(self::once()) ->method('loadCriteria') - ->with($this->equalTo($criteria)) - ->will($this->returnValue([$entity])); + ->with(self::equalTo($criteria)) + ->will(self::returnValue([$entity])); - $this->assertEquals([$entity], $persister->loadCriteria($criteria)); + self::assertEquals([$entity], $persister->loadCriteria($criteria)); } public function testInvokeGetManyToManyCollection(): void @@ -313,12 +313,12 @@ public function testInvokeGetManyToManyCollection(): void $persister = $this->createPersisterDefault(); $entity = new Country('Foo'); - $this->entityPersister->expects($this->once()) + $this->entityPersister->expects(self::once()) ->method('getManyToManyCollection') - ->with($this->equalTo([]), $this->equalTo('Foo'), $this->equalTo(1), $this->equalTo(2)) - ->will($this->returnValue([$entity])); + ->with(self::equalTo([]), self::equalTo('Foo'), self::equalTo(1), self::equalTo(2)) + ->will(self::returnValue([$entity])); - $this->assertEquals([$entity], $persister->getManyToManyCollection([], 'Foo', 1, 2)); + self::assertEquals([$entity], $persister->getManyToManyCollection([], 'Foo', 1, 2)); } public function testInvokeGetOneToManyCollection(): void @@ -326,12 +326,12 @@ public function testInvokeGetOneToManyCollection(): void $persister = $this->createPersisterDefault(); $entity = new Country('Foo'); - $this->entityPersister->expects($this->once()) + $this->entityPersister->expects(self::once()) ->method('getOneToManyCollection') - ->with($this->equalTo([]), $this->equalTo('Foo'), $this->equalTo(1), $this->equalTo(2)) - ->will($this->returnValue([$entity])); + ->with(self::equalTo([]), self::equalTo('Foo'), self::equalTo(1), self::equalTo(2)) + ->will(self::returnValue([$entity])); - $this->assertEquals([$entity], $persister->getOneToManyCollection([], 'Foo', 1, 2)); + self::assertEquals([$entity], $persister->getOneToManyCollection([], 'Foo', 1, 2)); } public function testInvokeLoadManyToManyCollection(): void @@ -342,12 +342,12 @@ public function testInvokeLoadManyToManyCollection(): void $persister = $this->createPersisterDefault(); $entity = new Country('Foo'); - $this->entityPersister->expects($this->once()) + $this->entityPersister->expects(self::once()) ->method('loadManyToManyCollection') - ->with($this->equalTo($assoc), $this->equalTo('Foo'), $coll) - ->will($this->returnValue([$entity])); + ->with(self::equalTo($assoc), self::equalTo('Foo'), $coll) + ->will(self::returnValue([$entity])); - $this->assertEquals([$entity], $persister->loadManyToManyCollection($assoc, 'Foo', $coll)); + self::assertEquals([$entity], $persister->loadManyToManyCollection($assoc, 'Foo', $coll)); } public function testInvokeLoadOneToManyCollection(): void @@ -358,12 +358,12 @@ public function testInvokeLoadOneToManyCollection(): void $persister = $this->createPersisterDefault(); $entity = new Country('Foo'); - $this->entityPersister->expects($this->once()) + $this->entityPersister->expects(self::once()) ->method('loadOneToManyCollection') - ->with($this->equalTo($assoc), $this->equalTo('Foo'), $coll) - ->will($this->returnValue([$entity])); + ->with(self::equalTo($assoc), self::equalTo('Foo'), $coll) + ->will(self::returnValue([$entity])); - $this->assertEquals([$entity], $persister->loadOneToManyCollection($assoc, 'Foo', $coll)); + self::assertEquals([$entity], $persister->loadOneToManyCollection($assoc, 'Foo', $coll)); } public function testInvokeLock(): void @@ -371,11 +371,11 @@ public function testInvokeLock(): void $identifier = ['id' => 1]; $persister = $this->createPersisterDefault(); - $this->entityPersister->expects($this->once()) + $this->entityPersister->expects(self::once()) ->method('lock') - ->with($this->equalTo($identifier), $this->equalTo(1)); + ->with(self::equalTo($identifier), self::equalTo(1)); - $this->assertNull($persister->lock($identifier, 1)); + self::assertNull($persister->lock($identifier, 1)); } public function testInvokeExists(): void @@ -383,10 +383,10 @@ public function testInvokeExists(): void $entity = new Country('Foo'); $persister = $this->createPersisterDefault(); - $this->entityPersister->expects($this->once()) + $this->entityPersister->expects(self::once()) ->method('exists') - ->with($this->equalTo($entity), $this->equalTo(null)); + ->with(self::equalTo($entity), self::equalTo(null)); - $this->assertNull($persister->exists($entity)); + self::assertNull($persister->exists($entity)); } } diff --git a/tests/Doctrine/Tests/ORM/Cache/Persister/Entity/NonStrictReadWriteCachedEntityPersisterTest.php b/tests/Doctrine/Tests/ORM/Cache/Persister/Entity/NonStrictReadWriteCachedEntityPersisterTest.php index 4dc5c7c0e6f..24ae0390abe 100644 --- a/tests/Doctrine/Tests/ORM/Cache/Persister/Entity/NonStrictReadWriteCachedEntityPersisterTest.php +++ b/tests/Doctrine/Tests/ORM/Cache/Persister/Entity/NonStrictReadWriteCachedEntityPersisterTest.php @@ -38,11 +38,11 @@ public function testTransactionRollBackShouldClearQueue(): void $persister->update($entity); $persister->delete($entity); - $this->assertCount(2, $property->getValue($persister)); + self::assertCount(2, $property->getValue($persister)); $persister->afterTransactionRolledBack(); - $this->assertCount(0, $property->getValue($persister)); + self::assertCount(0, $property->getValue($persister)); } public function testInsertTransactionCommitShouldPutCache(): void @@ -55,19 +55,19 @@ public function testInsertTransactionCommitShouldPutCache(): void $property->setAccessible(true); - $this->region->expects($this->once()) + $this->region->expects(self::once()) ->method('put') - ->with($this->equalTo($key), $this->equalTo($entry)); + ->with(self::equalTo($key), self::equalTo($entry)); - $this->entityPersister->expects($this->once()) + $this->entityPersister->expects(self::once()) ->method('addInsert') - ->with($this->equalTo($entity)); + ->with(self::equalTo($entity)); - $this->entityPersister->expects($this->once()) + $this->entityPersister->expects(self::once()) ->method('getInserts') - ->will($this->returnValue([$entity])); + ->will(self::returnValue([$entity])); - $this->entityPersister->expects($this->once()) + $this->entityPersister->expects(self::once()) ->method('executeInserts'); $this->em->getUnitOfWork()->registerManaged($entity, ['id' => 1], ['id' => 1, 'name' => 'Foo']); @@ -75,11 +75,11 @@ public function testInsertTransactionCommitShouldPutCache(): void $persister->addInsert($entity); $persister->executeInserts(); - $this->assertCount(1, $property->getValue($persister)); + self::assertCount(1, $property->getValue($persister)); $persister->afterTransactionComplete(); - $this->assertCount(0, $property->getValue($persister)); + self::assertCount(0, $property->getValue($persister)); } public function testUpdateTransactionCommitShouldPutCache(): void @@ -92,23 +92,23 @@ public function testUpdateTransactionCommitShouldPutCache(): void $property->setAccessible(true); - $this->region->expects($this->once()) + $this->region->expects(self::once()) ->method('put') - ->with($this->equalTo($key), $this->equalTo($entry)); + ->with(self::equalTo($key), self::equalTo($entry)); - $this->entityPersister->expects($this->once()) + $this->entityPersister->expects(self::once()) ->method('update') - ->with($this->equalTo($entity)); + ->with(self::equalTo($entity)); $this->em->getUnitOfWork()->registerManaged($entity, ['id' => 1], ['id' => 1, 'name' => 'Foo']); $persister->update($entity); - $this->assertCount(1, $property->getValue($persister)); + self::assertCount(1, $property->getValue($persister)); $persister->afterTransactionComplete(); - $this->assertCount(0, $property->getValue($persister)); + self::assertCount(0, $property->getValue($persister)); } public function testDeleteTransactionCommitShouldEvictCache(): void @@ -120,22 +120,22 @@ public function testDeleteTransactionCommitShouldEvictCache(): void $property->setAccessible(true); - $this->region->expects($this->once()) + $this->region->expects(self::once()) ->method('evict') - ->with($this->equalTo($key)); + ->with(self::equalTo($key)); - $this->entityPersister->expects($this->once()) + $this->entityPersister->expects(self::once()) ->method('delete') - ->with($this->equalTo($entity)); + ->with(self::equalTo($entity)); $this->em->getUnitOfWork()->registerManaged($entity, ['id' => 1], ['id' => 1, 'name' => 'Foo']); $persister->delete($entity); - $this->assertCount(1, $property->getValue($persister)); + self::assertCount(1, $property->getValue($persister)); $persister->afterTransactionComplete(); - $this->assertCount(0, $property->getValue($persister)); + self::assertCount(0, $property->getValue($persister)); } } diff --git a/tests/Doctrine/Tests/ORM/Cache/Persister/Entity/ReadWriteCachedEntityPersisterTest.php b/tests/Doctrine/Tests/ORM/Cache/Persister/Entity/ReadWriteCachedEntityPersisterTest.php index 3cb28c5604f..34c0f273665 100644 --- a/tests/Doctrine/Tests/ORM/Cache/Persister/Entity/ReadWriteCachedEntityPersisterTest.php +++ b/tests/Doctrine/Tests/ORM/Cache/Persister/Entity/ReadWriteCachedEntityPersisterTest.php @@ -38,10 +38,10 @@ public function testDeleteShouldLockItem(): void $persister = $this->createPersisterDefault(); $key = new EntityCacheKey(Country::class, ['id' => 1]); - $this->region->expects($this->once()) + $this->region->expects(self::once()) ->method('lock') - ->with($this->equalTo($key)) - ->will($this->returnValue($lock)); + ->with(self::equalTo($key)) + ->will(self::returnValue($lock)); $this->em->getUnitOfWork()->registerManaged($entity, ['id' => 1], ['id' => 1, 'name' => 'Foo']); @@ -55,10 +55,10 @@ public function testUpdateShouldLockItem(): void $persister = $this->createPersisterDefault(); $key = new EntityCacheKey(Country::class, ['id' => 1]); - $this->region->expects($this->once()) + $this->region->expects(self::once()) ->method('lock') - ->with($this->equalTo($key)) - ->will($this->returnValue($lock)); + ->with(self::equalTo($key)) + ->will(self::returnValue($lock)); $this->em->getUnitOfWork()->registerManaged($entity, ['id' => 1], ['id' => 1, 'name' => 'Foo']); @@ -72,15 +72,15 @@ public function testUpdateTransactionRollBackShouldEvictItem(): void $persister = $this->createPersisterDefault(); $key = new EntityCacheKey(Country::class, ['id' => 1]); - $this->region->expects($this->once()) + $this->region->expects(self::once()) ->method('lock') - ->with($this->equalTo($key)) - ->will($this->returnValue($lock)); + ->with(self::equalTo($key)) + ->will(self::returnValue($lock)); - $this->region->expects($this->once()) + $this->region->expects(self::once()) ->method('evict') - ->with($this->equalTo($key)) - ->will($this->returnValue($lock)); + ->with(self::equalTo($key)) + ->will(self::returnValue($lock)); $this->em->getUnitOfWork()->registerManaged($entity, ['id' => 1], ['id' => 1, 'name' => 'Foo']); @@ -95,14 +95,14 @@ public function testDeleteTransactionRollBackShouldEvictItem(): void $persister = $this->createPersisterDefault(); $key = new EntityCacheKey(Country::class, ['id' => 1]); - $this->region->expects($this->once()) + $this->region->expects(self::once()) ->method('lock') - ->with($this->equalTo($key)) - ->will($this->returnValue($lock)); + ->with(self::equalTo($key)) + ->will(self::returnValue($lock)); - $this->region->expects($this->once()) + $this->region->expects(self::once()) ->method('evict') - ->with($this->equalTo($key)); + ->with(self::equalTo($key)); $this->em->getUnitOfWork()->registerManaged($entity, ['id' => 1], ['id' => 1, 'name' => 'Foo']); @@ -120,25 +120,25 @@ public function testTransactionRollBackShouldClearQueue(): void $property->setAccessible(true); - $this->region->expects($this->exactly(2)) + $this->region->expects(self::exactly(2)) ->method('lock') - ->with($this->equalTo($key)) - ->will($this->returnValue($lock)); + ->with(self::equalTo($key)) + ->will(self::returnValue($lock)); - $this->region->expects($this->exactly(2)) + $this->region->expects(self::exactly(2)) ->method('evict') - ->with($this->equalTo($key)); + ->with(self::equalTo($key)); $this->em->getUnitOfWork()->registerManaged($entity, ['id' => 1], ['id' => 1, 'name' => 'Foo']); $persister->update($entity); $persister->delete($entity); - $this->assertCount(2, $property->getValue($persister)); + self::assertCount(2, $property->getValue($persister)); $persister->afterTransactionRolledBack(); - $this->assertCount(0, $property->getValue($persister)); + self::assertCount(0, $property->getValue($persister)); } public function testTransactionCommitShouldClearQueue(): void @@ -151,25 +151,25 @@ public function testTransactionCommitShouldClearQueue(): void $property->setAccessible(true); - $this->region->expects($this->exactly(2)) + $this->region->expects(self::exactly(2)) ->method('lock') - ->with($this->equalTo($key)) - ->will($this->returnValue($lock)); + ->with(self::equalTo($key)) + ->will(self::returnValue($lock)); - $this->region->expects($this->exactly(2)) + $this->region->expects(self::exactly(2)) ->method('evict') - ->with($this->equalTo($key)); + ->with(self::equalTo($key)); $this->em->getUnitOfWork()->registerManaged($entity, ['id' => 1], ['id' => 1, 'name' => 'Foo']); $persister->update($entity); $persister->delete($entity); - $this->assertCount(2, $property->getValue($persister)); + self::assertCount(2, $property->getValue($persister)); $persister->afterTransactionComplete(); - $this->assertCount(0, $property->getValue($persister)); + self::assertCount(0, $property->getValue($persister)); } public function testDeleteLockFailureShouldIgnoreQueue(): void @@ -181,19 +181,19 @@ public function testDeleteLockFailureShouldIgnoreQueue(): void $property->setAccessible(true); - $this->region->expects($this->once()) + $this->region->expects(self::once()) ->method('lock') - ->with($this->equalTo($key)) - ->will($this->returnValue(null)); + ->with(self::equalTo($key)) + ->will(self::returnValue(null)); - $this->entityPersister->expects($this->once()) + $this->entityPersister->expects(self::once()) ->method('delete') - ->with($this->equalTo($entity)); + ->with(self::equalTo($entity)); $this->em->getUnitOfWork()->registerManaged($entity, ['id' => 1], ['id' => 1, 'name' => 'Foo']); $persister->delete($entity); - $this->assertCount(0, $property->getValue($persister)); + self::assertCount(0, $property->getValue($persister)); } public function testUpdateLockFailureShouldIgnoreQueue(): void @@ -205,18 +205,18 @@ public function testUpdateLockFailureShouldIgnoreQueue(): void $property->setAccessible(true); - $this->region->expects($this->once()) + $this->region->expects(self::once()) ->method('lock') - ->with($this->equalTo($key)) - ->will($this->returnValue(null)); + ->with(self::equalTo($key)) + ->will(self::returnValue(null)); - $this->entityPersister->expects($this->once()) + $this->entityPersister->expects(self::once()) ->method('update') - ->with($this->equalTo($entity)); + ->with(self::equalTo($entity)); $this->em->getUnitOfWork()->registerManaged($entity, ['id' => 1], ['id' => 1, 'name' => 'Foo']); $persister->update($entity); - $this->assertCount(0, $property->getValue($persister)); + self::assertCount(0, $property->getValue($persister)); } } diff --git a/tests/Doctrine/Tests/ORM/Cache/StatisticsCacheLoggerTest.php b/tests/Doctrine/Tests/ORM/Cache/StatisticsCacheLoggerTest.php index cfa8a3b4010..8d89a4ad3ee 100644 --- a/tests/Doctrine/Tests/ORM/Cache/StatisticsCacheLoggerTest.php +++ b/tests/Doctrine/Tests/ORM/Cache/StatisticsCacheLoggerTest.php @@ -35,12 +35,12 @@ public function testEntityCache(): void $this->logger->entityCachePut($name, $key); $this->logger->entityCacheMiss($name, $key); - $this->assertEquals(1, $this->logger->getHitCount()); - $this->assertEquals(1, $this->logger->getPutCount()); - $this->assertEquals(1, $this->logger->getMissCount()); - $this->assertEquals(1, $this->logger->getRegionHitCount($name)); - $this->assertEquals(1, $this->logger->getRegionPutCount($name)); - $this->assertEquals(1, $this->logger->getRegionMissCount($name)); + self::assertEquals(1, $this->logger->getHitCount()); + self::assertEquals(1, $this->logger->getPutCount()); + self::assertEquals(1, $this->logger->getMissCount()); + self::assertEquals(1, $this->logger->getRegionHitCount($name)); + self::assertEquals(1, $this->logger->getRegionPutCount($name)); + self::assertEquals(1, $this->logger->getRegionMissCount($name)); } public function testCollectionCache(): void @@ -52,12 +52,12 @@ public function testCollectionCache(): void $this->logger->collectionCachePut($name, $key); $this->logger->collectionCacheMiss($name, $key); - $this->assertEquals(1, $this->logger->getHitCount()); - $this->assertEquals(1, $this->logger->getPutCount()); - $this->assertEquals(1, $this->logger->getMissCount()); - $this->assertEquals(1, $this->logger->getRegionHitCount($name)); - $this->assertEquals(1, $this->logger->getRegionPutCount($name)); - $this->assertEquals(1, $this->logger->getRegionMissCount($name)); + self::assertEquals(1, $this->logger->getHitCount()); + self::assertEquals(1, $this->logger->getPutCount()); + self::assertEquals(1, $this->logger->getMissCount()); + self::assertEquals(1, $this->logger->getRegionHitCount($name)); + self::assertEquals(1, $this->logger->getRegionPutCount($name)); + self::assertEquals(1, $this->logger->getRegionMissCount($name)); } public function testQueryCache(): void @@ -69,12 +69,12 @@ public function testQueryCache(): void $this->logger->queryCachePut($name, $key); $this->logger->queryCacheMiss($name, $key); - $this->assertEquals(1, $this->logger->getHitCount()); - $this->assertEquals(1, $this->logger->getPutCount()); - $this->assertEquals(1, $this->logger->getMissCount()); - $this->assertEquals(1, $this->logger->getRegionHitCount($name)); - $this->assertEquals(1, $this->logger->getRegionPutCount($name)); - $this->assertEquals(1, $this->logger->getRegionMissCount($name)); + self::assertEquals(1, $this->logger->getHitCount()); + self::assertEquals(1, $this->logger->getPutCount()); + self::assertEquals(1, $this->logger->getMissCount()); + self::assertEquals(1, $this->logger->getRegionHitCount($name)); + self::assertEquals(1, $this->logger->getRegionPutCount($name)); + self::assertEquals(1, $this->logger->getRegionMissCount($name)); } public function testMultipleCaches(): void @@ -99,36 +99,36 @@ public function testMultipleCaches(): void $this->logger->collectionCachePut($coolRegion, $coolKey); $this->logger->collectionCacheMiss($coolRegion, $coolKey); - $this->assertEquals(3, $this->logger->getHitCount()); - $this->assertEquals(3, $this->logger->getPutCount()); - $this->assertEquals(3, $this->logger->getMissCount()); + self::assertEquals(3, $this->logger->getHitCount()); + self::assertEquals(3, $this->logger->getPutCount()); + self::assertEquals(3, $this->logger->getMissCount()); - $this->assertEquals(1, $this->logger->getRegionHitCount($queryRegion)); - $this->assertEquals(1, $this->logger->getRegionPutCount($queryRegion)); - $this->assertEquals(1, $this->logger->getRegionMissCount($queryRegion)); + self::assertEquals(1, $this->logger->getRegionHitCount($queryRegion)); + self::assertEquals(1, $this->logger->getRegionPutCount($queryRegion)); + self::assertEquals(1, $this->logger->getRegionMissCount($queryRegion)); - $this->assertEquals(1, $this->logger->getRegionHitCount($coolRegion)); - $this->assertEquals(1, $this->logger->getRegionPutCount($coolRegion)); - $this->assertEquals(1, $this->logger->getRegionMissCount($coolRegion)); + self::assertEquals(1, $this->logger->getRegionHitCount($coolRegion)); + self::assertEquals(1, $this->logger->getRegionPutCount($coolRegion)); + self::assertEquals(1, $this->logger->getRegionMissCount($coolRegion)); - $this->assertEquals(1, $this->logger->getRegionHitCount($entityRegion)); - $this->assertEquals(1, $this->logger->getRegionPutCount($entityRegion)); - $this->assertEquals(1, $this->logger->getRegionMissCount($entityRegion)); + self::assertEquals(1, $this->logger->getRegionHitCount($entityRegion)); + self::assertEquals(1, $this->logger->getRegionPutCount($entityRegion)); + self::assertEquals(1, $this->logger->getRegionMissCount($entityRegion)); $miss = $this->logger->getRegionsMiss(); $hit = $this->logger->getRegionsHit(); $put = $this->logger->getRegionsPut(); - $this->assertArrayHasKey($coolRegion, $miss); - $this->assertArrayHasKey($queryRegion, $miss); - $this->assertArrayHasKey($entityRegion, $miss); + self::assertArrayHasKey($coolRegion, $miss); + self::assertArrayHasKey($queryRegion, $miss); + self::assertArrayHasKey($entityRegion, $miss); - $this->assertArrayHasKey($coolRegion, $put); - $this->assertArrayHasKey($queryRegion, $put); - $this->assertArrayHasKey($entityRegion, $put); + self::assertArrayHasKey($coolRegion, $put); + self::assertArrayHasKey($queryRegion, $put); + self::assertArrayHasKey($entityRegion, $put); - $this->assertArrayHasKey($coolRegion, $hit); - $this->assertArrayHasKey($queryRegion, $hit); - $this->assertArrayHasKey($entityRegion, $hit); + self::assertArrayHasKey($coolRegion, $hit); + self::assertArrayHasKey($queryRegion, $hit); + self::assertArrayHasKey($entityRegion, $hit); } } diff --git a/tests/Doctrine/Tests/ORM/CommitOrderCalculatorTest.php b/tests/Doctrine/Tests/ORM/CommitOrderCalculatorTest.php index 605e3af93aa..a9d3004683a 100644 --- a/tests/Doctrine/Tests/ORM/CommitOrderCalculatorTest.php +++ b/tests/Doctrine/Tests/ORM/CommitOrderCalculatorTest.php @@ -49,7 +49,7 @@ public function testCommitOrdering1(): void // There is only 1 valid ordering for this constellation $correctOrder = [$class5, $class1, $class2, $class3, $class4]; - $this->assertSame($correctOrder, $sorted); + self::assertSame($correctOrder, $sorted); } public function testCommitOrdering2(): void @@ -68,7 +68,7 @@ public function testCommitOrdering2(): void // There is only 1 valid ordering for this constellation $correctOrder = [$class2, $class1]; - $this->assertSame($correctOrder, $sorted); + self::assertSame($correctOrder, $sorted); } public function testCommitOrdering3(): void @@ -101,7 +101,7 @@ public function testCommitOrdering3(): void ]; // We want to perform a strict comparison of the array - $this->assertContains($sorted, $correctOrders, '', false, true); + self::assertContains($sorted, $correctOrders, '', false, true); } } diff --git a/tests/Doctrine/Tests/ORM/ConfigurationTest.php b/tests/Doctrine/Tests/ORM/ConfigurationTest.php index 71bb203d7a1..666d0bfcb40 100644 --- a/tests/Doctrine/Tests/ORM/ConfigurationTest.php +++ b/tests/Doctrine/Tests/ORM/ConfigurationTest.php @@ -50,41 +50,41 @@ protected function setUp(): void public function testSetGetProxyDir(): void { - $this->assertSame(null, $this->configuration->getProxyDir()); // defaults + self::assertSame(null, $this->configuration->getProxyDir()); // defaults $this->configuration->setProxyDir(__DIR__); - $this->assertSame(__DIR__, $this->configuration->getProxyDir()); + self::assertSame(__DIR__, $this->configuration->getProxyDir()); } public function testSetGetAutoGenerateProxyClasses(): void { - $this->assertSame(AbstractProxyFactory::AUTOGENERATE_ALWAYS, $this->configuration->getAutoGenerateProxyClasses()); // defaults + self::assertSame(AbstractProxyFactory::AUTOGENERATE_ALWAYS, $this->configuration->getAutoGenerateProxyClasses()); // defaults $this->configuration->setAutoGenerateProxyClasses(false); - $this->assertSame(AbstractProxyFactory::AUTOGENERATE_NEVER, $this->configuration->getAutoGenerateProxyClasses()); + self::assertSame(AbstractProxyFactory::AUTOGENERATE_NEVER, $this->configuration->getAutoGenerateProxyClasses()); $this->configuration->setAutoGenerateProxyClasses(true); - $this->assertSame(AbstractProxyFactory::AUTOGENERATE_ALWAYS, $this->configuration->getAutoGenerateProxyClasses()); + self::assertSame(AbstractProxyFactory::AUTOGENERATE_ALWAYS, $this->configuration->getAutoGenerateProxyClasses()); $this->configuration->setAutoGenerateProxyClasses(AbstractProxyFactory::AUTOGENERATE_FILE_NOT_EXISTS); - $this->assertSame(AbstractProxyFactory::AUTOGENERATE_FILE_NOT_EXISTS, $this->configuration->getAutoGenerateProxyClasses()); + self::assertSame(AbstractProxyFactory::AUTOGENERATE_FILE_NOT_EXISTS, $this->configuration->getAutoGenerateProxyClasses()); } public function testSetGetProxyNamespace(): void { - $this->assertSame(null, $this->configuration->getProxyNamespace()); // defaults + self::assertSame(null, $this->configuration->getProxyNamespace()); // defaults $this->configuration->setProxyNamespace(__NAMESPACE__); - $this->assertSame(__NAMESPACE__, $this->configuration->getProxyNamespace()); + self::assertSame(__NAMESPACE__, $this->configuration->getProxyNamespace()); } public function testSetGetMetadataDriverImpl(): void { - $this->assertSame(null, $this->configuration->getMetadataDriverImpl()); // defaults + self::assertSame(null, $this->configuration->getMetadataDriverImpl()); // defaults $metadataDriver = $this->createMock(MappingDriver::class); $this->configuration->setMetadataDriverImpl($metadataDriver); - $this->assertSame($metadataDriver, $this->configuration->getMetadataDriverImpl()); + self::assertSame($metadataDriver, $this->configuration->getMetadataDriverImpl()); } public function testNewDefaultAnnotationDriver(): void @@ -98,7 +98,7 @@ public function testNewDefaultAnnotationDriver(): void $reflectionClass->getMethod('namespacedAnnotationMethod'), AnnotationNamespace\PrePersist::class ); - $this->assertInstanceOf(AnnotationNamespace\PrePersist::class, $annotation); + self::assertInstanceOf(AnnotationNamespace\PrePersist::class, $annotation); $annotationDriver = $this->configuration->newDefaultAnnotationDriver($paths); $reader = $annotationDriver->getReader(); @@ -106,59 +106,59 @@ public function testNewDefaultAnnotationDriver(): void $reflectionClass->getMethod('simpleAnnotationMethod'), AnnotationNamespace\PrePersist::class ); - $this->assertInstanceOf(AnnotationNamespace\PrePersist::class, $annotation); + self::assertInstanceOf(AnnotationNamespace\PrePersist::class, $annotation); } public function testSetGetEntityNamespace(): void { $this->configuration->addEntityNamespace('TestNamespace', __NAMESPACE__); - $this->assertSame(__NAMESPACE__, $this->configuration->getEntityNamespace('TestNamespace')); + self::assertSame(__NAMESPACE__, $this->configuration->getEntityNamespace('TestNamespace')); $namespaces = ['OtherNamespace' => __NAMESPACE__]; $this->configuration->setEntityNamespaces($namespaces); - $this->assertSame($namespaces, $this->configuration->getEntityNamespaces()); + self::assertSame($namespaces, $this->configuration->getEntityNamespaces()); $this->expectException(ORMException::class); $this->configuration->getEntityNamespace('NonExistingNamespace'); } public function testSetGetQueryCacheImpl(): void { - $this->assertSame(null, $this->configuration->getQueryCacheImpl()); // defaults + self::assertSame(null, $this->configuration->getQueryCacheImpl()); // defaults $queryCacheImpl = $this->createMock(Cache::class); $this->configuration->setQueryCacheImpl($queryCacheImpl); - $this->assertSame($queryCacheImpl, $this->configuration->getQueryCacheImpl()); + self::assertSame($queryCacheImpl, $this->configuration->getQueryCacheImpl()); } public function testSetGetHydrationCacheImpl(): void { - $this->assertSame(null, $this->configuration->getHydrationCacheImpl()); // defaults + self::assertSame(null, $this->configuration->getHydrationCacheImpl()); // defaults $queryCacheImpl = $this->createMock(Cache::class); $this->configuration->setHydrationCacheImpl($queryCacheImpl); - $this->assertSame($queryCacheImpl, $this->configuration->getHydrationCacheImpl()); + self::assertSame($queryCacheImpl, $this->configuration->getHydrationCacheImpl()); } public function testSetGetMetadataCacheImpl(): void { - $this->assertSame(null, $this->configuration->getMetadataCacheImpl()); // defaults + self::assertSame(null, $this->configuration->getMetadataCacheImpl()); // defaults $queryCacheImpl = $this->createMock(Cache::class); $this->configuration->setMetadataCacheImpl($queryCacheImpl); - $this->assertSame($queryCacheImpl, $this->configuration->getMetadataCacheImpl()); - $this->assertNotNull($this->configuration->getMetadataCache()); + self::assertSame($queryCacheImpl, $this->configuration->getMetadataCacheImpl()); + self::assertNotNull($this->configuration->getMetadataCache()); } public function testSetGetMetadataCache(): void { - $this->assertNull($this->configuration->getMetadataCache()); + self::assertNull($this->configuration->getMetadataCache()); $cache = $this->createStub(CacheItemPoolInterface::class); $this->configuration->setMetadataCache($cache); - $this->assertSame($cache, $this->configuration->getMetadataCache()); - $this->assertNotNull($this->configuration->getMetadataCacheImpl()); + self::assertSame($cache, $this->configuration->getMetadataCache()); + self::assertNotNull($this->configuration->getMetadataCacheImpl()); } public function testAddGetNamedQuery(): void { $dql = 'SELECT u FROM User u'; $this->configuration->addNamedQuery('QueryName', $dql); - $this->assertSame($dql, $this->configuration->getNamedQuery('QueryName')); + self::assertSame($dql, $this->configuration->getNamedQuery('QueryName')); $this->expectException(ORMException::class); $this->expectExceptionMessage('a named query'); $this->configuration->getNamedQuery('NonExistingQuery'); @@ -170,8 +170,8 @@ public function testAddGetNamedNativeQuery(): void $rsm = $this->createMock(ResultSetMapping::class); $this->configuration->addNamedNativeQuery('QueryName', $sql, $rsm); $fetched = $this->configuration->getNamedNativeQuery('QueryName'); - $this->assertSame($sql, $fetched[0]); - $this->assertSame($rsm, $fetched[1]); + self::assertSame($sql, $fetched[0]); + self::assertSame($rsm, $fetched[1]); $this->expectException(ORMException::class); $this->expectExceptionMessage('a named native query'); $this->configuration->getNamedNativeQuery('NonExistingQuery'); @@ -238,7 +238,7 @@ public function testEnsureProductionSettingsMissingMetadataCache(): void public function testEnsureProductionSettingsQueryArrayCache(): void { if (! class_exists(ArrayCache::class)) { - $this->markTestSkipped('Test only applies with doctrine/cache 1.x'); + self::markTestSkipped('Test only applies with doctrine/cache 1.x'); } $this->setProductionSettings(); @@ -253,7 +253,7 @@ public function testEnsureProductionSettingsQueryArrayCache(): void public function testEnsureProductionSettingsLegacyMetadataArrayCache(): void { if (! class_exists(ArrayCache::class)) { - $this->markTestSkipped('Test only applies with doctrine/cache 1.x'); + self::markTestSkipped('Test only applies with doctrine/cache 1.x'); } $this->setProductionSettings(); @@ -301,87 +301,87 @@ public function testEnsureProductionSettingsAutoGenerateProxyClassesEval(): void public function testAddGetCustomStringFunction(): void { $this->configuration->addCustomStringFunction('FunctionName', self::class); - $this->assertSame(self::class, $this->configuration->getCustomStringFunction('FunctionName')); - $this->assertSame(null, $this->configuration->getCustomStringFunction('NonExistingFunction')); + self::assertSame(self::class, $this->configuration->getCustomStringFunction('FunctionName')); + self::assertSame(null, $this->configuration->getCustomStringFunction('NonExistingFunction')); $this->configuration->setCustomStringFunctions(['OtherFunctionName' => self::class]); - $this->assertSame(self::class, $this->configuration->getCustomStringFunction('OtherFunctionName')); + self::assertSame(self::class, $this->configuration->getCustomStringFunction('OtherFunctionName')); } public function testAddGetCustomNumericFunction(): void { $this->configuration->addCustomNumericFunction('FunctionName', self::class); - $this->assertSame(self::class, $this->configuration->getCustomNumericFunction('FunctionName')); - $this->assertSame(null, $this->configuration->getCustomNumericFunction('NonExistingFunction')); + self::assertSame(self::class, $this->configuration->getCustomNumericFunction('FunctionName')); + self::assertSame(null, $this->configuration->getCustomNumericFunction('NonExistingFunction')); $this->configuration->setCustomNumericFunctions(['OtherFunctionName' => self::class]); - $this->assertSame(self::class, $this->configuration->getCustomNumericFunction('OtherFunctionName')); + self::assertSame(self::class, $this->configuration->getCustomNumericFunction('OtherFunctionName')); } public function testAddGetCustomDatetimeFunction(): void { $this->configuration->addCustomDatetimeFunction('FunctionName', self::class); - $this->assertSame(self::class, $this->configuration->getCustomDatetimeFunction('FunctionName')); - $this->assertSame(null, $this->configuration->getCustomDatetimeFunction('NonExistingFunction')); + self::assertSame(self::class, $this->configuration->getCustomDatetimeFunction('FunctionName')); + self::assertSame(null, $this->configuration->getCustomDatetimeFunction('NonExistingFunction')); $this->configuration->setCustomDatetimeFunctions(['OtherFunctionName' => self::class]); - $this->assertSame(self::class, $this->configuration->getCustomDatetimeFunction('OtherFunctionName')); + self::assertSame(self::class, $this->configuration->getCustomDatetimeFunction('OtherFunctionName')); } public function testAddGetCustomHydrationMode(): void { - $this->assertSame(null, $this->configuration->getCustomHydrationMode('NonExisting')); + self::assertSame(null, $this->configuration->getCustomHydrationMode('NonExisting')); $this->configuration->addCustomHydrationMode('HydrationModeName', self::class); - $this->assertSame(self::class, $this->configuration->getCustomHydrationMode('HydrationModeName')); + self::assertSame(self::class, $this->configuration->getCustomHydrationMode('HydrationModeName')); } public function testSetCustomHydrationModes(): void { $this->configuration->addCustomHydrationMode('HydrationModeName', self::class); - $this->assertSame(self::class, $this->configuration->getCustomHydrationMode('HydrationModeName')); + self::assertSame(self::class, $this->configuration->getCustomHydrationMode('HydrationModeName')); $this->configuration->setCustomHydrationModes( ['AnotherHydrationModeName' => self::class] ); - $this->assertNull($this->configuration->getCustomHydrationMode('HydrationModeName')); - $this->assertSame(self::class, $this->configuration->getCustomHydrationMode('AnotherHydrationModeName')); + self::assertNull($this->configuration->getCustomHydrationMode('HydrationModeName')); + self::assertSame(self::class, $this->configuration->getCustomHydrationMode('AnotherHydrationModeName')); } public function testSetGetClassMetadataFactoryName(): void { - $this->assertSame(AnnotationNamespace\ClassMetadataFactory::class, $this->configuration->getClassMetadataFactoryName()); + self::assertSame(AnnotationNamespace\ClassMetadataFactory::class, $this->configuration->getClassMetadataFactoryName()); $this->configuration->setClassMetadataFactoryName(self::class); - $this->assertSame(self::class, $this->configuration->getClassMetadataFactoryName()); + self::assertSame(self::class, $this->configuration->getClassMetadataFactoryName()); } public function testAddGetFilters(): void { - $this->assertSame(null, $this->configuration->getFilterClassName('NonExistingFilter')); + self::assertSame(null, $this->configuration->getFilterClassName('NonExistingFilter')); $this->configuration->addFilter('FilterName', self::class); - $this->assertSame(self::class, $this->configuration->getFilterClassName('FilterName')); + self::assertSame(self::class, $this->configuration->getFilterClassName('FilterName')); } public function setDefaultRepositoryClassName(): void { - $this->assertSame(EntityRepository::class, $this->configuration->getDefaultRepositoryClassName()); + self::assertSame(EntityRepository::class, $this->configuration->getDefaultRepositoryClassName()); $this->configuration->setDefaultRepositoryClassName(DDC753CustomRepository::class); - $this->assertSame(DDC753CustomRepository::class, $this->configuration->getDefaultRepositoryClassName()); + self::assertSame(DDC753CustomRepository::class, $this->configuration->getDefaultRepositoryClassName()); $this->expectException(ORMException::class); $this->configuration->setDefaultRepositoryClassName(self::class); } public function testSetGetNamingStrategy(): void { - $this->assertInstanceOf(NamingStrategy::class, $this->configuration->getNamingStrategy()); + self::assertInstanceOf(NamingStrategy::class, $this->configuration->getNamingStrategy()); $namingStrategy = $this->createMock(NamingStrategy::class); $this->configuration->setNamingStrategy($namingStrategy); - $this->assertSame($namingStrategy, $this->configuration->getNamingStrategy()); + self::assertSame($namingStrategy, $this->configuration->getNamingStrategy()); } public function testSetGetQuoteStrategy(): void { - $this->assertInstanceOf(QuoteStrategy::class, $this->configuration->getQuoteStrategy()); + self::assertInstanceOf(QuoteStrategy::class, $this->configuration->getQuoteStrategy()); $quoteStrategy = $this->createMock(QuoteStrategy::class); $this->configuration->setQuoteStrategy($quoteStrategy); - $this->assertSame($quoteStrategy, $this->configuration->getQuoteStrategy()); + self::assertSame($quoteStrategy, $this->configuration->getQuoteStrategy()); } /** @@ -389,11 +389,11 @@ public function testSetGetQuoteStrategy(): void */ public function testSetGetEntityListenerResolver(): void { - $this->assertInstanceOf(EntityListenerResolver::class, $this->configuration->getEntityListenerResolver()); - $this->assertInstanceOf(AnnotationNamespace\DefaultEntityListenerResolver::class, $this->configuration->getEntityListenerResolver()); + self::assertInstanceOf(EntityListenerResolver::class, $this->configuration->getEntityListenerResolver()); + self::assertInstanceOf(AnnotationNamespace\DefaultEntityListenerResolver::class, $this->configuration->getEntityListenerResolver()); $resolver = $this->createMock(EntityListenerResolver::class); $this->configuration->setEntityListenerResolver($resolver); - $this->assertSame($resolver, $this->configuration->getEntityListenerResolver()); + self::assertSame($resolver, $this->configuration->getEntityListenerResolver()); } /** @@ -403,9 +403,9 @@ public function testSetGetSecondLevelCacheConfig(): void { $mockClass = $this->createMock(CacheConfiguration::class); - $this->assertNull($this->configuration->getSecondLevelCacheConfiguration()); + self::assertNull($this->configuration->getSecondLevelCacheConfiguration()); $this->configuration->setSecondLevelCacheConfiguration($mockClass); - $this->assertEquals($mockClass, $this->configuration->getSecondLevelCacheConfiguration()); + self::assertEquals($mockClass, $this->configuration->getSecondLevelCacheConfiguration()); } } diff --git a/tests/Doctrine/Tests/ORM/Decorator/EntityManagerDecoratorTest.php b/tests/Doctrine/Tests/ORM/Decorator/EntityManagerDecoratorTest.php index 375caf9a85d..05e72becc44 100644 --- a/tests/Doctrine/Tests/ORM/Decorator/EntityManagerDecoratorTest.php +++ b/tests/Doctrine/Tests/ORM/Decorator/EntityManagerDecoratorTest.php @@ -90,7 +90,7 @@ public function testAllMethodCallsAreDelegatedToTheWrappedInstance($method, arra { $return = ! in_array($method, self::VOID_METHODS, true) ? 'INNER VALUE FROM ' . $method : null; - $this->wrapped->expects($this->once()) + $this->wrapped->expects(self::once()) ->method($method) ->with(...$parameters) ->willReturn($return); @@ -98,6 +98,6 @@ public function testAllMethodCallsAreDelegatedToTheWrappedInstance($method, arra $decorator = new class ($this->wrapped) extends EntityManagerDecorator { }; - $this->assertSame($return, $decorator->$method(...$parameters)); + self::assertSame($return, $decorator->$method(...$parameters)); } } diff --git a/tests/Doctrine/Tests/ORM/Entity/ConstructorTest.php b/tests/Doctrine/Tests/ORM/Entity/ConstructorTest.php index a6e3637802f..d39071c37ec 100644 --- a/tests/Doctrine/Tests/ORM/Entity/ConstructorTest.php +++ b/tests/Doctrine/Tests/ORM/Entity/ConstructorTest.php @@ -11,7 +11,7 @@ class ConstructorTest extends OrmTestCase public function testFieldInitializationInConstructor(): void { $entity = new ConstructorTestEntity1('romanb'); - $this->assertEquals('romanb', $entity->username); + self::assertEquals('romanb', $entity->username); } } diff --git a/tests/Doctrine/Tests/ORM/EntityManagerTest.php b/tests/Doctrine/Tests/ORM/EntityManagerTest.php index 82f169e871d..8b054b81d2c 100644 --- a/tests/Doctrine/Tests/ORM/EntityManagerTest.php +++ b/tests/Doctrine/Tests/ORM/EntityManagerTest.php @@ -50,39 +50,39 @@ protected function setUp(): void */ public function testIsOpen(): void { - $this->assertTrue($this->entityManager->isOpen()); + self::assertTrue($this->entityManager->isOpen()); $this->entityManager->close(); - $this->assertFalse($this->entityManager->isOpen()); + self::assertFalse($this->entityManager->isOpen()); } public function testGetConnection(): void { - $this->assertInstanceOf(Connection::class, $this->entityManager->getConnection()); + self::assertInstanceOf(Connection::class, $this->entityManager->getConnection()); } public function testGetMetadataFactory(): void { - $this->assertInstanceOf(ClassMetadataFactory::class, $this->entityManager->getMetadataFactory()); + self::assertInstanceOf(ClassMetadataFactory::class, $this->entityManager->getMetadataFactory()); } public function testGetConfiguration(): void { - $this->assertInstanceOf(Configuration::class, $this->entityManager->getConfiguration()); + self::assertInstanceOf(Configuration::class, $this->entityManager->getConfiguration()); } public function testGetUnitOfWork(): void { - $this->assertInstanceOf(UnitOfWork::class, $this->entityManager->getUnitOfWork()); + self::assertInstanceOf(UnitOfWork::class, $this->entityManager->getUnitOfWork()); } public function testGetProxyFactory(): void { - $this->assertInstanceOf(ProxyFactory::class, $this->entityManager->getProxyFactory()); + self::assertInstanceOf(ProxyFactory::class, $this->entityManager->getProxyFactory()); } public function testGetEventManager(): void { - $this->assertInstanceOf(EventManager::class, $this->entityManager->getEventManager()); + self::assertInstanceOf(EventManager::class, $this->entityManager->getEventManager()); } public function testCreateNativeQuery(): void @@ -90,7 +90,7 @@ public function testCreateNativeQuery(): void $rsm = new ResultSetMapping(); $query = $this->entityManager->createNativeQuery('SELECT foo', $rsm); - $this->assertSame('SELECT foo', $query->getSql()); + self::assertSame('SELECT foo', $query->getSql()); } /** @@ -103,12 +103,12 @@ public function testCreateNamedNativeQuery(): void $query = $this->entityManager->createNamedNativeQuery('foo'); - $this->assertInstanceOf(NativeQuery::class, $query); + self::assertInstanceOf(NativeQuery::class, $query); } public function testCreateQueryBuilder(): void { - $this->assertInstanceOf(QueryBuilder::class, $this->entityManager->createQueryBuilder()); + self::assertInstanceOf(QueryBuilder::class, $this->entityManager->createQueryBuilder()); } public function testCreateQueryBuilderAliasValid(): void @@ -117,32 +117,32 @@ public function testCreateQueryBuilderAliasValid(): void ->select('u')->from(CmsUser::class, 'u'); $q2 = clone $q; - $this->assertEquals('SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u', $q->getQuery()->getDql()); - $this->assertEquals('SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u', $q2->getQuery()->getDql()); + self::assertEquals('SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u', $q->getQuery()->getDql()); + self::assertEquals('SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u', $q2->getQuery()->getDql()); $q3 = clone $q; - $this->assertEquals('SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u', $q3->getQuery()->getDql()); + self::assertEquals('SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u', $q3->getQuery()->getDql()); } public function testCreateQueryDqlIsOptional(): void { - $this->assertInstanceOf(Query::class, $this->entityManager->createQuery()); + self::assertInstanceOf(Query::class, $this->entityManager->createQuery()); } public function testGetPartialReference(): void { $user = $this->entityManager->getPartialReference(CmsUser::class, 42); - $this->assertTrue($this->entityManager->contains($user)); - $this->assertEquals(42, $user->id); - $this->assertNull($user->getName()); + self::assertTrue($this->entityManager->contains($user)); + self::assertEquals(42, $user->id); + self::assertNull($user->getName()); } public function testCreateQuery(): void { $q = $this->entityManager->createQuery('SELECT 1'); - $this->assertInstanceOf(Query::class, $q); - $this->assertEquals('SELECT 1', $q->getDql()); + self::assertInstanceOf(Query::class, $q); + self::assertEquals('SELECT 1', $q->getDql()); } /** @@ -153,8 +153,8 @@ public function testCreateNamedQuery(): void $this->entityManager->getConfiguration()->addNamedQuery('foo', 'SELECT 1'); $query = $this->entityManager->createNamedQuery('foo'); - $this->assertInstanceOf(Query::class, $query); - $this->assertEquals('SELECT 1', $query->getDql()); + self::assertInstanceOf(Query::class, $query); + self::assertEquals('SELECT 1', $query->getDql()); } /** @@ -217,12 +217,12 @@ public function testTransactionalAcceptsReturn(): void return 'foo'; }); - $this->assertEquals('foo', $return); + self::assertEquals('foo', $return); } public function testTransactionalAcceptsVariousCallables(): void { - $this->assertSame('callback', $this->entityManager->transactional([$this, 'transactionalCallback'])); + self::assertSame('callback', $this->entityManager->transactional([$this, 'transactionalCallback'])); } public function testTransactionalThrowsInvalidArgumentExceptionIfNonCallablePassed(): void @@ -235,7 +235,7 @@ public function testTransactionalThrowsInvalidArgumentExceptionIfNonCallablePass public function transactionalCallback($em): string { - $this->assertSame($this->entityManager, $em); + self::assertSame($this->entityManager, $em); return 'callback'; } @@ -301,11 +301,11 @@ public function testClearManagerWithProxyClassName(): void $this->entityManager->persist($entity); - $this->assertTrue($this->entityManager->contains($entity)); + self::assertTrue($this->entityManager->contains($entity)); $this->entityManager->clear(get_class($proxy)); - $this->assertFalse($this->entityManager->contains($entity)); + self::assertFalse($this->entityManager->contains($entity)); } /** @@ -317,11 +317,11 @@ public function testClearManagerWithNullValue(): void $this->entityManager->persist($entity); - $this->assertTrue($this->entityManager->contains($entity)); + self::assertTrue($this->entityManager->contains($entity)); $this->entityManager->clear(null); - $this->assertFalse($this->entityManager->contains($entity)); + self::assertFalse($this->entityManager->contains($entity)); } public function testDeprecatedClearWithArguments(): void diff --git a/tests/Doctrine/Tests/ORM/EntityNotFoundExceptionTest.php b/tests/Doctrine/Tests/ORM/EntityNotFoundExceptionTest.php index 49784ca7403..8cb401c8a57 100644 --- a/tests/Doctrine/Tests/ORM/EntityNotFoundExceptionTest.php +++ b/tests/Doctrine/Tests/ORM/EntityNotFoundExceptionTest.php @@ -21,23 +21,23 @@ public function testFromClassNameAndIdentifier(): void ['foo' => 'bar'] ); - $this->assertInstanceOf(EntityNotFoundException::class, $exception); - $this->assertSame('Entity of type \'foo\' for IDs foo(bar) was not found', $exception->getMessage()); + self::assertInstanceOf(EntityNotFoundException::class, $exception); + self::assertSame('Entity of type \'foo\' for IDs foo(bar) was not found', $exception->getMessage()); $exception = EntityNotFoundException::fromClassNameAndIdentifier( 'foo', [] ); - $this->assertInstanceOf(EntityNotFoundException::class, $exception); - $this->assertSame('Entity of type \'foo\' was not found', $exception->getMessage()); + self::assertInstanceOf(EntityNotFoundException::class, $exception); + self::assertSame('Entity of type \'foo\' was not found', $exception->getMessage()); } public function testNoIdentifierFound(): void { $exception = EntityNotFoundException::noIdentifierFound('foo'); - $this->assertInstanceOf(EntityNotFoundException::class, $exception); - $this->assertSame('Unable to find "foo" entity identifier associated with the UnitOfWork', $exception->getMessage()); + self::assertInstanceOf(EntityNotFoundException::class, $exception); + self::assertSame('Unable to find "foo" entity identifier associated with the UnitOfWork', $exception->getMessage()); } } diff --git a/tests/Doctrine/Tests/ORM/Event/OnClassMetadataNotFoundEventArgsTest.php b/tests/Doctrine/Tests/ORM/Event/OnClassMetadataNotFoundEventArgsTest.php index 5646c93433a..e80ba2ff75f 100644 --- a/tests/Doctrine/Tests/ORM/Event/OnClassMetadataNotFoundEventArgsTest.php +++ b/tests/Doctrine/Tests/ORM/Event/OnClassMetadataNotFoundEventArgsTest.php @@ -25,20 +25,20 @@ public function testEventArgsMutability(): void $args = new OnClassMetadataNotFoundEventArgs('foo', $objectManager); - $this->assertSame('foo', $args->getClassName()); - $this->assertSame($objectManager, $args->getObjectManager()); + self::assertSame('foo', $args->getClassName()); + self::assertSame($objectManager, $args->getObjectManager()); - $this->assertNull($args->getFoundMetadata()); + self::assertNull($args->getFoundMetadata()); $metadata = $this->createMock(ClassMetadata::class); assert($metadata instanceof ClassMetadata); $args->setFoundMetadata($metadata); - $this->assertSame($metadata, $args->getFoundMetadata()); + self::assertSame($metadata, $args->getFoundMetadata()); $args->setFoundMetadata(null); - $this->assertNull($args->getFoundMetadata()); + self::assertNull($args->getFoundMetadata()); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/AbstractManyToManyAssociationTestCase.php b/tests/Doctrine/Tests/ORM/Functional/AbstractManyToManyAssociationTestCase.php index 78adbf46546..fb497deea6a 100644 --- a/tests/Doctrine/Tests/ORM/Functional/AbstractManyToManyAssociationTestCase.php +++ b/tests/Doctrine/Tests/ORM/Functional/AbstractManyToManyAssociationTestCase.php @@ -26,12 +26,12 @@ class AbstractManyToManyAssociationTestCase extends OrmFunctionalTestCase public function assertForeignKeysContain($firstId, $secondId): void { - $this->assertEquals(1, $this->countForeignKeys($firstId, $secondId)); + self::assertEquals(1, $this->countForeignKeys($firstId, $secondId)); } public function assertForeignKeysNotContain($firstId, $secondId): void { - $this->assertEquals(0, $this->countForeignKeys($firstId, $secondId)); + self::assertEquals(0, $this->countForeignKeys($firstId, $secondId)); } protected function countForeignKeys($firstId, $secondId): int diff --git a/tests/Doctrine/Tests/ORM/Functional/AdvancedAssociationTest.php b/tests/Doctrine/Tests/ORM/Functional/AdvancedAssociationTest.php index b77d9e86c7b..64a627ab8df 100644 --- a/tests/Doctrine/Tests/ORM/Functional/AdvancedAssociationTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/AdvancedAssociationTest.php @@ -82,17 +82,17 @@ public function testIssue(): void // test1 - lazy-loading many-to-one after find() $phrase2 = $this->_em->find(Phrase::class, $phrase->getId()); - $this->assertTrue(is_numeric($phrase2->getType()->getId())); + self::assertTrue(is_numeric($phrase2->getType()->getId())); $this->_em->clear(); // test2 - eager load in DQL query $query = $this->_em->createQuery('SELECT p,t FROM Doctrine\Tests\ORM\Functional\Phrase p JOIN p.type t'); $res = $query->getResult(); - $this->assertEquals(1, count($res)); - $this->assertInstanceOf(PhraseType::class, $res[0]->getType()); - $this->assertInstanceOf(PersistentCollection::class, $res[0]->getType()->getPhrases()); - $this->assertFalse($res[0]->getType()->getPhrases()->isInitialized()); + self::assertEquals(1, count($res)); + self::assertInstanceOf(PhraseType::class, $res[0]->getType()); + self::assertInstanceOf(PersistentCollection::class, $res[0]->getType()->getPhrases()); + self::assertFalse($res[0]->getType()->getPhrases()->isInitialized()); $this->_em->clear(); @@ -103,18 +103,18 @@ public function testIssue(): void // test2 - eager load in DQL query with double-join back and forth $query = $this->_em->createQuery('SELECT p,t,pp FROM Doctrine\Tests\ORM\Functional\Phrase p JOIN p.type t JOIN t.phrases pp'); $res = $query->getResult(); - $this->assertEquals(1, count($res)); - $this->assertInstanceOf(PhraseType::class, $res[0]->getType()); - $this->assertInstanceOf(PersistentCollection::class, $res[0]->getType()->getPhrases()); - $this->assertTrue($res[0]->getType()->getPhrases()->isInitialized()); + self::assertEquals(1, count($res)); + self::assertInstanceOf(PhraseType::class, $res[0]->getType()); + self::assertInstanceOf(PersistentCollection::class, $res[0]->getType()->getPhrases()); + self::assertTrue($res[0]->getType()->getPhrases()->isInitialized()); $this->_em->clear(); // test3 - lazy-loading one-to-many after find() $phrase3 = $this->_em->find(Phrase::class, $phrase->getId()); $definitions = $phrase3->getDefinitions(); - $this->assertInstanceOf(PersistentCollection::class, $definitions); - $this->assertInstanceOf(Definition::class, $definitions[0]); + self::assertInstanceOf(PersistentCollection::class, $definitions); + self::assertInstanceOf(Definition::class, $definitions[0]); $this->_em->clear(); @@ -123,10 +123,10 @@ public function testIssue(): void $res = $query->getResult(); $definitions = $res[0]->getDefinitions(); - $this->assertEquals(1, count($res)); + self::assertEquals(1, count($res)); - $this->assertInstanceOf(Definition::class, $definitions[0]); - $this->assertEquals(2, $definitions->count()); + self::assertInstanceOf(Definition::class, $definitions[0]); + self::assertEquals(2, $definitions->count()); $this->_em->clear(); @@ -153,7 +153,7 @@ public function testManyToMany(): void $res = $query->getResult(); $types = $res[0]->getTypes(); - $this->assertInstanceOf(Type::class, $types[0]); + self::assertInstanceOf(Type::class, $types[0]); $this->_em->clear(); diff --git a/tests/Doctrine/Tests/ORM/Functional/AdvancedDqlQueryTest.php b/tests/Doctrine/Tests/ORM/Functional/AdvancedDqlQueryTest.php index ad816381dab..e95e1e08d89 100644 --- a/tests/Doctrine/Tests/ORM/Functional/AdvancedDqlQueryTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/AdvancedDqlQueryTest.php @@ -33,11 +33,11 @@ public function testAggregateWithHavingClause(): void $result = $this->_em->createQuery($dql)->getScalarResult(); - $this->assertEquals(2, count($result)); - $this->assertEquals('IT', $result[0]['department']); - $this->assertEquals(150000, $result[0]['avgSalary']); - $this->assertEquals('IT2', $result[1]['department']); - $this->assertEquals(600000, $result[1]['avgSalary']); + self::assertEquals(2, count($result)); + self::assertEquals('IT', $result[0]['department']); + self::assertEquals(150000, $result[0]['avgSalary']); + self::assertEquals('IT2', $result[1]['department']); + self::assertEquals(600000, $result[1]['avgSalary']); } public function testCommentsInDQL(): void @@ -51,11 +51,11 @@ public function testCommentsInDQL(): void $result = $this->_em->createQuery($dql)->getScalarResult(); - $this->assertEquals(2, count($result)); - $this->assertEquals('IT', $result[0]['department']); - $this->assertEquals(150000, $result[0]['avgSalary']); - $this->assertEquals('IT2', $result[1]['department']); - $this->assertEquals(600000, $result[1]['avgSalary']); + self::assertEquals(2, count($result)); + self::assertEquals('IT', $result[0]['department']); + self::assertEquals(150000, $result[0]['avgSalary']); + self::assertEquals('IT2', $result[1]['department']); + self::assertEquals(600000, $result[1]['avgSalary']); } public function testUnnamedScalarResultsAreOneBased(): void @@ -66,9 +66,9 @@ public function testUnnamedScalarResultsAreOneBased(): void $result = $this->_em->createQuery($dql)->getScalarResult(); - $this->assertEquals(2, count($result)); - $this->assertEquals(150000, $result[0][1]); - $this->assertEquals(600000, $result[1][1]); + self::assertEquals(2, count($result)); + self::assertEquals(150000, $result[0][1]); + self::assertEquals(600000, $result[1][1]); } public function testOrderByResultVariableCollectionSize(): void @@ -80,19 +80,19 @@ public function testOrderByResultVariableCollectionSize(): void $result = $this->_em->createQuery($dql)->getScalarResult(); - $this->assertEquals(4, count($result)); + self::assertEquals(4, count($result)); - $this->assertEquals('Jonathan W.', $result[0]['name']); - $this->assertEquals(3, $result[0]['friends']); + self::assertEquals('Jonathan W.', $result[0]['name']); + self::assertEquals(3, $result[0]['friends']); - $this->assertEquals('Guilherme B.', $result[1]['name']); - $this->assertEquals(2, $result[1]['friends']); + self::assertEquals('Guilherme B.', $result[1]['name']); + self::assertEquals(2, $result[1]['friends']); - $this->assertEquals('Benjamin E.', $result[2]['name']); - $this->assertEquals(2, $result[2]['friends']); + self::assertEquals('Benjamin E.', $result[2]['name']); + self::assertEquals(2, $result[2]['friends']); - $this->assertEquals('Roman B.', $result[3]['name']); - $this->assertEquals(1, $result[3]['friends']); + self::assertEquals('Roman B.', $result[3]['name']); + self::assertEquals(1, $result[3]['friends']); } public function testOrderBySimpleCaseExpression(): void @@ -148,12 +148,12 @@ public function testIsNullAssociation(): void $query = $this->_em->createQuery($dql); $result = $query->getResult(); - $this->assertEquals(2, count($result)); - $this->assertTrue($result[0]->getId() > 0); - $this->assertNull($result[0]->getSpouse()); + self::assertEquals(2, count($result)); + self::assertTrue($result[0]->getId() > 0); + self::assertNull($result[0]->getSpouse()); - $this->assertTrue($result[1]->getId() > 0); - $this->assertNull($result[1]->getSpouse()); + self::assertTrue($result[1]->getId() > 0); + self::assertNull($result[1]->getSpouse()); $this->_em->clear(); @@ -167,8 +167,8 @@ public function testSelectSubselect(): void $query = $this->_em->createQuery($dql); $result = $query->getArrayResult(); - $this->assertEquals(1, count($result)); - $this->assertEquals('Caramba', $result[0]['brandName']); + self::assertEquals(1, count($result)); + self::assertEquals('Caramba', $result[0]['brandName']); $this->_em->clear(); } @@ -182,8 +182,8 @@ public function testInSubselect(): void $query = $this->_em->createQuery($dql); $result = $query->getScalarResult(); - $this->assertEquals(1, count($result)); - $this->assertEquals('Roman B.', $result[0]['name']); + self::assertEquals(1, count($result)); + self::assertEquals('Roman B.', $result[0]['name']); $this->_em->clear(); @@ -197,7 +197,7 @@ public function testGroupByMultipleFields(): void $query = $this->_em->createQuery($dql); $result = $query->getResult(); - $this->assertEquals(4, count($result)); + self::assertEquals(4, count($result)); $this->_em->clear(); @@ -227,7 +227,7 @@ public function testDeleteAs(): void $dql = 'SELECT count(p) FROM Doctrine\Tests\Models\Company\CompanyEmployee p'; $result = $this->_em->createQuery($dql)->getSingleScalarResult(); - $this->assertEquals(0, $result); + self::assertEquals(0, $result); } public function generateFixture(): void diff --git a/tests/Doctrine/Tests/ORM/Functional/BasicFunctionalTest.php b/tests/Doctrine/Tests/ORM/Functional/BasicFunctionalTest.php index 24bb66da0f9..addb7f3fdd6 100644 --- a/tests/Doctrine/Tests/ORM/Functional/BasicFunctionalTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/BasicFunctionalTest.php @@ -45,45 +45,45 @@ public function testBasicUnitsOfWorkWithOneToManyAssociation(): void $this->_em->flush(); - $this->assertTrue(is_numeric($user->id)); - $this->assertTrue($this->_em->contains($user)); + self::assertTrue(is_numeric($user->id)); + self::assertTrue($this->_em->contains($user)); // Read $user2 = $this->_em->find(CmsUser::class, $user->id); - $this->assertTrue($user === $user2); + self::assertTrue($user === $user2); // Add a phonenumber $ph = new CmsPhonenumber(); $ph->phonenumber = '12345'; $user->addPhonenumber($ph); $this->_em->flush(); - $this->assertTrue($this->_em->contains($ph)); - $this->assertTrue($this->_em->contains($user)); + self::assertTrue($this->_em->contains($ph)); + self::assertTrue($this->_em->contains($user)); // Update name $user->name = 'guilherme'; $this->_em->flush(); - $this->assertEquals('guilherme', $user->name); + self::assertEquals('guilherme', $user->name); // Add another phonenumber $ph2 = new CmsPhonenumber(); $ph2->phonenumber = '6789'; $user->addPhonenumber($ph2); $this->_em->flush(); - $this->assertTrue($this->_em->contains($ph2)); + self::assertTrue($this->_em->contains($ph2)); // Delete $this->_em->remove($user); - $this->assertTrue($this->_em->getUnitOfWork()->isScheduledForDelete($user)); - $this->assertTrue($this->_em->getUnitOfWork()->isScheduledForDelete($ph)); - $this->assertTrue($this->_em->getUnitOfWork()->isScheduledForDelete($ph2)); + self::assertTrue($this->_em->getUnitOfWork()->isScheduledForDelete($user)); + self::assertTrue($this->_em->getUnitOfWork()->isScheduledForDelete($ph)); + self::assertTrue($this->_em->getUnitOfWork()->isScheduledForDelete($ph2)); $this->_em->flush(); - $this->assertFalse($this->_em->getUnitOfWork()->isScheduledForDelete($user)); - $this->assertFalse($this->_em->getUnitOfWork()->isScheduledForDelete($ph)); - $this->assertFalse($this->_em->getUnitOfWork()->isScheduledForDelete($ph2)); - $this->assertEquals(UnitOfWork::STATE_NEW, $this->_em->getUnitOfWork()->getEntityState($user)); - $this->assertEquals(UnitOfWork::STATE_NEW, $this->_em->getUnitOfWork()->getEntityState($ph)); - $this->assertEquals(UnitOfWork::STATE_NEW, $this->_em->getUnitOfWork()->getEntityState($ph2)); + self::assertFalse($this->_em->getUnitOfWork()->isScheduledForDelete($user)); + self::assertFalse($this->_em->getUnitOfWork()->isScheduledForDelete($ph)); + self::assertFalse($this->_em->getUnitOfWork()->isScheduledForDelete($ph2)); + self::assertEquals(UnitOfWork::STATE_NEW, $this->_em->getUnitOfWork()->getEntityState($user)); + self::assertEquals(UnitOfWork::STATE_NEW, $this->_em->getUnitOfWork()->getEntityState($ph)); + self::assertEquals(UnitOfWork::STATE_NEW, $this->_em->getUnitOfWork()->getEntityState($ph2)); } public function testOneToManyAssociationModification(): void @@ -110,8 +110,8 @@ public function testOneToManyAssociationModification(): void $this->_em->flush(); - $this->assertEquals(1, count($user->phonenumbers)); - $this->assertNull($ph1->user); + self::assertEquals(1, count($user->phonenumbers)); + self::assertNull($ph1->user); } public function testBasicOneToOne(): void @@ -138,7 +138,7 @@ public function testBasicOneToOne(): void 'SELECT user_id FROM cms_addresses WHERE id=?', [$address->id] )->fetchColumn(); - $this->assertTrue(is_numeric($userId)); + self::assertTrue(is_numeric($userId)); $this->_em->clear(); @@ -147,8 +147,8 @@ public function testBasicOneToOne(): void ->getSingleResult(); // Address has been eager-loaded because it cant be lazy - $this->assertInstanceOf(CmsAddress::class, $user2->address); - $this->assertNotInstanceOf(Proxy::class, $user2->address); + self::assertInstanceOf(CmsAddress::class, $user2->address); + self::assertNotInstanceOf(Proxy::class, $user2->address); } /** @@ -161,15 +161,15 @@ public function testRemove(): void $user->username = 'gblanco'; $user->status = 'developer'; - $this->assertEquals(UnitOfWork::STATE_NEW, $this->_em->getUnitOfWork()->getEntityState($user), 'State should be UnitOfWork::STATE_NEW'); + self::assertEquals(UnitOfWork::STATE_NEW, $this->_em->getUnitOfWork()->getEntityState($user), 'State should be UnitOfWork::STATE_NEW'); $this->_em->persist($user); - $this->assertEquals(UnitOfWork::STATE_MANAGED, $this->_em->getUnitOfWork()->getEntityState($user), 'State should be UnitOfWork::STATE_MANAGED'); + self::assertEquals(UnitOfWork::STATE_MANAGED, $this->_em->getUnitOfWork()->getEntityState($user), 'State should be UnitOfWork::STATE_MANAGED'); $this->_em->remove($user); - $this->assertEquals(UnitOfWork::STATE_NEW, $this->_em->getUnitOfWork()->getEntityState($user), 'State should be UnitOfWork::STATE_NEW'); + self::assertEquals(UnitOfWork::STATE_NEW, $this->_em->getUnitOfWork()->getEntityState($user), 'State should be UnitOfWork::STATE_NEW'); $this->_em->persist($user); $this->_em->flush(); @@ -177,12 +177,12 @@ public function testRemove(): void $this->_em->remove($user); - $this->assertEquals(UnitOfWork::STATE_REMOVED, $this->_em->getUnitOfWork()->getEntityState($user), 'State should be UnitOfWork::STATE_REMOVED'); + self::assertEquals(UnitOfWork::STATE_REMOVED, $this->_em->getUnitOfWork()->getEntityState($user), 'State should be UnitOfWork::STATE_REMOVED'); $this->_em->flush(); - $this->assertEquals(UnitOfWork::STATE_NEW, $this->_em->getUnitOfWork()->getEntityState($user), 'State should be UnitOfWork::STATE_NEW'); + self::assertEquals(UnitOfWork::STATE_NEW, $this->_em->getUnitOfWork()->getEntityState($user), 'State should be UnitOfWork::STATE_NEW'); - $this->assertNull($this->_em->find(CmsUser::class, $id)); + self::assertNull($this->_em->find(CmsUser::class, $id)); } public function testOneToManyOrphanRemoval(): void @@ -203,18 +203,18 @@ public function testOneToManyOrphanRemoval(): void $this->_em->flush(); $user->getPhonenumbers()->remove(0); - $this->assertEquals(2, count($user->getPhonenumbers())); + self::assertEquals(2, count($user->getPhonenumbers())); $this->_em->flush(); // Check that there are just 2 phonenumbers left $count = $this->_em->getConnection()->fetchColumn('SELECT COUNT(*) FROM cms_phonenumbers'); - $this->assertEquals(2, $count); // only 2 remaining + self::assertEquals(2, $count); // only 2 remaining // check that clear() removes the others via orphan removal $user->getPhonenumbers()->clear(); $this->_em->flush(); - $this->assertEquals(0, $this->_em->getConnection()->fetchColumn('select count(*) from cms_phonenumbers')); + self::assertEquals(0, $this->_em->getConnection()->fetchColumn('select count(*) from cms_phonenumbers')); } public function testBasicQuery(): void @@ -230,10 +230,10 @@ public function testBasicQuery(): void $users = $query->getResult(); - $this->assertEquals(1, count($users)); - $this->assertEquals('Guilherme', $users[0]->name); - $this->assertEquals('gblanco', $users[0]->username); - $this->assertEquals('developer', $users[0]->status); + self::assertEquals(1, count($users)); + self::assertEquals('Guilherme', $users[0]->name); + self::assertEquals('gblanco', $users[0]->username); + self::assertEquals('developer', $users[0]->status); //$this->assertNull($users[0]->phonenumbers); //$this->assertNull($users[0]->articles); @@ -243,19 +243,19 @@ public function testBasicQuery(): void $usersArray = $query->getArrayResult(); - $this->assertTrue(is_array($usersArray)); - $this->assertEquals(1, count($usersArray)); - $this->assertEquals('Guilherme', $usersArray[0]['name']); - $this->assertEquals('gblanco', $usersArray[0]['username']); - $this->assertEquals('developer', $usersArray[0]['status']); + self::assertTrue(is_array($usersArray)); + self::assertEquals(1, count($usersArray)); + self::assertEquals('Guilherme', $usersArray[0]['name']); + self::assertEquals('gblanco', $usersArray[0]['username']); + self::assertEquals('developer', $usersArray[0]['status']); $usersScalar = $query->getScalarResult(); - $this->assertTrue(is_array($usersScalar)); - $this->assertEquals(1, count($usersScalar)); - $this->assertEquals('Guilherme', $usersScalar[0]['u_name']); - $this->assertEquals('gblanco', $usersScalar[0]['u_username']); - $this->assertEquals('developer', $usersScalar[0]['u_status']); + self::assertTrue(is_array($usersScalar)); + self::assertEquals(1, count($usersScalar)); + self::assertEquals('Guilherme', $usersScalar[0]['u_name']); + self::assertEquals('gblanco', $usersScalar[0]['u_username']); + self::assertEquals('developer', $usersScalar[0]['u_status']); } public function testBasicOneToManyInnerJoin(): void @@ -271,7 +271,7 @@ public function testBasicOneToManyInnerJoin(): void $users = $query->getResult(); - $this->assertEquals(0, count($users)); + self::assertEquals(0, count($users)); } public function testBasicOneToManyLeftJoin(): void @@ -287,13 +287,13 @@ public function testBasicOneToManyLeftJoin(): void $users = $query->getResult(); - $this->assertEquals(1, count($users)); - $this->assertEquals('Guilherme', $users[0]->name); - $this->assertEquals('gblanco', $users[0]->username); - $this->assertEquals('developer', $users[0]->status); - $this->assertInstanceOf(PersistentCollection::class, $users[0]->phonenumbers); - $this->assertTrue($users[0]->phonenumbers->isInitialized()); - $this->assertEquals(0, $users[0]->phonenumbers->count()); + self::assertEquals(1, count($users)); + self::assertEquals('Guilherme', $users[0]->name); + self::assertEquals('gblanco', $users[0]->username); + self::assertEquals('developer', $users[0]->status); + self::assertInstanceOf(PersistentCollection::class, $users[0]->phonenumbers); + self::assertTrue($users[0]->phonenumbers->isInitialized()); + self::assertEquals(0, $users[0]->phonenumbers->count()); } public function testBasicRefresh(): void @@ -308,9 +308,9 @@ public function testBasicRefresh(): void $user->status = 'mascot'; - $this->assertEquals('mascot', $user->status); + self::assertEquals('mascot', $user->status); $this->_em->refresh($user); - $this->assertEquals('developer', $user->status); + self::assertEquals('developer', $user->status); } /** @@ -339,10 +339,10 @@ public function testRefreshResetsCollection(): void $user->addPhonenumber($ph2); - $this->assertEquals(2, count($user->phonenumbers)); + self::assertEquals(2, count($user->phonenumbers)); $this->_em->refresh($user); - $this->assertEquals(1, count($user->phonenumbers)); + self::assertEquals(1, count($user->phonenumbers)); } /** @@ -371,14 +371,14 @@ public function testDqlRefreshResetsCollection(): void $user->addPhonenumber($ph2); - $this->assertEquals(2, count($user->phonenumbers)); + self::assertEquals(2, count($user->phonenumbers)); $dql = 'SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.id = ?1'; $user = $this->_em->createQuery($dql) ->setParameter(1, $user->id) ->setHint(Query::HINT_REFRESH, true) ->getSingleResult(); - $this->assertEquals(1, count($user->phonenumbers)); + self::assertEquals(1, count($user->phonenumbers)); } /** @@ -414,7 +414,7 @@ public function testCreateEntityOfProxy(): void ->setParameter(1, $userId) ->getSingleResult(); - $this->assertEquals(1, count($user->phonenumbers)); + self::assertEquals(1, count($user->phonenumbers)); } public function testAddToCollectionDoesNotInitialize(): void @@ -434,19 +434,19 @@ public function testAddToCollectionDoesNotInitialize(): void $this->_em->flush(); $this->_em->clear(); - $this->assertEquals(3, $user->getPhonenumbers()->count()); + self::assertEquals(3, $user->getPhonenumbers()->count()); $query = $this->_em->createQuery("select u from Doctrine\Tests\Models\CMS\CmsUser u where u.username='gblanco'"); $gblanco = $query->getSingleResult(); - $this->assertFalse($gblanco->getPhonenumbers()->isInitialized()); + self::assertFalse($gblanco->getPhonenumbers()->isInitialized()); $newPhone = new CmsPhonenumber(); $newPhone->phonenumber = 555; $gblanco->addPhonenumber($newPhone); - $this->assertFalse($gblanco->getPhonenumbers()->isInitialized()); + self::assertFalse($gblanco->getPhonenumbers()->isInitialized()); $this->_em->persist($gblanco); $this->_em->flush(); @@ -454,7 +454,7 @@ public function testAddToCollectionDoesNotInitialize(): void $query = $this->_em->createQuery("select u, p from Doctrine\Tests\Models\CMS\CmsUser u join u.phonenumbers p where u.username='gblanco'"); $gblanco2 = $query->getSingleResult(); - $this->assertEquals(4, $gblanco2->getPhonenumbers()->count()); + self::assertEquals(4, $gblanco2->getPhonenumbers()->count()); } public function testInitializeCollectionWithNewObjectsRetainsNewObjects(): void @@ -474,28 +474,28 @@ public function testInitializeCollectionWithNewObjectsRetainsNewObjects(): void $this->_em->flush(); $this->_em->clear(); - $this->assertEquals(3, $user->getPhonenumbers()->count()); + self::assertEquals(3, $user->getPhonenumbers()->count()); $query = $this->_em->createQuery("select u from Doctrine\Tests\Models\CMS\CmsUser u where u.username='gblanco'"); $gblanco = $query->getSingleResult(); - $this->assertFalse($gblanco->getPhonenumbers()->isInitialized()); + self::assertFalse($gblanco->getPhonenumbers()->isInitialized()); $newPhone = new CmsPhonenumber(); $newPhone->phonenumber = 555; $gblanco->addPhonenumber($newPhone); - $this->assertFalse($gblanco->getPhonenumbers()->isInitialized()); - $this->assertEquals(4, $gblanco->getPhonenumbers()->count()); - $this->assertTrue($gblanco->getPhonenumbers()->isInitialized()); + self::assertFalse($gblanco->getPhonenumbers()->isInitialized()); + self::assertEquals(4, $gblanco->getPhonenumbers()->count()); + self::assertTrue($gblanco->getPhonenumbers()->isInitialized()); $this->_em->flush(); $this->_em->clear(); $query = $this->_em->createQuery("select u, p from Doctrine\Tests\Models\CMS\CmsUser u join u.phonenumbers p where u.username='gblanco'"); $gblanco2 = $query->getSingleResult(); - $this->assertEquals(4, $gblanco2->getPhonenumbers()->count()); + self::assertEquals(4, $gblanco2->getPhonenumbers()->count()); } public function testSetSetAssociationWithGetReference(): void @@ -515,8 +515,8 @@ public function testSetSetAssociationWithGetReference(): void $this->_em->flush(); $this->_em->clear(CmsAddress::class); - $this->assertFalse($this->_em->contains($address)); - $this->assertTrue($this->_em->contains($user)); + self::assertFalse($this->_em->contains($address)); + self::assertTrue($this->_em->contains($user)); // Assume we only got the identifier of the address and now want to attach // that address to the user without actually loading it, using getReference(). @@ -531,9 +531,9 @@ public function testSetSetAssociationWithGetReference(): void $query = $this->_em->createQuery("select u, a from Doctrine\Tests\Models\CMS\CmsUser u join u.address a where u.username='gblanco'"); $gblanco = $query->getSingleResult(); - $this->assertInstanceOf(CmsUser::class, $gblanco); - $this->assertInstanceOf(CmsAddress::class, $gblanco->getAddress()); - $this->assertEquals('Berlin', $gblanco->getAddress()->getCity()); + self::assertInstanceOf(CmsUser::class, $gblanco); + self::assertInstanceOf(CmsAddress::class, $gblanco->getAddress()); + self::assertEquals('Berlin', $gblanco->getAddress()->getCity()); } public function testOneToManyCascadeRemove(): void @@ -561,12 +561,12 @@ public function testOneToManyCascadeRemove(): void $this->_em->clear(); - $this->assertEquals(0, $this->_em->createQuery( + self::assertEquals(0, $this->_em->createQuery( 'select count(p.phonenumber) from Doctrine\Tests\Models\CMS\CmsPhonenumber p' ) ->getSingleScalarResult()); - $this->assertEquals(0, $this->_em->createQuery( + self::assertEquals(0, $this->_em->createQuery( 'select count(u.id) from Doctrine\Tests\Models\CMS\CmsUser u' ) ->getSingleScalarResult()); @@ -594,10 +594,10 @@ public function testTextColumnSaveAndRetrieve(): void // test find() with leading backslash at the same time $articleNew = $this->_em->find('\Doctrine\Tests\Models\CMS\CmsArticle', $articleId); - $this->assertTrue($this->_em->contains($articleNew)); - $this->assertEquals('Lorem ipsum dolor sunt.', $articleNew->text); + self::assertTrue($this->_em->contains($articleNew)); + self::assertEquals('Lorem ipsum dolor sunt.', $articleNew->text); - $this->assertNotSame($article, $articleNew); + self::assertNotSame($article, $articleNew); $articleNew->text = 'Lorem ipsum dolor sunt. And stuff!'; @@ -605,8 +605,8 @@ public function testTextColumnSaveAndRetrieve(): void $this->_em->clear(); $articleNew = $this->_em->find(CmsArticle::class, $articleId); - $this->assertEquals('Lorem ipsum dolor sunt. And stuff!', $articleNew->text); - $this->assertTrue($this->_em->contains($articleNew)); + self::assertEquals('Lorem ipsum dolor sunt. And stuff!', $articleNew->text); + self::assertTrue($this->_em->contains($articleNew)); } public function testFlushDoesNotIssueUnnecessaryUpdates(): void @@ -640,15 +640,15 @@ public function testFlushDoesNotIssueUnnecessaryUpdates(): void $query = $this->_em->createQuery('select u,a,ad from Doctrine\Tests\Models\CMS\CmsUser u join u.articles a join u.address ad'); $user2 = $query->getSingleResult(); - $this->assertEquals(1, count($user2->articles)); - $this->assertInstanceOf(CmsAddress::class, $user2->address); + self::assertEquals(1, count($user2->articles)); + self::assertInstanceOf(CmsAddress::class, $user2->address); $oldLogger = $this->_em->getConnection()->getConfiguration()->getSQLLogger(); $debugStack = new DebugStack(); $this->_em->getConnection()->getConfiguration()->setSQLLogger($debugStack); $this->_em->flush(); - $this->assertEquals(0, count($debugStack->queries)); + self::assertEquals(0, count($debugStack->queries)); $this->_em->getConnection()->getConfiguration()->setSQLLogger($oldLogger); } @@ -671,7 +671,7 @@ public function testRemoveEntityByReference(): void $this->_em->flush(); $this->_em->clear(); - $this->assertEquals(0, $this->_em->getConnection()->fetchColumn('select count(*) from cms_users')); + self::assertEquals(0, $this->_em->getConnection()->fetchColumn('select count(*) from cms_users')); //$this->_em->getConnection()->getConfiguration()->setSQLLogger(null); } @@ -702,12 +702,12 @@ public function testQueryEntityByReference(): void ->setParameter('user', $userRef) ->getSingleResult(); - $this->assertInstanceOf(Proxy::class, $address2->getUser()); - $this->assertTrue($userRef === $address2->getUser()); - $this->assertFalse($userRef->__isInitialized__); - $this->assertEquals('Germany', $address2->country); - $this->assertEquals('Berlin', $address2->city); - $this->assertEquals('12345', $address2->zip); + self::assertInstanceOf(Proxy::class, $address2->getUser()); + self::assertTrue($userRef === $address2->getUser()); + self::assertFalse($userRef->__isInitialized__); + self::assertEquals('Germany', $address2->country); + self::assertEquals('Berlin', $address2->city); + self::assertEquals('12345', $address2->zip); } public function testOneToOneNullUpdate(): void @@ -728,12 +728,12 @@ public function testOneToOneNullUpdate(): void $this->_em->persist($user); $this->_em->flush(); - $this->assertEquals(1, $this->_em->getConnection()->fetchColumn('select 1 from cms_addresses where user_id = ' . $user->id)); + self::assertEquals(1, $this->_em->getConnection()->fetchColumn('select 1 from cms_addresses where user_id = ' . $user->id)); $address->user = null; $this->_em->flush(); - $this->assertNotEquals(1, $this->_em->getConnection()->fetchColumn('select 1 from cms_addresses where user_id = ' . $user->id)); + self::assertNotEquals(1, $this->_em->getConnection()->fetchColumn('select 1 from cms_addresses where user_id = ' . $user->id)); } /** @@ -840,14 +840,14 @@ public function testOneToOneOrphanRemoval(): void $this->_em->flush(); - $this->assertEquals(0, $this->_em->getConnection()->fetchColumn('select count(*) from cms_addresses')); + self::assertEquals(0, $this->_em->getConnection()->fetchColumn('select count(*) from cms_addresses')); // check orphan removal through replacement $user->address = $address; $address->user = $user; $this->_em->flush(); - $this->assertEquals(1, $this->_em->getConnection()->fetchColumn('select count(*) from cms_addresses')); + self::assertEquals(1, $this->_em->getConnection()->fetchColumn('select count(*) from cms_addresses')); // remove $address to free up unique key id $this->_em->remove($address); @@ -862,7 +862,7 @@ public function testOneToOneOrphanRemoval(): void $user->address = $newAddress; $this->_em->flush(); - $this->assertEquals(1, $this->_em->getConnection()->fetchColumn('select count(*) from cms_addresses')); + self::assertEquals(1, $this->_em->getConnection()->fetchColumn('select count(*) from cms_addresses')); } public function testGetPartialReferenceToUpdateObjectWithoutLoadingIt(): void @@ -877,15 +877,15 @@ public function testGetPartialReferenceToUpdateObjectWithoutLoadingIt(): void $this->_em->clear(); $user = $this->_em->getPartialReference(CmsUser::class, $userId); - $this->assertTrue($this->_em->contains($user)); - $this->assertNull($user->getName()); - $this->assertEquals($userId, $user->id); + self::assertTrue($this->_em->contains($user)); + self::assertNull($user->getName()); + self::assertEquals($userId, $user->id); $user->name = 'Stephan'; $this->_em->flush(); $this->_em->clear(); - $this->assertEquals('Benjamin E.', $this->_em->find(get_class($user), $userId)->name); + self::assertEquals('Benjamin E.', $this->_em->find(get_class($user), $userId)->name); } public function testMergePersistsNewEntities(): void @@ -896,19 +896,19 @@ public function testMergePersistsNewEntities(): void $user->status = 'active'; $managedUser = $this->_em->merge($user); - $this->assertEquals('beberlei', $managedUser->username); - $this->assertEquals('Benjamin E.', $managedUser->name); - $this->assertEquals('active', $managedUser->status); + self::assertEquals('beberlei', $managedUser->username); + self::assertEquals('Benjamin E.', $managedUser->name); + self::assertEquals('active', $managedUser->status); - $this->assertTrue($user !== $managedUser); - $this->assertTrue($this->_em->contains($managedUser)); + self::assertTrue($user !== $managedUser); + self::assertTrue($this->_em->contains($managedUser)); $this->_em->flush(); $userId = $managedUser->id; $this->_em->clear(); $user2 = $this->_em->find(get_class($managedUser), $userId); - $this->assertInstanceOf(CmsUser::class, $user2); + self::assertInstanceOf(CmsUser::class, $user2); } public function testMergeNonPersistedProperties(): void @@ -921,21 +921,21 @@ public function testMergeNonPersistedProperties(): void $user->nonPersistedPropertyObject = new CmsPhonenumber(); $managedUser = $this->_em->merge($user); - $this->assertEquals('test', $managedUser->nonPersistedProperty); - $this->assertSame($user->nonPersistedProperty, $managedUser->nonPersistedProperty); - $this->assertSame($user->nonPersistedPropertyObject, $managedUser->nonPersistedPropertyObject); + self::assertEquals('test', $managedUser->nonPersistedProperty); + self::assertSame($user->nonPersistedProperty, $managedUser->nonPersistedProperty); + self::assertSame($user->nonPersistedPropertyObject, $managedUser->nonPersistedPropertyObject); - $this->assertTrue($user !== $managedUser); - $this->assertTrue($this->_em->contains($managedUser)); + self::assertTrue($user !== $managedUser); + self::assertTrue($this->_em->contains($managedUser)); $this->_em->flush(); $userId = $managedUser->id; $this->_em->clear(); $user2 = $this->_em->find(get_class($managedUser), $userId); - $this->assertNull($user2->nonPersistedProperty); - $this->assertNull($user2->nonPersistedPropertyObject); - $this->assertEquals('active', $user2->status); + self::assertNull($user2->nonPersistedProperty); + self::assertNull($user2->nonPersistedPropertyObject); + self::assertEquals('active', $user2->status); } public function testMergeThrowsExceptionIfEntityWithGeneratedIdentifierDoesNotExist(): void @@ -976,7 +976,7 @@ public function testOneToOneMergeSetNull(): void $this->_em->flush(); $this->_em->clear(); - $this->assertNull($this->_em->find(get_class($ph), $ph->phonenumber)->getUser()); + self::assertNull($this->_em->find(get_class($ph), $ph->phonenumber)->getUser()); } /** @@ -1005,9 +1005,9 @@ public function testManyToOneFetchModeQuery(): void ->setParameter(1, $article->id) ->setFetchMode(CmsArticle::class, 'user', ClassMetadata::FETCH_EAGER) ->getSingleResult(); - $this->assertInstanceOf(Proxy::class, $article->user, 'It IS a proxy, ...'); - $this->assertTrue($article->user->__isInitialized__, '...but its initialized!'); - $this->assertEquals($qc + 2, $this->getCurrentQueryCount()); + self::assertInstanceOf(Proxy::class, $article->user, 'It IS a proxy, ...'); + self::assertTrue($article->user->__isInitialized__, '...but its initialized!'); + self::assertEquals($qc + 2, $this->getCurrentQueryCount()); } /** @@ -1049,14 +1049,14 @@ public function testClearWithEntityName(): void $this->_em->clear(CmsUser::class); - $this->assertEquals(UnitOfWork::STATE_DETACHED, $unitOfWork->getEntityState($user)); - $this->assertEquals(UnitOfWork::STATE_DETACHED, $unitOfWork->getEntityState($article1)); - $this->assertEquals(UnitOfWork::STATE_DETACHED, $unitOfWork->getEntityState($article2)); - $this->assertEquals(UnitOfWork::STATE_MANAGED, $unitOfWork->getEntityState($address)); + self::assertEquals(UnitOfWork::STATE_DETACHED, $unitOfWork->getEntityState($user)); + self::assertEquals(UnitOfWork::STATE_DETACHED, $unitOfWork->getEntityState($article1)); + self::assertEquals(UnitOfWork::STATE_DETACHED, $unitOfWork->getEntityState($article2)); + self::assertEquals(UnitOfWork::STATE_MANAGED, $unitOfWork->getEntityState($address)); $this->_em->clear(); - $this->assertEquals(UnitOfWork::STATE_DETACHED, $unitOfWork->getEntityState($address)); + self::assertEquals(UnitOfWork::STATE_DETACHED, $unitOfWork->getEntityState($address)); } public function testFlushManyExplicitEntities(): void @@ -1084,10 +1084,10 @@ public function testFlushManyExplicitEntities(): void $this->_em->flush([$userA, $userB]); $this->_em->refresh($userC); - $this->assertTrue($userA->id > 0, 'user a has an id'); - $this->assertTrue($userB->id > 0, 'user b has an id'); - $this->assertTrue($userC->id > 0, 'user c has an id'); - $this->assertEquals('UserC', $userC->name, 'name has not changed because we did not flush it'); + self::assertTrue($userA->id > 0, 'user a has an id'); + self::assertTrue($userB->id > 0, 'user b has an id'); + self::assertTrue($userC->id > 0, 'user c has an id'); + self::assertEquals('UserC', $userC->name, 'name has not changed because we did not flush it'); } /** @@ -1108,7 +1108,7 @@ public function testFlushSingleManagedEntity(): void $this->_em->clear(); $user = $this->_em->find(get_class($user), $user->id); - $this->assertEquals('administrator', $user->status); + self::assertEquals('administrator', $user->status); } /** @@ -1150,8 +1150,8 @@ public function testFlushSingleAndNewEntity(): void $this->_em->persist($otherUser); $this->_em->flush($user); - $this->assertTrue($this->_em->contains($otherUser), 'Other user is contained in EntityManager'); - $this->assertTrue($otherUser->id > 0, 'other user has an id'); + self::assertTrue($this->_em->contains($otherUser), 'Other user is contained in EntityManager'); + self::assertTrue($otherUser->id > 0, 'other user has an id'); } /** @@ -1177,8 +1177,8 @@ public function testFlushAndCascadePersist(): void $this->_em->flush($user); - $this->assertTrue($this->_em->contains($address), 'Other user is contained in EntityManager'); - $this->assertTrue($address->id > 0, 'other user has an id'); + self::assertTrue($this->_em->contains($address), 'Other user is contained in EntityManager'); + self::assertTrue($address->id > 0, 'other user has an id'); } /** @@ -1227,7 +1227,7 @@ public function testFlushSingleNewEntityThenRemove(): void $this->_em->flush($user); $this->_em->clear(); - $this->assertNull($this->_em->find(get_class($user), $userId)); + self::assertNull($this->_em->find(get_class($user), $userId)); } /** @@ -1254,8 +1254,8 @@ public function testProxyIsIgnored(): void $this->_em->persist($otherUser); $this->_em->flush($user); - $this->assertTrue($this->_em->contains($otherUser), 'Other user is contained in EntityManager'); - $this->assertTrue($otherUser->id > 0, 'other user has an id'); + self::assertTrue($this->_em->contains($otherUser), 'Other user is contained in EntityManager'); + self::assertTrue($otherUser->id > 0, 'other user has an id'); } /** @@ -1284,7 +1284,7 @@ public function testFlushSingleSaveOnlySingle(): void $this->_em->clear(); $user2 = $this->_em->find(get_class($user2), $user2->id); - $this->assertEquals('developer', $user2->status); + self::assertEquals('developer', $user2->status); } /** diff --git a/tests/Doctrine/Tests/ORM/Functional/ClassTableInheritanceSecondTest.php b/tests/Doctrine/Tests/ORM/Functional/ClassTableInheritanceSecondTest.php index 580eeb1f698..1bf30b98862 100644 --- a/tests/Doctrine/Tests/ORM/Functional/ClassTableInheritanceSecondTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/ClassTableInheritanceSecondTest.php @@ -67,11 +67,11 @@ public function testOneToOneAssocToBaseTypeBidirectional(): void $related2 = $this->_em->find(CTIRelated::class, $relatedId); - $this->assertInstanceOf(CTIRelated::class, $related2); - $this->assertInstanceOf(CTIChild::class, $related2->getCTIParent()); - $this->assertEquals('hello', $related2->getCTIParent()->getData()); + self::assertInstanceOf(CTIRelated::class, $related2); + self::assertInstanceOf(CTIChild::class, $related2->getCTIParent()); + self::assertEquals('hello', $related2->getCTIParent()->getData()); - $this->assertSame($related2, $related2->getCTIParent()->getRelated()); + self::assertSame($related2, $related2->getCTIParent()->getRelated()); } public function testManyToManyToCTIHierarchy(): void @@ -89,10 +89,10 @@ public function testManyToManyToCTIHierarchy(): void $this->_em->clear(); $mmrel2 = $this->_em->find(get_class($mmrel), $mmrel->getId()); - $this->assertFalse($mmrel2->getCTIChildren()->isInitialized()); - $this->assertEquals(1, count($mmrel2->getCTIChildren())); - $this->assertTrue($mmrel2->getCTIChildren()->isInitialized()); - $this->assertInstanceOf(CTIChild::class, $mmrel2->getCTIChildren()->get(0)); + self::assertFalse($mmrel2->getCTIChildren()->isInitialized()); + self::assertEquals(1, count($mmrel2->getCTIChildren())); + self::assertTrue($mmrel2->getCTIChildren()->isInitialized()); + self::assertInstanceOf(CTIChild::class, $mmrel2->getCTIChildren()->get(0)); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/ClassTableInheritanceTest.php b/tests/Doctrine/Tests/ORM/Functional/ClassTableInheritanceTest.php index 660a1a02006..4e7c2ace36d 100644 --- a/tests/Doctrine/Tests/ORM/Functional/ClassTableInheritanceTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/ClassTableInheritanceTest.php @@ -58,14 +58,14 @@ public function testCRUD(): void $entities = $query->getResult(); - $this->assertCount(2, $entities); - $this->assertInstanceOf(CompanyPerson::class, $entities[0]); - $this->assertInstanceOf(CompanyEmployee::class, $entities[1]); - $this->assertTrue(is_numeric($entities[0]->getId())); - $this->assertTrue(is_numeric($entities[1]->getId())); - $this->assertEquals('Roman S. Borschel', $entities[0]->getName()); - $this->assertEquals('Guilherme Blanco', $entities[1]->getName()); - $this->assertEquals(100000, $entities[1]->getSalary()); + self::assertCount(2, $entities); + self::assertInstanceOf(CompanyPerson::class, $entities[0]); + self::assertInstanceOf(CompanyEmployee::class, $entities[1]); + self::assertTrue(is_numeric($entities[0]->getId())); + self::assertTrue(is_numeric($entities[1]->getId())); + self::assertEquals('Roman S. Borschel', $entities[0]->getName()); + self::assertEquals('Guilherme Blanco', $entities[1]->getName()); + self::assertEquals(100000, $entities[1]->getSalary()); $this->_em->clear(); @@ -79,7 +79,7 @@ public function testCRUD(): void self::assertCount(1, $entities); self::assertInstanceOf(CompanyEmployee::class, $entities[0]); - $this->assertTrue(is_numeric($entities[0]->getId())); + self::assertTrue(is_numeric($entities[0]->getId())); self::assertEquals('Guilherme Blanco', $entities[0]->getName()); self::assertEquals(100000, $entities[0]->getSalary()); @@ -90,8 +90,8 @@ public function testCRUD(): void $this->_em->clear(); $guilherme = $this->_em->getRepository(get_class($employee))->findOneBy(['name' => 'Guilherme Blanco']); - $this->assertInstanceOf(CompanyEmployee::class, $guilherme); - $this->assertEquals('Guilherme Blanco', $guilherme->getName()); + self::assertInstanceOf(CompanyEmployee::class, $guilherme); + self::assertEquals('Guilherme Blanco', $guilherme->getName()); $this->_em->clear(); @@ -101,11 +101,11 @@ public function testCRUD(): void $query->setParameter(3, 100000); $query->getSQL(); $numUpdated = $query->execute(); - $this->assertEquals(1, $numUpdated); + self::assertEquals(1, $numUpdated); $query = $this->_em->createQuery('delete from ' . CompanyPerson::class . ' p'); $numDeleted = $query->execute(); - $this->assertEquals(2, $numDeleted); + self::assertEquals(2, $numDeleted); } public function testMultiLevelUpdateAndFind(): void @@ -128,11 +128,11 @@ public function testMultiLevelUpdateAndFind(): void $manager = $this->_em->find(CompanyManager::class, $manager->getId()); - $this->assertInstanceOf(CompanyManager::class, $manager); - $this->assertEquals('Roman B.', $manager->getName()); - $this->assertEquals(119000, $manager->getSalary()); - $this->assertEquals('CEO', $manager->getTitle()); - $this->assertTrue(is_numeric($manager->getId())); + self::assertInstanceOf(CompanyManager::class, $manager); + self::assertEquals('Roman B.', $manager->getName()); + self::assertEquals(119000, $manager->getSalary()); + self::assertEquals('CEO', $manager->getTitle()); + self::assertTrue(is_numeric($manager->getId())); } public function testFindOnBaseClass(): void @@ -149,11 +149,11 @@ public function testFindOnBaseClass(): void $person = $this->_em->find(CompanyPerson::class, $manager->getId()); - $this->assertInstanceOf(CompanyManager::class, $person); - $this->assertEquals('Roman S. Borschel', $person->getName()); - $this->assertEquals(100000, $person->getSalary()); - $this->assertEquals('CTO', $person->getTitle()); - $this->assertTrue(is_numeric($person->getId())); + self::assertInstanceOf(CompanyManager::class, $person); + self::assertEquals('Roman S. Borschel', $person->getName()); + self::assertEquals(100000, $person->getSalary()); + self::assertEquals('CTO', $person->getTitle()); + self::assertTrue(is_numeric($person->getId())); } public function testSelfReferencingOneToOne(): void @@ -168,8 +168,8 @@ public function testSelfReferencingOneToOne(): void $wife->setName('Mary Smith'); $wife->setSpouse($manager); - $this->assertSame($manager, $wife->getSpouse()); - $this->assertSame($wife, $manager->getSpouse()); + self::assertSame($manager, $wife->getSpouse()); + self::assertSame($wife, $manager->getSpouse()); $this->_em->persist($manager); $this->_em->persist($wife); @@ -179,12 +179,12 @@ public function testSelfReferencingOneToOne(): void $query = $this->_em->createQuery('select p, s from ' . CompanyPerson::class . ' p join p.spouse s where p.name=\'Mary Smith\''); $result = $query->getResult(); - $this->assertCount(1, $result); - $this->assertInstanceOf(CompanyPerson::class, $result[0]); - $this->assertEquals('Mary Smith', $result[0]->getName()); - $this->assertInstanceOf(CompanyEmployee::class, $result[0]->getSpouse()); - $this->assertEquals('John Smith', $result[0]->getSpouse()->getName()); - $this->assertSame($result[0], $result[0]->getSpouse()->getSpouse()); + self::assertCount(1, $result); + self::assertInstanceOf(CompanyPerson::class, $result[0]); + self::assertEquals('Mary Smith', $result[0]->getName()); + self::assertInstanceOf(CompanyEmployee::class, $result[0]->getSpouse()); + self::assertEquals('John Smith', $result[0]->getSpouse()->getName()); + self::assertSame($result[0], $result[0]->getSpouse()->getSpouse()); $this->_em->clear(); @@ -201,8 +201,8 @@ public function testSelfReferencingManyToMany(): void $person1->addFriend($person2); - $this->assertCount(1, $person1->getFriends()); - $this->assertCount(1, $person2->getFriends()); + self::assertCount(1, $person1->getFriends()); + self::assertCount(1, $person2->getFriends()); $this->_em->persist($person1); $this->_em->persist($person2); @@ -215,12 +215,12 @@ public function testSelfReferencingManyToMany(): void $query->setParameter(1, 'Roman'); $result = $query->getResult(); - $this->assertCount(1, $result); - $this->assertCount(1, $result[0]->getFriends()); - $this->assertEquals('Roman', $result[0]->getName()); + self::assertCount(1, $result); + self::assertCount(1, $result[0]->getFriends()); + self::assertEquals('Roman', $result[0]->getName()); $friends = $result[0]->getFriends(); - $this->assertEquals('Jonathan', $friends[0]->getName()); + self::assertEquals('Jonathan', $friends[0]->getName()); } public function testLazyLoading1(): void @@ -244,21 +244,21 @@ public function testLazyLoading1(): void $result = $q->getResult(); - $this->assertCount(1, $result); - $this->assertInstanceOf(CompanyOrganization::class, $result[0]); - $this->assertNull($result[0]->getMainEvent()); + self::assertCount(1, $result); + self::assertInstanceOf(CompanyOrganization::class, $result[0]); + self::assertNull($result[0]->getMainEvent()); $events = $result[0]->getEvents(); - $this->assertInstanceOf(PersistentCollection::class, $events); - $this->assertFalse($events->isInitialized()); + self::assertInstanceOf(PersistentCollection::class, $events); + self::assertFalse($events->isInitialized()); - $this->assertCount(2, $events); + self::assertCount(2, $events); if ($events[0] instanceof CompanyAuction) { - $this->assertInstanceOf(CompanyRaffle::class, $events[1]); + self::assertInstanceOf(CompanyRaffle::class, $events[1]); } else { - $this->assertInstanceOf(CompanyRaffle::class, $events[0]); - $this->assertInstanceOf(CompanyAuction::class, $events[1]); + self::assertInstanceOf(CompanyRaffle::class, $events[0]); + self::assertInstanceOf(CompanyAuction::class, $events[1]); } $this->_em->clear(); @@ -281,8 +281,8 @@ public function testLazyLoading2(): void $q->setParameter(1, $event1->getId()); $result = $q->getResult(); - $this->assertCount(1, $result); - $this->assertInstanceOf(CompanyAuction::class, $result[0], sprintf('Is of class %s', get_class($result[0]))); + self::assertCount(1, $result); + self::assertInstanceOf(CompanyAuction::class, $result[0], sprintf('Is of class %s', get_class($result[0]))); $this->_em->clear(); @@ -295,13 +295,13 @@ public function testLazyLoading2(): void $result = $q->getResult(); - $this->assertCount(1, $result); - $this->assertInstanceOf(CompanyOrganization::class, $result[0]); + self::assertCount(1, $result); + self::assertInstanceOf(CompanyOrganization::class, $result[0]); $mainEvent = $result[0]->getMainEvent(); // mainEvent should have been loaded because it can't be lazy - $this->assertInstanceOf(CompanyAuction::class, $mainEvent); - $this->assertNotInstanceOf(Proxy::class, $mainEvent); + self::assertInstanceOf(CompanyAuction::class, $mainEvent); + self::assertNotInstanceOf(Proxy::class, $mainEvent); $this->_em->clear(); @@ -319,7 +319,7 @@ public function testBulkUpdateIssueDDC368(): void $query = $this->_em->createQuery('SELECT count(p.id) FROM ' . CompanyEmployee::class . ' p WHERE p.salary = 1'); $result = $query->getResult(); - $this->assertGreaterThan(0, count($result)); + self::assertGreaterThan(0, count($result)); $this->_em->clear(); @@ -365,7 +365,7 @@ public function testDeleteJoinTableRecords(): void $this->_em->remove($employee1); $this->_em->flush(); - $this->assertNull($this->_em->find(get_class($employee1), $employee1Id)); + self::assertNull($this->_em->find(get_class($employee1), $employee1Id)); } /** @@ -393,8 +393,8 @@ public function testQueryForInheritedSingleValuedAssociation(): void ->setParameter(1, $person->getId()) ->getSingleResult(); - $this->assertEquals($manager->getId(), $dqlManager->getId()); - $this->assertEquals($person->getId(), $dqlManager->getSpouse()->getId()); + self::assertEquals($manager->getId(), $dqlManager->getId()); + self::assertEquals($person->getId(), $dqlManager->getSpouse()->getId()); } /** @@ -421,12 +421,12 @@ public function testFindByAssociation(): void $repos = $this->_em->getRepository(CompanyManager::class); $pmanager = $repos->findOneBy(['spouse' => $person->getId()]); - $this->assertEquals($manager->getId(), $pmanager->getId()); + self::assertEquals($manager->getId(), $pmanager->getId()); $repos = $this->_em->getRepository(CompanyPerson::class); $pmanager = $repos->findOneBy(['spouse' => $person->getId()]); - $this->assertEquals($manager->getId(), $pmanager->getId()); + self::assertEquals($manager->getId(), $pmanager->getId()); } /** @@ -445,13 +445,13 @@ public function testGetReferenceEntityWithSubclasses(): void $this->_em->clear(); $ref = $this->_em->getReference(CompanyPerson::class, $manager->getId()); - $this->assertNotInstanceOf(Proxy::class, $ref, 'Cannot Request a proxy from a class that has subclasses.'); - $this->assertInstanceOf(CompanyPerson::class, $ref); - $this->assertInstanceOf(CompanyEmployee::class, $ref, 'Direct fetch of the reference has to load the child class Employee directly.'); + self::assertNotInstanceOf(Proxy::class, $ref, 'Cannot Request a proxy from a class that has subclasses.'); + self::assertInstanceOf(CompanyPerson::class, $ref); + self::assertInstanceOf(CompanyEmployee::class, $ref, 'Direct fetch of the reference has to load the child class Employee directly.'); $this->_em->clear(); $ref = $this->_em->getReference(CompanyManager::class, $manager->getId()); - $this->assertInstanceOf(Proxy::class, $ref, 'A proxy can be generated only if no subclasses exists for the requested reference.'); + self::assertInstanceOf(Proxy::class, $ref, 'A proxy can be generated only if no subclasses exists for the requested reference.'); } /** @@ -477,7 +477,7 @@ public function testGetSubClassManyToManyCollection(): void $manager = $this->_em->find(CompanyManager::class, $manager->getId()); - $this->assertCount(1, $manager->getFriends()); + self::assertCount(1, $manager->getFriends()); } /** @@ -491,12 +491,12 @@ public function testExistsSubclass(): void $manager->setTitle('Awesome!'); $manager->setDepartment('IT'); - $this->assertFalse($this->_em->getUnitOfWork()->getEntityPersister(get_class($manager))->exists($manager)); + self::assertFalse($this->_em->getUnitOfWork()->getEntityPersister(get_class($manager))->exists($manager)); $this->_em->persist($manager); $this->_em->flush(); - $this->assertTrue($this->_em->getUnitOfWork()->getEntityPersister(get_class($manager))->exists($manager)); + self::assertTrue($this->_em->getUnitOfWork()->getEntityPersister(get_class($manager))->exists($manager)); } /** @@ -517,12 +517,12 @@ public function testMatching(): void $users = $repository->matching(new Criteria( Criteria::expr()->eq('department', 'IT') )); - $this->assertCount(1, $users); + self::assertCount(1, $users); $repository = $this->_em->getRepository(CompanyManager::class); $users = $repository->matching(new Criteria( Criteria::expr()->eq('department', 'IT') )); - $this->assertCount(1, $users); + self::assertCount(1, $users); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/ClearEventTest.php b/tests/Doctrine/Tests/ORM/Functional/ClearEventTest.php index 41eda5658ab..ff6880853a4 100644 --- a/tests/Doctrine/Tests/ORM/Functional/ClearEventTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/ClearEventTest.php @@ -20,7 +20,7 @@ public function testEventIsCalledOnClear(): void $this->_em->clear(); - $this->assertTrue($listener->called); + self::assertTrue($listener->called); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/CompositePrimaryKeyTest.php b/tests/Doctrine/Tests/ORM/Functional/CompositePrimaryKeyTest.php index 53740b304a7..1bd16890d0a 100644 --- a/tests/Doctrine/Tests/ORM/Functional/CompositePrimaryKeyTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/CompositePrimaryKeyTest.php @@ -55,10 +55,10 @@ public function testPersistCompositePkEntity(): void $poi = $this->_em->find(NavPointOfInterest::class, ['lat' => 100, 'long' => 200]); - $this->assertInstanceOf(NavPointOfInterest::class, $poi); - $this->assertEquals(100, $poi->getLat()); - $this->assertEquals(200, $poi->getLong()); - $this->assertEquals('Brandenburger Tor', $poi->getName()); + self::assertInstanceOf(NavPointOfInterest::class, $poi); + self::assertEquals(100, $poi->getLat()); + self::assertEquals(200, $poi->getLong()); + self::assertEquals('Brandenburger Tor', $poi->getName()); } /** @@ -96,9 +96,9 @@ public function testIdentityFunctionWithCompositePrimaryKey(): void $query = $this->_em->createQuery($dql); $result = $query->getResult(); - $this->assertCount(1, $result); - $this->assertEquals(200, $result[0]['long']); - $this->assertEquals(100, $result[0]['lat']); + self::assertCount(1, $result); + self::assertEquals(200, $result[0]['long']); + self::assertEquals(100, $result[0]['lat']); $this->_em->clear(); @@ -112,7 +112,7 @@ public function testManyToManyCompositeRelation(): void $tour = $this->_em->find(NavTour::class, $tour->getId()); - $this->assertEquals(1, count($tour->getPointOfInterests())); + self::assertEquals(1, count($tour->getPointOfInterests())); } public function testCompositeDqlEagerFetching(): void @@ -131,13 +131,13 @@ public function testCompositeDqlEagerFetching(): void $pois = $tours[0]->getPointOfInterests(); - $this->assertEquals(1, count($pois)); - $this->assertEquals('Brandenburger Tor', $pois[0]->getName()); + self::assertEquals(1, count($pois)); + self::assertEquals('Brandenburger Tor', $pois[0]->getName()); } public function testCompositeCollectionMemberExpression(): void { - $this->markTestSkipped('How to test this?'); + self::markTestSkipped('How to test this?'); $this->putGermanysBrandenburderTor(); $this->putTripAroundEurope(); @@ -147,7 +147,7 @@ public function testCompositeCollectionMemberExpression(): void $tours = $this->_em->createQuery($dql) ->getResult(); - $this->assertEquals(1, count($tours)); + self::assertEquals(1, count($tours)); $this->_em->clear(); @@ -189,6 +189,6 @@ public function testDeleteCompositePersistentCollection(): void $this->_em->clear(); $poi = $this->_em->find(NavPointOfInterest::class, ['lat' => 100, 'long' => 200]); - $this->assertEquals(0, count($poi->getVisitors())); + self::assertEquals(0, count($poi->getVisitors())); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/CompositePrimaryKeyWithAssociationsTest.php b/tests/Doctrine/Tests/ORM/Functional/CompositePrimaryKeyWithAssociationsTest.php index 9a14da279e6..d143f97c6d2 100644 --- a/tests/Doctrine/Tests/ORM/Functional/CompositePrimaryKeyWithAssociationsTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/CompositePrimaryKeyWithAssociationsTest.php @@ -49,15 +49,15 @@ public function testFindByAbleToGetCompositeEntitiesWithMixedTypeIdentifiers(): $admin1Rome = $admin1Repo->findOneBy(['country' => 'IT', 'id' => 1]); $names = $admin1NamesRepo->findBy(['admin1' => $admin1Rome]); - $this->assertCount(2, $names); + self::assertCount(2, $names); $name1 = $admin1NamesRepo->findOneBy(['admin1' => $admin1Rome, 'id' => 1]); $name2 = $admin1NamesRepo->findOneBy(['admin1' => $admin1Rome, 'id' => 2]); - $this->assertEquals(1, $name1->id); - $this->assertEquals('Roma', $name1->name); + self::assertEquals(1, $name1->id); + self::assertEquals('Roma', $name1->name); - $this->assertEquals(2, $name2->id); - $this->assertEquals('Rome', $name2->name); + self::assertEquals(2, $name2->id); + self::assertEquals('Rome', $name2->name); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/CustomFunctionsTest.php b/tests/Doctrine/Tests/ORM/Functional/CustomFunctionsTest.php index 674da3cf899..11bde255131 100644 --- a/tests/Doctrine/Tests/ORM/Functional/CustomFunctionsTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/CustomFunctionsTest.php @@ -48,8 +48,8 @@ public function testCustomFunctionDefinedWithCallback(): void $users = $query->getResult(); - $this->assertEquals(1, count($users)); - $this->assertSame($user, $users[0]); + self::assertEquals(1, count($users)); + self::assertSame($user, $users[0]); } public function testCustomFunctionOverride(): void @@ -66,7 +66,7 @@ public function testCustomFunctionOverride(): void $usersCount = $query->getSingleScalarResult(); - $this->assertEquals(1, $usersCount); + self::assertEquals(1, $usersCount); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/CustomIdObjectTypeTest.php b/tests/Doctrine/Tests/ORM/Functional/CustomIdObjectTypeTest.php index 5ecf7448072..7cc731b81b5 100644 --- a/tests/Doctrine/Tests/ORM/Functional/CustomIdObjectTypeTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/CustomIdObjectTypeTest.php @@ -35,7 +35,7 @@ public function testFindByCustomIdObject(): void $result = $this->_em->find(CustomIdObjectTypeParent::class, $parent->id); - $this->assertSame($parent, $result); + self::assertSame($parent, $result); } /** @@ -60,8 +60,8 @@ public function testFetchJoinCustomIdObject(): void ) ->getResult(); - $this->assertCount(1, $result); - $this->assertSame($parent, $result[0]); + self::assertCount(1, $result); + self::assertSame($parent, $result[0]); } /** @@ -89,7 +89,7 @@ public function testFetchJoinWhereCustomIdObject(): void ->setParameter(1, $parent->children->first()->id) ->getResult(); - $this->assertCount(1, $result); - $this->assertSame($parent, $result[0]); + self::assertCount(1, $result); + self::assertSame($parent, $result[0]); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/DatabaseDriverTest.php b/tests/Doctrine/Tests/ORM/Functional/DatabaseDriverTest.php index 4115db466d4..78ffda293ea 100644 --- a/tests/Doctrine/Tests/ORM/Functional/DatabaseDriverTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/DatabaseDriverTest.php @@ -35,7 +35,7 @@ protected function setUp(): void public function testIssue2059(): void { if (! $this->_em->getConnection()->getDatabasePlatform()->supportsForeignKeyConstraints()) { - $this->markTestSkipped('Platform does not support foreign keys.'); + self::markTestSkipped('Platform does not support foreign keys.'); } $user = new Table('ddc2059_user'); @@ -50,14 +50,14 @@ public function testIssue2059(): void $metadata = $this->convertToClassMetadata([$project, $user], []); - $this->assertTrue(isset($metadata['Ddc2059Project']->fieldMappings['user'])); - $this->assertTrue(isset($metadata['Ddc2059Project']->associationMappings['user2'])); + self::assertTrue(isset($metadata['Ddc2059Project']->fieldMappings['user'])); + self::assertTrue(isset($metadata['Ddc2059Project']->associationMappings['user2'])); } public function testLoadMetadataFromDatabase(): void { if (! $this->_em->getConnection()->getDatabasePlatform()->supportsForeignKeyConstraints()) { - $this->markTestSkipped('Platform does not support foreign keys.'); + self::markTestSkipped('Platform does not support foreign keys.'); } $table = new Table('dbdriver_foo'); @@ -69,26 +69,26 @@ public function testLoadMetadataFromDatabase(): void $metadatas = $this->extractClassMetadata(['DbdriverFoo']); - $this->assertArrayHasKey('DbdriverFoo', $metadatas); + self::assertArrayHasKey('DbdriverFoo', $metadatas); $metadata = $metadatas['DbdriverFoo']; - $this->assertArrayHasKey('id', $metadata->fieldMappings); - $this->assertEquals('id', $metadata->fieldMappings['id']['fieldName']); - $this->assertEquals('id', strtolower($metadata->fieldMappings['id']['columnName'])); - $this->assertEquals('integer', (string) $metadata->fieldMappings['id']['type']); - - $this->assertArrayHasKey('bar', $metadata->fieldMappings); - $this->assertEquals('bar', $metadata->fieldMappings['bar']['fieldName']); - $this->assertEquals('bar', strtolower($metadata->fieldMappings['bar']['columnName'])); - $this->assertEquals('string', (string) $metadata->fieldMappings['bar']['type']); - $this->assertEquals(200, $metadata->fieldMappings['bar']['length']); - $this->assertTrue($metadata->fieldMappings['bar']['nullable']); + self::assertArrayHasKey('id', $metadata->fieldMappings); + self::assertEquals('id', $metadata->fieldMappings['id']['fieldName']); + self::assertEquals('id', strtolower($metadata->fieldMappings['id']['columnName'])); + self::assertEquals('integer', (string) $metadata->fieldMappings['id']['type']); + + self::assertArrayHasKey('bar', $metadata->fieldMappings); + self::assertEquals('bar', $metadata->fieldMappings['bar']['fieldName']); + self::assertEquals('bar', strtolower($metadata->fieldMappings['bar']['columnName'])); + self::assertEquals('string', (string) $metadata->fieldMappings['bar']['type']); + self::assertEquals(200, $metadata->fieldMappings['bar']['length']); + self::assertTrue($metadata->fieldMappings['bar']['nullable']); } public function testLoadMetadataWithForeignKeyFromDatabase(): void { if (! $this->_em->getConnection()->getDatabasePlatform()->supportsForeignKeyConstraints()) { - $this->markTestSkipped('Platform does not support foreign keys.'); + self::markTestSkipped('Platform does not support foreign keys.'); } $tableB = new Table('dbdriver_bar'); @@ -107,36 +107,36 @@ public function testLoadMetadataWithForeignKeyFromDatabase(): void $metadatas = $this->extractClassMetadata(['DbdriverBar', 'DbdriverBaz']); - $this->assertArrayHasKey('DbdriverBaz', $metadatas); + self::assertArrayHasKey('DbdriverBaz', $metadatas); $bazMetadata = $metadatas['DbdriverBaz']; - $this->assertArrayNotHasKey('barId', $bazMetadata->fieldMappings, "The foreign Key field should not be inflected as 'barId' field, its an association."); - $this->assertArrayHasKey('id', $bazMetadata->fieldMappings); + self::assertArrayNotHasKey('barId', $bazMetadata->fieldMappings, "The foreign Key field should not be inflected as 'barId' field, its an association."); + self::assertArrayHasKey('id', $bazMetadata->fieldMappings); $bazMetadata->associationMappings = array_change_key_case($bazMetadata->associationMappings, CASE_LOWER); - $this->assertArrayHasKey('bar', $bazMetadata->associationMappings); - $this->assertEquals(ClassMetadataInfo::MANY_TO_ONE, $bazMetadata->associationMappings['bar']['type']); + self::assertArrayHasKey('bar', $bazMetadata->associationMappings); + self::assertEquals(ClassMetadataInfo::MANY_TO_ONE, $bazMetadata->associationMappings['bar']['type']); } public function testDetectManyToManyTables(): void { if (! $this->_em->getConnection()->getDatabasePlatform()->supportsForeignKeyConstraints()) { - $this->markTestSkipped('Platform does not support foreign keys.'); + self::markTestSkipped('Platform does not support foreign keys.'); } $metadatas = $this->extractClassMetadata(['CmsUsers', 'CmsGroups', 'CmsTags']); - $this->assertArrayHasKey('CmsUsers', $metadatas, 'CmsUsers entity was not detected.'); - $this->assertArrayHasKey('CmsGroups', $metadatas, 'CmsGroups entity was not detected.'); - $this->assertArrayHasKey('CmsTags', $metadatas, 'CmsTags entity was not detected.'); + self::assertArrayHasKey('CmsUsers', $metadatas, 'CmsUsers entity was not detected.'); + self::assertArrayHasKey('CmsGroups', $metadatas, 'CmsGroups entity was not detected.'); + self::assertArrayHasKey('CmsTags', $metadatas, 'CmsTags entity was not detected.'); - $this->assertEquals(3, count($metadatas['CmsUsers']->associationMappings)); - $this->assertArrayHasKey('group', $metadatas['CmsUsers']->associationMappings); - $this->assertEquals(1, count($metadatas['CmsGroups']->associationMappings)); - $this->assertArrayHasKey('user', $metadatas['CmsGroups']->associationMappings); - $this->assertEquals(1, count($metadatas['CmsTags']->associationMappings)); - $this->assertArrayHasKey('user', $metadatas['CmsGroups']->associationMappings); + self::assertEquals(3, count($metadatas['CmsUsers']->associationMappings)); + self::assertArrayHasKey('group', $metadatas['CmsUsers']->associationMappings); + self::assertEquals(1, count($metadatas['CmsGroups']->associationMappings)); + self::assertArrayHasKey('user', $metadatas['CmsGroups']->associationMappings); + self::assertEquals(1, count($metadatas['CmsTags']->associationMappings)); + self::assertArrayHasKey('user', $metadatas['CmsGroups']->associationMappings); } public function testIgnoreManyToManyTableWithoutFurtherForeignKeyDetails(): void @@ -156,13 +156,13 @@ public function testIgnoreManyToManyTableWithoutFurtherForeignKeyDetails(): void $metadatas = $this->convertToClassMetadata([$tableA, $tableB], [$tableMany]); - $this->assertEquals(0, count($metadatas['DbdriverBaz']->associationMappings), 'no association mappings should be detected.'); + self::assertEquals(0, count($metadatas['DbdriverBaz']->associationMappings), 'no association mappings should be detected.'); } public function testLoadMetadataFromDatabaseDetail(): void { if (! $this->_em->getConnection()->getDatabasePlatform()->supportsForeignKeyConstraints()) { - $this->markTestSkipped('Platform does not support foreign keys.'); + self::markTestSkipped('Platform does not support foreign keys.'); } $table = new Table('dbdriver_foo'); @@ -186,14 +186,14 @@ public function testLoadMetadataFromDatabaseDetail(): void $metadatas = $this->extractClassMetadata(['DbdriverFoo']); - $this->assertArrayHasKey('DbdriverFoo', $metadatas); + self::assertArrayHasKey('DbdriverFoo', $metadatas); $metadata = $metadatas['DbdriverFoo']; - $this->assertArrayHasKey('id', $metadata->fieldMappings); - $this->assertEquals('id', $metadata->fieldMappings['id']['fieldName']); - $this->assertEquals('id', strtolower($metadata->fieldMappings['id']['columnName'])); - $this->assertEquals('integer', (string) $metadata->fieldMappings['id']['type']); + self::assertArrayHasKey('id', $metadata->fieldMappings); + self::assertEquals('id', $metadata->fieldMappings['id']['fieldName']); + self::assertEquals('id', strtolower($metadata->fieldMappings['id']['columnName'])); + self::assertEquals('integer', (string) $metadata->fieldMappings['id']['type']); // FIXME: Condition here is fugly. // NOTE: PostgreSQL and SQL SERVER do not support UNSIGNED integer @@ -201,28 +201,28 @@ public function testLoadMetadataFromDatabaseDetail(): void ! $this->_em->getConnection()->getDatabasePlatform() instanceof PostgreSqlPlatform && ! $this->_em->getConnection()->getDatabasePlatform() instanceof SQLServerPlatform ) { - $this->assertArrayHasKey('columnUnsigned', $metadata->fieldMappings); - $this->assertTrue($metadata->fieldMappings['columnUnsigned']['options']['unsigned']); + self::assertArrayHasKey('columnUnsigned', $metadata->fieldMappings); + self::assertTrue($metadata->fieldMappings['columnUnsigned']['options']['unsigned']); } - $this->assertArrayHasKey('columnComment', $metadata->fieldMappings); - $this->assertEquals('test_comment', $metadata->fieldMappings['columnComment']['options']['comment']); + self::assertArrayHasKey('columnComment', $metadata->fieldMappings); + self::assertEquals('test_comment', $metadata->fieldMappings['columnComment']['options']['comment']); - $this->assertArrayHasKey('columnDefault', $metadata->fieldMappings); - $this->assertEquals('test_default', $metadata->fieldMappings['columnDefault']['options']['default']); + self::assertArrayHasKey('columnDefault', $metadata->fieldMappings); + self::assertEquals('test_default', $metadata->fieldMappings['columnDefault']['options']['default']); - $this->assertArrayHasKey('columnDecimal', $metadata->fieldMappings); - $this->assertEquals(4, $metadata->fieldMappings['columnDecimal']['precision']); - $this->assertEquals(3, $metadata->fieldMappings['columnDecimal']['scale']); + self::assertArrayHasKey('columnDecimal', $metadata->fieldMappings); + self::assertEquals(4, $metadata->fieldMappings['columnDecimal']['precision']); + self::assertEquals(3, $metadata->fieldMappings['columnDecimal']['scale']); - $this->assertTrue(! empty($metadata->table['indexes']['index1']['columns'])); - $this->assertEquals( + self::assertTrue(! empty($metadata->table['indexes']['index1']['columns'])); + self::assertEquals( ['column_index1', 'column_index2'], $metadata->table['indexes']['index1']['columns'] ); - $this->assertTrue(! empty($metadata->table['uniqueConstraints']['unique_index1']['columns'])); - $this->assertEquals( + self::assertTrue(! empty($metadata->table['uniqueConstraints']['unique_index1']['columns'])); + self::assertEquals( ['column_unique_index1', 'column_unique_index2'], $metadata->table['uniqueConstraints']['unique_index1']['columns'] ); diff --git a/tests/Doctrine/Tests/ORM/Functional/DatabaseDriverTestCase.php b/tests/Doctrine/Tests/ORM/Functional/DatabaseDriverTestCase.php index bd8a44cbcb8..3e55ae9c179 100644 --- a/tests/Doctrine/Tests/ORM/Functional/DatabaseDriverTestCase.php +++ b/tests/Doctrine/Tests/ORM/Functional/DatabaseDriverTestCase.php @@ -63,7 +63,7 @@ protected function extractClassMetadata(array $classNames): array } if (count($metadatas) !== count($classNames)) { - $this->fail("Have not found all classes matching the names '" . implode(', ', $classNames) . "' only tables " . implode(', ', array_keys($metadatas))); + self::fail("Have not found all classes matching the names '" . implode(', ', $classNames) . "' only tables " . implode(', ', array_keys($metadatas))); } return $metadatas; diff --git a/tests/Doctrine/Tests/ORM/Functional/DefaultValuesTest.php b/tests/Doctrine/Tests/ORM/Functional/DefaultValuesTest.php index 26f474b1846..d2fd2794427 100644 --- a/tests/Doctrine/Tests/ORM/Functional/DefaultValuesTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/DefaultValuesTest.php @@ -51,7 +51,7 @@ public function testSimpleDetachMerge(): void $user2 = $this->_em->getReference(get_class($user), $userId); $this->_em->flush(); - $this->assertFalse($user2->__isInitialized__); + self::assertFalse($user2->__isInitialized__); $a = new DefaultValueAddress(); $a->country = 'de'; @@ -63,13 +63,13 @@ public function testSimpleDetachMerge(): void $this->_em->persist($a); $this->_em->flush(); - $this->assertFalse($user2->__isInitialized__); + self::assertFalse($user2->__isInitialized__); $this->_em->clear(); $a2 = $this->_em->find(get_class($a), $a->id); - $this->assertInstanceOf(DefaultValueUser::class, $a2->getUser()); - $this->assertEquals($userId, $a2->getUser()->getId()); - $this->assertEquals('Poweruser', $a2->getUser()->type); + self::assertInstanceOf(DefaultValueUser::class, $a2->getUser()); + self::assertEquals($userId, $a2->getUser()->getId()); + self::assertEquals('Poweruser', $a2->getUser()->type); } /** @@ -86,14 +86,14 @@ public function testGetPartialReferenceWithDefaultValueNotEvaluatedInFlush(): vo $this->_em->clear(); $user = $this->_em->getPartialReference(DefaultValueUser::class, $user->id); - $this->assertTrue($this->_em->getUnitOfWork()->isReadOnly($user)); + self::assertTrue($this->_em->getUnitOfWork()->isReadOnly($user)); $this->_em->flush(); $this->_em->clear(); $user = $this->_em->find(DefaultValueUser::class, $user->id); - $this->assertEquals('Normaluser', $user->type); + self::assertEquals('Normaluser', $user->type); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/DetachedEntityTest.php b/tests/Doctrine/Tests/ORM/Functional/DetachedEntityTest.php index 03e9fcff7fa..a34c109fb58 100644 --- a/tests/Doctrine/Tests/ORM/Functional/DetachedEntityTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/DetachedEntityTest.php @@ -40,15 +40,15 @@ public function testSimpleDetachMerge(): void $this->_em->clear(); // $user is now detached - $this->assertFalse($this->_em->contains($user)); + self::assertFalse($this->_em->contains($user)); $user->name = 'Roman B.'; $user2 = $this->_em->merge($user); - $this->assertFalse($user === $user2); - $this->assertTrue($this->_em->contains($user2)); - $this->assertEquals('Roman B.', $user2->name); + self::assertFalse($user === $user2); + self::assertTrue($this->_em->contains($user2)); + self::assertEquals('Roman B.', $user2->name); } public function testSerializeUnserializeModifyMerge(): void @@ -65,20 +65,20 @@ public function testSerializeUnserializeModifyMerge(): void $this->_em->persist($user); $this->_em->flush(); - $this->assertTrue($this->_em->contains($user)); - $this->assertTrue($user->phonenumbers->isInitialized()); + self::assertTrue($this->_em->contains($user)); + self::assertTrue($user->phonenumbers->isInitialized()); $serialized = serialize($user); $this->_em->clear(); - $this->assertFalse($this->_em->contains($user)); + self::assertFalse($this->_em->contains($user)); unset($user); $user = unserialize($serialized); - $this->assertEquals(1, count($user->getPhonenumbers()), 'Pre-Condition: 1 Phonenumber'); + self::assertEquals(1, count($user->getPhonenumbers()), 'Pre-Condition: 1 Phonenumber'); $ph2 = new CmsPhonenumber(); @@ -87,29 +87,29 @@ public function testSerializeUnserializeModifyMerge(): void $oldPhonenumbers = $user->getPhonenumbers(); - $this->assertEquals(2, count($oldPhonenumbers), 'Pre-Condition: 2 Phonenumbers'); - $this->assertFalse($this->_em->contains($user)); + self::assertEquals(2, count($oldPhonenumbers), 'Pre-Condition: 2 Phonenumbers'); + self::assertFalse($this->_em->contains($user)); $this->_em->persist($ph2); // Merge back in $user = $this->_em->merge($user); // merge cascaded to phonenumbers - $this->assertInstanceOf(CmsUser::class, $user->phonenumbers[0]->user); - $this->assertInstanceOf(CmsUser::class, $user->phonenumbers[1]->user); + self::assertInstanceOf(CmsUser::class, $user->phonenumbers[0]->user); + self::assertInstanceOf(CmsUser::class, $user->phonenumbers[1]->user); $im = $this->_em->getUnitOfWork()->getIdentityMap(); $this->_em->flush(); - $this->assertTrue($this->_em->contains($user), 'Failed to assert that merged user is contained inside EntityManager persistence context.'); + self::assertTrue($this->_em->contains($user), 'Failed to assert that merged user is contained inside EntityManager persistence context.'); $phonenumbers = $user->getPhonenumbers(); - $this->assertNotSame($oldPhonenumbers, $phonenumbers, 'Merge should replace the Detached Collection with a new PersistentCollection.'); - $this->assertEquals(2, count($phonenumbers), 'Failed to assert that two phonenumbers are contained in the merged users phonenumber collection.'); + self::assertNotSame($oldPhonenumbers, $phonenumbers, 'Merge should replace the Detached Collection with a new PersistentCollection.'); + self::assertEquals(2, count($phonenumbers), 'Failed to assert that two phonenumbers are contained in the merged users phonenumber collection.'); - $this->assertInstanceOf(CmsPhonenumber::class, $phonenumbers[1]); - $this->assertTrue($this->_em->contains($phonenumbers[1]), 'Failed to assert that second phonenumber in collection is contained inside EntityManager persistence context.'); + self::assertInstanceOf(CmsPhonenumber::class, $phonenumbers[1]); + self::assertTrue($this->_em->contains($phonenumbers[1]), 'Failed to assert that second phonenumber in collection is contained inside EntityManager persistence context.'); - $this->assertInstanceOf(CmsPhonenumber::class, $phonenumbers[0]); - $this->assertTrue($this->_em->getUnitOfWork()->isInIdentityMap($phonenumbers[0])); - $this->assertTrue($this->_em->contains($phonenumbers[0]), 'Failed to assert that first phonenumber in collection is contained inside EntityManager persistence context.'); + self::assertInstanceOf(CmsPhonenumber::class, $phonenumbers[0]); + self::assertTrue($this->_em->getUnitOfWork()->isInIdentityMap($phonenumbers[0])); + self::assertTrue($this->_em->contains($phonenumbers[0]), 'Failed to assert that first phonenumber in collection is contained inside EntityManager persistence context.'); } /** @@ -151,16 +151,16 @@ public function testUninitializedLazyAssociationsAreIgnoredOnMerge(): void $this->_em->clear(); $address2 = $this->_em->find(get_class($address), $address->id); - $this->assertInstanceOf(Proxy::class, $address2->user); - $this->assertFalse($address2->user->__isInitialized__); + self::assertInstanceOf(Proxy::class, $address2->user); + self::assertFalse($address2->user->__isInitialized__); $detachedAddress2 = unserialize(serialize($address2)); - $this->assertInstanceOf(Proxy::class, $detachedAddress2->user); - $this->assertFalse($detachedAddress2->user->__isInitialized__); + self::assertInstanceOf(Proxy::class, $detachedAddress2->user); + self::assertFalse($detachedAddress2->user->__isInitialized__); $managedAddress2 = $this->_em->merge($detachedAddress2); - $this->assertInstanceOf(Proxy::class, $managedAddress2->user); - $this->assertFalse($managedAddress2->user === $detachedAddress2->user); - $this->assertFalse($managedAddress2->user->__isInitialized__); + self::assertInstanceOf(Proxy::class, $managedAddress2->user); + self::assertFalse($managedAddress2->user === $detachedAddress2->user); + self::assertFalse($managedAddress2->user->__isInitialized__); } /** @@ -184,8 +184,8 @@ public function testUseDetachedEntityAsQueryParameter(): void $newUser = $query->getSingleResult(); - $this->assertInstanceOf(CmsUser::class, $newUser); - $this->assertEquals('gblanco', $newUser->username); + self::assertInstanceOf(CmsUser::class, $newUser); + self::assertEquals('gblanco', $newUser->username); } /** @@ -203,8 +203,8 @@ public function testDetachManagedUnpersistedEntity(): void $this->_em->flush(); - $this->assertFalse($this->_em->contains($user)); - $this->assertFalse($this->_em->getUnitOfWork()->isInIdentityMap($user)); + self::assertFalse($this->_em->contains($user)); + self::assertFalse($this->_em->getUnitOfWork()->isInIdentityMap($user)); } /** diff --git a/tests/Doctrine/Tests/ORM/Functional/EntityListenersTest.php b/tests/Doctrine/Tests/ORM/Functional/EntityListenersTest.php index 234d8ce486d..7bb67ae7370 100644 --- a/tests/Doctrine/Tests/ORM/Functional/EntityListenersTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/EntityListenersTest.php @@ -39,10 +39,10 @@ public function testPreFlushListeners(): void $this->_em->persist($fix); $this->_em->flush(); - $this->assertCount(1, $this->listener->preFlushCalls); - $this->assertSame($fix, $this->listener->preFlushCalls[0][0]); - $this->assertInstanceOf(CompanyFixContract::class, $this->listener->preFlushCalls[0][0]); - $this->assertInstanceOf(PreFlushEventArgs::class, $this->listener->preFlushCalls[0][1]); + self::assertCount(1, $this->listener->preFlushCalls); + self::assertSame($fix, $this->listener->preFlushCalls[0][0]); + self::assertInstanceOf(CompanyFixContract::class, $this->listener->preFlushCalls[0][0]); + self::assertInstanceOf(PreFlushEventArgs::class, $this->listener->preFlushCalls[0][1]); } public function testPostLoadListeners(): void @@ -59,10 +59,10 @@ public function testPostLoadListeners(): void $dql = 'SELECT f FROM Doctrine\Tests\Models\Company\CompanyFixContract f WHERE f.id = ?1'; $fix = $this->_em->createQuery($dql)->setParameter(1, $fix->getId())->getSingleResult(); - $this->assertCount(1, $this->listener->postLoadCalls); - $this->assertSame($fix, $this->listener->postLoadCalls[0][0]); - $this->assertInstanceOf(CompanyFixContract::class, $this->listener->postLoadCalls[0][0]); - $this->assertInstanceOf(LifecycleEventArgs::class, $this->listener->postLoadCalls[0][1]); + self::assertCount(1, $this->listener->postLoadCalls); + self::assertSame($fix, $this->listener->postLoadCalls[0][0]); + self::assertInstanceOf(CompanyFixContract::class, $this->listener->postLoadCalls[0][0]); + self::assertInstanceOf(LifecycleEventArgs::class, $this->listener->postLoadCalls[0][1]); } public function testPrePersistListeners(): void @@ -75,10 +75,10 @@ public function testPrePersistListeners(): void $this->_em->persist($fix); $this->_em->flush(); - $this->assertCount(1, $this->listener->prePersistCalls); - $this->assertSame($fix, $this->listener->prePersistCalls[0][0]); - $this->assertInstanceOf(CompanyFixContract::class, $this->listener->prePersistCalls[0][0]); - $this->assertInstanceOf(LifecycleEventArgs::class, $this->listener->prePersistCalls[0][1]); + self::assertCount(1, $this->listener->prePersistCalls); + self::assertSame($fix, $this->listener->prePersistCalls[0][0]); + self::assertInstanceOf(CompanyFixContract::class, $this->listener->prePersistCalls[0][0]); + self::assertInstanceOf(LifecycleEventArgs::class, $this->listener->prePersistCalls[0][1]); } public function testPostPersistListeners(): void @@ -91,10 +91,10 @@ public function testPostPersistListeners(): void $this->_em->persist($fix); $this->_em->flush(); - $this->assertCount(1, $this->listener->postPersistCalls); - $this->assertSame($fix, $this->listener->postPersistCalls[0][0]); - $this->assertInstanceOf(CompanyFixContract::class, $this->listener->postPersistCalls[0][0]); - $this->assertInstanceOf(LifecycleEventArgs::class, $this->listener->postPersistCalls[0][1]); + self::assertCount(1, $this->listener->postPersistCalls); + self::assertSame($fix, $this->listener->postPersistCalls[0][0]); + self::assertInstanceOf(CompanyFixContract::class, $this->listener->postPersistCalls[0][0]); + self::assertInstanceOf(LifecycleEventArgs::class, $this->listener->postPersistCalls[0][1]); } public function testPreUpdateListeners(): void @@ -112,10 +112,10 @@ public function testPreUpdateListeners(): void $this->_em->persist($fix); $this->_em->flush(); - $this->assertCount(1, $this->listener->preUpdateCalls); - $this->assertSame($fix, $this->listener->preUpdateCalls[0][0]); - $this->assertInstanceOf(CompanyFixContract::class, $this->listener->preUpdateCalls[0][0]); - $this->assertInstanceOf(PreUpdateEventArgs::class, $this->listener->preUpdateCalls[0][1]); + self::assertCount(1, $this->listener->preUpdateCalls); + self::assertSame($fix, $this->listener->preUpdateCalls[0][0]); + self::assertInstanceOf(CompanyFixContract::class, $this->listener->preUpdateCalls[0][0]); + self::assertInstanceOf(PreUpdateEventArgs::class, $this->listener->preUpdateCalls[0][1]); } public function testPostUpdateListeners(): void @@ -133,10 +133,10 @@ public function testPostUpdateListeners(): void $this->_em->persist($fix); $this->_em->flush(); - $this->assertCount(1, $this->listener->postUpdateCalls); - $this->assertSame($fix, $this->listener->postUpdateCalls[0][0]); - $this->assertInstanceOf(CompanyFixContract::class, $this->listener->postUpdateCalls[0][0]); - $this->assertInstanceOf(LifecycleEventArgs::class, $this->listener->postUpdateCalls[0][1]); + self::assertCount(1, $this->listener->postUpdateCalls); + self::assertSame($fix, $this->listener->postUpdateCalls[0][0]); + self::assertInstanceOf(CompanyFixContract::class, $this->listener->postUpdateCalls[0][0]); + self::assertInstanceOf(LifecycleEventArgs::class, $this->listener->postUpdateCalls[0][1]); } public function testPreRemoveListeners(): void @@ -152,10 +152,10 @@ public function testPreRemoveListeners(): void $this->_em->remove($fix); $this->_em->flush(); - $this->assertCount(1, $this->listener->preRemoveCalls); - $this->assertSame($fix, $this->listener->preRemoveCalls[0][0]); - $this->assertInstanceOf(CompanyFixContract::class, $this->listener->preRemoveCalls[0][0]); - $this->assertInstanceOf(LifecycleEventArgs::class, $this->listener->preRemoveCalls[0][1]); + self::assertCount(1, $this->listener->preRemoveCalls); + self::assertSame($fix, $this->listener->preRemoveCalls[0][0]); + self::assertInstanceOf(CompanyFixContract::class, $this->listener->preRemoveCalls[0][0]); + self::assertInstanceOf(LifecycleEventArgs::class, $this->listener->preRemoveCalls[0][1]); } public function testPostRemoveListeners(): void @@ -171,9 +171,9 @@ public function testPostRemoveListeners(): void $this->_em->remove($fix); $this->_em->flush(); - $this->assertCount(1, $this->listener->postRemoveCalls); - $this->assertSame($fix, $this->listener->postRemoveCalls[0][0]); - $this->assertInstanceOf(CompanyFixContract::class, $this->listener->postRemoveCalls[0][0]); - $this->assertInstanceOf(LifecycleEventArgs::class, $this->listener->postRemoveCalls[0][1]); + self::assertCount(1, $this->listener->postRemoveCalls); + self::assertSame($fix, $this->listener->postRemoveCalls[0][0]); + self::assertInstanceOf(CompanyFixContract::class, $this->listener->postRemoveCalls[0][0]); + self::assertInstanceOf(LifecycleEventArgs::class, $this->listener->postRemoveCalls[0][1]); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/EntityRepositoryCriteriaTest.php b/tests/Doctrine/Tests/ORM/Functional/EntityRepositoryCriteriaTest.php index 8964db57bef..ea1d9f3e996 100644 --- a/tests/Doctrine/Tests/ORM/Functional/EntityRepositoryCriteriaTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/EntityRepositoryCriteriaTest.php @@ -71,7 +71,7 @@ public function testLteDateComparison(): void Criteria::expr()->lte('datetime', new DateTime('today')) )); - $this->assertEquals(2, count($dates)); + self::assertEquals(2, count($dates)); } private function loadNullFieldFixtures(): void @@ -103,7 +103,7 @@ public function testIsNullComparison(): void Criteria::expr()->isNull('time') )); - $this->assertEquals(1, count($dates)); + self::assertEquals(1, count($dates)); } public function testEqNullComparison(): void @@ -115,7 +115,7 @@ public function testEqNullComparison(): void Criteria::expr()->eq('time', null) )); - $this->assertEquals(1, count($dates)); + self::assertEquals(1, count($dates)); } public function testNotEqNullComparison(): void @@ -127,7 +127,7 @@ public function testNotEqNullComparison(): void Criteria::expr()->neq('time', null) )); - $this->assertEquals(1, count($dates)); + self::assertEquals(1, count($dates)); } public function testCanCountWithoutLoadingCollection(): void @@ -137,22 +137,22 @@ public function testCanCountWithoutLoadingCollection(): void $dates = $repository->matching(new Criteria()); - $this->assertFalse($dates->isInitialized()); - $this->assertCount(3, $dates); - $this->assertFalse($dates->isInitialized()); + self::assertFalse($dates->isInitialized()); + self::assertCount(3, $dates); + self::assertFalse($dates->isInitialized()); // Test it can work even with a constraint $dates = $repository->matching(new Criteria( Criteria::expr()->lte('datetime', new DateTime('today')) )); - $this->assertFalse($dates->isInitialized()); - $this->assertCount(2, $dates); - $this->assertFalse($dates->isInitialized()); + self::assertFalse($dates->isInitialized()); + self::assertCount(2, $dates); + self::assertFalse($dates->isInitialized()); // Trigger a loading, to make sure collection is initialized $date = $dates[0]; - $this->assertTrue($dates->isInitialized()); + self::assertTrue($dates->isInitialized()); } public function testCanContainsWithoutLoadingCollection(): void @@ -176,12 +176,12 @@ public function testCanContainsWithoutLoadingCollection(): void $user = $this->_em->find(User::class, $user->id); $tweets = $user->tweets->matching($criteria); - $this->assertInstanceOf(LazyCriteriaCollection::class, $tweets); - $this->assertFalse($tweets->isInitialized()); + self::assertInstanceOf(LazyCriteriaCollection::class, $tweets); + self::assertFalse($tweets->isInitialized()); $tweets->contains($tweet); - $this->assertTrue($tweets->contains($tweet)); + self::assertTrue($tweets->contains($tweet)); - $this->assertFalse($tweets->isInitialized()); + self::assertFalse($tweets->isInitialized()); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/EntityRepositoryTest.php b/tests/Doctrine/Tests/ORM/Functional/EntityRepositoryTest.php index e5ee4a16658..ade62607eff 100644 --- a/tests/Doctrine/Tests/ORM/Functional/EntityRepositoryTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/EntityRepositoryTest.php @@ -199,9 +199,9 @@ public function testBasicFind(): void $repos = $this->_em->getRepository(CmsUser::class); $user = $repos->find($user1Id); - $this->assertInstanceOf(CmsUser::class, $user); - $this->assertEquals('Roman', $user->name); - $this->assertEquals('freak', $user->status); + self::assertInstanceOf(CmsUser::class, $user); + self::assertEquals('Roman', $user->name); + self::assertEquals('freak', $user->status); } public function testFindByField(): void @@ -210,10 +210,10 @@ public function testFindByField(): void $repos = $this->_em->getRepository(CmsUser::class); $users = $repos->findBy(['status' => 'dev']); - $this->assertEquals(2, count($users)); - $this->assertInstanceOf(CmsUser::class, $users[0]); - $this->assertEquals('Guilherme', $users[0]->name); - $this->assertEquals('dev', $users[0]->status); + self::assertEquals(2, count($users)); + self::assertInstanceOf(CmsUser::class, $users[0]); + self::assertEquals('Guilherme', $users[0]->name); + self::assertEquals('dev', $users[0]->status); } public function testFindByAssociationWithIntegerAsParameter(): void @@ -234,8 +234,8 @@ public function testFindByAssociationWithIntegerAsParameter(): void $repository = $this->_em->getRepository(CmsAddress::class); $addresses = $repository->findBy(['user' => [$user1->getId(), $user2->getId()]]); - $this->assertEquals(2, count($addresses)); - $this->assertInstanceOf(CmsAddress::class, $addresses[0]); + self::assertEquals(2, count($addresses)); + self::assertInstanceOf(CmsAddress::class, $addresses[0]); } public function testFindByAssociationWithObjectAsParameter(): void @@ -256,8 +256,8 @@ public function testFindByAssociationWithObjectAsParameter(): void $repository = $this->_em->getRepository(CmsAddress::class); $addresses = $repository->findBy(['user' => [$user1, $user2]]); - $this->assertEquals(2, count($addresses)); - $this->assertInstanceOf(CmsAddress::class, $addresses[0]); + self::assertEquals(2, count($addresses)); + self::assertInstanceOf(CmsAddress::class, $addresses[0]); } public function testFindFieldByMagicCall(): void @@ -266,10 +266,10 @@ public function testFindFieldByMagicCall(): void $repos = $this->_em->getRepository(CmsUser::class); $users = $repos->findByStatus('dev'); - $this->assertEquals(2, count($users)); - $this->assertInstanceOf(CmsUser::class, $users[0]); - $this->assertEquals('Guilherme', $users[0]->name); - $this->assertEquals('dev', $users[0]->status); + self::assertEquals(2, count($users)); + self::assertInstanceOf(CmsUser::class, $users[0]); + self::assertEquals('Guilherme', $users[0]->name); + self::assertEquals('dev', $users[0]->status); } public function testFindAll(): void @@ -278,7 +278,7 @@ public function testFindAll(): void $repos = $this->_em->getRepository(CmsUser::class); $users = $repos->findAll(); - $this->assertEquals(4, count($users)); + self::assertEquals(4, count($users)); } public function testFindByAlias(): void @@ -291,7 +291,7 @@ public function testFindByAlias(): void $repos = $this->_em->getRepository('CMS:CmsUser'); $users = $repos->findAll(); - $this->assertEquals(4, count($users)); + self::assertEquals(4, count($users)); } public function testCount(): void @@ -300,13 +300,13 @@ public function testCount(): void $repos = $this->_em->getRepository(CmsUser::class); $userCount = $repos->count([]); - $this->assertSame(4, $userCount); + self::assertSame(4, $userCount); $userCount = $repos->count(['status' => 'dev']); - $this->assertSame(2, $userCount); + self::assertSame(2, $userCount); $userCount = $repos->count(['status' => 'nonexistent']); - $this->assertSame(0, $userCount); + self::assertSame(0, $userCount); } public function testCountBy(): void @@ -315,7 +315,7 @@ public function testCountBy(): void $repos = $this->_em->getRepository(CmsUser::class); $userCount = $repos->countByStatus('dev'); - $this->assertSame(2, $userCount); + self::assertSame(2, $userCount); } public function testExceptionIsThrownWhenCallingFindByWithoutParameter(): void @@ -400,7 +400,7 @@ public function testFindMagicCallByNullValue(): void $repos = $this->_em->getRepository(CmsUser::class); $users = $repos->findByStatus(null); - $this->assertEquals(1, count($users)); + self::assertEquals(1, count($users)); } /** @@ -437,8 +437,8 @@ public function testFindOneByAssociationKey(): void $repos = $this->_em->getRepository(CmsAddress::class); $address = $repos->findOneBy(['user' => $userId]); - $this->assertInstanceOf(CmsAddress::class, $address); - $this->assertEquals($addressId, $address->id); + self::assertInstanceOf(CmsAddress::class, $address); + self::assertEquals($addressId, $address->id); } /** @@ -452,7 +452,7 @@ public function testFindOneByOrderBy(): void $userAsc = $repos->findOneBy([], ['username' => 'ASC']); $userDesc = $repos->findOneBy([], ['username' => 'DESC']); - $this->assertNotSame($userAsc, $userDesc); + self::assertNotSame($userAsc, $userDesc); } /** @@ -464,9 +464,9 @@ public function testFindByAssociationKey(): void $repos = $this->_em->getRepository(CmsAddress::class); $addresses = $repos->findBy(['user' => $userId]); - $this->assertContainsOnly(CmsAddress::class, $addresses); - $this->assertEquals(1, count($addresses)); - $this->assertEquals($addressId, $addresses[0]->id); + self::assertContainsOnly(CmsAddress::class, $addresses); + self::assertEquals(1, count($addresses)); + self::assertEquals($addressId, $addresses[0]->id); } /** @@ -478,9 +478,9 @@ public function testFindAssociationByMagicCall(): void $repos = $this->_em->getRepository(CmsAddress::class); $addresses = $repos->findByUser($userId); - $this->assertContainsOnly(CmsAddress::class, $addresses); - $this->assertEquals(1, count($addresses)); - $this->assertEquals($addressId, $addresses[0]->id); + self::assertContainsOnly(CmsAddress::class, $addresses); + self::assertEquals(1, count($addresses)); + self::assertEquals($addressId, $addresses[0]->id); } /** @@ -492,8 +492,8 @@ public function testFindOneAssociationByMagicCall(): void $repos = $this->_em->getRepository(CmsAddress::class); $address = $repos->findOneByUser($userId); - $this->assertInstanceOf(CmsAddress::class, $address); - $this->assertEquals($addressId, $address->id); + self::assertInstanceOf(CmsAddress::class, $address); + self::assertEquals($addressId, $address->id); } public function testValidNamedQueryRetrieval(): void @@ -504,8 +504,8 @@ public function testValidNamedQueryRetrieval(): void $query = $repos->createNamedQuery('all'); - $this->assertInstanceOf(Query::class, $query); - $this->assertEquals('SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u', $query->getDQL()); + self::assertInstanceOf(Query::class, $query); + self::assertEquals('SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u', $query->getDQL()); } public function testInvalidNamedQueryRetrieval(): void @@ -526,8 +526,8 @@ public function testIsNullCriteriaDoesNotGenerateAParameter(): void $users = $repos->findBy(['status' => null, 'username' => 'romanb']); $params = $this->_sqlLoggerStack->queries[$this->_sqlLoggerStack->currentQuery]['params']; - $this->assertEquals(1, count($params), 'Should only execute with one parameter.'); - $this->assertEquals(['romanb'], $params); + self::assertEquals(1, count($params), 'Should only execute with one parameter.'); + self::assertEquals(['romanb'], $params); } public function testIsNullCriteria(): void @@ -537,7 +537,7 @@ public function testIsNullCriteria(): void $repos = $this->_em->getRepository(CmsUser::class); $users = $repos->findBy(['status' => null]); - $this->assertEquals(1, count($users)); + self::assertEquals(1, count($users)); } /** @@ -552,10 +552,10 @@ public function testFindByLimitOffset(): void $users1 = $repos->findBy([], null, 1, 0); $users2 = $repos->findBy([], null, 1, 1); - $this->assertEquals(4, count($repos->findBy([]))); - $this->assertEquals(1, count($users1)); - $this->assertEquals(1, count($users2)); - $this->assertNotSame($users1[0], $users2[0]); + self::assertEquals(4, count($repos->findBy([]))); + self::assertEquals(1, count($users1)); + self::assertEquals(1, count($users2)); + self::assertNotSame($users1[0], $users2[0]); } /** @@ -569,10 +569,10 @@ public function testFindByOrderBy(): void $usersAsc = $repos->findBy([], ['username' => 'ASC']); $usersDesc = $repos->findBy([], ['username' => 'DESC']); - $this->assertEquals(4, count($usersAsc), 'Pre-condition: only four users in fixture'); - $this->assertEquals(4, count($usersDesc), 'Pre-condition: only four users in fixture'); - $this->assertSame($usersAsc[0], $usersDesc[3]); - $this->assertSame($usersAsc[3], $usersDesc[0]); + self::assertEquals(4, count($usersAsc), 'Pre-condition: only four users in fixture'); + self::assertEquals(4, count($usersDesc), 'Pre-condition: only four users in fixture'); + self::assertSame($usersAsc[0], $usersDesc[3]); + self::assertSame($usersAsc[3], $usersDesc[0]); } /** @@ -586,11 +586,11 @@ public function testFindByOrderByAssociation(): void $resultAsc = $repository->findBy([], ['email' => 'ASC']); $resultDesc = $repository->findBy([], ['email' => 'DESC']); - $this->assertCount(3, $resultAsc); - $this->assertCount(3, $resultDesc); + self::assertCount(3, $resultAsc); + self::assertCount(3, $resultDesc); - $this->assertEquals($resultAsc[0]->getEmail()->getId(), $resultDesc[2]->getEmail()->getId()); - $this->assertEquals($resultAsc[2]->getEmail()->getId(), $resultDesc[0]->getEmail()->getId()); + self::assertEquals($resultAsc[0]->getEmail()->getId(), $resultDesc[2]->getEmail()->getId()); + self::assertEquals($resultAsc[2]->getEmail()->getId(), $resultDesc[0]->getEmail()->getId()); } /** @@ -604,15 +604,15 @@ public function testFindFieldByMagicCallOrderBy(): void $usersAsc = $repos->findByStatus('dev', ['username' => 'ASC']); $usersDesc = $repos->findByStatus('dev', ['username' => 'DESC']); - $this->assertEquals(2, count($usersAsc)); - $this->assertEquals(2, count($usersDesc)); + self::assertEquals(2, count($usersAsc)); + self::assertEquals(2, count($usersDesc)); - $this->assertInstanceOf(CmsUser::class, $usersAsc[0]); - $this->assertEquals('Alexander', $usersAsc[0]->name); - $this->assertEquals('dev', $usersAsc[0]->status); + self::assertInstanceOf(CmsUser::class, $usersAsc[0]); + self::assertEquals('Alexander', $usersAsc[0]->name); + self::assertEquals('dev', $usersAsc[0]->status); - $this->assertSame($usersAsc[0], $usersDesc[1]); - $this->assertSame($usersAsc[1], $usersDesc[0]); + self::assertSame($usersAsc[0], $usersDesc[1]); + self::assertSame($usersAsc[1], $usersDesc[0]); } /** @@ -626,9 +626,9 @@ public function testFindFieldByMagicCallLimitOffset(): void $users1 = $repos->findByStatus('dev', [], 1, 0); $users2 = $repos->findByStatus('dev', [], 1, 1); - $this->assertEquals(1, count($users1)); - $this->assertEquals(1, count($users2)); - $this->assertNotSame($users1[0], $users2[0]); + self::assertEquals(1, count($users1)); + self::assertEquals(1, count($users2)); + self::assertNotSame($users1[0], $users2[0]); } /** @@ -636,21 +636,21 @@ public function testFindFieldByMagicCallLimitOffset(): void */ public function testDefaultRepositoryClassName(): void { - $this->assertEquals($this->_em->getConfiguration()->getDefaultRepositoryClassName(), EntityRepository::class); + self::assertEquals($this->_em->getConfiguration()->getDefaultRepositoryClassName(), EntityRepository::class); $this->_em->getConfiguration()->setDefaultRepositoryClassName(DDC753DefaultRepository::class); - $this->assertEquals($this->_em->getConfiguration()->getDefaultRepositoryClassName(), DDC753DefaultRepository::class); + self::assertEquals($this->_em->getConfiguration()->getDefaultRepositoryClassName(), DDC753DefaultRepository::class); $repos = $this->_em->getRepository(DDC753EntityWithDefaultCustomRepository::class); - $this->assertInstanceOf(DDC753DefaultRepository::class, $repos); - $this->assertTrue($repos->isDefaultRepository()); + self::assertInstanceOf(DDC753DefaultRepository::class, $repos); + self::assertTrue($repos->isDefaultRepository()); $repos = $this->_em->getRepository(DDC753EntityWithCustomRepository::class); - $this->assertInstanceOf(DDC753CustomRepository::class, $repos); - $this->assertTrue($repos->isCustomRepository()); + self::assertInstanceOf(DDC753CustomRepository::class, $repos); + self::assertTrue($repos->isCustomRepository()); - $this->assertEquals($this->_em->getConfiguration()->getDefaultRepositoryClassName(), DDC753DefaultRepository::class); + self::assertEquals($this->_em->getConfiguration()->getDefaultRepositoryClassName(), DDC753DefaultRepository::class); $this->_em->getConfiguration()->setDefaultRepositoryClassName(EntityRepository::class); - $this->assertEquals($this->_em->getConfiguration()->getDefaultRepositoryClassName(), EntityRepository::class); + self::assertEquals($this->_em->getConfiguration()->getDefaultRepositoryClassName(), EntityRepository::class); } /** @@ -660,7 +660,7 @@ public function testSetDefaultRepositoryInvalidClassError(): void { $this->expectException(InvalidEntityRepository::class); $this->expectExceptionMessage('Invalid repository class \'Doctrine\Tests\Models\DDC753\DDC753InvalidRepository\'. It must be a Doctrine\Persistence\ObjectRepository.'); - $this->assertEquals($this->_em->getConfiguration()->getDefaultRepositoryClassName(), EntityRepository::class); + self::assertEquals($this->_em->getConfiguration()->getDefaultRepositoryClassName(), EntityRepository::class); $this->_em->getConfiguration()->setDefaultRepositoryClassName(DDC753InvalidRepository::class); } @@ -676,8 +676,8 @@ public function testSingleRepositoryInstanceForDifferentEntityAliases(): void $repository = $this->_em->getRepository(CmsUser::class); - $this->assertSame($repository, $this->_em->getRepository('Aliased:CmsUser')); - $this->assertSame($repository, $this->_em->getRepository('AliasedAgain:CmsUser')); + self::assertSame($repository, $this->_em->getRepository('Aliased:CmsUser')); + self::assertSame($repository, $this->_em->getRepository('AliasedAgain:CmsUser')); } /** @@ -685,7 +685,7 @@ public function testSingleRepositoryInstanceForDifferentEntityAliases(): void */ public function testCanRetrieveRepositoryFromClassNameWithLeadingBackslash(): void { - $this->assertSame( + self::assertSame( $this->_em->getRepository('\\' . CmsUser::class), $this->_em->getRepository(CmsUser::class) ); @@ -723,8 +723,8 @@ public function testFindByAssociationArray(): void $data = $repo->findBy(['user' => [1, 2, 3]]); $query = array_pop($this->_sqlLoggerStack->queries); - $this->assertEquals([1, 2, 3], $query['params'][0]); - $this->assertEquals(Connection::PARAM_INT_ARRAY, $query['types'][0]); + self::assertEquals([1, 2, 3], $query['params'][0]); + self::assertEquals(Connection::PARAM_INT_ARRAY, $query['types'][0]); } /** @@ -737,7 +737,7 @@ public function testMatchingEmptyCriteria(): void $repository = $this->_em->getRepository(CmsUser::class); $users = $repository->matching(new Criteria()); - $this->assertEquals(4, count($users)); + self::assertEquals(4, count($users)); } /** @@ -752,7 +752,7 @@ public function testMatchingCriteriaEqComparison(): void Criteria::expr()->eq('username', 'beberlei') )); - $this->assertEquals(1, count($users)); + self::assertEquals(1, count($users)); } /** @@ -767,7 +767,7 @@ public function testMatchingCriteriaNeqComparison(): void Criteria::expr()->neq('username', 'beberlei') )); - $this->assertEquals(3, count($users)); + self::assertEquals(3, count($users)); } /** @@ -782,7 +782,7 @@ public function testMatchingCriteriaInComparison(): void Criteria::expr()->in('username', ['beberlei', 'gblanco']) )); - $this->assertEquals(2, count($users)); + self::assertEquals(2, count($users)); } /** @@ -797,7 +797,7 @@ public function testMatchingCriteriaNotInComparison(): void Criteria::expr()->notIn('username', ['beberlei', 'gblanco', 'asm89']) )); - $this->assertEquals(1, count($users)); + self::assertEquals(1, count($users)); } /** @@ -812,7 +812,7 @@ public function testMatchingCriteriaLtComparison(): void Criteria::expr()->lt('id', $firstUserId + 1) )); - $this->assertEquals(1, count($users)); + self::assertEquals(1, count($users)); } /** @@ -827,7 +827,7 @@ public function testMatchingCriteriaLeComparison(): void Criteria::expr()->lte('id', $firstUserId + 1) )); - $this->assertEquals(2, count($users)); + self::assertEquals(2, count($users)); } /** @@ -842,7 +842,7 @@ public function testMatchingCriteriaGtComparison(): void Criteria::expr()->gt('id', $firstUserId) )); - $this->assertEquals(3, count($users)); + self::assertEquals(3, count($users)); } /** @@ -857,7 +857,7 @@ public function testMatchingCriteriaGteComparison(): void Criteria::expr()->gte('id', $firstUserId) )); - $this->assertEquals(4, count($users)); + self::assertEquals(4, count($users)); } /** @@ -876,11 +876,11 @@ public function testMatchingCriteriaAssocationByObjectInMemory(): void $repository = $this->_em->getRepository(CmsAddress::class); $addresses = $repository->matching($criteria); - $this->assertEquals(1, count($addresses)); + self::assertEquals(1, count($addresses)); $addresses = new ArrayCollection($repository->findAll()); - $this->assertEquals(1, count($addresses->matching($criteria))); + self::assertEquals(1, count($addresses->matching($criteria))); } /** @@ -899,11 +899,11 @@ public function testMatchingCriteriaAssocationInWithArray(): void $repository = $this->_em->getRepository(CmsAddress::class); $addresses = $repository->matching($criteria); - $this->assertEquals(1, count($addresses)); + self::assertEquals(1, count($addresses)); $addresses = new ArrayCollection($repository->findAll()); - $this->assertEquals(1, count($addresses->matching($criteria))); + self::assertEquals(1, count($addresses->matching($criteria))); } public function testMatchingCriteriaContainsComparison(): void @@ -913,13 +913,13 @@ public function testMatchingCriteriaContainsComparison(): void $repository = $this->_em->getRepository(CmsUser::class); $users = $repository->matching(new Criteria(Criteria::expr()->contains('name', 'Foobar'))); - $this->assertEquals(0, count($users)); + self::assertEquals(0, count($users)); $users = $repository->matching(new Criteria(Criteria::expr()->contains('name', 'Rom'))); - $this->assertEquals(1, count($users)); + self::assertEquals(1, count($users)); $users = $repository->matching(new Criteria(Criteria::expr()->contains('status', 'dev'))); - $this->assertEquals(2, count($users)); + self::assertEquals(2, count($users)); } public function testMatchingCriteriaStartsWithComparison(): void @@ -929,13 +929,13 @@ public function testMatchingCriteriaStartsWithComparison(): void $repository = $this->_em->getRepository(CmsUser::class); $users = $repository->matching(new Criteria(Criteria::expr()->startsWith('name', 'Foo'))); - $this->assertCount(0, $users); + self::assertCount(0, $users); $users = $repository->matching(new Criteria(Criteria::expr()->startsWith('name', 'R'))); - $this->assertCount(1, $users); + self::assertCount(1, $users); $users = $repository->matching(new Criteria(Criteria::expr()->startsWith('status', 'de'))); - $this->assertCount(2, $users); + self::assertCount(2, $users); } public function testMatchingCriteriaEndsWithComparison(): void @@ -945,13 +945,13 @@ public function testMatchingCriteriaEndsWithComparison(): void $repository = $this->_em->getRepository(CmsUser::class); $users = $repository->matching(new Criteria(Criteria::expr()->endsWith('name', 'foo'))); - $this->assertCount(0, $users); + self::assertCount(0, $users); $users = $repository->matching(new Criteria(Criteria::expr()->endsWith('name', 'oman'))); - $this->assertCount(1, $users); + self::assertCount(1, $users); $users = $repository->matching(new Criteria(Criteria::expr()->endsWith('status', 'ev'))); - $this->assertCount(2, $users); + self::assertCount(2, $users); } /** @@ -973,14 +973,14 @@ public function testMatchingCriteriaNullAssocComparison(): void $usersIsNull = $repository->matching($criteriaIsNull); $usersEqNull = $repository->matching($criteriaEqNull); - $this->assertCount(1, $usersIsNull); - $this->assertCount(1, $usersEqNull); + self::assertCount(1, $usersIsNull); + self::assertCount(1, $usersEqNull); - $this->assertInstanceOf(CmsUser::class, $usersIsNull[0]); - $this->assertInstanceOf(CmsUser::class, $usersEqNull[0]); + self::assertInstanceOf(CmsUser::class, $usersIsNull[0]); + self::assertInstanceOf(CmsUser::class, $usersEqNull[0]); - $this->assertNull($usersIsNull[0]->getEmail()); - $this->assertNull($usersEqNull[0]->getEmail()); + self::assertNull($usersIsNull[0]->getEmail()); + self::assertNull($usersEqNull[0]->getEmail()); } /** @@ -991,8 +991,8 @@ public function testCreateResultSetMappingBuilder(): void $repository = $this->_em->getRepository(CmsUser::class); $rsm = $repository->createResultSetMappingBuilder('u'); - $this->assertInstanceOf(Query\ResultSetMappingBuilder::class, $rsm); - $this->assertEquals(['u' => CmsUser::class], $rsm->aliasMap); + self::assertInstanceOf(Query\ResultSetMappingBuilder::class, $rsm); + self::assertEquals(['u' => CmsUser::class], $rsm->aliasMap); } /** @@ -1069,8 +1069,8 @@ public function testFindByNullValueInInCondition(): void $users = $this->_em->getRepository(CmsUser::class)->findBy(['status' => [null]]); - $this->assertCount(1, $users); - $this->assertSame($user1, reset($users)); + self::assertCount(1, $users); + self::assertSame($user1, reset($users)); } /** @@ -1097,8 +1097,8 @@ public function testFindByNullValueInMultipleInCriteriaValues(): void ->getRepository(CmsUser::class) ->findBy(['status' => ['foo', null]]); - $this->assertCount(1, $users); - $this->assertSame($user1, reset($users)); + self::assertCount(1, $users); + self::assertSame($user1, reset($users)); } /** @@ -1125,10 +1125,10 @@ public function testFindMultipleByNullValueInMultipleInCriteriaValues(): void ->getRepository(CmsUser::class) ->findBy(['status' => ['dbal maintainer', null]]); - $this->assertCount(2, $users); + self::assertCount(2, $users); foreach ($users as $user) { - $this->assertTrue(in_array($user, [$user1, $user2], true)); + self::assertTrue(in_array($user, [$user1, $user2], true)); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/ExtraLazyCollectionTest.php b/tests/Doctrine/Tests/ORM/Functional/ExtraLazyCollectionTest.php index 64baa99e71e..6ebc0d04823 100644 --- a/tests/Doctrine/Tests/ORM/Functional/ExtraLazyCollectionTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/ExtraLazyCollectionTest.php @@ -117,14 +117,14 @@ public function testCountNotInitializesCollection(): void $user = $this->_em->find(CmsUser::class, $this->userId); $queryCount = $this->getCurrentQueryCount(); - $this->assertFalse($user->groups->isInitialized()); - $this->assertEquals(3, count($user->groups)); - $this->assertFalse($user->groups->isInitialized()); + self::assertFalse($user->groups->isInitialized()); + self::assertEquals(3, count($user->groups)); + self::assertFalse($user->groups->isInitialized()); foreach ($user->groups as $group) { } - $this->assertEquals($queryCount + 2, $this->getCurrentQueryCount(), 'Expecting two queries to be fired for count, then iteration.'); + self::assertEquals($queryCount + 2, $this->getCurrentQueryCount(), 'Expecting two queries to be fired for count, then iteration.'); } /** @@ -140,9 +140,9 @@ public function testCountWhenNewEntityPresent(): void $user->addGroup($newGroup); $this->_em->persist($newGroup); - $this->assertFalse($user->groups->isInitialized()); - $this->assertEquals(4, count($user->groups)); - $this->assertFalse($user->groups->isInitialized()); + self::assertFalse($user->groups->isInitialized()); + self::assertEquals(4, count($user->groups)); + self::assertFalse($user->groups->isInitialized()); } /** @@ -157,9 +157,9 @@ public function testCountWhenInitialized(): void foreach ($user->groups as $group) { } - $this->assertTrue($user->groups->isInitialized()); - $this->assertEquals(3, count($user->groups)); - $this->assertEquals($queryCount + 1, $this->getCurrentQueryCount(), 'Should only execute one query to initialize collection, no extra query for count() more.'); + self::assertTrue($user->groups->isInitialized()); + self::assertEquals(3, count($user->groups)); + self::assertEquals($queryCount + 1, $this->getCurrentQueryCount(), 'Should only execute one query to initialize collection, no extra query for count() more.'); } /** @@ -168,10 +168,10 @@ public function testCountWhenInitialized(): void public function testCountInverseCollection(): void { $group = $this->_em->find(CmsGroup::class, $this->groupId); - $this->assertFalse($group->users->isInitialized(), 'Pre-Condition'); + self::assertFalse($group->users->isInitialized(), 'Pre-Condition'); - $this->assertEquals(4, count($group->users)); - $this->assertFalse($group->users->isInitialized(), 'Extra Lazy collection should not be initialized by counting the collection.'); + self::assertEquals(4, count($group->users)); + self::assertFalse($group->users->isInitialized(), 'Extra Lazy collection should not be initialized by counting the collection.'); } /** @@ -180,9 +180,9 @@ public function testCountInverseCollection(): void public function testCountOneToMany(): void { $user = $this->_em->find(CmsUser::class, $this->userId); - $this->assertFalse($user->groups->isInitialized(), 'Pre-Condition'); + self::assertFalse($user->groups->isInitialized(), 'Pre-Condition'); - $this->assertEquals(2, count($user->articles)); + self::assertEquals(2, count($user->articles)); } /** @@ -192,8 +192,8 @@ public function testCountOneToManyJoinedInheritance(): void { $otherClass = $this->_em->find(DDC2504OtherClass::class, $this->ddc2504OtherClassId); - $this->assertFalse($otherClass->childClasses->isInitialized(), 'Pre-Condition'); - $this->assertEquals(2, count($otherClass->childClasses)); + self::assertFalse($otherClass->childClasses->isInitialized(), 'Pre-Condition'); + self::assertEquals(2, count($otherClass->childClasses)); } /** @@ -202,10 +202,10 @@ public function testCountOneToManyJoinedInheritance(): void public function testFullSlice(): void { $user = $this->_em->find(CmsUser::class, $this->userId); - $this->assertFalse($user->groups->isInitialized(), 'Pre-Condition: Collection is not initialized.'); + self::assertFalse($user->groups->isInitialized(), 'Pre-Condition: Collection is not initialized.'); $someGroups = $user->groups->slice(null); - $this->assertEquals(3, count($someGroups)); + self::assertEquals(3, count($someGroups)); } /** @@ -215,29 +215,29 @@ public function testFullSlice(): void public function testSlice(): void { $user = $this->_em->find(CmsUser::class, $this->userId); - $this->assertFalse($user->groups->isInitialized(), 'Pre-Condition: Collection is not initialized.'); + self::assertFalse($user->groups->isInitialized(), 'Pre-Condition: Collection is not initialized.'); $queryCount = $this->getCurrentQueryCount(); $someGroups = $user->groups->slice(0, 2); - $this->assertContainsOnly(CmsGroup::class, $someGroups); - $this->assertEquals(2, count($someGroups)); - $this->assertFalse($user->groups->isInitialized(), "Slice should not initialize the collection if it wasn't before!"); + self::assertContainsOnly(CmsGroup::class, $someGroups); + self::assertEquals(2, count($someGroups)); + self::assertFalse($user->groups->isInitialized(), "Slice should not initialize the collection if it wasn't before!"); $otherGroup = $user->groups->slice(2, 1); - $this->assertContainsOnly(CmsGroup::class, $otherGroup); - $this->assertEquals(1, count($otherGroup)); - $this->assertFalse($user->groups->isInitialized()); + self::assertContainsOnly(CmsGroup::class, $otherGroup); + self::assertEquals(1, count($otherGroup)); + self::assertFalse($user->groups->isInitialized()); foreach ($user->groups as $group) { } - $this->assertTrue($user->groups->isInitialized()); - $this->assertEquals(3, count($user->groups)); + self::assertTrue($user->groups->isInitialized()); + self::assertEquals(3, count($user->groups)); - $this->assertEquals($queryCount + 3, $this->getCurrentQueryCount()); + self::assertEquals($queryCount + 3, $this->getCurrentQueryCount()); } /** @@ -254,11 +254,11 @@ public function testSliceInitializedCollection(): void $someGroups = $user->groups->slice(0, 2); - $this->assertEquals($queryCount + 1, $this->getCurrentQueryCount()); + self::assertEquals($queryCount + 1, $this->getCurrentQueryCount()); - $this->assertEquals(2, count($someGroups)); - $this->assertTrue($user->groups->contains(array_shift($someGroups))); - $this->assertTrue($user->groups->contains(array_shift($someGroups))); + self::assertEquals(2, count($someGroups)); + self::assertTrue($user->groups->contains(array_shift($someGroups))); + self::assertTrue($user->groups->contains(array_shift($someGroups))); } /** @@ -267,19 +267,19 @@ public function testSliceInitializedCollection(): void public function testSliceInverseCollection(): void { $group = $this->_em->find(CmsGroup::class, $this->groupId); - $this->assertFalse($group->users->isInitialized(), 'Pre-Condition'); + self::assertFalse($group->users->isInitialized(), 'Pre-Condition'); $queryCount = $this->getCurrentQueryCount(); $someUsers = $group->users->slice(0, 2); $otherUsers = $group->users->slice(2, 2); - $this->assertContainsOnly(CmsUser::class, $someUsers); - $this->assertContainsOnly(CmsUser::class, $otherUsers); - $this->assertEquals(2, count($someUsers)); - $this->assertEquals(2, count($otherUsers)); + self::assertContainsOnly(CmsUser::class, $someUsers); + self::assertContainsOnly(CmsUser::class, $otherUsers); + self::assertEquals(2, count($someUsers)); + self::assertEquals(2, count($otherUsers)); // +2 queries executed by slice - $this->assertEquals($queryCount + 2, $this->getCurrentQueryCount(), 'Slicing two parts should only execute two additional queries.'); + self::assertEquals($queryCount + 2, $this->getCurrentQueryCount(), 'Slicing two parts should only execute two additional queries.'); } /** @@ -288,14 +288,14 @@ public function testSliceInverseCollection(): void public function testSliceOneToMany(): void { $user = $this->_em->find(CmsUser::class, $this->userId); - $this->assertFalse($user->articles->isInitialized(), 'Pre-Condition: Collection is not initialized.'); + self::assertFalse($user->articles->isInitialized(), 'Pre-Condition: Collection is not initialized.'); $queryCount = $this->getCurrentQueryCount(); $someArticle = $user->articles->slice(0, 1); $otherArticle = $user->articles->slice(1, 1); - $this->assertEquals($queryCount + 2, $this->getCurrentQueryCount()); + self::assertEquals($queryCount + 2, $this->getCurrentQueryCount()); } /** @@ -304,15 +304,15 @@ public function testSliceOneToMany(): void public function testContainsOneToMany(): void { $user = $this->_em->find(CmsUser::class, $this->userId); - $this->assertFalse($user->articles->isInitialized(), 'Pre-Condition: Collection is not initialized.'); + self::assertFalse($user->articles->isInitialized(), 'Pre-Condition: Collection is not initialized.'); // Test One to Many existence retrieved from DB $article = $this->_em->find(CmsArticle::class, $this->articleId); $queryCount = $this->getCurrentQueryCount(); - $this->assertTrue($user->articles->contains($article)); - $this->assertFalse($user->articles->isInitialized(), 'Post-Condition: Collection is not initialized.'); - $this->assertEquals($queryCount + 1, $this->getCurrentQueryCount()); + self::assertTrue($user->articles->contains($article)); + self::assertFalse($user->articles->isInitialized(), 'Post-Condition: Collection is not initialized.'); + self::assertEquals($queryCount + 1, $this->getCurrentQueryCount()); // Test One to Many existence with state new $article = new CmsArticle(); @@ -320,17 +320,17 @@ public function testContainsOneToMany(): void $article->text = 'blub'; $queryCount = $this->getCurrentQueryCount(); - $this->assertFalse($user->articles->contains($article)); - $this->assertEquals($queryCount, $this->getCurrentQueryCount(), 'Checking for contains of new entity should cause no query to be executed.'); + self::assertFalse($user->articles->contains($article)); + self::assertEquals($queryCount, $this->getCurrentQueryCount(), 'Checking for contains of new entity should cause no query to be executed.'); // Test One to Many existence with state clear $this->_em->persist($article); $this->_em->flush(); $queryCount = $this->getCurrentQueryCount(); - $this->assertFalse($user->articles->contains($article)); - $this->assertEquals($queryCount + 1, $this->getCurrentQueryCount(), 'Checking for contains of persisted entity should cause one query to be executed.'); - $this->assertFalse($user->articles->isInitialized(), 'Post-Condition: Collection is not initialized.'); + self::assertFalse($user->articles->contains($article)); + self::assertEquals($queryCount + 1, $this->getCurrentQueryCount(), 'Checking for contains of persisted entity should cause one query to be executed.'); + self::assertFalse($user->articles->isInitialized(), 'Post-Condition: Collection is not initialized.'); // Test One to Many existence with state managed $article = new CmsArticle(); @@ -341,9 +341,9 @@ public function testContainsOneToMany(): void $queryCount = $this->getCurrentQueryCount(); - $this->assertFalse($user->articles->contains($article)); - $this->assertEquals($queryCount, $this->getCurrentQueryCount(), 'Checking for contains of managed entity (but not persisted) should cause no query to be executed.'); - $this->assertFalse($user->articles->isInitialized(), 'Post-Condition: Collection is not initialized.'); + self::assertFalse($user->articles->contains($article)); + self::assertEquals($queryCount, $this->getCurrentQueryCount(), 'Checking for contains of managed entity (but not persisted) should cause no query to be executed.'); + self::assertFalse($user->articles->isInitialized(), 'Post-Condition: Collection is not initialized.'); } /** @@ -353,7 +353,7 @@ public function testLazyOneToManyJoinedInheritanceIsLazilyInitialized(): void { $otherClass = $this->_em->find(DDC2504OtherClass::class, $this->ddc2504OtherClassId); - $this->assertFalse($otherClass->childClasses->isInitialized(), 'Collection is not initialized.'); + self::assertFalse($otherClass->childClasses->isInitialized(), 'Collection is not initialized.'); } /** @@ -367,9 +367,9 @@ public function testContainsOnOneToManyJoinedInheritanceWillNotInitializeCollect $childClass = $this->_em->find(DDC2504ChildClass::class, $this->ddc2504ChildClassId); $queryCount = $this->getCurrentQueryCount(); - $this->assertTrue($otherClass->childClasses->contains($childClass)); - $this->assertFalse($otherClass->childClasses->isInitialized(), 'Collection is not initialized.'); - $this->assertEquals($queryCount + 1, $this->getCurrentQueryCount(), 'Search operation was performed via SQL'); + self::assertTrue($otherClass->childClasses->contains($childClass)); + self::assertFalse($otherClass->childClasses->isInitialized(), 'Collection is not initialized.'); + self::assertEquals($queryCount + 1, $this->getCurrentQueryCount(), 'Search operation was performed via SQL'); } /** @@ -380,8 +380,8 @@ public function testContainsOnOneToManyJoinedInheritanceWillNotCauseQueriesWhenN $otherClass = $this->_em->find(DDC2504OtherClass::class, $this->ddc2504OtherClassId); $queryCount = $this->getCurrentQueryCount(); - $this->assertFalse($otherClass->childClasses->contains(new DDC2504ChildClass())); - $this->assertEquals( + self::assertFalse($otherClass->childClasses->contains(new DDC2504ChildClass())); + self::assertEquals( $queryCount, $this->getCurrentQueryCount(), 'Checking for contains of new entity should cause no query to be executed.' @@ -401,9 +401,9 @@ public function testContainsOnOneToManyJoinedInheritanceWillNotInitializeCollect $this->_em->flush(); $queryCount = $this->getCurrentQueryCount(); - $this->assertFalse($otherClass->childClasses->contains($childClass)); - $this->assertEquals($queryCount + 1, $this->getCurrentQueryCount(), 'Checking for contains of persisted entity should cause one query to be executed.'); - $this->assertFalse($otherClass->childClasses->isInitialized(), 'Post-Condition: Collection is not initialized.'); + self::assertFalse($otherClass->childClasses->contains($childClass)); + self::assertEquals($queryCount + 1, $this->getCurrentQueryCount(), 'Checking for contains of persisted entity should cause one query to be executed.'); + self::assertFalse($otherClass->childClasses->isInitialized(), 'Post-Condition: Collection is not initialized.'); } /** @@ -418,9 +418,9 @@ public function testContainsOnOneToManyJoinedInheritanceWillNotInitializeCollect $queryCount = $this->getCurrentQueryCount(); - $this->assertFalse($otherClass->childClasses->contains($childClass)); - $this->assertEquals($queryCount, $this->getCurrentQueryCount(), 'Checking for contains of managed entity (but not persisted) should cause no query to be executed.'); - $this->assertFalse($otherClass->childClasses->isInitialized(), 'Post-Condition: Collection is not initialized.'); + self::assertFalse($otherClass->childClasses->contains($childClass)); + self::assertEquals($queryCount, $this->getCurrentQueryCount(), 'Checking for contains of managed entity (but not persisted) should cause no query to be executed.'); + self::assertFalse($otherClass->childClasses->isInitialized(), 'Post-Condition: Collection is not initialized.'); } /** @@ -430,9 +430,9 @@ public function testCountingOnOneToManyJoinedInheritanceWillNotInitializeCollect { $otherClass = $this->_em->find(DDC2504OtherClass::class, $this->ddc2504OtherClassId); - $this->assertEquals(2, count($otherClass->childClasses)); + self::assertEquals(2, count($otherClass->childClasses)); - $this->assertFalse($otherClass->childClasses->isInitialized()); + self::assertFalse($otherClass->childClasses->isInitialized()); } /** @@ -441,15 +441,15 @@ public function testCountingOnOneToManyJoinedInheritanceWillNotInitializeCollect public function testContainsManyToMany(): void { $user = $this->_em->find(CmsUser::class, $this->userId); - $this->assertFalse($user->groups->isInitialized(), 'Pre-Condition: Collection is not initialized.'); + self::assertFalse($user->groups->isInitialized(), 'Pre-Condition: Collection is not initialized.'); // Test Many to Many existence retrieved from DB $group = $this->_em->find(CmsGroup::class, $this->groupId); $queryCount = $this->getCurrentQueryCount(); - $this->assertTrue($user->groups->contains($group)); - $this->assertEquals($queryCount + 1, $this->getCurrentQueryCount(), 'Checking for contains of managed entity should cause one query to be executed.'); - $this->assertFalse($user->groups->isInitialized(), 'Post-Condition: Collection is not initialized.'); + self::assertTrue($user->groups->contains($group)); + self::assertEquals($queryCount + 1, $this->getCurrentQueryCount(), 'Checking for contains of managed entity should cause one query to be executed.'); + self::assertFalse($user->groups->isInitialized(), 'Post-Condition: Collection is not initialized.'); // Test Many to Many existence with state new $group = new CmsGroup(); @@ -457,9 +457,9 @@ public function testContainsManyToMany(): void $queryCount = $this->getCurrentQueryCount(); - $this->assertFalse($user->groups->contains($group)); - $this->assertEquals($queryCount, $this->getCurrentQueryCount(), 'Checking for contains of new entity should cause no query to be executed.'); - $this->assertFalse($user->groups->isInitialized(), 'Post-Condition: Collection is not initialized.'); + self::assertFalse($user->groups->contains($group)); + self::assertEquals($queryCount, $this->getCurrentQueryCount(), 'Checking for contains of new entity should cause no query to be executed.'); + self::assertFalse($user->groups->isInitialized(), 'Post-Condition: Collection is not initialized.'); // Test Many to Many existence with state clear $this->_em->persist($group); @@ -467,9 +467,9 @@ public function testContainsManyToMany(): void $queryCount = $this->getCurrentQueryCount(); - $this->assertFalse($user->groups->contains($group)); - $this->assertEquals($queryCount + 1, $this->getCurrentQueryCount(), 'Checking for contains of persisted entity should cause one query to be executed.'); - $this->assertFalse($user->groups->isInitialized(), 'Post-Condition: Collection is not initialized.'); + self::assertFalse($user->groups->contains($group)); + self::assertEquals($queryCount + 1, $this->getCurrentQueryCount(), 'Checking for contains of persisted entity should cause one query to be executed.'); + self::assertFalse($user->groups->isInitialized(), 'Post-Condition: Collection is not initialized.'); // Test Many to Many existence with state managed $group = new CmsGroup(); @@ -479,9 +479,9 @@ public function testContainsManyToMany(): void $queryCount = $this->getCurrentQueryCount(); - $this->assertFalse($user->groups->contains($group)); - $this->assertEquals($queryCount, $this->getCurrentQueryCount(), 'Checking for contains of managed entity (but not persisted) should cause no query to be executed.'); - $this->assertFalse($user->groups->isInitialized(), 'Post-Condition: Collection is not initialized.'); + self::assertFalse($user->groups->contains($group)); + self::assertEquals($queryCount, $this->getCurrentQueryCount(), 'Checking for contains of managed entity (but not persisted) should cause no query to be executed.'); + self::assertFalse($user->groups->isInitialized(), 'Post-Condition: Collection is not initialized.'); } /** @@ -490,22 +490,22 @@ public function testContainsManyToMany(): void public function testContainsManyToManyInverse(): void { $group = $this->_em->find(CmsGroup::class, $this->groupId); - $this->assertFalse($group->users->isInitialized(), 'Pre-Condition: Collection is not initialized.'); + self::assertFalse($group->users->isInitialized(), 'Pre-Condition: Collection is not initialized.'); $user = $this->_em->find(CmsUser::class, $this->userId); $queryCount = $this->getCurrentQueryCount(); - $this->assertTrue($group->users->contains($user)); - $this->assertEquals($queryCount + 1, $this->getCurrentQueryCount(), 'Checking for contains of managed entity should cause one query to be executed.'); - $this->assertFalse($user->groups->isInitialized(), 'Post-Condition: Collection is not initialized.'); + self::assertTrue($group->users->contains($user)); + self::assertEquals($queryCount + 1, $this->getCurrentQueryCount(), 'Checking for contains of managed entity should cause one query to be executed.'); + self::assertFalse($user->groups->isInitialized(), 'Post-Condition: Collection is not initialized.'); $newUser = new CmsUser(); $newUser->name = 'A New group!'; $queryCount = $this->getCurrentQueryCount(); - $this->assertFalse($group->users->contains($newUser)); - $this->assertEquals($queryCount, $this->getCurrentQueryCount(), 'Checking for contains of new entity should cause no query to be executed.'); - $this->assertFalse($user->groups->isInitialized(), 'Post-Condition: Collection is not initialized.'); + self::assertFalse($group->users->contains($newUser)); + self::assertEquals($queryCount, $this->getCurrentQueryCount(), 'Checking for contains of new entity should cause no query to be executed.'); + self::assertFalse($user->groups->isInitialized(), 'Post-Condition: Collection is not initialized.'); } /** @@ -521,13 +521,13 @@ public function testCountAfterAddThenFlush(): void $user->addGroup($newGroup); $this->_em->persist($newGroup); - $this->assertFalse($user->groups->isInitialized()); - $this->assertEquals(4, count($user->groups)); - $this->assertFalse($user->groups->isInitialized()); + self::assertFalse($user->groups->isInitialized()); + self::assertEquals(4, count($user->groups)); + self::assertFalse($user->groups->isInitialized()); $this->_em->flush(); - $this->assertEquals(4, count($user->groups)); + self::assertEquals(4, count($user->groups)); } /** @@ -548,8 +548,8 @@ public function testSliceOnDirtyCollection(): void $qc = $this->getCurrentQueryCount(); $groups = $user->groups->slice(0, 10); - $this->assertEquals(4, count($groups)); - $this->assertEquals($qc + 1, $this->getCurrentQueryCount()); + self::assertEquals(4, count($groups)); + self::assertEquals($qc + 1, $this->getCurrentQueryCount()); } /** @@ -564,12 +564,12 @@ public function testGetIndexByIdentifier(): void $queryCount = $this->getCurrentQueryCount(); $phonenumber = $user->phonenumbers->get($this->phonenumber); - $this->assertFalse($user->phonenumbers->isInitialized()); - $this->assertEquals($queryCount + 1, $this->getCurrentQueryCount()); - $this->assertSame($phonenumber, $this->_em->find(CmsPhonenumber::class, $this->phonenumber)); + self::assertFalse($user->phonenumbers->isInitialized()); + self::assertEquals($queryCount + 1, $this->getCurrentQueryCount()); + self::assertSame($phonenumber, $this->_em->find(CmsPhonenumber::class, $this->phonenumber)); $article = $user->phonenumbers->get($this->phonenumber); - $this->assertEquals($queryCount + 1, $this->getCurrentQueryCount(), 'Getting the same entity should not cause an extra query to be executed'); + self::assertEquals($queryCount + 1, $this->getCurrentQueryCount(), 'Getting the same entity should not cause an extra query to be executed'); } /** @@ -584,9 +584,9 @@ public function testGetIndexByOneToMany(): void $article = $user->articles->get($this->topic); - $this->assertFalse($user->articles->isInitialized()); - $this->assertEquals($queryCount + 1, $this->getCurrentQueryCount()); - $this->assertSame($article, $this->_em->find(CmsArticle::class, $this->articleId)); + self::assertFalse($user->articles->isInitialized()); + self::assertEquals($queryCount + 1, $this->getCurrentQueryCount()); + self::assertSame($article, $this->_em->find(CmsArticle::class, $this->articleId)); } /** @@ -601,9 +601,9 @@ public function testGetIndexByManyToManyInverseSide(): void $user = $group->users->get($this->username); - $this->assertFalse($group->users->isInitialized()); - $this->assertEquals($queryCount + 1, $this->getCurrentQueryCount()); - $this->assertSame($user, $this->_em->find(CmsUser::class, $this->userId)); + self::assertFalse($group->users->isInitialized()); + self::assertEquals($queryCount + 1, $this->getCurrentQueryCount()); + self::assertSame($user, $this->_em->find(CmsUser::class, $this->userId)); } /** @@ -618,9 +618,9 @@ public function testGetIndexByManyToManyOwningSide(): void $group = $user->groups->get($this->groupname); - $this->assertFalse($user->groups->isInitialized()); - $this->assertEquals($queryCount + 1, $this->getCurrentQueryCount()); - $this->assertSame($group, $this->_em->find(CmsGroup::class, $this->groupId)); + self::assertFalse($user->groups->isInitialized()); + self::assertEquals($queryCount + 1, $this->getCurrentQueryCount()); + self::assertSame($group, $this->_em->find(CmsGroup::class, $this->groupId)); } /** @@ -629,8 +629,8 @@ public function testGetIndexByManyToManyOwningSide(): void public function testGetNonExistentIndexBy(): void { $user = $this->_em->find(CmsUser::class, $this->userId); - $this->assertNull($user->articles->get(-1)); - $this->assertNull($user->groups->get(-1)); + self::assertNull($user->articles->get(-1)); + self::assertNull($user->groups->get(-1)); } public function testContainsKeyIndexByOneToMany(): void @@ -642,9 +642,9 @@ public function testContainsKeyIndexByOneToMany(): void $contains = $user->articles->containsKey($this->topic); - $this->assertTrue($contains); - $this->assertFalse($user->articles->isInitialized()); - $this->assertEquals($queryCount + 1, $this->getCurrentQueryCount()); + self::assertTrue($contains); + self::assertFalse($user->articles->isInitialized()); + self::assertEquals($queryCount + 1, $this->getCurrentQueryCount()); } public function testContainsKeyIndexByOneToManyJoinedInheritance(): void @@ -658,9 +658,9 @@ public function testContainsKeyIndexByOneToManyJoinedInheritance(): void $contains = $otherClass->childClasses->containsKey($this->ddc2504ChildClassId); - $this->assertTrue($contains); - $this->assertFalse($otherClass->childClasses->isInitialized()); - $this->assertEquals($queryCount + 1, $this->getCurrentQueryCount()); + self::assertTrue($contains); + self::assertFalse($otherClass->childClasses->isInitialized()); + self::assertEquals($queryCount + 1, $this->getCurrentQueryCount()); } public function testContainsKeyIndexByManyToMany(): void @@ -673,9 +673,9 @@ public function testContainsKeyIndexByManyToMany(): void $contains = $user->groups->containsKey($group->name); - $this->assertTrue($contains, 'The item is not into collection'); - $this->assertFalse($user->groups->isInitialized(), 'The collection must not be initialized'); - $this->assertEquals($queryCount + 1, $this->getCurrentQueryCount()); + self::assertTrue($contains, 'The item is not into collection'); + self::assertFalse($user->groups->isInitialized(), 'The collection must not be initialized'); + self::assertEquals($queryCount + 1, $this->getCurrentQueryCount()); } public function testContainsKeyIndexByManyToManyNonOwning(): void @@ -687,9 +687,9 @@ public function testContainsKeyIndexByManyToManyNonOwning(): void $contains = $group->users->containsKey($user->username); - $this->assertTrue($contains, 'The item is not into collection'); - $this->assertFalse($group->users->isInitialized(), 'The collection must not be initialized'); - $this->assertEquals($queryCount + 1, $this->getCurrentQueryCount()); + self::assertTrue($contains, 'The item is not into collection'); + self::assertFalse($group->users->isInitialized(), 'The collection must not be initialized'); + self::assertEquals($queryCount + 1, $this->getCurrentQueryCount()); } public function testContainsKeyIndexByWithPkManyToMany(): void @@ -703,9 +703,9 @@ public function testContainsKeyIndexByWithPkManyToMany(): void $contains = $user->groups->containsKey($this->groupId); - $this->assertTrue($contains, 'The item is not into collection'); - $this->assertFalse($user->groups->isInitialized(), 'The collection must not be initialized'); - $this->assertEquals($queryCount + 1, $this->getCurrentQueryCount()); + self::assertTrue($contains, 'The item is not into collection'); + self::assertFalse($user->groups->isInitialized(), 'The collection must not be initialized'); + self::assertEquals($queryCount + 1, $this->getCurrentQueryCount()); } public function testContainsKeyIndexByWithPkManyToManyNonOwning(): void @@ -719,9 +719,9 @@ public function testContainsKeyIndexByWithPkManyToManyNonOwning(): void $contains = $group->users->containsKey($this->userId2); - $this->assertTrue($contains, 'The item is not into collection'); - $this->assertFalse($group->users->isInitialized(), 'The collection must not be initialized'); - $this->assertEquals($queryCount + 1, $this->getCurrentQueryCount()); + self::assertTrue($contains, 'The item is not into collection'); + self::assertFalse($group->users->isInitialized(), 'The collection must not be initialized'); + self::assertEquals($queryCount + 1, $this->getCurrentQueryCount()); } public function testContainsKeyNonExistentIndexByOneToMany(): void @@ -732,9 +732,9 @@ public function testContainsKeyNonExistentIndexByOneToMany(): void $contains = $user->articles->containsKey('NonExistentTopic'); - $this->assertFalse($contains); - $this->assertFalse($user->articles->isInitialized()); - $this->assertEquals($queryCount + 1, $this->getCurrentQueryCount()); + self::assertFalse($contains); + self::assertFalse($user->articles->isInitialized()); + self::assertEquals($queryCount + 1, $this->getCurrentQueryCount()); } public function testContainsKeyNonExistentIndexByManyToMany(): void @@ -745,9 +745,9 @@ public function testContainsKeyNonExistentIndexByManyToMany(): void $contains = $user->groups->containsKey('NonExistentTopic'); - $this->assertFalse($contains); - $this->assertFalse($user->groups->isInitialized()); - $this->assertEquals($queryCount + 1, $this->getCurrentQueryCount()); + self::assertFalse($contains); + self::assertFalse($user->groups->isInitialized()); + self::assertEquals($queryCount + 1, $this->getCurrentQueryCount()); } private function loadFixture(): void diff --git a/tests/Doctrine/Tests/ORM/Functional/FlushEventTest.php b/tests/Doctrine/Tests/ORM/Functional/FlushEventTest.php index 4e66b8e42d8..532f85f5034 100644 --- a/tests/Doctrine/Tests/ORM/Functional/FlushEventTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/FlushEventTest.php @@ -35,15 +35,15 @@ public function testPersistNewEntitiesOnPreFlush(): void $this->_em->persist($user); - $this->assertEquals(0, $user->phonenumbers->count()); + self::assertEquals(0, $user->phonenumbers->count()); $this->_em->flush(); - $this->assertEquals(1, $user->phonenumbers->count()); - $this->assertTrue($this->_em->contains($user->phonenumbers->get(0))); - $this->assertTrue($user->phonenumbers->get(0)->getUser() === $user); + self::assertEquals(1, $user->phonenumbers->count()); + self::assertTrue($this->_em->contains($user->phonenumbers->get(0))); + self::assertTrue($user->phonenumbers->get(0)->getUser() === $user); - $this->assertFalse($user->phonenumbers->isDirty()); + self::assertFalse($user->phonenumbers->isDirty()); // Can be used together with SQL Logging to check that a subsequent flush has // nothing to do. This proofs the correctness of the changes that happened in onFlush. @@ -63,13 +63,13 @@ public function testPreAndOnFlushCalledAlways(): void $this->_em->flush(); - $this->assertEquals(1, $listener->preFlush); - $this->assertEquals(1, $listener->onFlush); + self::assertEquals(1, $listener->preFlush); + self::assertEquals(1, $listener->onFlush); $this->_em->flush(); - $this->assertEquals(2, $listener->preFlush); - $this->assertEquals(2, $listener->onFlush); + self::assertEquals(2, $listener->preFlush); + self::assertEquals(2, $listener->onFlush); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/HydrationCacheTest.php b/tests/Doctrine/Tests/ORM/Functional/HydrationCacheTest.php index 1bebd3801e8..b08f2213553 100644 --- a/tests/Doctrine/Tests/ORM/Functional/HydrationCacheTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/HydrationCacheTest.php @@ -45,30 +45,30 @@ public function testHydrationCache(): void ->setHydrationCacheProfile(new QueryCacheProfile(null, null, $cache)) ->getResult(); - $this->assertEquals($c, $this->getCurrentQueryCount(), 'Should not execute query. Its cached!'); + self::assertEquals($c, $this->getCurrentQueryCount(), 'Should not execute query. Its cached!'); $users = $this->_em->createQuery($dql) ->setHydrationCacheProfile(new QueryCacheProfile(null, null, $cache)) ->getArrayResult(); - $this->assertEquals($c + 1, $this->getCurrentQueryCount(), 'Hydration is part of cache key.'); + self::assertEquals($c + 1, $this->getCurrentQueryCount(), 'Hydration is part of cache key.'); $users = $this->_em->createQuery($dql) ->setHydrationCacheProfile(new QueryCacheProfile(null, null, $cache)) ->getArrayResult(); - $this->assertEquals($c + 1, $this->getCurrentQueryCount(), 'Hydration now cached'); + self::assertEquals($c + 1, $this->getCurrentQueryCount(), 'Hydration now cached'); $users = $this->_em->createQuery($dql) ->setHydrationCacheProfile(new QueryCacheProfile(null, 'cachekey', $cache)) ->getArrayResult(); - $this->assertTrue($cache->contains('cachekey'), 'Explicit cache key'); + self::assertTrue($cache->contains('cachekey'), 'Explicit cache key'); $users = $this->_em->createQuery($dql) ->setHydrationCacheProfile(new QueryCacheProfile(null, 'cachekey', $cache)) ->getArrayResult(); - $this->assertEquals($c + 2, $this->getCurrentQueryCount(), 'Hydration now cached'); + self::assertEquals($c + 2, $this->getCurrentQueryCount(), 'Hydration now cached'); } public function testHydrationParametersSerialization(): void @@ -86,6 +86,6 @@ public function testHydrationParametersSerialization(): void $query->getResult(); - $this->assertEquals($c, $this->getCurrentQueryCount(), 'Should not execute query. Its cached!'); + self::assertEquals($c, $this->getCurrentQueryCount(), 'Should not execute query. Its cached!'); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/IdentityMapTest.php b/tests/Doctrine/Tests/ORM/Functional/IdentityMapTest.php index ad673e361d9..0c3166b7ef0 100644 --- a/tests/Doctrine/Tests/ORM/Functional/IdentityMapTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/IdentityMapTest.php @@ -46,16 +46,16 @@ public function testBasicIdentityManagement(): void $this->_em->clear(); $user2 = $this->_em->find(get_class($user), $user->getId()); - $this->assertTrue($user2 !== $user); + self::assertTrue($user2 !== $user); $user3 = $this->_em->find(get_class($user), $user->getId()); - $this->assertTrue($user2 === $user3); + self::assertTrue($user2 === $user3); $address2 = $this->_em->find(get_class($address), $address->getId()); - $this->assertTrue($address2 !== $address); + self::assertTrue($address2 !== $address); $address3 = $this->_em->find(get_class($address), $address->getId()); - $this->assertTrue($address2 === $address3); + self::assertTrue($address2 === $address3); - $this->assertTrue($user2->getAddress() === $address2); // !!! + self::assertTrue($user2->getAddress() === $address2); // !!! } public function testSingleValuedAssociationIdentityMapBehaviorWithRefresh(): void @@ -82,7 +82,7 @@ public function testSingleValuedAssociationIdentityMapBehaviorWithRefresh(): voi $this->_em->persist($user2); $this->_em->flush(); - $this->assertSame($user1, $address->user); + self::assertSame($user1, $address->user); //external update to CmsAddress $this->_em->getConnection()->executeUpdate('update cms_addresses set user_id = ?', [$user2->getId()]); @@ -92,12 +92,12 @@ public function testSingleValuedAssociationIdentityMapBehaviorWithRefresh(): voi $this->_em->refresh($address); // Now the association should be "correct", referencing $user2 - $this->assertSame($user2, $address->user); - $this->assertSame($user2->address, $address); // check back reference also + self::assertSame($user2, $address->user); + self::assertSame($user2->address, $address); // check back reference also // Attention! refreshes can result in broken bidirectional associations! this is currently expected! // $user1 still points to $address! - $this->assertSame($user1->address, $address); + self::assertSame($user1->address, $address); } public function testSingleValuedAssociationIdentityMapBehaviorWithRefreshQuery(): void @@ -124,7 +124,7 @@ public function testSingleValuedAssociationIdentityMapBehaviorWithRefreshQuery() $this->_em->persist($user2); $this->_em->flush(); - $this->assertSame($user1, $address->user); + self::assertSame($user1, $address->user); //external update to CmsAddress $this->_em->getConnection()->executeUpdate('update cms_addresses set user_id = ?', [$user2->getId()]); @@ -133,11 +133,11 @@ public function testSingleValuedAssociationIdentityMapBehaviorWithRefreshQuery() $q = $this->_em->createQuery('select a, u from Doctrine\Tests\Models\CMS\CmsAddress a join a.user u'); $address2 = $q->getSingleResult(); - $this->assertSame($address, $address2); + self::assertSame($address, $address2); // Should still be $user1 - $this->assertSame($user1, $address2->user); - $this->assertTrue($user2->address === null); + self::assertSame($user1, $address2->user); + self::assertTrue($user2->address === null); // But we want to have this external change! // Solution 2: Alternatively, a refresh query should work @@ -145,15 +145,15 @@ public function testSingleValuedAssociationIdentityMapBehaviorWithRefreshQuery() $q->setHint(Query::HINT_REFRESH, true); $address3 = $q->getSingleResult(); - $this->assertSame($address, $address3); // should still be the same, always from identity map + self::assertSame($address, $address3); // should still be the same, always from identity map // Now the association should be "correct", referencing $user2 - $this->assertSame($user2, $address2->user); - $this->assertSame($user2->address, $address2); // check back reference also + self::assertSame($user2, $address2->user); + self::assertSame($user2->address, $address2); // check back reference also // Attention! refreshes can result in broken bidirectional associations! this is currently expected! // $user1 still points to $address2! - $this->assertSame($user1->address, $address2); + self::assertSame($user1->address, $address2); } public function testCollectionValuedAssociationIdentityMapBehaviorWithRefreshQuery(): void @@ -179,8 +179,8 @@ public function testCollectionValuedAssociationIdentityMapBehaviorWithRefreshQue $this->_em->persist($user); // cascaded to phone numbers $this->_em->flush(); - $this->assertEquals(3, count($user->getPhonenumbers())); - $this->assertFalse($user->getPhonenumbers()->isDirty()); + self::assertEquals(3, count($user->getPhonenumbers())); + self::assertFalse($user->getPhonenumbers()->isDirty()); //external update to CmsAddress $this->_em->getConnection()->executeUpdate('insert into cms_phonenumbers (phonenumber, user_id) VALUES (?,?)', [999, $user->getId()]); @@ -189,10 +189,10 @@ public function testCollectionValuedAssociationIdentityMapBehaviorWithRefreshQue $q = $this->_em->createQuery('select u, p from Doctrine\Tests\Models\CMS\CmsUser u join u.phonenumbers p'); $user2 = $q->getSingleResult(); - $this->assertSame($user, $user2); + self::assertSame($user, $user2); // Should still be the same 3 phonenumbers - $this->assertEquals(3, count($user2->getPhonenumbers())); + self::assertEquals(3, count($user2->getPhonenumbers())); // But we want to have this external change! // Solution 1: refresh(). @@ -202,10 +202,10 @@ public function testCollectionValuedAssociationIdentityMapBehaviorWithRefreshQue $q->setHint(Query::HINT_REFRESH, true); $user3 = $q->getSingleResult(); - $this->assertSame($user, $user3); // should still be the same, always from identity map + self::assertSame($user, $user3); // should still be the same, always from identity map // Now the collection should be refreshed with correct count - $this->assertEquals(4, count($user3->getPhonenumbers())); + self::assertEquals(4, count($user3->getPhonenumbers())); } /** @@ -234,7 +234,7 @@ public function testCollectionValuedAssociationIdentityMapBehaviorWithRefresh(): $this->_em->persist($user); // cascaded to phone numbers $this->_em->flush(); - $this->assertEquals(3, count($user->getPhonenumbers())); + self::assertEquals(3, count($user->getPhonenumbers())); //external update to CmsAddress $this->_em->getConnection()->executeUpdate('insert into cms_phonenumbers (phonenumber, user_id) VALUES (?,?)', [999, $user->getId()]); @@ -243,18 +243,18 @@ public function testCollectionValuedAssociationIdentityMapBehaviorWithRefresh(): $q = $this->_em->createQuery('select u, p from Doctrine\Tests\Models\CMS\CmsUser u join u.phonenumbers p'); $user2 = $q->getSingleResult(); - $this->assertSame($user, $user2); + self::assertSame($user, $user2); // Should still be the same 3 phonenumbers - $this->assertEquals(3, count($user2->getPhonenumbers())); + self::assertEquals(3, count($user2->getPhonenumbers())); // But we want to have this external change! // Solution 1: refresh(). $this->_em->refresh($user2); - $this->assertSame($user, $user2); // should still be the same, always from identity map + self::assertSame($user, $user2); // should still be the same, always from identity map // Now the collection should be refreshed with correct count - $this->assertEquals(4, count($user2->getPhonenumbers())); + self::assertEquals(4, count($user2->getPhonenumbers())); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/IndexByAssociationTest.php b/tests/Doctrine/Tests/ORM/Functional/IndexByAssociationTest.php index 7a7a2eca665..e349f9d3d43 100644 --- a/tests/Doctrine/Tests/ORM/Functional/IndexByAssociationTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/IndexByAssociationTest.php @@ -53,11 +53,11 @@ public function testManyToOneFinder(): void $market = $this->_em->find(Market::class, $this->market->getId()); assert($market instanceof Market); - $this->assertEquals(2, count($market->stocks)); - $this->assertTrue(isset($market->stocks['AAPL']), 'AAPL symbol has to be key in indexed association.'); - $this->assertTrue(isset($market->stocks['GOOG']), 'GOOG symbol has to be key in indexed association.'); - $this->assertEquals('AAPL', $market->stocks['AAPL']->getSymbol()); - $this->assertEquals('GOOG', $market->stocks['GOOG']->getSymbol()); + self::assertEquals(2, count($market->stocks)); + self::assertTrue(isset($market->stocks['AAPL']), 'AAPL symbol has to be key in indexed association.'); + self::assertTrue(isset($market->stocks['GOOG']), 'GOOG symbol has to be key in indexed association.'); + self::assertEquals('AAPL', $market->stocks['AAPL']->getSymbol()); + self::assertEquals('GOOG', $market->stocks['GOOG']->getSymbol()); } public function testManyToOneDQL(): void @@ -65,22 +65,22 @@ public function testManyToOneDQL(): void $dql = 'SELECT m, s FROM Doctrine\Tests\Models\StockExchange\Market m JOIN m.stocks s WHERE m.id = ?1'; $market = $this->_em->createQuery($dql)->setParameter(1, $this->market->getId())->getSingleResult(); - $this->assertEquals(2, count($market->stocks)); - $this->assertTrue(isset($market->stocks['AAPL']), 'AAPL symbol has to be key in indexed association.'); - $this->assertTrue(isset($market->stocks['GOOG']), 'GOOG symbol has to be key in indexed association.'); - $this->assertEquals('AAPL', $market->stocks['AAPL']->getSymbol()); - $this->assertEquals('GOOG', $market->stocks['GOOG']->getSymbol()); + self::assertEquals(2, count($market->stocks)); + self::assertTrue(isset($market->stocks['AAPL']), 'AAPL symbol has to be key in indexed association.'); + self::assertTrue(isset($market->stocks['GOOG']), 'GOOG symbol has to be key in indexed association.'); + self::assertEquals('AAPL', $market->stocks['AAPL']->getSymbol()); + self::assertEquals('GOOG', $market->stocks['GOOG']->getSymbol()); } public function testManyToMany(): void { $bond = $this->_em->find(Bond::class, $this->bond->getId()); - $this->assertEquals(2, count($bond->stocks)); - $this->assertTrue(isset($bond->stocks['AAPL']), 'AAPL symbol has to be key in indexed association.'); - $this->assertTrue(isset($bond->stocks['GOOG']), 'GOOG symbol has to be key in indexed association.'); - $this->assertEquals('AAPL', $bond->stocks['AAPL']->getSymbol()); - $this->assertEquals('GOOG', $bond->stocks['GOOG']->getSymbol()); + self::assertEquals(2, count($bond->stocks)); + self::assertTrue(isset($bond->stocks['AAPL']), 'AAPL symbol has to be key in indexed association.'); + self::assertTrue(isset($bond->stocks['GOOG']), 'GOOG symbol has to be key in indexed association.'); + self::assertEquals('AAPL', $bond->stocks['AAPL']->getSymbol()); + self::assertEquals('GOOG', $bond->stocks['GOOG']->getSymbol()); } public function testManytoManyDQL(): void @@ -88,11 +88,11 @@ public function testManytoManyDQL(): void $dql = 'SELECT b, s FROM Doctrine\Tests\Models\StockExchange\Bond b JOIN b.stocks s WHERE b.id = ?1'; $bond = $this->_em->createQuery($dql)->setParameter(1, $this->bond->getId())->getSingleResult(); - $this->assertEquals(2, count($bond->stocks)); - $this->assertTrue(isset($bond->stocks['AAPL']), 'AAPL symbol has to be key in indexed association.'); - $this->assertTrue(isset($bond->stocks['GOOG']), 'GOOG symbol has to be key in indexed association.'); - $this->assertEquals('AAPL', $bond->stocks['AAPL']->getSymbol()); - $this->assertEquals('GOOG', $bond->stocks['GOOG']->getSymbol()); + self::assertEquals(2, count($bond->stocks)); + self::assertTrue(isset($bond->stocks['AAPL']), 'AAPL symbol has to be key in indexed association.'); + self::assertTrue(isset($bond->stocks['GOOG']), 'GOOG symbol has to be key in indexed association.'); + self::assertEquals('AAPL', $bond->stocks['AAPL']->getSymbol()); + self::assertEquals('GOOG', $bond->stocks['GOOG']->getSymbol()); } public function testDqlOverrideIndexBy(): void @@ -100,8 +100,8 @@ public function testDqlOverrideIndexBy(): void $dql = 'SELECT b, s FROM Doctrine\Tests\Models\StockExchange\Bond b JOIN b.stocks s INDEX BY s.id WHERE b.id = ?1'; $bond = $this->_em->createQuery($dql)->setParameter(1, $this->bond->getId())->getSingleResult(); - $this->assertEquals(2, count($bond->stocks)); - $this->assertFalse(isset($bond->stocks['AAPL']), 'AAPL symbol not exists in re-indexed association.'); - $this->assertFalse(isset($bond->stocks['GOOG']), 'GOOG symbol not exists in re-indexed association.'); + self::assertEquals(2, count($bond->stocks)); + self::assertFalse(isset($bond->stocks['AAPL']), 'AAPL symbol not exists in re-indexed association.'); + self::assertFalse(isset($bond->stocks['GOOG']), 'GOOG symbol not exists in re-indexed association.'); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/JoinedTableCompositeKeyTest.php b/tests/Doctrine/Tests/ORM/Functional/JoinedTableCompositeKeyTest.php index 779e23c35ef..cdb427f5d25 100644 --- a/tests/Doctrine/Tests/ORM/Functional/JoinedTableCompositeKeyTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/JoinedTableCompositeKeyTest.php @@ -25,7 +25,7 @@ public function testInsertWithCompositeKey(): void $this->_em->clear(); $entity = $this->findEntity(); - $this->assertEquals($childEntity, $entity); + self::assertEquals($childEntity, $entity); } /** @@ -47,7 +47,7 @@ public function testUpdateWithCompositeKey(): void $this->_em->clear(); $persistedEntity = $this->findEntity(); - $this->assertEquals($entity, $persistedEntity); + self::assertEquals($entity, $persistedEntity); } private function findEntity(): JoinedChildClass diff --git a/tests/Doctrine/Tests/ORM/Functional/LifecycleCallbackTest.php b/tests/Doctrine/Tests/ORM/Functional/LifecycleCallbackTest.php index e9fbd3ffae8..2eecdff0076 100644 --- a/tests/Doctrine/Tests/ORM/Functional/LifecycleCallbackTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/LifecycleCallbackTest.php @@ -62,20 +62,20 @@ public function testPreSavePostSaveCallbacksAreInvoked(): void $this->_em->persist($entity); $this->_em->flush(); - $this->assertTrue($entity->prePersistCallbackInvoked); - $this->assertTrue($entity->postPersistCallbackInvoked); + self::assertTrue($entity->prePersistCallbackInvoked); + self::assertTrue($entity->postPersistCallbackInvoked); $this->_em->clear(); $query = $this->_em->createQuery('select e from Doctrine\Tests\ORM\Functional\LifecycleCallbackTestEntity e'); $result = $query->getResult(); - $this->assertTrue($result[0]->postLoadCallbackInvoked); + self::assertTrue($result[0]->postLoadCallbackInvoked); $result[0]->value = 'hello again'; $this->_em->flush(); - $this->assertEquals('changed from preUpdate callback!', $result[0]->value); + self::assertEquals('changed from preUpdate callback!', $result[0]->value); } public function testPreFlushCallbacksAreInvoked(): void @@ -86,19 +86,19 @@ public function testPreFlushCallbacksAreInvoked(): void $this->_em->flush(); - $this->assertTrue($entity->prePersistCallbackInvoked); - $this->assertTrue($entity->preFlushCallbackInvoked); + self::assertTrue($entity->prePersistCallbackInvoked); + self::assertTrue($entity->preFlushCallbackInvoked); $entity->preFlushCallbackInvoked = false; $this->_em->flush(); - $this->assertTrue($entity->preFlushCallbackInvoked); + self::assertTrue($entity->preFlushCallbackInvoked); $entity->value = 'bye'; $entity->preFlushCallbackInvoked = false; $this->_em->flush(); - $this->assertTrue($entity->preFlushCallbackInvoked); + self::assertTrue($entity->preFlushCallbackInvoked); } public function testChangesDontGetLost(): void @@ -116,8 +116,8 @@ public function testChangesDontGetLost(): void $user2 = $this->_em->find(get_class($user), $user->getId()); - $this->assertEquals('Alice', $user2->getName()); - $this->assertEquals('Hello World', $user2->getValue()); + self::assertEquals('Alice', $user2->getName()); + self::assertEquals('Hello World', $user2->getValue()); } /** @@ -134,10 +134,10 @@ public function testGetReferenceWithPostLoadEventIsDelayedUntilProxyTrigger(): v $this->_em->clear(); $reference = $this->_em->getReference(LifecycleCallbackTestEntity::class, $id); - $this->assertFalse($reference->postLoadCallbackInvoked); + self::assertFalse($reference->postLoadCallbackInvoked); $reference->getValue(); // trigger proxy load - $this->assertTrue($reference->postLoadCallbackInvoked); + self::assertTrue($reference->postLoadCallbackInvoked); } /** @@ -154,11 +154,11 @@ public function testPostLoadTriggeredOnRefresh(): void $this->_em->clear(); $reference = $this->_em->find(LifecycleCallbackTestEntity::class, $id); - $this->assertTrue($reference->postLoadCallbackInvoked); + self::assertTrue($reference->postLoadCallbackInvoked); $reference->postLoadCallbackInvoked = false; $this->_em->refresh($reference); - $this->assertTrue($reference->postLoadCallbackInvoked, 'postLoad should be invoked when refresh() is called.'); + self::assertTrue($reference->postLoadCallbackInvoked, 'postLoad should be invoked when refresh() is called.'); } /** @@ -182,8 +182,8 @@ public function testCascadedEntitiesCallsPrePersist(): void //$this->_em->persist($c); $this->_em->flush(); - $this->assertTrue($e1->prePersistCallbackInvoked); - $this->assertTrue($e2->prePersistCallbackInvoked); + self::assertTrue($e1->prePersistCallbackInvoked); + self::assertTrue($e2->prePersistCallbackInvoked); } /** @@ -222,10 +222,10 @@ public function testCascadedEntitiesLoadedInPostLoad(): void ->createQuery(sprintf($dql, $e1->getId(), $e2->getId())) ->getResult(); - $this->assertTrue(current($entities)->postLoadCallbackInvoked); - $this->assertTrue(current($entities)->postLoadCascaderNotNull); - $this->assertTrue(current($entities)->cascader->postLoadCallbackInvoked); - $this->assertEquals(current($entities)->cascader->postLoadEntitiesCount, 2); + self::assertTrue(current($entities)->postLoadCallbackInvoked); + self::assertTrue(current($entities)->postLoadCascaderNotNull); + self::assertTrue(current($entities)->cascader->postLoadCallbackInvoked); + self::assertEquals(current($entities)->cascader->postLoadEntitiesCount, 2); } /** @@ -264,8 +264,8 @@ public function testCascadedEntitiesNotLoadedInPostLoadDuringIteration(): void $result = $query->iterate(); foreach ($result as $entity) { - $this->assertTrue($entity[0]->postLoadCallbackInvoked); - $this->assertFalse($entity[0]->postLoadCascaderNotNull); + self::assertTrue($entity[0]->postLoadCallbackInvoked); + self::assertFalse($entity[0]->postLoadCascaderNotNull); break; } @@ -299,8 +299,8 @@ public function testCascadedEntitiesNotLoadedInPostLoadDuringIterationWithSimple $result = $query->iterate(null, Query::HYDRATE_SIMPLEOBJECT); foreach ($result as $entity) { - $this->assertTrue($entity[0]->postLoadCallbackInvoked); - $this->assertFalse($entity[0]->postLoadCascaderNotNull); + self::assertTrue($entity[0]->postLoadCallbackInvoked); + self::assertFalse($entity[0]->postLoadCascaderNotNull); break; } @@ -350,16 +350,16 @@ public function testPostLoadIsInvokedOnFetchJoinedEntities(): void ->createQuery($dql)->setParameter('entA_id', $entA->getId()) ->getOneOrNullResult(); - $this->assertTrue($fetchedA->postLoadCallbackInvoked); + self::assertTrue($fetchedA->postLoadCallbackInvoked); foreach ($fetchedA->entities as $fetchJoinedEntB) { - $this->assertTrue($fetchJoinedEntB->postLoadCallbackInvoked); + self::assertTrue($fetchJoinedEntB->postLoadCallbackInvoked); } } public function testLifecycleCallbacksGetInherited(): void { $childMeta = $this->_em->getClassMetadata(LifecycleCallbackChildEntity::class); - $this->assertEquals(['prePersist' => [0 => 'doStuff']], $childMeta->lifecycleCallbacks); + self::assertEquals(['prePersist' => [0 => 'doStuff']], $childMeta->lifecycleCallbacks); } public function testLifecycleListenerChangeUpdateChangeSet(): void @@ -385,7 +385,7 @@ public function testLifecycleListenerChangeUpdateChangeSet(): void $bob = $this->_em->createQuery($dql)->getSingleResult(); - $this->assertEquals('Bob', $bob->getName()); + self::assertEquals('Bob', $bob->getName()); } /** @@ -408,23 +408,23 @@ public function testLifecycleCallbackEventArgs(): void $this->_em->remove($e); $this->_em->flush(); - $this->assertArrayHasKey('preFlushHandler', $e->calls); - $this->assertArrayHasKey('postLoadHandler', $e->calls); - $this->assertArrayHasKey('prePersistHandler', $e->calls); - $this->assertArrayHasKey('postPersistHandler', $e->calls); - $this->assertArrayHasKey('preUpdateHandler', $e->calls); - $this->assertArrayHasKey('postUpdateHandler', $e->calls); - $this->assertArrayHasKey('preRemoveHandler', $e->calls); - $this->assertArrayHasKey('postRemoveHandler', $e->calls); - - $this->assertInstanceOf(PreFlushEventArgs::class, $e->calls['preFlushHandler']); - $this->assertInstanceOf(LifecycleEventArgs::class, $e->calls['postLoadHandler']); - $this->assertInstanceOf(LifecycleEventArgs::class, $e->calls['prePersistHandler']); - $this->assertInstanceOf(LifecycleEventArgs::class, $e->calls['postPersistHandler']); - $this->assertInstanceOf(PreUpdateEventArgs::class, $e->calls['preUpdateHandler']); - $this->assertInstanceOf(LifecycleEventArgs::class, $e->calls['postUpdateHandler']); - $this->assertInstanceOf(LifecycleEventArgs::class, $e->calls['preRemoveHandler']); - $this->assertInstanceOf(LifecycleEventArgs::class, $e->calls['postRemoveHandler']); + self::assertArrayHasKey('preFlushHandler', $e->calls); + self::assertArrayHasKey('postLoadHandler', $e->calls); + self::assertArrayHasKey('prePersistHandler', $e->calls); + self::assertArrayHasKey('postPersistHandler', $e->calls); + self::assertArrayHasKey('preUpdateHandler', $e->calls); + self::assertArrayHasKey('postUpdateHandler', $e->calls); + self::assertArrayHasKey('preRemoveHandler', $e->calls); + self::assertArrayHasKey('postRemoveHandler', $e->calls); + + self::assertInstanceOf(PreFlushEventArgs::class, $e->calls['preFlushHandler']); + self::assertInstanceOf(LifecycleEventArgs::class, $e->calls['postLoadHandler']); + self::assertInstanceOf(LifecycleEventArgs::class, $e->calls['prePersistHandler']); + self::assertInstanceOf(LifecycleEventArgs::class, $e->calls['postPersistHandler']); + self::assertInstanceOf(PreUpdateEventArgs::class, $e->calls['preUpdateHandler']); + self::assertInstanceOf(LifecycleEventArgs::class, $e->calls['postUpdateHandler']); + self::assertInstanceOf(LifecycleEventArgs::class, $e->calls['preRemoveHandler']); + self::assertInstanceOf(LifecycleEventArgs::class, $e->calls['postRemoveHandler']); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Locking/GearmanLockTest.php b/tests/Doctrine/Tests/ORM/Functional/Locking/GearmanLockTest.php index 068ac09ee1d..84d71ec4921 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Locking/GearmanLockTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/Locking/GearmanLockTest.php @@ -30,7 +30,7 @@ class GearmanLockTest extends OrmFunctionalTestCase protected function setUp(): void { if (! class_exists('GearmanClient', false)) { - $this->markTestSkipped('pecl/gearman is required for this test to run.'); + self::markTestSkipped('pecl/gearman is required for this test to run.'); } $this->useModelSet('cms'); @@ -144,12 +144,12 @@ protected function assertLockWorked($forTime = 2, $notLongerThan = null): void $this->gearman->runTasks(); - $this->assertTrue( + self::assertTrue( $this->maxRunTime > $forTime, 'Because of locking this tests should have run at least ' . $forTime . ' seconds, ' . 'but only did for ' . $this->maxRunTime . ' seconds.' ); - $this->assertTrue( + self::assertTrue( $this->maxRunTime < $notLongerThan, 'The longest task should not run longer than ' . $notLongerThan . ' seconds, ' . 'but did for ' . $this->maxRunTime . ' seconds.' @@ -192,6 +192,6 @@ protected function startJob($fn, $fixture): void ] )); - $this->assertEquals(GEARMAN_SUCCESS, $this->gearman->returnCode()); + self::assertEquals(GEARMAN_SUCCESS, $this->gearman->returnCode()); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Locking/LockTest.php b/tests/Doctrine/Tests/ORM/Functional/Locking/LockTest.php index 82a3db78cc4..98ce0543097 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Locking/LockTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/Locking/LockTest.php @@ -159,7 +159,7 @@ public function testLockPessimisticWrite(): void $writeLockSql = $this->_em->getConnection()->getDatabasePlatform()->getWriteLockSQL(); if (! $writeLockSql) { - $this->markTestSkipped('Database Driver has no Write Lock support.'); + self::markTestSkipped('Database Driver has no Write Lock support.'); } $article = new CmsArticle(); @@ -181,7 +181,7 @@ public function testLockPessimisticWrite(): void $query = array_pop($this->_sqlLoggerStack->queries); $query = array_pop($this->_sqlLoggerStack->queries); - $this->assertStringContainsString($writeLockSql, $query['sql']); + self::assertStringContainsString($writeLockSql, $query['sql']); } /** @@ -192,7 +192,7 @@ public function testLockPessimisticRead(): void $readLockSql = $this->_em->getConnection()->getDatabasePlatform()->getReadLockSQL(); if (! $readLockSql) { - $this->markTestSkipped('Database Driver has no Write Lock support.'); + self::markTestSkipped('Database Driver has no Write Lock support.'); } $article = new CmsArticle(); @@ -216,7 +216,7 @@ public function testLockPessimisticRead(): void array_pop($this->_sqlLoggerStack->queries); $query = array_pop($this->_sqlLoggerStack->queries); - $this->assertStringContainsString($readLockSql, $query['sql']); + self::assertStringContainsString($readLockSql, $query['sql']); } /** diff --git a/tests/Doctrine/Tests/ORM/Functional/Locking/OptimisticTest.php b/tests/Doctrine/Tests/ORM/Functional/Locking/OptimisticTest.php index 4d540c9107b..aed039e5ee5 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Locking/OptimisticTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/Locking/OptimisticTest.php @@ -53,7 +53,7 @@ public function testJoinedChildInsertSetsInitialVersionValue(): OptimisticJoined $this->_em->persist($test); $this->_em->flush(); - $this->assertEquals(1, $test->version); + self::assertEquals(1, $test->version); return $test; } @@ -80,7 +80,7 @@ public function testJoinedChildFailureThrowsException(OptimisticJoinedChild $chi try { $this->_em->flush(); } catch (OptimisticLockException $e) { - $this->assertSame($test, $e->getEntity()); + self::assertSame($test, $e->getEntity()); } } @@ -93,7 +93,7 @@ public function testJoinedParentInsertSetsInitialVersionValue(): OptimisticJoine $this->_em->persist($test); $this->_em->flush(); - $this->assertEquals(1, $test->version); + self::assertEquals(1, $test->version); return $test; } @@ -120,7 +120,7 @@ public function testJoinedParentFailureThrowsException(OptimisticJoinedParent $p try { $this->_em->flush(); } catch (OptimisticLockException $e) { - $this->assertSame($test, $e->getEntity()); + self::assertSame($test, $e->getEntity()); } } @@ -134,8 +134,8 @@ public function testMultipleFlushesDoIncrementalUpdates(): void $this->_em->persist($test); $this->_em->flush(); - $this->assertIsInt($test->getVersion()); - $this->assertEquals($i + 1, $test->getVersion()); + self::assertIsInt($test->getVersion()); + self::assertEquals($i + 1, $test->getVersion()); } } @@ -148,8 +148,8 @@ public function testStandardInsertSetsInitialVersionValue(): OptimisticStandard $this->_em->persist($test); $this->_em->flush(); - $this->assertIsInt($test->getVersion()); - $this->assertEquals(1, $test->getVersion()); + self::assertIsInt($test->getVersion()); + self::assertEquals(1, $test->getVersion()); return $test; } @@ -176,7 +176,7 @@ public function testStandardFailureThrowsException(OptimisticStandard $entity): try { $this->_em->flush(); } catch (OptimisticLockException $e) { - $this->assertSame($test, $e->getEntity()); + self::assertSame($test, $e->getEntity()); } } @@ -202,12 +202,12 @@ public function testOptimisticTimestampSetsDefaultValue(): OptimisticTimestamp $test->name = 'Testing'; - $this->assertNull($test->version, 'Pre-Condition'); + self::assertNull($test->version, 'Pre-Condition'); $this->_em->persist($test); $this->_em->flush(); - $this->assertInstanceOf('DateTime', $test->version); + self::assertInstanceOf('DateTime', $test->version); return $test; } @@ -223,7 +223,7 @@ public function testOptimisticTimestampFailureThrowsException(OptimisticTimestam $test = $q->getSingleResult(); - $this->assertInstanceOf('DateTime', $test->version); + self::assertInstanceOf('DateTime', $test->version); // Manually increment the version datetime column $format = $this->_em->getConnection()->getDatabasePlatform()->getDateTimeFormatString(); @@ -240,8 +240,8 @@ public function testOptimisticTimestampFailureThrowsException(OptimisticTimestam $caughtException = $e; } - $this->assertNotNull($caughtException, 'No OptimisticLockingException was thrown'); - $this->assertSame($test, $caughtException->getEntity()); + self::assertNotNull($caughtException, 'No OptimisticLockingException was thrown'); + self::assertSame($test, $caughtException->getEntity()); } /** @@ -255,7 +255,7 @@ public function testOptimisticTimestampLockFailureThrowsException(OptimisticTime $test = $q->getSingleResult(); - $this->assertInstanceOf('DateTime', $test->version); + self::assertInstanceOf('DateTime', $test->version); // Try to lock the record with an older timestamp and it should throw an exception $caughtException = null; @@ -271,8 +271,8 @@ public function testOptimisticTimestampLockFailureThrowsException(OptimisticTime $caughtException = $e; } - $this->assertNotNull($caughtException, 'No OptimisticLockingException was thrown'); - $this->assertSame($test, $caughtException->getEntity()); + self::assertNotNull($caughtException, 'No OptimisticLockingException was thrown'); + self::assertSame($test, $caughtException->getEntity()); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/ManyToManyBasicAssociationTest.php b/tests/Doctrine/Tests/ORM/Functional/ManyToManyBasicAssociationTest.php index ae555120ac1..0e0dcb4bbc7 100644 --- a/tests/Doctrine/Tests/ORM/Functional/ManyToManyBasicAssociationTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/ManyToManyBasicAssociationTest.php @@ -48,24 +48,24 @@ public function testBasicManyToManyJoin(): void $user = $this->addCmsUserGblancoWithGroups(1); $this->_em->clear(); - $this->assertEquals(0, $this->_em->getUnitOfWork()->size()); + self::assertEquals(0, $this->_em->getUnitOfWork()->size()); $query = $this->_em->createQuery('select u, g from Doctrine\Tests\Models\CMS\CmsUser u join u.groups g'); $result = $query->getResult(); - $this->assertEquals(2, $this->_em->getUnitOfWork()->size()); - $this->assertInstanceOf(CmsUser::class, $result[0]); - $this->assertEquals('Guilherme', $result[0]->name); - $this->assertEquals(1, $result[0]->getGroups()->count()); + self::assertEquals(2, $this->_em->getUnitOfWork()->size()); + self::assertInstanceOf(CmsUser::class, $result[0]); + self::assertEquals('Guilherme', $result[0]->name); + self::assertEquals(1, $result[0]->getGroups()->count()); $groups = $result[0]->getGroups(); - $this->assertEquals('Developers_0', $groups[0]->getName()); + self::assertEquals('Developers_0', $groups[0]->getName()); - $this->assertEquals(UnitOfWork::STATE_MANAGED, $this->_em->getUnitOfWork()->getEntityState($result[0])); - $this->assertEquals(UnitOfWork::STATE_MANAGED, $this->_em->getUnitOfWork()->getEntityState($groups[0])); + self::assertEquals(UnitOfWork::STATE_MANAGED, $this->_em->getUnitOfWork()->getEntityState($result[0])); + self::assertEquals(UnitOfWork::STATE_MANAGED, $this->_em->getUnitOfWork()->getEntityState($groups[0])); - $this->assertInstanceOf(PersistentCollection::class, $groups); - $this->assertInstanceOf(PersistentCollection::class, $groups[0]->getUsers()); + self::assertInstanceOf(PersistentCollection::class, $groups); + self::assertInstanceOf(PersistentCollection::class, $groups[0]->getUsers()); $groups[0]->getUsers()->clear(); $groups->clear(); @@ -74,7 +74,7 @@ public function testBasicManyToManyJoin(): void $this->_em->clear(); $query = $this->_em->createQuery('select u, g from Doctrine\Tests\Models\CMS\CmsUser u join u.groups g'); - $this->assertEquals(0, count($query->getResult())); + self::assertEquals(0, count($query->getResult())); } public function testManyToManyAddRemove(): void @@ -87,14 +87,14 @@ public function testManyToManyAddRemove(): void // Get user $user = $uRep->findOneById($user->getId()); - $this->assertNotNull($user, 'Has to return exactly one entry.'); + self::assertNotNull($user, 'Has to return exactly one entry.'); - $this->assertFalse($user->getGroups()->isInitialized()); + self::assertFalse($user->getGroups()->isInitialized()); // Check groups - $this->assertEquals(2, $user->getGroups()->count()); + self::assertEquals(2, $user->getGroups()->count()); - $this->assertTrue($user->getGroups()->isInitialized()); + self::assertTrue($user->getGroups()->isInitialized()); // Remove first group unset($user->groups[0]); @@ -107,7 +107,7 @@ public function testManyToManyAddRemove(): void $user2 = $uRep->findOneById($user->getId()); // Check groups - $this->assertEquals(1, $user2->getGroups()->count()); + self::assertEquals(1, $user2->getGroups()->count()); } public function testManyToManyInverseSideIgnored(): void @@ -128,8 +128,8 @@ public function testManyToManyInverseSideIgnored(): void // Association should not exist $user2 = $this->_em->find(get_class($user), $user->getId()); - $this->assertNotNull($user2, 'Has to return exactly one entry.'); - $this->assertEquals(0, $user2->getGroups()->count()); + self::assertNotNull($user2, 'Has to return exactly one entry.'); + self::assertEquals(0, $user2->getGroups()->count()); } public function testManyToManyCollectionClearing(): void @@ -158,10 +158,10 @@ public function testManyToManyCollectionClearAndAdd(): void $user->groups[] = $group; } - $this->assertInstanceOf(PersistentCollection::class, $user->groups); - $this->assertTrue($user->groups->isDirty()); + self::assertInstanceOf(PersistentCollection::class, $user->groups); + self::assertTrue($user->groups->isDirty()); - $this->assertEquals($groupCount, count($user->groups), 'There should be 10 groups in the collection.'); + self::assertEquals($groupCount, count($user->groups), 'There should be 10 groups in the collection.'); $this->_em->flush(); @@ -171,7 +171,7 @@ public function testManyToManyCollectionClearAndAdd(): void public function assertGblancoGroupCountIs(int $expectedGroupCount): void { $countDql = "SELECT count(g.id) FROM Doctrine\Tests\Models\CMS\CmsUser u JOIN u.groups g WHERE u.username = 'gblanco'"; - $this->assertEquals( + self::assertEquals( $expectedGroupCount, $this->_em->createQuery($countDql)->getSingleScalarResult(), "Failed to verify that CmsUser with username 'gblanco' has a group count of 10 with a DQL count query." @@ -195,18 +195,18 @@ public function testRetrieveManyToManyAndAddMore(): void $newGroup->setName('12Monkeys'); $freshUser->addGroup($newGroup); - $this->assertFalse($freshUser->groups->isInitialized(), 'CmsUser::groups Collection has to be uninitialized for this test.'); + self::assertFalse($freshUser->groups->isInitialized(), 'CmsUser::groups Collection has to be uninitialized for this test.'); $this->_em->flush(); - $this->assertFalse($freshUser->groups->isInitialized(), 'CmsUser::groups Collection has to be uninitialized for this test.'); - $this->assertEquals(3, count($freshUser->getGroups())); - $this->assertEquals(3, count($freshUser->getGroups()->getSnapshot()), 'Snapshot of CmsUser::groups should contain 3 entries.'); + self::assertFalse($freshUser->groups->isInitialized(), 'CmsUser::groups Collection has to be uninitialized for this test.'); + self::assertEquals(3, count($freshUser->getGroups())); + self::assertEquals(3, count($freshUser->getGroups()->getSnapshot()), 'Snapshot of CmsUser::groups should contain 3 entries.'); $this->_em->clear(); $freshUser = $this->_em->find(CmsUser::class, $user->getId()); - $this->assertEquals(3, count($freshUser->getGroups())); + self::assertEquals(3, count($freshUser->getGroups())); } /** @@ -221,7 +221,7 @@ public function testRemoveUserWithManyGroups(): void $this->_em->flush(); $newUser = $this->_em->find(get_class($user), $userId); - $this->assertNull($newUser); + self::assertNull($newUser); } /** @@ -239,7 +239,7 @@ public function testRemoveGroupWithUser(): void $this->_em->clear(); $newUser = $this->_em->find(get_class($user), $user->getId()); - $this->assertEquals(0, count($newUser->getGroups())); + self::assertEquals(0, count($newUser->getGroups())); } public function testDereferenceCollectionDelete(): void @@ -251,7 +251,7 @@ public function testDereferenceCollectionDelete(): void $this->_em->clear(); $newUser = $this->_em->find(get_class($user), $user->getId()); - $this->assertEquals(0, count($newUser->getGroups())); + self::assertEquals(0, count($newUser->getGroups())); } /** @@ -270,8 +270,8 @@ public function testWorkWithDqlHydratedEmptyCollection(): void $newUser = $this->_em->createQuery('SELECT u, g FROM Doctrine\Tests\Models\CMS\CmsUser u LEFT JOIN u.groups g WHERE u.id = ?1') ->setParameter(1, $user->getId()) ->getSingleResult(); - $this->assertEquals(0, count($newUser->groups)); - $this->assertIsArray($newUser->groups->getMapping()); + self::assertEquals(0, count($newUser->groups)); + self::assertIsArray($newUser->groups->getMapping()); $newUser->addGroup($group); @@ -279,7 +279,7 @@ public function testWorkWithDqlHydratedEmptyCollection(): void $this->_em->clear(); $newUser = $this->_em->find(get_class($user), $user->getId()); - $this->assertEquals(1, count($newUser->groups)); + self::assertEquals(1, count($newUser->groups)); } public function addCmsUserGblancoWithGroups(int $groupCount = 1): CmsUser @@ -298,7 +298,7 @@ public function addCmsUserGblancoWithGroups(int $groupCount = 1): CmsUser $this->_em->persist($user); $this->_em->flush(); - $this->assertNotNull($user->getId(), "User 'gblanco' should have an ID assigned after the persist()/flush() operation."); + self::assertNotNull($user->getId(), "User 'gblanco' should have an ID assigned after the persist()/flush() operation."); return $user; } @@ -324,7 +324,7 @@ public function testClearAndResetCollection(): void $coll = new ArrayCollection([$group1, $group2]); $user->groups = $coll; $this->_em->flush(); - $this->assertInstanceOf( + self::assertInstanceOf( PersistentCollection::class, $user->groups, 'UnitOfWork should have replaced ArrayCollection with PersistentCollection.' @@ -334,9 +334,9 @@ public function testClearAndResetCollection(): void $this->_em->clear(); $user = $this->_em->find(get_class($user), $user->id); - $this->assertEquals(2, count($user->groups)); - $this->assertEquals('Developers_New1', $user->groups[0]->name); - $this->assertEquals('Developers_New2', $user->groups[1]->name); + self::assertEquals(2, count($user->groups)); + self::assertEquals('Developers_New1', $user->groups[0]->name); + self::assertEquals('Developers_New2', $user->groups[1]->name); } /** @@ -349,9 +349,9 @@ public function testInitializePersistentCollection(): void $user = $this->_em->find(get_class($user), $user->id); - $this->assertFalse($user->groups->isInitialized(), 'Pre-condition: lazy collection'); + self::assertFalse($user->groups->isInitialized(), 'Pre-condition: lazy collection'); $this->_em->getUnitOfWork()->initializeObject($user->groups); - $this->assertTrue($user->groups->isInitialized(), 'Collection should be initialized after calling UnitOfWork::initializeObject()'); + self::assertTrue($user->groups->isInitialized(), 'Collection should be initialized after calling UnitOfWork::initializeObject()'); } /** @@ -366,12 +366,12 @@ public function testClearBeforeLazyLoad(): void $user = $this->_em->find(get_class($user), $user->id); $user->groups->clear(); - $this->assertEquals(0, count($user->groups)); + self::assertEquals(0, count($user->groups)); $this->_em->flush(); $user = $this->_em->find(get_class($user), $user->id); - $this->assertEquals(0, count($user->groups)); + self::assertEquals(0, count($user->groups)); } /** @@ -403,7 +403,7 @@ public function testManyToManyOrderByIsNotIgnored(): void $criteria = Criteria::create() ->orderBy(['name' => Criteria::ASC]); - $this->assertEquals( + self::assertEquals( ['A', 'B', 'C', 'Developers_0'], $user ->getGroups() @@ -447,7 +447,7 @@ public function testManyToManyOrderByHonorsFieldNameColumnNameAliases(): void $criteria = Criteria::create() ->orderBy(['name' => Criteria::ASC]); - $this->assertEquals( + self::assertEquals( ['A', 'B', 'C'], $user ->getTags() @@ -467,14 +467,14 @@ public function testMatchingWithLimit(): void $user = $this->_em->find(get_class($user), $user->id); $groups = $user->groups; - $this->assertFalse($user->groups->isInitialized(), 'Pre-condition: lazy collection'); + self::assertFalse($user->groups->isInitialized(), 'Pre-condition: lazy collection'); $criteria = Criteria::create()->setMaxResults(1); $result = $groups->matching($criteria); - $this->assertCount(1, $result); + self::assertCount(1, $result); - $this->assertFalse($user->groups->isInitialized(), 'Post-condition: matching does not initialize collection'); + self::assertFalse($user->groups->isInitialized(), 'Post-condition: matching does not initialize collection'); } public function testMatchingWithOffset(): void @@ -485,17 +485,17 @@ public function testMatchingWithOffset(): void $user = $this->_em->find(get_class($user), $user->id); $groups = $user->groups; - $this->assertFalse($user->groups->isInitialized(), 'Pre-condition: lazy collection'); + self::assertFalse($user->groups->isInitialized(), 'Pre-condition: lazy collection'); $criteria = Criteria::create()->setFirstResult(1); $result = $groups->matching($criteria); - $this->assertCount(1, $result); + self::assertCount(1, $result); $firstGroup = $result->first(); - $this->assertEquals('Developers_1', $firstGroup->name); + self::assertEquals('Developers_1', $firstGroup->name); - $this->assertFalse($user->groups->isInitialized(), 'Post-condition: matching does not initialize collection'); + self::assertFalse($user->groups->isInitialized(), 'Post-condition: matching does not initialize collection'); } public function testMatchingWithLimitAndOffset(): void @@ -506,20 +506,20 @@ public function testMatchingWithLimitAndOffset(): void $user = $this->_em->find(get_class($user), $user->id); $groups = $user->groups; - $this->assertFalse($user->groups->isInitialized(), 'Pre-condition: lazy collection'); + self::assertFalse($user->groups->isInitialized(), 'Pre-condition: lazy collection'); $criteria = Criteria::create()->setFirstResult(1)->setMaxResults(3); $result = $groups->matching($criteria); - $this->assertCount(3, $result); + self::assertCount(3, $result); $firstGroup = $result->first(); - $this->assertEquals('Developers_1', $firstGroup->name); + self::assertEquals('Developers_1', $firstGroup->name); $lastGroup = $result->last(); - $this->assertEquals('Developers_3', $lastGroup->name); + self::assertEquals('Developers_3', $lastGroup->name); - $this->assertFalse($user->groups->isInitialized(), 'Post-condition: matching does not initialize collection'); + self::assertFalse($user->groups->isInitialized(), 'Post-condition: matching does not initialize collection'); } public function testMatching(): void @@ -530,16 +530,16 @@ public function testMatching(): void $user = $this->_em->find(get_class($user), $user->id); $groups = $user->groups; - $this->assertFalse($user->groups->isInitialized(), 'Pre-condition: lazy collection'); + self::assertFalse($user->groups->isInitialized(), 'Pre-condition: lazy collection'); $criteria = Criteria::create()->where(Criteria::expr()->eq('name', (string) 'Developers_0')); $result = $groups->matching($criteria); - $this->assertCount(1, $result); + self::assertCount(1, $result); $firstGroup = $result->first(); - $this->assertEquals('Developers_0', $firstGroup->name); + self::assertEquals('Developers_0', $firstGroup->name); - $this->assertFalse($user->groups->isInitialized(), 'Post-condition: matching does not initialize collection'); + self::assertFalse($user->groups->isInitialized(), 'Post-condition: matching does not initialize collection'); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/ManyToManyBidirectionalAssociationTest.php b/tests/Doctrine/Tests/ORM/Functional/ManyToManyBidirectionalAssociationTest.php index ed0399b26b0..7bc291bd99a 100644 --- a/tests/Doctrine/Tests/ORM/Functional/ManyToManyBidirectionalAssociationTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/ManyToManyBidirectionalAssociationTest.php @@ -116,13 +116,13 @@ protected function findProducts(): array $query = $this->_em->createQuery('SELECT p, c FROM Doctrine\Tests\Models\ECommerce\ECommerceProduct p LEFT JOIN p.categories c ORDER BY p.id, c.id'); //$query->setHint(Query::HINT_FORCE_PARTIAL_LOAD, true); $result = $query->getResult(); - $this->assertEquals(2, count($result)); + self::assertEquals(2, count($result)); $cats1 = $result[0]->getCategories(); $cats2 = $result[1]->getCategories(); - $this->assertTrue($cats1->isInitialized()); - $this->assertTrue($cats2->isInitialized()); - $this->assertFalse($cats1[0]->getProducts()->isInitialized()); - $this->assertFalse($cats2[0]->getProducts()->isInitialized()); + self::assertTrue($cats1->isInitialized()); + self::assertTrue($cats2->isInitialized()); + self::assertFalse($cats1[0]->getProducts()->isInitialized()); + self::assertFalse($cats2[0]->getProducts()->isInitialized()); return $result; } @@ -135,16 +135,16 @@ protected function findCategories(): array $query = $this->_em->createQuery('SELECT c, p FROM Doctrine\Tests\Models\ECommerce\ECommerceCategory c LEFT JOIN c.products p ORDER BY c.id, p.id'); //$query->setHint(Query::HINT_FORCE_PARTIAL_LOAD, true); $result = $query->getResult(); - $this->assertEquals(2, count($result)); - $this->assertInstanceOf(ECommerceCategory::class, $result[0]); - $this->assertInstanceOf(ECommerceCategory::class, $result[1]); + self::assertEquals(2, count($result)); + self::assertInstanceOf(ECommerceCategory::class, $result[0]); + self::assertInstanceOf(ECommerceCategory::class, $result[1]); $prods1 = $result[0]->getProducts(); $prods2 = $result[1]->getProducts(); - $this->assertTrue($prods1->isInitialized()); - $this->assertTrue($prods2->isInitialized()); + self::assertTrue($prods1->isInitialized()); + self::assertTrue($prods2->isInitialized()); - $this->assertFalse($prods1[0]->getCategories()->isInitialized()); - $this->assertFalse($prods2[0]->getCategories()->isInitialized()); + self::assertFalse($prods1[0]->getCategories()->isInitialized()); + self::assertFalse($prods2[0]->getCategories()->isInitialized()); return $result; } @@ -159,30 +159,30 @@ public function assertLazyLoadFromInverseSide(array $products): void $firstProductCategories = $firstProduct->getCategories(); $secondProductCategories = $secondProduct->getCategories(); - $this->assertEquals(2, count($firstProductCategories)); - $this->assertEquals(2, count($secondProductCategories)); + self::assertEquals(2, count($firstProductCategories)); + self::assertEquals(2, count($secondProductCategories)); - $this->assertTrue($firstProductCategories[0] === $secondProductCategories[0]); - $this->assertTrue($firstProductCategories[1] === $secondProductCategories[1]); + self::assertTrue($firstProductCategories[0] === $secondProductCategories[0]); + self::assertTrue($firstProductCategories[1] === $secondProductCategories[1]); $firstCategoryProducts = $firstProductCategories[0]->getProducts(); $secondCategoryProducts = $firstProductCategories[1]->getProducts(); - $this->assertFalse($firstCategoryProducts->isInitialized()); - $this->assertFalse($secondCategoryProducts->isInitialized()); - $this->assertEquals(0, $firstCategoryProducts->unwrap()->count()); - $this->assertEquals(0, $secondCategoryProducts->unwrap()->count()); + self::assertFalse($firstCategoryProducts->isInitialized()); + self::assertFalse($secondCategoryProducts->isInitialized()); + self::assertEquals(0, $firstCategoryProducts->unwrap()->count()); + self::assertEquals(0, $secondCategoryProducts->unwrap()->count()); - $this->assertEquals(2, count($firstCategoryProducts)); // lazy-load - $this->assertTrue($firstCategoryProducts->isInitialized()); - $this->assertFalse($secondCategoryProducts->isInitialized()); - $this->assertEquals(2, count($secondCategoryProducts)); // lazy-load - $this->assertTrue($secondCategoryProducts->isInitialized()); + self::assertEquals(2, count($firstCategoryProducts)); // lazy-load + self::assertTrue($firstCategoryProducts->isInitialized()); + self::assertFalse($secondCategoryProducts->isInitialized()); + self::assertEquals(2, count($secondCategoryProducts)); // lazy-load + self::assertTrue($secondCategoryProducts->isInitialized()); - $this->assertInstanceOf(ECommerceProduct::class, $firstCategoryProducts[0]); - $this->assertInstanceOf(ECommerceProduct::class, $firstCategoryProducts[1]); - $this->assertInstanceOf(ECommerceProduct::class, $secondCategoryProducts[0]); - $this->assertInstanceOf(ECommerceProduct::class, $secondCategoryProducts[1]); + self::assertInstanceOf(ECommerceProduct::class, $firstCategoryProducts[0]); + self::assertInstanceOf(ECommerceProduct::class, $firstCategoryProducts[1]); + self::assertInstanceOf(ECommerceProduct::class, $secondCategoryProducts[0]); + self::assertInstanceOf(ECommerceProduct::class, $secondCategoryProducts[1]); $this->assertCollectionEquals($firstCategoryProducts, $secondCategoryProducts); } @@ -197,30 +197,30 @@ public function assertLazyLoadFromOwningSide(array $categories): void $firstCategoryProducts = $firstCategory->getProducts(); $secondCategoryProducts = $secondCategory->getProducts(); - $this->assertEquals(2, count($firstCategoryProducts)); - $this->assertEquals(2, count($secondCategoryProducts)); + self::assertEquals(2, count($firstCategoryProducts)); + self::assertEquals(2, count($secondCategoryProducts)); - $this->assertTrue($firstCategoryProducts[0] === $secondCategoryProducts[0]); - $this->assertTrue($firstCategoryProducts[1] === $secondCategoryProducts[1]); + self::assertTrue($firstCategoryProducts[0] === $secondCategoryProducts[0]); + self::assertTrue($firstCategoryProducts[1] === $secondCategoryProducts[1]); $firstProductCategories = $firstCategoryProducts[0]->getCategories(); $secondProductCategories = $firstCategoryProducts[1]->getCategories(); - $this->assertFalse($firstProductCategories->isInitialized()); - $this->assertFalse($secondProductCategories->isInitialized()); - $this->assertEquals(0, $firstProductCategories->unwrap()->count()); - $this->assertEquals(0, $secondProductCategories->unwrap()->count()); - - $this->assertEquals(2, count($firstProductCategories)); // lazy-load - $this->assertTrue($firstProductCategories->isInitialized()); - $this->assertFalse($secondProductCategories->isInitialized()); - $this->assertEquals(2, count($secondProductCategories)); // lazy-load - $this->assertTrue($secondProductCategories->isInitialized()); - - $this->assertInstanceOf(ECommerceCategory::class, $firstProductCategories[0]); - $this->assertInstanceOf(ECommerceCategory::class, $firstProductCategories[1]); - $this->assertInstanceOf(ECommerceCategory::class, $secondProductCategories[0]); - $this->assertInstanceOf(ECommerceCategory::class, $secondProductCategories[1]); + self::assertFalse($firstProductCategories->isInitialized()); + self::assertFalse($secondProductCategories->isInitialized()); + self::assertEquals(0, $firstProductCategories->unwrap()->count()); + self::assertEquals(0, $secondProductCategories->unwrap()->count()); + + self::assertEquals(2, count($firstProductCategories)); // lazy-load + self::assertTrue($firstProductCategories->isInitialized()); + self::assertFalse($secondProductCategories->isInitialized()); + self::assertEquals(2, count($secondProductCategories)); // lazy-load + self::assertTrue($secondProductCategories->isInitialized()); + + self::assertInstanceOf(ECommerceCategory::class, $firstProductCategories[0]); + self::assertInstanceOf(ECommerceCategory::class, $firstProductCategories[1]); + self::assertInstanceOf(ECommerceCategory::class, $secondProductCategories[0]); + self::assertInstanceOf(ECommerceCategory::class, $secondProductCategories[1]); $this->assertCollectionEquals($firstProductCategories, $secondProductCategories); } diff --git a/tests/Doctrine/Tests/ORM/Functional/ManyToManyEventTest.php b/tests/Doctrine/Tests/ORM/Functional/ManyToManyEventTest.php index 7893d655410..20f3427ec99 100644 --- a/tests/Doctrine/Tests/ORM/Functional/ManyToManyEventTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/ManyToManyEventTest.php @@ -31,7 +31,7 @@ public function testListenerShouldBeNotifiedOnlyWhenUpdating(): void $user = $this->createNewValidUser(); $this->_em->persist($user); $this->_em->flush(); - $this->assertFalse($this->listener->wasNotified); + self::assertFalse($this->listener->wasNotified); $group = new CmsGroup(); $group->name = 'admins'; @@ -39,7 +39,7 @@ public function testListenerShouldBeNotifiedOnlyWhenUpdating(): void $this->_em->persist($user); $this->_em->flush(); - $this->assertTrue($this->listener->wasNotified); + self::assertTrue($this->listener->wasNotified); } private function createNewValidUser(): CmsUser diff --git a/tests/Doctrine/Tests/ORM/Functional/ManyToManySelfReferentialAssociationTest.php b/tests/Doctrine/Tests/ORM/Functional/ManyToManySelfReferentialAssociationTest.php index ec8eff8e8d5..6b78c356dc5 100644 --- a/tests/Doctrine/Tests/ORM/Functional/ManyToManySelfReferentialAssociationTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/ManyToManySelfReferentialAssociationTest.php @@ -110,20 +110,20 @@ public function testLazyLoadsOwningSide(): void public function assertLoadingOfOwningSide(array $products): void { [$firstProduct, $secondProduct] = $products; - $this->assertEquals(2, count($firstProduct->getRelated())); - $this->assertEquals(2, count($secondProduct->getRelated())); + self::assertEquals(2, count($firstProduct->getRelated())); + self::assertEquals(2, count($secondProduct->getRelated())); $categories = $firstProduct->getRelated(); $firstRelatedBy = $categories[0]->getRelated(); $secondRelatedBy = $categories[1]->getRelated(); - $this->assertEquals(2, count($firstRelatedBy)); - $this->assertEquals(2, count($secondRelatedBy)); + self::assertEquals(2, count($firstRelatedBy)); + self::assertEquals(2, count($secondRelatedBy)); - $this->assertInstanceOf(ECommerceProduct::class, $firstRelatedBy[0]); - $this->assertInstanceOf(ECommerceProduct::class, $firstRelatedBy[1]); - $this->assertInstanceOf(ECommerceProduct::class, $secondRelatedBy[0]); - $this->assertInstanceOf(ECommerceProduct::class, $secondRelatedBy[1]); + self::assertInstanceOf(ECommerceProduct::class, $firstRelatedBy[0]); + self::assertInstanceOf(ECommerceProduct::class, $firstRelatedBy[1]); + self::assertInstanceOf(ECommerceProduct::class, $secondRelatedBy[0]); + self::assertInstanceOf(ECommerceProduct::class, $secondRelatedBy[1]); $this->assertCollectionEquals($firstRelatedBy, $secondRelatedBy); } diff --git a/tests/Doctrine/Tests/ORM/Functional/ManyToManyUnidirectionalAssociationTest.php b/tests/Doctrine/Tests/ORM/Functional/ManyToManyUnidirectionalAssociationTest.php index c279bd615eb..515d281abe3 100644 --- a/tests/Doctrine/Tests/ORM/Functional/ManyToManyUnidirectionalAssociationTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/ManyToManyUnidirectionalAssociationTest.php @@ -81,8 +81,8 @@ public function testEagerLoad(): void $products = $firstCart->getProducts(); $secondCart = $result[1]; - $this->assertInstanceOf(ECommerceProduct::class, $products[0]); - $this->assertInstanceOf(ECommerceProduct::class, $products[1]); + self::assertInstanceOf(ECommerceProduct::class, $products[0]); + self::assertInstanceOf(ECommerceProduct::class, $products[1]); $this->assertCollectionEquals($products, $secondCart->getProducts()); //$this->assertEquals("Doctrine 1.x Manual", $products[0]->getName()); //$this->assertEquals("Doctrine 2.x Manual", $products[1]->getName()); @@ -100,8 +100,8 @@ public function testLazyLoadsCollection(): void $products = $firstCart->getProducts(); $secondCart = $result[1]; - $this->assertInstanceOf(ECommerceProduct::class, $products[0]); - $this->assertInstanceOf(ECommerceProduct::class, $products[1]); + self::assertInstanceOf(ECommerceProduct::class, $products[0]); + self::assertInstanceOf(ECommerceProduct::class, $products[1]); $this->assertCollectionEquals($products, $secondCart->getProducts()); } diff --git a/tests/Doctrine/Tests/ORM/Functional/ManyToOneOrphanRemovalTest.php b/tests/Doctrine/Tests/ORM/Functional/ManyToOneOrphanRemovalTest.php index b7016df3f05..b3ae14a870b 100644 --- a/tests/Doctrine/Tests/ORM/Functional/ManyToOneOrphanRemovalTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/ManyToOneOrphanRemovalTest.php @@ -74,14 +74,14 @@ public function testOrphanRemovalIsPurelyOrnemental(): void ); $result = $query->getResult(); - $this->assertEquals(0, count($result), 'Person should be removed by EntityManager'); + self::assertEquals(0, count($result), 'Person should be removed by EntityManager'); $query = $this->_em->createQuery( 'SELECT p FROM Doctrine\Tests\Models\OrnementalOrphanRemoval\PhoneNumber p' ); $result = $query->getResult(); - $this->assertEquals(2, count($result), 'Orphan removal should not kick in'); + self::assertEquals(2, count($result), 'Orphan removal should not kick in'); } protected function getEntityManager( diff --git a/tests/Doctrine/Tests/ORM/Functional/MappedSuperclassTest.php b/tests/Doctrine/Tests/ORM/Functional/MappedSuperclassTest.php index 7c6da7d46c6..0e19921739e 100644 --- a/tests/Doctrine/Tests/ORM/Functional/MappedSuperclassTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/MappedSuperclassTest.php @@ -44,10 +44,10 @@ public function testCRUD(): void $cleanFile = $this->_em->find(get_class($file), $file->getId()); - $this->assertInstanceOf(Directory::class, $cleanFile->getParent()); - $this->assertInstanceOf(Proxy::class, $cleanFile->getParent()); - $this->assertEquals($directory->getId(), $cleanFile->getParent()->getId()); - $this->assertInstanceOf(Directory::class, $cleanFile->getParent()->getParent()); - $this->assertEquals($root->getId(), $cleanFile->getParent()->getParent()->getId()); + self::assertInstanceOf(Directory::class, $cleanFile->getParent()); + self::assertInstanceOf(Proxy::class, $cleanFile->getParent()); + self::assertEquals($directory->getId(), $cleanFile->getParent()->getId()); + self::assertInstanceOf(Directory::class, $cleanFile->getParent()->getParent()); + self::assertEquals($root->getId(), $cleanFile->getParent()->getParent()->getId()); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/MergeCompositeToOneKeyTest.php b/tests/Doctrine/Tests/ORM/Functional/MergeCompositeToOneKeyTest.php index a7362e424aa..e4672d9ffe1 100644 --- a/tests/Doctrine/Tests/ORM/Functional/MergeCompositeToOneKeyTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/MergeCompositeToOneKeyTest.php @@ -40,9 +40,9 @@ public function testMergingOfEntityWithCompositeIdentifierContainingToOneAssocia $merged = $this->_em->merge($state); assert($merged instanceof CompositeToOneKeyState); - $this->assertInstanceOf(CompositeToOneKeyState::class, $state); - $this->assertNotSame($state, $merged); - $this->assertInstanceOf(Country::class, $merged->country); - $this->assertNotSame($country, $merged->country); + self::assertInstanceOf(CompositeToOneKeyState::class, $state); + self::assertNotSame($state, $merged); + self::assertInstanceOf(Country::class, $merged->country); + self::assertNotSame($country, $merged->country); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/MergeProxiesTest.php b/tests/Doctrine/Tests/ORM/Functional/MergeProxiesTest.php index 8b2623dc676..f668441cbbb 100644 --- a/tests/Doctrine/Tests/ORM/Functional/MergeProxiesTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/MergeProxiesTest.php @@ -43,10 +43,10 @@ public function testMergeDetachedUnInitializedProxy(): void $managed = $this->_em->getReference(DateTimeModel::class, 123); - $this->assertSame($managed, $this->_em->merge($detachedUninitialized)); + self::assertSame($managed, $this->_em->merge($detachedUninitialized)); - $this->assertFalse($managed->__isInitialized()); - $this->assertFalse($detachedUninitialized->__isInitialized()); + self::assertFalse($managed->__isInitialized()); + self::assertFalse($detachedUninitialized->__isInitialized()); } /** @@ -63,13 +63,13 @@ public function testMergeUnserializedUnInitializedProxy(): void $managed = $this->_em->getReference(DateTimeModel::class, 123); - $this->assertSame( + self::assertSame( $managed, $this->_em->merge(unserialize(serialize($this->_em->merge($detachedUninitialized)))) ); - $this->assertFalse($managed->__isInitialized()); - $this->assertFalse($detachedUninitialized->__isInitialized()); + self::assertFalse($managed->__isInitialized()); + self::assertFalse($detachedUninitialized->__isInitialized()); } /** @@ -82,9 +82,9 @@ public function testMergeManagedProxy(): void { $managed = $this->_em->getReference(DateTimeModel::class, 123); - $this->assertSame($managed, $this->_em->merge($managed)); + self::assertSame($managed, $this->_em->merge($managed)); - $this->assertFalse($managed->__isInitialized()); + self::assertFalse($managed->__isInitialized()); } /** @@ -106,14 +106,14 @@ public function testMergeWithExistingUninitializedManagedProxy(): void $managed = $this->_em->getReference(DateTimeModel::class, $date->id); - $this->assertInstanceOf(Proxy::class, $managed); - $this->assertFalse($managed->__isInitialized()); + self::assertInstanceOf(Proxy::class, $managed); + self::assertFalse($managed->__isInitialized()); $date->date = $dateTime = new DateTime(); - $this->assertSame($managed, $this->_em->merge($date)); - $this->assertTrue($managed->__isInitialized()); - $this->assertSame($dateTime, $managed->date, 'Data was merged into the proxy after initialization'); + self::assertSame($managed, $this->_em->merge($date)); + self::assertTrue($managed->__isInitialized()); + self::assertSame($dateTime, $managed->date, 'Data was merged into the proxy after initialization'); } /** @@ -144,20 +144,20 @@ public function testMergingProxyFromDifferentEntityManagerWithExistingManagedIns $proxy2 = $em2->getReference(DateTimeModel::class, $file1->id); $merged2 = $em2->merge($proxy1); - $this->assertNotSame($proxy1, $merged2); - $this->assertSame($proxy2, $merged2); + self::assertNotSame($proxy1, $merged2); + self::assertSame($proxy2, $merged2); - $this->assertFalse($proxy1->__isInitialized()); - $this->assertFalse($proxy2->__isInitialized()); + self::assertFalse($proxy1->__isInitialized()); + self::assertFalse($proxy2->__isInitialized()); $proxy1->__load(); - $this->assertCount( + self::assertCount( $queryCount1 + 1, $logger1->queries, 'Loading the first proxy was done through the first entity manager' ); - $this->assertCount( + self::assertCount( $queryCount2, $logger2->queries, 'No queries were executed on the second entity manager, as it is unrelated with the first proxy' @@ -165,12 +165,12 @@ public function testMergingProxyFromDifferentEntityManagerWithExistingManagedIns $proxy2->__load(); - $this->assertCount( + self::assertCount( $queryCount1 + 1, $logger1->queries, 'Loading the second proxy does not affect the first entity manager' ); - $this->assertCount( + self::assertCount( $queryCount2 + 1, $logger2->queries, 'Loading of the second proxy instance was done through the second entity manager' @@ -204,16 +204,16 @@ public function testMergingUnInitializedProxyDoesNotInitializeIt(): void $unManagedProxy = $em1->getReference(DateTimeModel::class, $file1->id); $mergedInstance = $em2->merge($unManagedProxy); - $this->assertNotInstanceOf(Proxy::class, $mergedInstance); - $this->assertNotSame($unManagedProxy, $mergedInstance); - $this->assertFalse($unManagedProxy->__isInitialized()); + self::assertNotInstanceOf(Proxy::class, $mergedInstance); + self::assertNotSame($unManagedProxy, $mergedInstance); + self::assertFalse($unManagedProxy->__isInitialized()); - $this->assertCount( + self::assertCount( $queryCount1, $logger1->queries, 'Loading the merged instance affected only the first entity manager' ); - $this->assertCount( + self::assertCount( $queryCount1 + 1, $logger2->queries, 'Loading the merged instance was done via the second entity manager' @@ -221,12 +221,12 @@ public function testMergingUnInitializedProxyDoesNotInitializeIt(): void $unManagedProxy->__load(); - $this->assertCount( + self::assertCount( $queryCount1 + 1, $logger1->queries, 'Loading the first proxy was done through the first entity manager' ); - $this->assertCount( + self::assertCount( $queryCount2 + 1, $logger2->queries, 'No queries were executed on the second entity manager, as it is unrelated with the first proxy' diff --git a/tests/Doctrine/Tests/ORM/Functional/MergeSharedEntitiesTest.php b/tests/Doctrine/Tests/ORM/Functional/MergeSharedEntitiesTest.php index 74266741941..e5b5705c12e 100644 --- a/tests/Doctrine/Tests/ORM/Functional/MergeSharedEntitiesTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/MergeSharedEntitiesTest.php @@ -43,7 +43,7 @@ public function testMergeSharedNewEntities(): void $picture = $this->_em->merge($picture); - $this->assertEquals($picture->file, $picture->otherFile, 'Identical entities must remain identical'); + self::assertEquals($picture->file, $picture->otherFile, 'Identical entities must remain identical'); } public function testMergeSharedManagedEntities(): void @@ -61,7 +61,7 @@ public function testMergeSharedManagedEntities(): void $picture = $this->_em->merge($picture); - $this->assertEquals($picture->file, $picture->otherFile, 'Identical entities must remain identical'); + self::assertEquals($picture->file, $picture->otherFile, 'Identical entities must remain identical'); } public function testMergeSharedDetachedSerializedEntities(): void @@ -81,7 +81,7 @@ public function testMergeSharedDetachedSerializedEntities(): void $picture = $this->_em->merge(unserialize($serializedPicture)); - $this->assertEquals($picture->file, $picture->otherFile, 'Identical entities must remain identical'); + self::assertEquals($picture->file, $picture->otherFile, 'Identical entities must remain identical'); } /** @@ -99,8 +99,8 @@ public function testMergeInheritedTransientPrivateProperties(): void $admin2->setSession('zeh current session data'); - $this->assertSame($admin1, $this->_em->merge($admin2)); - $this->assertSame('zeh current session data', $admin1->getSession()); + self::assertSame($admin1, $this->_em->merge($admin2)); + self::assertSame('zeh current session data', $admin1->getSession()); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/MergeVersionedManyToOneTest.php b/tests/Doctrine/Tests/ORM/Functional/MergeVersionedManyToOneTest.php index b648e614235..ae1ea0786b9 100644 --- a/tests/Doctrine/Tests/ORM/Functional/MergeVersionedManyToOneTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/MergeVersionedManyToOneTest.php @@ -41,6 +41,6 @@ public function testSetVersionOnCreate(): void $articleMerged->name = 'Article Merged'; $this->_em->flush(); - $this->assertEquals(2, $articleMerged->version); + self::assertEquals(2, $articleMerged->version); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/NativeQueryTest.php b/tests/Doctrine/Tests/ORM/Functional/NativeQueryTest.php index 592ca42c9b3..18e89210d40 100644 --- a/tests/Doctrine/Tests/ORM/Functional/NativeQueryTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/NativeQueryTest.php @@ -69,9 +69,9 @@ public function testBasicNativeQuery(): void $users = $query->getResult(); - $this->assertEquals(1, count($users)); - $this->assertInstanceOf(CmsUser::class, $users[0]); - $this->assertEquals('Roman', $users[0]->name); + self::assertEquals(1, count($users)); + self::assertInstanceOf(CmsUser::class, $users[0]); + self::assertEquals('Roman', $users[0]->name); } public function testBasicNativeQueryWithMetaResult(): void @@ -106,13 +106,13 @@ public function testBasicNativeQueryWithMetaResult(): void $addresses = $query->getResult(); - $this->assertEquals(1, count($addresses)); - $this->assertTrue($addresses[0] instanceof CmsAddress); - $this->assertEquals($addr->country, $addresses[0]->country); - $this->assertEquals($addr->zip, $addresses[0]->zip); - $this->assertEquals($addr->city, $addresses[0]->city); - $this->assertEquals($addr->street, $addresses[0]->street); - $this->assertTrue($addresses[0]->user instanceof CmsUser); + self::assertEquals(1, count($addresses)); + self::assertTrue($addresses[0] instanceof CmsAddress); + self::assertEquals($addr->country, $addresses[0]->country); + self::assertEquals($addr->zip, $addresses[0]->zip); + self::assertEquals($addr->city, $addresses[0]->city); + self::assertEquals($addr->street, $addresses[0]->street); + self::assertTrue($addresses[0]->user instanceof CmsUser); } public function testJoinedOneToManyNativeQuery(): void @@ -144,15 +144,15 @@ public function testJoinedOneToManyNativeQuery(): void $query->setParameter(1, 'romanb'); $users = $query->getResult(); - $this->assertEquals(1, count($users)); - $this->assertInstanceOf(CmsUser::class, $users[0]); - $this->assertEquals('Roman', $users[0]->name); - $this->assertInstanceOf(PersistentCollection::class, $users[0]->getPhonenumbers()); - $this->assertTrue($users[0]->getPhonenumbers()->isInitialized()); - $this->assertEquals(1, count($users[0]->getPhonenumbers())); + self::assertEquals(1, count($users)); + self::assertInstanceOf(CmsUser::class, $users[0]); + self::assertEquals('Roman', $users[0]->name); + self::assertInstanceOf(PersistentCollection::class, $users[0]->getPhonenumbers()); + self::assertTrue($users[0]->getPhonenumbers()->isInitialized()); + self::assertEquals(1, count($users[0]->getPhonenumbers())); $phones = $users[0]->getPhonenumbers(); - $this->assertEquals(424242, $phones[0]->phonenumber); - $this->assertTrue($phones[0]->getUser() === $users[0]); + self::assertEquals(424242, $phones[0]->phonenumber); + self::assertTrue($phones[0]->getUser() === $users[0]); } public function testJoinedOneToOneNativeQuery(): void @@ -190,16 +190,16 @@ public function testJoinedOneToOneNativeQuery(): void $users = $query->getResult(); - $this->assertEquals(1, count($users)); - $this->assertInstanceOf(CmsUser::class, $users[0]); - $this->assertEquals('Roman', $users[0]->name); - $this->assertInstanceOf(PersistentCollection::class, $users[0]->getPhonenumbers()); - $this->assertFalse($users[0]->getPhonenumbers()->isInitialized()); - $this->assertInstanceOf(CmsAddress::class, $users[0]->getAddress()); - $this->assertTrue($users[0]->getAddress()->getUser() === $users[0]); - $this->assertEquals('germany', $users[0]->getAddress()->getCountry()); - $this->assertEquals(10827, $users[0]->getAddress()->getZipCode()); - $this->assertEquals('Berlin', $users[0]->getAddress()->getCity()); + self::assertEquals(1, count($users)); + self::assertInstanceOf(CmsUser::class, $users[0]); + self::assertEquals('Roman', $users[0]->name); + self::assertInstanceOf(PersistentCollection::class, $users[0]->getPhonenumbers()); + self::assertFalse($users[0]->getPhonenumbers()->isInitialized()); + self::assertInstanceOf(CmsAddress::class, $users[0]->getAddress()); + self::assertTrue($users[0]->getAddress()->getUser() === $users[0]); + self::assertEquals('germany', $users[0]->getAddress()->getCountry()); + self::assertEquals(10827, $users[0]->getAddress()->getZipCode()); + self::assertEquals('Berlin', $users[0]->getAddress()->getCity()); } public function testFluentInterface(): void @@ -220,7 +220,7 @@ public function testFluentInterface(): void ->setResultCacheDriver(null) ->setResultCacheLifetime(3500); - $this->assertSame($q, $q2); + self::assertSame($q, $q2); } public function testJoinedOneToManyNativeQueryWithRSMBuilder(): void @@ -247,15 +247,15 @@ public function testJoinedOneToManyNativeQueryWithRSMBuilder(): void $query->setParameter(1, 'romanb'); $users = $query->getResult(); - $this->assertEquals(1, count($users)); - $this->assertInstanceOf(CmsUser::class, $users[0]); - $this->assertEquals('Roman', $users[0]->name); - $this->assertInstanceOf(PersistentCollection::class, $users[0]->getPhonenumbers()); - $this->assertTrue($users[0]->getPhonenumbers()->isInitialized()); - $this->assertEquals(1, count($users[0]->getPhonenumbers())); + self::assertEquals(1, count($users)); + self::assertInstanceOf(CmsUser::class, $users[0]); + self::assertEquals('Roman', $users[0]->name); + self::assertInstanceOf(PersistentCollection::class, $users[0]->getPhonenumbers()); + self::assertTrue($users[0]->getPhonenumbers()->isInitialized()); + self::assertEquals(1, count($users[0]->getPhonenumbers())); $phones = $users[0]->getPhonenumbers(); - $this->assertEquals(424242, $phones[0]->phonenumber); - $this->assertTrue($phones[0]->getUser() === $users[0]); + self::assertEquals(424242, $phones[0]->phonenumber); + self::assertTrue($phones[0]->getUser() === $users[0]); $this->_em->clear(); @@ -265,8 +265,8 @@ public function testJoinedOneToManyNativeQueryWithRSMBuilder(): void $query->setParameter(1, $phone->phonenumber); $phone = $query->getSingleResult(); - $this->assertNotNull($phone->getUser()); - $this->assertEquals($user->name, $phone->getUser()->getName()); + self::assertNotNull($phone->getUser()); + self::assertEquals($user->name, $phone->getUser()->getName()); } public function testJoinedOneToOneNativeQueryWithRSMBuilder(): void @@ -297,16 +297,16 @@ public function testJoinedOneToOneNativeQueryWithRSMBuilder(): void $users = $query->getResult(); - $this->assertEquals(1, count($users)); - $this->assertInstanceOf(CmsUser::class, $users[0]); - $this->assertEquals('Roman', $users[0]->name); - $this->assertInstanceOf(PersistentCollection::class, $users[0]->getPhonenumbers()); - $this->assertFalse($users[0]->getPhonenumbers()->isInitialized()); - $this->assertInstanceOf(CmsAddress::class, $users[0]->getAddress()); - $this->assertTrue($users[0]->getAddress()->getUser() === $users[0]); - $this->assertEquals('germany', $users[0]->getAddress()->getCountry()); - $this->assertEquals(10827, $users[0]->getAddress()->getZipCode()); - $this->assertEquals('Berlin', $users[0]->getAddress()->getCity()); + self::assertEquals(1, count($users)); + self::assertInstanceOf(CmsUser::class, $users[0]); + self::assertEquals('Roman', $users[0]->name); + self::assertInstanceOf(PersistentCollection::class, $users[0]->getPhonenumbers()); + self::assertFalse($users[0]->getPhonenumbers()->isInitialized()); + self::assertInstanceOf(CmsAddress::class, $users[0]->getAddress()); + self::assertTrue($users[0]->getAddress()->getUser() === $users[0]); + self::assertEquals('germany', $users[0]->getAddress()->getCountry()); + self::assertEquals(10827, $users[0]->getAddress()->getZipCode()); + self::assertEquals('Berlin', $users[0]->getAddress()->getCity()); $this->_em->clear(); @@ -316,8 +316,8 @@ public function testJoinedOneToOneNativeQueryWithRSMBuilder(): void $query->setParameter(1, $addr->getId()); $address = $query->getSingleResult(); - $this->assertNotNull($address->getUser()); - $this->assertEquals($user->name, $address->getUser()->getName()); + self::assertNotNull($address->getUser()); + self::assertEquals($user->name, $address->getUser()->getName()); } /** @@ -396,11 +396,11 @@ public function testBasicNativeNamedQueryWithSqlResultSetMapping(): void $query = $repository->createNativeNamedQuery('find-all'); $result = $query->getResult(); - $this->assertCount(1, $result); - $this->assertInstanceOf(CmsAddress::class, $result[0]); - $this->assertEquals($addr->id, $result[0]->id); - $this->assertEquals($addr->city, $result[0]->city); - $this->assertEquals($addr->country, $result[0]->country); + self::assertCount(1, $result); + self::assertInstanceOf(CmsAddress::class, $result[0]); + self::assertEquals($addr->id, $result[0]->id); + self::assertEquals($addr->city, $result[0]->city); + self::assertEquals($addr->country, $result[0]->country); } /** @@ -432,12 +432,12 @@ public function testBasicNativeNamedQueryWithResultClass(): void ->setParameter(1, 'FabioBatSilva') ->getResult(); - $this->assertEquals(1, count($result)); - $this->assertInstanceOf(CmsUser::class, $result[0]); - $this->assertNull($result[0]->name); - $this->assertNull($result[0]->email); - $this->assertEquals($user->id, $result[0]->id); - $this->assertEquals('FabioBatSilva', $result[0]->username); + self::assertEquals(1, count($result)); + self::assertInstanceOf(CmsUser::class, $result[0]); + self::assertNull($result[0]->name); + self::assertNull($result[0]->email); + self::assertEquals($user->id, $result[0]->id); + self::assertEquals('FabioBatSilva', $result[0]->username); $this->_em->clear(); @@ -445,13 +445,13 @@ public function testBasicNativeNamedQueryWithResultClass(): void ->setParameter(1, 'FabioBatSilva') ->getResult(); - $this->assertEquals(1, count($result)); - $this->assertInstanceOf(CmsUser::class, $result[0]); - $this->assertEquals($user->id, $result[0]->id); - $this->assertEquals('Fabio B. Silva', $result[0]->name); - $this->assertEquals('FabioBatSilva', $result[0]->username); - $this->assertEquals('dev', $result[0]->status); - $this->assertInstanceOf(CmsEmail::class, $result[0]->email); + self::assertEquals(1, count($result)); + self::assertInstanceOf(CmsUser::class, $result[0]); + self::assertEquals($user->id, $result[0]->id); + self::assertEquals('Fabio B. Silva', $result[0]->name); + self::assertEquals('FabioBatSilva', $result[0]->username); + self::assertEquals('dev', $result[0]->status); + self::assertInstanceOf(CmsEmail::class, $result[0]->email); } /** @@ -480,16 +480,16 @@ public function testJoinedOneToOneNativeNamedQueryWithResultSetMapping(): void ->setParameter(1, 'FabioBatSilva') ->getResult(); - $this->assertEquals(1, count($result)); - $this->assertInstanceOf(CmsUser::class, $result[0]); - $this->assertEquals('Fabio B. Silva', $result[0]->name); - $this->assertInstanceOf(PersistentCollection::class, $result[0]->getPhonenumbers()); - $this->assertFalse($result[0]->getPhonenumbers()->isInitialized()); - $this->assertInstanceOf(CmsAddress::class, $result[0]->getAddress()); - $this->assertTrue($result[0]->getAddress()->getUser() === $result[0]); - $this->assertEquals('Brazil', $result[0]->getAddress()->getCountry()); - $this->assertEquals(10827, $result[0]->getAddress()->getZipCode()); - $this->assertEquals('São Paulo', $result[0]->getAddress()->getCity()); + self::assertEquals(1, count($result)); + self::assertInstanceOf(CmsUser::class, $result[0]); + self::assertEquals('Fabio B. Silva', $result[0]->name); + self::assertInstanceOf(PersistentCollection::class, $result[0]->getPhonenumbers()); + self::assertFalse($result[0]->getPhonenumbers()->isInitialized()); + self::assertInstanceOf(CmsAddress::class, $result[0]->getAddress()); + self::assertTrue($result[0]->getAddress()->getUser() === $result[0]); + self::assertEquals('Brazil', $result[0]->getAddress()->getCountry()); + self::assertEquals(10827, $result[0]->getAddress()->getZipCode()); + self::assertEquals('São Paulo', $result[0]->getAddress()->getCity()); } /** @@ -517,15 +517,15 @@ public function testJoinedOneToManyNativeNamedQueryWithResultSetMapping(): void $result = $repository->createNativeNamedQuery('fetchJoinedPhonenumber') ->setParameter(1, 'FabioBatSilva')->getResult(); - $this->assertEquals(1, count($result)); - $this->assertInstanceOf(CmsUser::class, $result[0]); - $this->assertEquals('Fabio B. Silva', $result[0]->name); - $this->assertInstanceOf(PersistentCollection::class, $result[0]->getPhonenumbers()); - $this->assertTrue($result[0]->getPhonenumbers()->isInitialized()); - $this->assertEquals(1, count($result[0]->getPhonenumbers())); + self::assertEquals(1, count($result)); + self::assertInstanceOf(CmsUser::class, $result[0]); + self::assertEquals('Fabio B. Silva', $result[0]->name); + self::assertInstanceOf(PersistentCollection::class, $result[0]->getPhonenumbers()); + self::assertTrue($result[0]->getPhonenumbers()->isInitialized()); + self::assertEquals(1, count($result[0]->getPhonenumbers())); $phones = $result[0]->getPhonenumbers(); - $this->assertEquals(424242, $phones[0]->phonenumber); - $this->assertTrue($phones[0]->getUser() === $result[0]); + self::assertEquals(424242, $phones[0]->phonenumber); + self::assertTrue($phones[0]->getUser() === $result[0]); } /** @@ -565,19 +565,19 @@ public function testMixedNativeNamedQueryNormalJoin(): void $result = $repository->createNativeNamedQuery('fetchUserPhonenumberCount') ->setParameter(1, ['test', 'FabioBatSilva'])->getResult(); - $this->assertEquals(2, count($result)); - $this->assertTrue(is_array($result[0])); - $this->assertTrue(is_array($result[1])); + self::assertEquals(2, count($result)); + self::assertTrue(is_array($result[0])); + self::assertTrue(is_array($result[1])); // first user => 2 phonenumbers - $this->assertInstanceOf(CmsUser::class, $result[0][0]); - $this->assertEquals('Fabio B. Silva', $result[0][0]->name); - $this->assertEquals(2, $result[0]['numphones']); + self::assertInstanceOf(CmsUser::class, $result[0][0]); + self::assertEquals('Fabio B. Silva', $result[0][0]->name); + self::assertEquals(2, $result[0]['numphones']); // second user => 1 phonenumbers - $this->assertInstanceOf(CmsUser::class, $result[1][0]); - $this->assertEquals('test tester', $result[1][0]->name); - $this->assertEquals(1, $result[1]['numphones']); + self::assertInstanceOf(CmsUser::class, $result[1][0]); + self::assertEquals('test tester', $result[1][0]->name); + self::assertEquals(1, $result[1]['numphones']); } /** @@ -604,26 +604,26 @@ public function testNativeNamedQueryInheritance(): void $result = $repository->createNativeNamedQuery('fetchAllWithSqlResultSetMapping') ->getResult(); - $this->assertEquals(2, count($result)); - $this->assertInstanceOf(CompanyPerson::class, $result[0]); - $this->assertInstanceOf(CompanyEmployee::class, $result[1]); - $this->assertTrue(is_numeric($result[0]->getId())); - $this->assertTrue(is_numeric($result[1]->getId())); - $this->assertEquals('Fabio B. Silva', $result[0]->getName()); - $this->assertEquals('Fabio Silva', $result[1]->getName()); + self::assertEquals(2, count($result)); + self::assertInstanceOf(CompanyPerson::class, $result[0]); + self::assertInstanceOf(CompanyEmployee::class, $result[1]); + self::assertTrue(is_numeric($result[0]->getId())); + self::assertTrue(is_numeric($result[1]->getId())); + self::assertEquals('Fabio B. Silva', $result[0]->getName()); + self::assertEquals('Fabio Silva', $result[1]->getName()); $this->_em->clear(); $result = $repository->createNativeNamedQuery('fetchAllWithResultClass') ->getResult(); - $this->assertEquals(2, count($result)); - $this->assertInstanceOf(CompanyPerson::class, $result[0]); - $this->assertInstanceOf(CompanyEmployee::class, $result[1]); - $this->assertTrue(is_numeric($result[0]->getId())); - $this->assertTrue(is_numeric($result[1]->getId())); - $this->assertEquals('Fabio B. Silva', $result[0]->getName()); - $this->assertEquals('Fabio Silva', $result[1]->getName()); + self::assertEquals(2, count($result)); + self::assertInstanceOf(CompanyPerson::class, $result[0]); + self::assertInstanceOf(CompanyEmployee::class, $result[1]); + self::assertTrue(is_numeric($result[0]->getId())); + self::assertTrue(is_numeric($result[1]->getId())); + self::assertEquals('Fabio B. Silva', $result[0]->getName()); + self::assertEquals('Fabio Silva', $result[1]->getName()); } /** @@ -658,17 +658,17 @@ public function testMultipleEntityResults(): void $query = $repository->createNativeNamedQuery('fetchMultipleJoinsEntityResults'); $result = $query->getResult(); - $this->assertEquals(1, count($result)); - $this->assertTrue(is_array($result[0])); + self::assertEquals(1, count($result)); + self::assertTrue(is_array($result[0])); - $this->assertInstanceOf(CmsUser::class, $result[0][0]); - $this->assertEquals('Fabio B. Silva', $result[0][0]->name); - $this->assertInstanceOf(CmsAddress::class, $result[0][0]->getAddress()); - $this->assertTrue($result[0][0]->getAddress()->getUser() === $result[0][0]); - $this->assertEquals('Brazil', $result[0][0]->getAddress()->getCountry()); - $this->assertEquals(10827, $result[0][0]->getAddress()->getZipCode()); + self::assertInstanceOf(CmsUser::class, $result[0][0]); + self::assertEquals('Fabio B. Silva', $result[0][0]->name); + self::assertInstanceOf(CmsAddress::class, $result[0][0]->getAddress()); + self::assertTrue($result[0][0]->getAddress()->getUser() === $result[0][0]); + self::assertEquals('Brazil', $result[0][0]->getAddress()->getCountry()); + self::assertEquals(10827, $result[0][0]->getAddress()->getZipCode()); - $this->assertEquals(1, $result[0]['numphones']); + self::assertEquals(1, $result[0]['numphones']); } /** @@ -686,38 +686,38 @@ public function testNamedNativeQueryInheritance(): void $flexMappings = $flexMetadata->getSqlResultSetMappings(); // contract queries - $this->assertEquals('all-contracts', $contractQueries['all-contracts']['name']); - $this->assertEquals(CompanyContract::class, $contractQueries['all-contracts']['resultClass']); + self::assertEquals('all-contracts', $contractQueries['all-contracts']['name']); + self::assertEquals(CompanyContract::class, $contractQueries['all-contracts']['resultClass']); - $this->assertEquals('all', $contractQueries['all']['name']); - $this->assertEquals(CompanyContract::class, $contractQueries['all']['resultClass']); + self::assertEquals('all', $contractQueries['all']['name']); + self::assertEquals(CompanyContract::class, $contractQueries['all']['resultClass']); // flex contract queries - $this->assertEquals('all-contracts', $flexQueries['all-contracts']['name']); - $this->assertEquals(CompanyFlexContract::class, $flexQueries['all-contracts']['resultClass']); + self::assertEquals('all-contracts', $flexQueries['all-contracts']['name']); + self::assertEquals(CompanyFlexContract::class, $flexQueries['all-contracts']['resultClass']); - $this->assertEquals('all-flex', $flexQueries['all-flex']['name']); - $this->assertEquals(CompanyFlexContract::class, $flexQueries['all-flex']['resultClass']); + self::assertEquals('all-flex', $flexQueries['all-flex']['name']); + self::assertEquals(CompanyFlexContract::class, $flexQueries['all-flex']['resultClass']); - $this->assertEquals('all', $flexQueries['all']['name']); - $this->assertEquals(CompanyFlexContract::class, $flexQueries['all']['resultClass']); + self::assertEquals('all', $flexQueries['all']['name']); + self::assertEquals(CompanyFlexContract::class, $flexQueries['all']['resultClass']); // contract result mapping - $this->assertEquals('mapping-all-contracts', $contractMappings['mapping-all-contracts']['name']); - $this->assertEquals(CompanyContract::class, $contractMappings['mapping-all-contracts']['entities'][0]['entityClass']); + self::assertEquals('mapping-all-contracts', $contractMappings['mapping-all-contracts']['name']); + self::assertEquals(CompanyContract::class, $contractMappings['mapping-all-contracts']['entities'][0]['entityClass']); - $this->assertEquals('mapping-all', $contractMappings['mapping-all']['name']); - $this->assertEquals(CompanyContract::class, $contractMappings['mapping-all-contracts']['entities'][0]['entityClass']); + self::assertEquals('mapping-all', $contractMappings['mapping-all']['name']); + self::assertEquals(CompanyContract::class, $contractMappings['mapping-all-contracts']['entities'][0]['entityClass']); // flex contract result mapping - $this->assertEquals('mapping-all-contracts', $flexMappings['mapping-all-contracts']['name']); - $this->assertEquals(CompanyFlexContract::class, $flexMappings['mapping-all-contracts']['entities'][0]['entityClass']); + self::assertEquals('mapping-all-contracts', $flexMappings['mapping-all-contracts']['name']); + self::assertEquals(CompanyFlexContract::class, $flexMappings['mapping-all-contracts']['entities'][0]['entityClass']); - $this->assertEquals('mapping-all', $flexMappings['mapping-all']['name']); - $this->assertEquals(CompanyFlexContract::class, $flexMappings['mapping-all']['entities'][0]['entityClass']); + self::assertEquals('mapping-all', $flexMappings['mapping-all']['name']); + self::assertEquals(CompanyFlexContract::class, $flexMappings['mapping-all']['entities'][0]['entityClass']); - $this->assertEquals('mapping-all-flex', $flexMappings['mapping-all-flex']['name']); - $this->assertEquals(CompanyFlexContract::class, $flexMappings['mapping-all-flex']['entities'][0]['entityClass']); + self::assertEquals('mapping-all-flex', $flexMappings['mapping-all-flex']['name']); + self::assertEquals(CompanyFlexContract::class, $flexMappings['mapping-all-flex']['entities'][0]['entityClass']); } /** diff --git a/tests/Doctrine/Tests/ORM/Functional/NewOperatorTest.php b/tests/Doctrine/Tests/ORM/Functional/NewOperatorTest.php index a7a1ea5e418..66593d8903d 100644 --- a/tests/Doctrine/Tests/ORM/Functional/NewOperatorTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/NewOperatorTest.php @@ -127,23 +127,23 @@ public function testShouldSupportsBasicUsage($hydrationMode): void $query = $this->_em->createQuery($dql); $result = $query->getResult($hydrationMode); - $this->assertCount(3, $result); + self::assertCount(3, $result); - $this->assertInstanceOf(CmsUserDTO::class, $result[0]); - $this->assertInstanceOf(CmsUserDTO::class, $result[1]); - $this->assertInstanceOf(CmsUserDTO::class, $result[2]); + self::assertInstanceOf(CmsUserDTO::class, $result[0]); + self::assertInstanceOf(CmsUserDTO::class, $result[1]); + self::assertInstanceOf(CmsUserDTO::class, $result[2]); - $this->assertEquals($this->fixtures[0]->name, $result[0]->name); - $this->assertEquals($this->fixtures[1]->name, $result[1]->name); - $this->assertEquals($this->fixtures[2]->name, $result[2]->name); + self::assertEquals($this->fixtures[0]->name, $result[0]->name); + self::assertEquals($this->fixtures[1]->name, $result[1]->name); + self::assertEquals($this->fixtures[2]->name, $result[2]->name); - $this->assertEquals($this->fixtures[0]->email->email, $result[0]->email); - $this->assertEquals($this->fixtures[1]->email->email, $result[1]->email); - $this->assertEquals($this->fixtures[2]->email->email, $result[2]->email); + self::assertEquals($this->fixtures[0]->email->email, $result[0]->email); + self::assertEquals($this->fixtures[1]->email->email, $result[1]->email); + self::assertEquals($this->fixtures[2]->email->email, $result[2]->email); - $this->assertEquals($this->fixtures[0]->address->city, $result[0]->address); - $this->assertEquals($this->fixtures[1]->address->city, $result[1]->address); - $this->assertEquals($this->fixtures[2]->address->city, $result[2]->address); + self::assertEquals($this->fixtures[0]->address->city, $result[0]->address); + self::assertEquals($this->fixtures[1]->address->city, $result[1]->address); + self::assertEquals($this->fixtures[2]->address->city, $result[2]->address); } /** @@ -170,23 +170,23 @@ public function testShouldIgnoreAliasesForSingleObject($hydrationMode): void $query = $this->_em->createQuery($dql); $result = $query->getResult($hydrationMode); - $this->assertCount(3, $result); + self::assertCount(3, $result); - $this->assertInstanceOf(CmsUserDTO::class, $result[0]); - $this->assertInstanceOf(CmsUserDTO::class, $result[1]); - $this->assertInstanceOf(CmsUserDTO::class, $result[2]); + self::assertInstanceOf(CmsUserDTO::class, $result[0]); + self::assertInstanceOf(CmsUserDTO::class, $result[1]); + self::assertInstanceOf(CmsUserDTO::class, $result[2]); - $this->assertEquals($this->fixtures[0]->name, $result[0]->name); - $this->assertEquals($this->fixtures[1]->name, $result[1]->name); - $this->assertEquals($this->fixtures[2]->name, $result[2]->name); + self::assertEquals($this->fixtures[0]->name, $result[0]->name); + self::assertEquals($this->fixtures[1]->name, $result[1]->name); + self::assertEquals($this->fixtures[2]->name, $result[2]->name); - $this->assertEquals($this->fixtures[0]->email->email, $result[0]->email); - $this->assertEquals($this->fixtures[1]->email->email, $result[1]->email); - $this->assertEquals($this->fixtures[2]->email->email, $result[2]->email); + self::assertEquals($this->fixtures[0]->email->email, $result[0]->email); + self::assertEquals($this->fixtures[1]->email->email, $result[1]->email); + self::assertEquals($this->fixtures[2]->email->email, $result[2]->email); - $this->assertEquals($this->fixtures[0]->address->city, $result[0]->address); - $this->assertEquals($this->fixtures[1]->address->city, $result[1]->address); - $this->assertEquals($this->fixtures[2]->address->city, $result[2]->address); + self::assertEquals($this->fixtures[0]->address->city, $result[0]->address); + self::assertEquals($this->fixtures[1]->address->city, $result[1]->address); + self::assertEquals($this->fixtures[2]->address->city, $result[2]->address); } public function testShouldAssumeFromEntityNamespaceWhenNotGiven(): void @@ -206,11 +206,11 @@ public function testShouldAssumeFromEntityNamespaceWhenNotGiven(): void $query = $this->_em->createQuery($dql); $result = $query->getResult(); - $this->assertCount(3, $result); + self::assertCount(3, $result); - $this->assertInstanceOf(CmsUserDTO::class, $result[0]); - $this->assertInstanceOf(CmsUserDTO::class, $result[1]); - $this->assertInstanceOf(CmsUserDTO::class, $result[2]); + self::assertInstanceOf(CmsUserDTO::class, $result[0]); + self::assertInstanceOf(CmsUserDTO::class, $result[1]); + self::assertInstanceOf(CmsUserDTO::class, $result[2]); } public function testShouldSupportFromEntityNamespaceAlias(): void @@ -233,11 +233,11 @@ public function testShouldSupportFromEntityNamespaceAlias(): void $query = $this->_em->createQuery($dql); $result = $query->getResult(); - $this->assertCount(3, $result); + self::assertCount(3, $result); - $this->assertInstanceOf(CmsUserDTO::class, $result[0]); - $this->assertInstanceOf(CmsUserDTO::class, $result[1]); - $this->assertInstanceOf(CmsUserDTO::class, $result[2]); + self::assertInstanceOf(CmsUserDTO::class, $result[0]); + self::assertInstanceOf(CmsUserDTO::class, $result[1]); + self::assertInstanceOf(CmsUserDTO::class, $result[2]); } public function testShouldSupportValueObjectNamespaceAlias(): void @@ -260,11 +260,11 @@ public function testShouldSupportValueObjectNamespaceAlias(): void $query = $this->_em->createQuery($dql); $result = $query->getResult(); - $this->assertCount(3, $result); + self::assertCount(3, $result); - $this->assertInstanceOf(CmsUserDTO::class, $result[0]); - $this->assertInstanceOf(CmsUserDTO::class, $result[1]); - $this->assertInstanceOf(CmsUserDTO::class, $result[2]); + self::assertInstanceOf(CmsUserDTO::class, $result[0]); + self::assertInstanceOf(CmsUserDTO::class, $result[1]); + self::assertInstanceOf(CmsUserDTO::class, $result[2]); } public function testShouldSupportLiteralExpression(): void @@ -293,27 +293,27 @@ public function testShouldSupportLiteralExpression(): void $query = $this->_em->createQuery($dql); $result = $query->getResult(); - $this->assertCount(3, $result); + self::assertCount(3, $result); - $this->assertInstanceOf(CmsUserDTO::class, $result[0]); - $this->assertInstanceOf(CmsUserDTO::class, $result[1]); - $this->assertInstanceOf(CmsUserDTO::class, $result[2]); + self::assertInstanceOf(CmsUserDTO::class, $result[0]); + self::assertInstanceOf(CmsUserDTO::class, $result[1]); + self::assertInstanceOf(CmsUserDTO::class, $result[2]); - $this->assertEquals($this->fixtures[0]->name, $result[0]->name); - $this->assertEquals($this->fixtures[1]->name, $result[1]->name); - $this->assertEquals($this->fixtures[2]->name, $result[2]->name); + self::assertEquals($this->fixtures[0]->name, $result[0]->name); + self::assertEquals($this->fixtures[1]->name, $result[1]->name); + self::assertEquals($this->fixtures[2]->name, $result[2]->name); - $this->assertEquals('fabio.bat.silva@gmail.com', $result[0]->email); - $this->assertEquals('fabio.bat.silva@gmail.com', $result[1]->email); - $this->assertEquals('fabio.bat.silva@gmail.com', $result[2]->email); + self::assertEquals('fabio.bat.silva@gmail.com', $result[0]->email); + self::assertEquals('fabio.bat.silva@gmail.com', $result[1]->email); + self::assertEquals('fabio.bat.silva@gmail.com', $result[2]->email); - $this->assertEquals(false, $result[0]->address); - $this->assertEquals(false, $result[1]->address); - $this->assertEquals(false, $result[2]->address); + self::assertEquals(false, $result[0]->address); + self::assertEquals(false, $result[1]->address); + self::assertEquals(false, $result[2]->address); - $this->assertEquals(123, $result[0]->phonenumbers); - $this->assertEquals(123, $result[1]->phonenumbers); - $this->assertEquals(123, $result[2]->phonenumbers); + self::assertEquals(123, $result[0]->phonenumbers); + self::assertEquals(123, $result[1]->phonenumbers); + self::assertEquals(123, $result[2]->phonenumbers); } public function testShouldSupportCaseExpression(): void @@ -340,19 +340,19 @@ public function testShouldSupportCaseExpression(): void $query = $this->_em->createQuery($dql); $result = $query->getResult(); - $this->assertCount(3, $result); + self::assertCount(3, $result); - $this->assertInstanceOf(CmsUserDTO::class, $result[0]); - $this->assertInstanceOf(CmsUserDTO::class, $result[1]); - $this->assertInstanceOf(CmsUserDTO::class, $result[2]); + self::assertInstanceOf(CmsUserDTO::class, $result[0]); + self::assertInstanceOf(CmsUserDTO::class, $result[1]); + self::assertInstanceOf(CmsUserDTO::class, $result[2]); - $this->assertEquals($this->fixtures[0]->name, $result[0]->name); - $this->assertEquals($this->fixtures[1]->name, $result[1]->name); - $this->assertEquals($this->fixtures[2]->name, $result[2]->name); + self::assertEquals($this->fixtures[0]->name, $result[0]->name); + self::assertEquals($this->fixtures[1]->name, $result[1]->name); + self::assertEquals($this->fixtures[2]->name, $result[2]->name); - $this->assertEquals('TEST1', $result[0]->email); - $this->assertEquals('OTHER_TEST', $result[1]->email); - $this->assertEquals('OTHER_TEST', $result[2]->email); + self::assertEquals('TEST1', $result[0]->email); + self::assertEquals('OTHER_TEST', $result[1]->email); + self::assertEquals('OTHER_TEST', $result[2]->email); } public function testShouldSupportSimpleArithmeticExpression(): void @@ -381,35 +381,35 @@ public function testShouldSupportSimpleArithmeticExpression(): void $query = $this->_em->createQuery($dql); $result = $query->getResult(); - $this->assertCount(3, $result); + self::assertCount(3, $result); - $this->assertInstanceOf(CmsUserDTO::class, $result[0]); - $this->assertInstanceOf(CmsUserDTO::class, $result[1]); - $this->assertInstanceOf(CmsUserDTO::class, $result[2]); + self::assertInstanceOf(CmsUserDTO::class, $result[0]); + self::assertInstanceOf(CmsUserDTO::class, $result[1]); + self::assertInstanceOf(CmsUserDTO::class, $result[2]); - $this->assertEquals($this->fixtures[0]->name, $result[0]->name); - $this->assertEquals($this->fixtures[1]->name, $result[1]->name); - $this->assertEquals($this->fixtures[2]->name, $result[2]->name); + self::assertEquals($this->fixtures[0]->name, $result[0]->name); + self::assertEquals($this->fixtures[1]->name, $result[1]->name); + self::assertEquals($this->fixtures[2]->name, $result[2]->name); - $this->assertEquals($this->fixtures[0]->email->email, $result[0]->email); - $this->assertEquals($this->fixtures[1]->email->email, $result[1]->email); - $this->assertEquals($this->fixtures[2]->email->email, $result[2]->email); + self::assertEquals($this->fixtures[0]->email->email, $result[0]->email); + self::assertEquals($this->fixtures[1]->email->email, $result[1]->email); + self::assertEquals($this->fixtures[2]->email->email, $result[2]->email); - $this->assertEquals($this->fixtures[0]->address->city, $result[0]->address); - $this->assertEquals($this->fixtures[1]->address->city, $result[1]->address); - $this->assertEquals($this->fixtures[2]->address->city, $result[2]->address); + self::assertEquals($this->fixtures[0]->address->city, $result[0]->address); + self::assertEquals($this->fixtures[1]->address->city, $result[1]->address); + self::assertEquals($this->fixtures[2]->address->city, $result[2]->address); - $this->assertEquals( + self::assertEquals( $this->fixtures[0]->address->id + $this->fixtures[0]->id, $result[0]->phonenumbers ); - $this->assertEquals( + self::assertEquals( $this->fixtures[1]->address->id + $this->fixtures[1]->id, $result[1]->phonenumbers ); - $this->assertEquals( + self::assertEquals( $this->fixtures[2]->address->id + $this->fixtures[2]->id, $result[2]->phonenumbers ); @@ -441,35 +441,35 @@ public function testShouldSupportAggregateFunctions(): void $query = $this->_em->createQuery($dql); $result = $query->getResult(); - $this->assertCount(3, $result); + self::assertCount(3, $result); - $this->assertInstanceOf(CmsUserDTO::class, $result[0]); - $this->assertInstanceOf(CmsUserDTO::class, $result[1]); - $this->assertInstanceOf(CmsUserDTO::class, $result[2]); + self::assertInstanceOf(CmsUserDTO::class, $result[0]); + self::assertInstanceOf(CmsUserDTO::class, $result[1]); + self::assertInstanceOf(CmsUserDTO::class, $result[2]); - $this->assertEquals($this->fixtures[0]->name, $result[0]->name); - $this->assertEquals($this->fixtures[1]->name, $result[1]->name); - $this->assertEquals($this->fixtures[2]->name, $result[2]->name); + self::assertEquals($this->fixtures[0]->name, $result[0]->name); + self::assertEquals($this->fixtures[1]->name, $result[1]->name); + self::assertEquals($this->fixtures[2]->name, $result[2]->name); - $this->assertEquals($this->fixtures[0]->email->email, $result[0]->email); - $this->assertEquals($this->fixtures[1]->email->email, $result[1]->email); - $this->assertEquals($this->fixtures[2]->email->email, $result[2]->email); + self::assertEquals($this->fixtures[0]->email->email, $result[0]->email); + self::assertEquals($this->fixtures[1]->email->email, $result[1]->email); + self::assertEquals($this->fixtures[2]->email->email, $result[2]->email); - $this->assertEquals($this->fixtures[0]->address->city, $result[0]->address); - $this->assertEquals($this->fixtures[1]->address->city, $result[1]->address); - $this->assertEquals($this->fixtures[2]->address->city, $result[2]->address); + self::assertEquals($this->fixtures[0]->address->city, $result[0]->address); + self::assertEquals($this->fixtures[1]->address->city, $result[1]->address); + self::assertEquals($this->fixtures[2]->address->city, $result[2]->address); - $this->assertEquals( + self::assertEquals( count($this->fixtures[0]->phonenumbers), $result[0]->phonenumbers ); - $this->assertEquals( + self::assertEquals( count($this->fixtures[1]->phonenumbers), $result[1]->phonenumbers ); - $this->assertEquals( + self::assertEquals( count($this->fixtures[2]->phonenumbers), $result[2]->phonenumbers ); @@ -501,35 +501,35 @@ public function testShouldSupportArithmeticExpression(): void $query = $this->_em->createQuery($dql); $result = $query->getResult(); - $this->assertCount(3, $result); + self::assertCount(3, $result); - $this->assertInstanceOf(CmsUserDTO::class, $result[0]); - $this->assertInstanceOf(CmsUserDTO::class, $result[1]); - $this->assertInstanceOf(CmsUserDTO::class, $result[2]); + self::assertInstanceOf(CmsUserDTO::class, $result[0]); + self::assertInstanceOf(CmsUserDTO::class, $result[1]); + self::assertInstanceOf(CmsUserDTO::class, $result[2]); - $this->assertEquals($this->fixtures[0]->name, $result[0]->name); - $this->assertEquals($this->fixtures[1]->name, $result[1]->name); - $this->assertEquals($this->fixtures[2]->name, $result[2]->name); + self::assertEquals($this->fixtures[0]->name, $result[0]->name); + self::assertEquals($this->fixtures[1]->name, $result[1]->name); + self::assertEquals($this->fixtures[2]->name, $result[2]->name); - $this->assertEquals($this->fixtures[0]->email->email, $result[0]->email); - $this->assertEquals($this->fixtures[1]->email->email, $result[1]->email); - $this->assertEquals($this->fixtures[2]->email->email, $result[2]->email); + self::assertEquals($this->fixtures[0]->email->email, $result[0]->email); + self::assertEquals($this->fixtures[1]->email->email, $result[1]->email); + self::assertEquals($this->fixtures[2]->email->email, $result[2]->email); - $this->assertEquals($this->fixtures[0]->address->city, $result[0]->address); - $this->assertEquals($this->fixtures[1]->address->city, $result[1]->address); - $this->assertEquals($this->fixtures[2]->address->city, $result[2]->address); + self::assertEquals($this->fixtures[0]->address->city, $result[0]->address); + self::assertEquals($this->fixtures[1]->address->city, $result[1]->address); + self::assertEquals($this->fixtures[2]->address->city, $result[2]->address); - $this->assertEquals( + self::assertEquals( count($this->fixtures[0]->phonenumbers) + $this->fixtures[0]->id, $result[0]->phonenumbers ); - $this->assertEquals( + self::assertEquals( count($this->fixtures[1]->phonenumbers) + $this->fixtures[1]->id, $result[1]->phonenumbers ); - $this->assertEquals( + self::assertEquals( count($this->fixtures[2]->phonenumbers) + $this->fixtures[2]->id, $result[2]->phonenumbers ); @@ -559,31 +559,31 @@ public function testShouldSupportMultipleNewOperators(): void $query = $this->_em->createQuery($dql); $result = $query->getResult(); - $this->assertCount(3, $result); + self::assertCount(3, $result); - $this->assertInstanceOf(CmsUserDTO::class, $result[0][0]); - $this->assertInstanceOf(CmsUserDTO::class, $result[1][0]); - $this->assertInstanceOf(CmsUserDTO::class, $result[2][0]); + self::assertInstanceOf(CmsUserDTO::class, $result[0][0]); + self::assertInstanceOf(CmsUserDTO::class, $result[1][0]); + self::assertInstanceOf(CmsUserDTO::class, $result[2][0]); - $this->assertInstanceOf(CmsAddressDTO::class, $result[0][1]); - $this->assertInstanceOf(CmsAddressDTO::class, $result[1][1]); - $this->assertInstanceOf(CmsAddressDTO::class, $result[2][1]); + self::assertInstanceOf(CmsAddressDTO::class, $result[0][1]); + self::assertInstanceOf(CmsAddressDTO::class, $result[1][1]); + self::assertInstanceOf(CmsAddressDTO::class, $result[2][1]); - $this->assertEquals($this->fixtures[0]->name, $result[0][0]->name); - $this->assertEquals($this->fixtures[1]->name, $result[1][0]->name); - $this->assertEquals($this->fixtures[2]->name, $result[2][0]->name); + self::assertEquals($this->fixtures[0]->name, $result[0][0]->name); + self::assertEquals($this->fixtures[1]->name, $result[1][0]->name); + self::assertEquals($this->fixtures[2]->name, $result[2][0]->name); - $this->assertEquals($this->fixtures[0]->email->email, $result[0][0]->email); - $this->assertEquals($this->fixtures[1]->email->email, $result[1][0]->email); - $this->assertEquals($this->fixtures[2]->email->email, $result[2][0]->email); + self::assertEquals($this->fixtures[0]->email->email, $result[0][0]->email); + self::assertEquals($this->fixtures[1]->email->email, $result[1][0]->email); + self::assertEquals($this->fixtures[2]->email->email, $result[2][0]->email); - $this->assertEquals($this->fixtures[0]->address->city, $result[0][1]->city); - $this->assertEquals($this->fixtures[1]->address->city, $result[1][1]->city); - $this->assertEquals($this->fixtures[2]->address->city, $result[2][1]->city); + self::assertEquals($this->fixtures[0]->address->city, $result[0][1]->city); + self::assertEquals($this->fixtures[1]->address->city, $result[1][1]->city); + self::assertEquals($this->fixtures[2]->address->city, $result[2][1]->city); - $this->assertEquals($this->fixtures[0]->address->country, $result[0][1]->country); - $this->assertEquals($this->fixtures[1]->address->country, $result[1][1]->country); - $this->assertEquals($this->fixtures[2]->address->country, $result[2][1]->country); + self::assertEquals($this->fixtures[0]->address->country, $result[0][1]->country); + self::assertEquals($this->fixtures[1]->address->country, $result[1][1]->country); + self::assertEquals($this->fixtures[2]->address->country, $result[2][1]->country); } public function testShouldSupportMultipleNewOperatorsWithAliases(): void @@ -610,31 +610,31 @@ public function testShouldSupportMultipleNewOperatorsWithAliases(): void $query = $this->_em->createQuery($dql); $result = $query->getResult(); - $this->assertCount(3, $result); + self::assertCount(3, $result); - $this->assertInstanceOf(CmsUserDTO::class, $result[0]['cmsUser']); - $this->assertInstanceOf(CmsUserDTO::class, $result[1]['cmsUser']); - $this->assertInstanceOf(CmsUserDTO::class, $result[2]['cmsUser']); + self::assertInstanceOf(CmsUserDTO::class, $result[0]['cmsUser']); + self::assertInstanceOf(CmsUserDTO::class, $result[1]['cmsUser']); + self::assertInstanceOf(CmsUserDTO::class, $result[2]['cmsUser']); - $this->assertInstanceOf(CmsAddressDTO::class, $result[0]['cmsAddress']); - $this->assertInstanceOf(CmsAddressDTO::class, $result[1]['cmsAddress']); - $this->assertInstanceOf(CmsAddressDTO::class, $result[2]['cmsAddress']); + self::assertInstanceOf(CmsAddressDTO::class, $result[0]['cmsAddress']); + self::assertInstanceOf(CmsAddressDTO::class, $result[1]['cmsAddress']); + self::assertInstanceOf(CmsAddressDTO::class, $result[2]['cmsAddress']); - $this->assertEquals($this->fixtures[0]->name, $result[0]['cmsUser']->name); - $this->assertEquals($this->fixtures[1]->name, $result[1]['cmsUser']->name); - $this->assertEquals($this->fixtures[2]->name, $result[2]['cmsUser']->name); + self::assertEquals($this->fixtures[0]->name, $result[0]['cmsUser']->name); + self::assertEquals($this->fixtures[1]->name, $result[1]['cmsUser']->name); + self::assertEquals($this->fixtures[2]->name, $result[2]['cmsUser']->name); - $this->assertEquals($this->fixtures[0]->email->email, $result[0]['cmsUser']->email); - $this->assertEquals($this->fixtures[1]->email->email, $result[1]['cmsUser']->email); - $this->assertEquals($this->fixtures[2]->email->email, $result[2]['cmsUser']->email); + self::assertEquals($this->fixtures[0]->email->email, $result[0]['cmsUser']->email); + self::assertEquals($this->fixtures[1]->email->email, $result[1]['cmsUser']->email); + self::assertEquals($this->fixtures[2]->email->email, $result[2]['cmsUser']->email); - $this->assertEquals($this->fixtures[0]->address->city, $result[0]['cmsAddress']->city); - $this->assertEquals($this->fixtures[1]->address->city, $result[1]['cmsAddress']->city); - $this->assertEquals($this->fixtures[2]->address->city, $result[2]['cmsAddress']->city); + self::assertEquals($this->fixtures[0]->address->city, $result[0]['cmsAddress']->city); + self::assertEquals($this->fixtures[1]->address->city, $result[1]['cmsAddress']->city); + self::assertEquals($this->fixtures[2]->address->city, $result[2]['cmsAddress']->city); - $this->assertEquals($this->fixtures[0]->address->country, $result[0]['cmsAddress']->country); - $this->assertEquals($this->fixtures[1]->address->country, $result[1]['cmsAddress']->country); - $this->assertEquals($this->fixtures[2]->address->country, $result[2]['cmsAddress']->country); + self::assertEquals($this->fixtures[0]->address->country, $result[0]['cmsAddress']->country); + self::assertEquals($this->fixtures[1]->address->country, $result[1]['cmsAddress']->country); + self::assertEquals($this->fixtures[2]->address->country, $result[2]['cmsAddress']->country); } public function testShouldSupportMultipleNewOperatorsWithAndWithoutAliases(): void @@ -661,31 +661,31 @@ public function testShouldSupportMultipleNewOperatorsWithAndWithoutAliases(): vo $query = $this->_em->createQuery($dql); $result = $query->getResult(); - $this->assertCount(3, $result); + self::assertCount(3, $result); - $this->assertInstanceOf(CmsUserDTO::class, $result[0]['cmsUser']); - $this->assertInstanceOf(CmsUserDTO::class, $result[1]['cmsUser']); - $this->assertInstanceOf(CmsUserDTO::class, $result[2]['cmsUser']); + self::assertInstanceOf(CmsUserDTO::class, $result[0]['cmsUser']); + self::assertInstanceOf(CmsUserDTO::class, $result[1]['cmsUser']); + self::assertInstanceOf(CmsUserDTO::class, $result[2]['cmsUser']); - $this->assertInstanceOf(CmsAddressDTO::class, $result[0][0]); - $this->assertInstanceOf(CmsAddressDTO::class, $result[1][0]); - $this->assertInstanceOf(CmsAddressDTO::class, $result[2][0]); + self::assertInstanceOf(CmsAddressDTO::class, $result[0][0]); + self::assertInstanceOf(CmsAddressDTO::class, $result[1][0]); + self::assertInstanceOf(CmsAddressDTO::class, $result[2][0]); - $this->assertEquals($this->fixtures[0]->name, $result[0]['cmsUser']->name); - $this->assertEquals($this->fixtures[1]->name, $result[1]['cmsUser']->name); - $this->assertEquals($this->fixtures[2]->name, $result[2]['cmsUser']->name); + self::assertEquals($this->fixtures[0]->name, $result[0]['cmsUser']->name); + self::assertEquals($this->fixtures[1]->name, $result[1]['cmsUser']->name); + self::assertEquals($this->fixtures[2]->name, $result[2]['cmsUser']->name); - $this->assertEquals($this->fixtures[0]->email->email, $result[0]['cmsUser']->email); - $this->assertEquals($this->fixtures[1]->email->email, $result[1]['cmsUser']->email); - $this->assertEquals($this->fixtures[2]->email->email, $result[2]['cmsUser']->email); + self::assertEquals($this->fixtures[0]->email->email, $result[0]['cmsUser']->email); + self::assertEquals($this->fixtures[1]->email->email, $result[1]['cmsUser']->email); + self::assertEquals($this->fixtures[2]->email->email, $result[2]['cmsUser']->email); - $this->assertEquals($this->fixtures[0]->address->city, $result[0][0]->city); - $this->assertEquals($this->fixtures[1]->address->city, $result[1][0]->city); - $this->assertEquals($this->fixtures[2]->address->city, $result[2][0]->city); + self::assertEquals($this->fixtures[0]->address->city, $result[0][0]->city); + self::assertEquals($this->fixtures[1]->address->city, $result[1][0]->city); + self::assertEquals($this->fixtures[2]->address->city, $result[2][0]->city); - $this->assertEquals($this->fixtures[0]->address->country, $result[0][0]->country); - $this->assertEquals($this->fixtures[1]->address->country, $result[1][0]->country); - $this->assertEquals($this->fixtures[2]->address->country, $result[2][0]->country); + self::assertEquals($this->fixtures[0]->address->country, $result[0][0]->country); + self::assertEquals($this->fixtures[1]->address->country, $result[1][0]->country); + self::assertEquals($this->fixtures[2]->address->country, $result[2][0]->country); } public function testShouldSupportMultipleNewOperatorsAndSingleScalar(): void @@ -713,35 +713,35 @@ public function testShouldSupportMultipleNewOperatorsAndSingleScalar(): void $query = $this->_em->createQuery($dql); $result = $query->getResult(); - $this->assertCount(3, $result); + self::assertCount(3, $result); - $this->assertInstanceOf(CmsUserDTO::class, $result[0][0]); - $this->assertInstanceOf(CmsUserDTO::class, $result[1][0]); - $this->assertInstanceOf(CmsUserDTO::class, $result[2][0]); + self::assertInstanceOf(CmsUserDTO::class, $result[0][0]); + self::assertInstanceOf(CmsUserDTO::class, $result[1][0]); + self::assertInstanceOf(CmsUserDTO::class, $result[2][0]); - $this->assertInstanceOf(CmsAddressDTO::class, $result[0][1]); - $this->assertInstanceOf(CmsAddressDTO::class, $result[1][1]); - $this->assertInstanceOf(CmsAddressDTO::class, $result[2][1]); + self::assertInstanceOf(CmsAddressDTO::class, $result[0][1]); + self::assertInstanceOf(CmsAddressDTO::class, $result[1][1]); + self::assertInstanceOf(CmsAddressDTO::class, $result[2][1]); - $this->assertEquals($this->fixtures[0]->name, $result[0][0]->name); - $this->assertEquals($this->fixtures[1]->name, $result[1][0]->name); - $this->assertEquals($this->fixtures[2]->name, $result[2][0]->name); + self::assertEquals($this->fixtures[0]->name, $result[0][0]->name); + self::assertEquals($this->fixtures[1]->name, $result[1][0]->name); + self::assertEquals($this->fixtures[2]->name, $result[2][0]->name); - $this->assertEquals($this->fixtures[0]->email->email, $result[0][0]->email); - $this->assertEquals($this->fixtures[1]->email->email, $result[1][0]->email); - $this->assertEquals($this->fixtures[2]->email->email, $result[2][0]->email); + self::assertEquals($this->fixtures[0]->email->email, $result[0][0]->email); + self::assertEquals($this->fixtures[1]->email->email, $result[1][0]->email); + self::assertEquals($this->fixtures[2]->email->email, $result[2][0]->email); - $this->assertEquals($this->fixtures[0]->address->city, $result[0][1]->city); - $this->assertEquals($this->fixtures[1]->address->city, $result[1][1]->city); - $this->assertEquals($this->fixtures[2]->address->city, $result[2][1]->city); + self::assertEquals($this->fixtures[0]->address->city, $result[0][1]->city); + self::assertEquals($this->fixtures[1]->address->city, $result[1][1]->city); + self::assertEquals($this->fixtures[2]->address->city, $result[2][1]->city); - $this->assertEquals($this->fixtures[0]->address->country, $result[0][1]->country); - $this->assertEquals($this->fixtures[1]->address->country, $result[1][1]->country); - $this->assertEquals($this->fixtures[2]->address->country, $result[2][1]->country); + self::assertEquals($this->fixtures[0]->address->country, $result[0][1]->country); + self::assertEquals($this->fixtures[1]->address->country, $result[1][1]->country); + self::assertEquals($this->fixtures[2]->address->country, $result[2][1]->country); - $this->assertEquals($this->fixtures[0]->status, $result[0]['status']); - $this->assertEquals($this->fixtures[1]->status, $result[1]['status']); - $this->assertEquals($this->fixtures[2]->status, $result[2]['status']); + self::assertEquals($this->fixtures[0]->status, $result[0]['status']); + self::assertEquals($this->fixtures[1]->status, $result[1]['status']); + self::assertEquals($this->fixtures[2]->status, $result[2]['status']); } public function testShouldSupportMultipleNewOperatorsAndSingleScalarWithAliases(): void @@ -769,35 +769,35 @@ public function testShouldSupportMultipleNewOperatorsAndSingleScalarWithAliases( $query = $this->_em->createQuery($dql); $result = $query->getResult(); - $this->assertCount(3, $result); + self::assertCount(3, $result); - $this->assertInstanceOf(CmsUserDTO::class, $result[0]['cmsUser']); - $this->assertInstanceOf(CmsUserDTO::class, $result[1]['cmsUser']); - $this->assertInstanceOf(CmsUserDTO::class, $result[2]['cmsUser']); + self::assertInstanceOf(CmsUserDTO::class, $result[0]['cmsUser']); + self::assertInstanceOf(CmsUserDTO::class, $result[1]['cmsUser']); + self::assertInstanceOf(CmsUserDTO::class, $result[2]['cmsUser']); - $this->assertInstanceOf(CmsAddressDTO::class, $result[0]['cmsAddress']); - $this->assertInstanceOf(CmsAddressDTO::class, $result[1]['cmsAddress']); - $this->assertInstanceOf(CmsAddressDTO::class, $result[2]['cmsAddress']); + self::assertInstanceOf(CmsAddressDTO::class, $result[0]['cmsAddress']); + self::assertInstanceOf(CmsAddressDTO::class, $result[1]['cmsAddress']); + self::assertInstanceOf(CmsAddressDTO::class, $result[2]['cmsAddress']); - $this->assertEquals($this->fixtures[0]->name, $result[0]['cmsUser']->name); - $this->assertEquals($this->fixtures[1]->name, $result[1]['cmsUser']->name); - $this->assertEquals($this->fixtures[2]->name, $result[2]['cmsUser']->name); + self::assertEquals($this->fixtures[0]->name, $result[0]['cmsUser']->name); + self::assertEquals($this->fixtures[1]->name, $result[1]['cmsUser']->name); + self::assertEquals($this->fixtures[2]->name, $result[2]['cmsUser']->name); - $this->assertEquals($this->fixtures[0]->email->email, $result[0]['cmsUser']->email); - $this->assertEquals($this->fixtures[1]->email->email, $result[1]['cmsUser']->email); - $this->assertEquals($this->fixtures[2]->email->email, $result[2]['cmsUser']->email); + self::assertEquals($this->fixtures[0]->email->email, $result[0]['cmsUser']->email); + self::assertEquals($this->fixtures[1]->email->email, $result[1]['cmsUser']->email); + self::assertEquals($this->fixtures[2]->email->email, $result[2]['cmsUser']->email); - $this->assertEquals($this->fixtures[0]->address->city, $result[0]['cmsAddress']->city); - $this->assertEquals($this->fixtures[1]->address->city, $result[1]['cmsAddress']->city); - $this->assertEquals($this->fixtures[2]->address->city, $result[2]['cmsAddress']->city); + self::assertEquals($this->fixtures[0]->address->city, $result[0]['cmsAddress']->city); + self::assertEquals($this->fixtures[1]->address->city, $result[1]['cmsAddress']->city); + self::assertEquals($this->fixtures[2]->address->city, $result[2]['cmsAddress']->city); - $this->assertEquals($this->fixtures[0]->address->country, $result[0]['cmsAddress']->country); - $this->assertEquals($this->fixtures[1]->address->country, $result[1]['cmsAddress']->country); - $this->assertEquals($this->fixtures[2]->address->country, $result[2]['cmsAddress']->country); + self::assertEquals($this->fixtures[0]->address->country, $result[0]['cmsAddress']->country); + self::assertEquals($this->fixtures[1]->address->country, $result[1]['cmsAddress']->country); + self::assertEquals($this->fixtures[2]->address->country, $result[2]['cmsAddress']->country); - $this->assertEquals($this->fixtures[0]->status, $result[0]['cmsUserStatus']); - $this->assertEquals($this->fixtures[1]->status, $result[1]['cmsUserStatus']); - $this->assertEquals($this->fixtures[2]->status, $result[2]['cmsUserStatus']); + self::assertEquals($this->fixtures[0]->status, $result[0]['cmsUserStatus']); + self::assertEquals($this->fixtures[1]->status, $result[1]['cmsUserStatus']); + self::assertEquals($this->fixtures[2]->status, $result[2]['cmsUserStatus']); } public function testShouldSupportMultipleNewOperatorsAndSingleScalarWithAndWithoutAliases(): void @@ -825,35 +825,35 @@ public function testShouldSupportMultipleNewOperatorsAndSingleScalarWithAndWitho $query = $this->_em->createQuery($dql); $result = $query->getResult(); - $this->assertCount(3, $result); + self::assertCount(3, $result); - $this->assertInstanceOf(CmsUserDTO::class, $result[0]['cmsUser']); - $this->assertInstanceOf(CmsUserDTO::class, $result[1]['cmsUser']); - $this->assertInstanceOf(CmsUserDTO::class, $result[2]['cmsUser']); + self::assertInstanceOf(CmsUserDTO::class, $result[0]['cmsUser']); + self::assertInstanceOf(CmsUserDTO::class, $result[1]['cmsUser']); + self::assertInstanceOf(CmsUserDTO::class, $result[2]['cmsUser']); - $this->assertInstanceOf(CmsAddressDTO::class, $result[0][0]); - $this->assertInstanceOf(CmsAddressDTO::class, $result[1][0]); - $this->assertInstanceOf(CmsAddressDTO::class, $result[2][0]); + self::assertInstanceOf(CmsAddressDTO::class, $result[0][0]); + self::assertInstanceOf(CmsAddressDTO::class, $result[1][0]); + self::assertInstanceOf(CmsAddressDTO::class, $result[2][0]); - $this->assertEquals($this->fixtures[0]->name, $result[0]['cmsUser']->name); - $this->assertEquals($this->fixtures[1]->name, $result[1]['cmsUser']->name); - $this->assertEquals($this->fixtures[2]->name, $result[2]['cmsUser']->name); + self::assertEquals($this->fixtures[0]->name, $result[0]['cmsUser']->name); + self::assertEquals($this->fixtures[1]->name, $result[1]['cmsUser']->name); + self::assertEquals($this->fixtures[2]->name, $result[2]['cmsUser']->name); - $this->assertEquals($this->fixtures[0]->email->email, $result[0]['cmsUser']->email); - $this->assertEquals($this->fixtures[1]->email->email, $result[1]['cmsUser']->email); - $this->assertEquals($this->fixtures[2]->email->email, $result[2]['cmsUser']->email); + self::assertEquals($this->fixtures[0]->email->email, $result[0]['cmsUser']->email); + self::assertEquals($this->fixtures[1]->email->email, $result[1]['cmsUser']->email); + self::assertEquals($this->fixtures[2]->email->email, $result[2]['cmsUser']->email); - $this->assertEquals($this->fixtures[0]->address->city, $result[0][0]->city); - $this->assertEquals($this->fixtures[1]->address->city, $result[1][0]->city); - $this->assertEquals($this->fixtures[2]->address->city, $result[2][0]->city); + self::assertEquals($this->fixtures[0]->address->city, $result[0][0]->city); + self::assertEquals($this->fixtures[1]->address->city, $result[1][0]->city); + self::assertEquals($this->fixtures[2]->address->city, $result[2][0]->city); - $this->assertEquals($this->fixtures[0]->address->country, $result[0][0]->country); - $this->assertEquals($this->fixtures[1]->address->country, $result[1][0]->country); - $this->assertEquals($this->fixtures[2]->address->country, $result[2][0]->country); + self::assertEquals($this->fixtures[0]->address->country, $result[0][0]->country); + self::assertEquals($this->fixtures[1]->address->country, $result[1][0]->country); + self::assertEquals($this->fixtures[2]->address->country, $result[2][0]->country); - $this->assertEquals($this->fixtures[0]->status, $result[0]['status']); - $this->assertEquals($this->fixtures[1]->status, $result[1]['status']); - $this->assertEquals($this->fixtures[2]->status, $result[2]['status']); + self::assertEquals($this->fixtures[0]->status, $result[0]['status']); + self::assertEquals($this->fixtures[1]->status, $result[1]['status']); + self::assertEquals($this->fixtures[2]->status, $result[2]['status']); } public function testShouldSupportMultipleNewOperatorsAndMultipleScalars(): void @@ -882,39 +882,39 @@ public function testShouldSupportMultipleNewOperatorsAndMultipleScalars(): void $query = $this->_em->createQuery($dql); $result = $query->getResult(); - $this->assertCount(3, $result); + self::assertCount(3, $result); - $this->assertInstanceOf(CmsUserDTO::class, $result[0][0]); - $this->assertInstanceOf(CmsUserDTO::class, $result[1][0]); - $this->assertInstanceOf(CmsUserDTO::class, $result[2][0]); + self::assertInstanceOf(CmsUserDTO::class, $result[0][0]); + self::assertInstanceOf(CmsUserDTO::class, $result[1][0]); + self::assertInstanceOf(CmsUserDTO::class, $result[2][0]); - $this->assertInstanceOf(CmsAddressDTO::class, $result[0][1]); - $this->assertInstanceOf(CmsAddressDTO::class, $result[1][1]); - $this->assertInstanceOf(CmsAddressDTO::class, $result[2][1]); + self::assertInstanceOf(CmsAddressDTO::class, $result[0][1]); + self::assertInstanceOf(CmsAddressDTO::class, $result[1][1]); + self::assertInstanceOf(CmsAddressDTO::class, $result[2][1]); - $this->assertEquals($this->fixtures[0]->name, $result[0][0]->name); - $this->assertEquals($this->fixtures[1]->name, $result[1][0]->name); - $this->assertEquals($this->fixtures[2]->name, $result[2][0]->name); + self::assertEquals($this->fixtures[0]->name, $result[0][0]->name); + self::assertEquals($this->fixtures[1]->name, $result[1][0]->name); + self::assertEquals($this->fixtures[2]->name, $result[2][0]->name); - $this->assertEquals($this->fixtures[0]->email->email, $result[0][0]->email); - $this->assertEquals($this->fixtures[1]->email->email, $result[1][0]->email); - $this->assertEquals($this->fixtures[2]->email->email, $result[2][0]->email); + self::assertEquals($this->fixtures[0]->email->email, $result[0][0]->email); + self::assertEquals($this->fixtures[1]->email->email, $result[1][0]->email); + self::assertEquals($this->fixtures[2]->email->email, $result[2][0]->email); - $this->assertEquals($this->fixtures[0]->address->city, $result[0][1]->city); - $this->assertEquals($this->fixtures[1]->address->city, $result[1][1]->city); - $this->assertEquals($this->fixtures[2]->address->city, $result[2][1]->city); + self::assertEquals($this->fixtures[0]->address->city, $result[0][1]->city); + self::assertEquals($this->fixtures[1]->address->city, $result[1][1]->city); + self::assertEquals($this->fixtures[2]->address->city, $result[2][1]->city); - $this->assertEquals($this->fixtures[0]->address->country, $result[0][1]->country); - $this->assertEquals($this->fixtures[1]->address->country, $result[1][1]->country); - $this->assertEquals($this->fixtures[2]->address->country, $result[2][1]->country); + self::assertEquals($this->fixtures[0]->address->country, $result[0][1]->country); + self::assertEquals($this->fixtures[1]->address->country, $result[1][1]->country); + self::assertEquals($this->fixtures[2]->address->country, $result[2][1]->country); - $this->assertEquals($this->fixtures[0]->status, $result[0]['status']); - $this->assertEquals($this->fixtures[1]->status, $result[1]['status']); - $this->assertEquals($this->fixtures[2]->status, $result[2]['status']); + self::assertEquals($this->fixtures[0]->status, $result[0]['status']); + self::assertEquals($this->fixtures[1]->status, $result[1]['status']); + self::assertEquals($this->fixtures[2]->status, $result[2]['status']); - $this->assertEquals($this->fixtures[0]->username, $result[0]['username']); - $this->assertEquals($this->fixtures[1]->username, $result[1]['username']); - $this->assertEquals($this->fixtures[2]->username, $result[2]['username']); + self::assertEquals($this->fixtures[0]->username, $result[0]['username']); + self::assertEquals($this->fixtures[1]->username, $result[1]['username']); + self::assertEquals($this->fixtures[2]->username, $result[2]['username']); } public function testShouldSupportMultipleNewOperatorsAndMultipleScalarsWithAliases(): void @@ -943,39 +943,39 @@ public function testShouldSupportMultipleNewOperatorsAndMultipleScalarsWithAlias $query = $this->_em->createQuery($dql); $result = $query->getResult(); - $this->assertCount(3, $result); + self::assertCount(3, $result); - $this->assertInstanceOf(CmsUserDTO::class, $result[0]['cmsUser']); - $this->assertInstanceOf(CmsUserDTO::class, $result[1]['cmsUser']); - $this->assertInstanceOf(CmsUserDTO::class, $result[2]['cmsUser']); + self::assertInstanceOf(CmsUserDTO::class, $result[0]['cmsUser']); + self::assertInstanceOf(CmsUserDTO::class, $result[1]['cmsUser']); + self::assertInstanceOf(CmsUserDTO::class, $result[2]['cmsUser']); - $this->assertInstanceOf(CmsAddressDTO::class, $result[0]['cmsAddress']); - $this->assertInstanceOf(CmsAddressDTO::class, $result[1]['cmsAddress']); - $this->assertInstanceOf(CmsAddressDTO::class, $result[2]['cmsAddress']); + self::assertInstanceOf(CmsAddressDTO::class, $result[0]['cmsAddress']); + self::assertInstanceOf(CmsAddressDTO::class, $result[1]['cmsAddress']); + self::assertInstanceOf(CmsAddressDTO::class, $result[2]['cmsAddress']); - $this->assertEquals($this->fixtures[0]->name, $result[0]['cmsUser']->name); - $this->assertEquals($this->fixtures[1]->name, $result[1]['cmsUser']->name); - $this->assertEquals($this->fixtures[2]->name, $result[2]['cmsUser']->name); + self::assertEquals($this->fixtures[0]->name, $result[0]['cmsUser']->name); + self::assertEquals($this->fixtures[1]->name, $result[1]['cmsUser']->name); + self::assertEquals($this->fixtures[2]->name, $result[2]['cmsUser']->name); - $this->assertEquals($this->fixtures[0]->email->email, $result[0]['cmsUser']->email); - $this->assertEquals($this->fixtures[1]->email->email, $result[1]['cmsUser']->email); - $this->assertEquals($this->fixtures[2]->email->email, $result[2]['cmsUser']->email); + self::assertEquals($this->fixtures[0]->email->email, $result[0]['cmsUser']->email); + self::assertEquals($this->fixtures[1]->email->email, $result[1]['cmsUser']->email); + self::assertEquals($this->fixtures[2]->email->email, $result[2]['cmsUser']->email); - $this->assertEquals($this->fixtures[0]->address->city, $result[0]['cmsAddress']->city); - $this->assertEquals($this->fixtures[1]->address->city, $result[1]['cmsAddress']->city); - $this->assertEquals($this->fixtures[2]->address->city, $result[2]['cmsAddress']->city); + self::assertEquals($this->fixtures[0]->address->city, $result[0]['cmsAddress']->city); + self::assertEquals($this->fixtures[1]->address->city, $result[1]['cmsAddress']->city); + self::assertEquals($this->fixtures[2]->address->city, $result[2]['cmsAddress']->city); - $this->assertEquals($this->fixtures[0]->address->country, $result[0]['cmsAddress']->country); - $this->assertEquals($this->fixtures[1]->address->country, $result[1]['cmsAddress']->country); - $this->assertEquals($this->fixtures[2]->address->country, $result[2]['cmsAddress']->country); + self::assertEquals($this->fixtures[0]->address->country, $result[0]['cmsAddress']->country); + self::assertEquals($this->fixtures[1]->address->country, $result[1]['cmsAddress']->country); + self::assertEquals($this->fixtures[2]->address->country, $result[2]['cmsAddress']->country); - $this->assertEquals($this->fixtures[0]->status, $result[0]['cmsUserStatus']); - $this->assertEquals($this->fixtures[1]->status, $result[1]['cmsUserStatus']); - $this->assertEquals($this->fixtures[2]->status, $result[2]['cmsUserStatus']); + self::assertEquals($this->fixtures[0]->status, $result[0]['cmsUserStatus']); + self::assertEquals($this->fixtures[1]->status, $result[1]['cmsUserStatus']); + self::assertEquals($this->fixtures[2]->status, $result[2]['cmsUserStatus']); - $this->assertEquals($this->fixtures[0]->username, $result[0]['cmsUserUsername']); - $this->assertEquals($this->fixtures[1]->username, $result[1]['cmsUserUsername']); - $this->assertEquals($this->fixtures[2]->username, $result[2]['cmsUserUsername']); + self::assertEquals($this->fixtures[0]->username, $result[0]['cmsUserUsername']); + self::assertEquals($this->fixtures[1]->username, $result[1]['cmsUserUsername']); + self::assertEquals($this->fixtures[2]->username, $result[2]['cmsUserUsername']); } public function testShouldSupportMultipleNewOperatorsAndMultipleScalarsWithAndWithoutAliases(): void @@ -1004,39 +1004,39 @@ public function testShouldSupportMultipleNewOperatorsAndMultipleScalarsWithAndWi $query = $this->_em->createQuery($dql); $result = $query->getResult(); - $this->assertCount(3, $result); + self::assertCount(3, $result); - $this->assertInstanceOf(CmsUserDTO::class, $result[0]['cmsUser']); - $this->assertInstanceOf(CmsUserDTO::class, $result[1]['cmsUser']); - $this->assertInstanceOf(CmsUserDTO::class, $result[2]['cmsUser']); + self::assertInstanceOf(CmsUserDTO::class, $result[0]['cmsUser']); + self::assertInstanceOf(CmsUserDTO::class, $result[1]['cmsUser']); + self::assertInstanceOf(CmsUserDTO::class, $result[2]['cmsUser']); - $this->assertInstanceOf(CmsAddressDTO::class, $result[0][0]); - $this->assertInstanceOf(CmsAddressDTO::class, $result[1][0]); - $this->assertInstanceOf(CmsAddressDTO::class, $result[2][0]); + self::assertInstanceOf(CmsAddressDTO::class, $result[0][0]); + self::assertInstanceOf(CmsAddressDTO::class, $result[1][0]); + self::assertInstanceOf(CmsAddressDTO::class, $result[2][0]); - $this->assertEquals($this->fixtures[0]->name, $result[0]['cmsUser']->name); - $this->assertEquals($this->fixtures[1]->name, $result[1]['cmsUser']->name); - $this->assertEquals($this->fixtures[2]->name, $result[2]['cmsUser']->name); + self::assertEquals($this->fixtures[0]->name, $result[0]['cmsUser']->name); + self::assertEquals($this->fixtures[1]->name, $result[1]['cmsUser']->name); + self::assertEquals($this->fixtures[2]->name, $result[2]['cmsUser']->name); - $this->assertEquals($this->fixtures[0]->email->email, $result[0]['cmsUser']->email); - $this->assertEquals($this->fixtures[1]->email->email, $result[1]['cmsUser']->email); - $this->assertEquals($this->fixtures[2]->email->email, $result[2]['cmsUser']->email); + self::assertEquals($this->fixtures[0]->email->email, $result[0]['cmsUser']->email); + self::assertEquals($this->fixtures[1]->email->email, $result[1]['cmsUser']->email); + self::assertEquals($this->fixtures[2]->email->email, $result[2]['cmsUser']->email); - $this->assertEquals($this->fixtures[0]->address->city, $result[0][0]->city); - $this->assertEquals($this->fixtures[1]->address->city, $result[1][0]->city); - $this->assertEquals($this->fixtures[2]->address->city, $result[2][0]->city); + self::assertEquals($this->fixtures[0]->address->city, $result[0][0]->city); + self::assertEquals($this->fixtures[1]->address->city, $result[1][0]->city); + self::assertEquals($this->fixtures[2]->address->city, $result[2][0]->city); - $this->assertEquals($this->fixtures[0]->address->country, $result[0][0]->country); - $this->assertEquals($this->fixtures[1]->address->country, $result[1][0]->country); - $this->assertEquals($this->fixtures[2]->address->country, $result[2][0]->country); + self::assertEquals($this->fixtures[0]->address->country, $result[0][0]->country); + self::assertEquals($this->fixtures[1]->address->country, $result[1][0]->country); + self::assertEquals($this->fixtures[2]->address->country, $result[2][0]->country); - $this->assertEquals($this->fixtures[0]->status, $result[0]['status']); - $this->assertEquals($this->fixtures[1]->status, $result[1]['status']); - $this->assertEquals($this->fixtures[2]->status, $result[2]['status']); + self::assertEquals($this->fixtures[0]->status, $result[0]['status']); + self::assertEquals($this->fixtures[1]->status, $result[1]['status']); + self::assertEquals($this->fixtures[2]->status, $result[2]['status']); - $this->assertEquals($this->fixtures[0]->username, $result[0]['cmsUserUsername']); - $this->assertEquals($this->fixtures[1]->username, $result[1]['cmsUserUsername']); - $this->assertEquals($this->fixtures[2]->username, $result[2]['cmsUserUsername']); + self::assertEquals($this->fixtures[0]->username, $result[0]['cmsUserUsername']); + self::assertEquals($this->fixtures[1]->username, $result[1]['cmsUserUsername']); + self::assertEquals($this->fixtures[2]->username, $result[2]['cmsUserUsername']); } public function testInvalidClassException(): void diff --git a/tests/Doctrine/Tests/ORM/Functional/NotifyPolicyTest.php b/tests/Doctrine/Tests/ORM/Functional/NotifyPolicyTest.php index dc4fd1d3d5a..8a852a97336 100644 --- a/tests/Doctrine/Tests/ORM/Functional/NotifyPolicyTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/NotifyPolicyTest.php @@ -58,26 +58,26 @@ public function testChangeTracking(): void $this->_em->persist($user); $this->_em->persist($group); - $this->assertEquals(1, count($user->listeners)); - $this->assertEquals(1, count($group->listeners)); + self::assertEquals(1, count($user->listeners)); + self::assertEquals(1, count($group->listeners)); $this->_em->flush(); $this->_em->clear(); - $this->assertEquals(1, count($user->listeners)); - $this->assertEquals(1, count($group->listeners)); + self::assertEquals(1, count($user->listeners)); + self::assertEquals(1, count($group->listeners)); $userId = $user->getId(); $groupId = $group->getId(); unset($user, $group); $user = $this->_em->find(NotifyUser::class, $userId); - $this->assertEquals(1, $user->getGroups()->count()); + self::assertEquals(1, $user->getGroups()->count()); $group = $this->_em->find(NotifyGroup::class, $groupId); - $this->assertEquals(1, $group->getUsers()->count()); + self::assertEquals(1, $group->getUsers()->count()); - $this->assertEquals(1, count($user->listeners)); - $this->assertEquals(1, count($group->listeners)); + self::assertEquals(1, count($user->listeners)); + self::assertEquals(1, count($group->listeners)); $group2 = new NotifyGroup(); $group2->setName('nerds'); @@ -90,19 +90,19 @@ public function testChangeTracking(): void $this->_em->flush(); $this->_em->clear(); - $this->assertEquals(1, count($user->listeners)); - $this->assertEquals(1, count($group->listeners)); + self::assertEquals(1, count($user->listeners)); + self::assertEquals(1, count($group->listeners)); $group2Id = $group2->getId(); unset($group2, $user); $user = $this->_em->find(NotifyUser::class, $userId); - $this->assertEquals(2, $user->getGroups()->count()); + self::assertEquals(2, $user->getGroups()->count()); $group2 = $this->_em->find(NotifyGroup::class, $group2Id); - $this->assertEquals(1, $group2->getUsers()->count()); + self::assertEquals(1, $group2->getUsers()->count()); $group = $this->_em->find(NotifyGroup::class, $groupId); - $this->assertEquals(1, $group->getUsers()->count()); - $this->assertEquals('geeks', $group->getName()); + self::assertEquals(1, $group->getUsers()->count()); + self::assertEquals('geeks', $group->getName()); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/OneToManyBidirectionalAssociationTest.php b/tests/Doctrine/Tests/ORM/Functional/OneToManyBidirectionalAssociationTest.php index bd5e3edb172..60c639668c3 100644 --- a/tests/Doctrine/Tests/ORM/Functional/OneToManyBidirectionalAssociationTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/OneToManyBidirectionalAssociationTest.php @@ -55,7 +55,7 @@ public function testSavesAnEmptyCollection(): void $this->_em->persist($this->product); $this->_em->flush(); - $this->assertEquals(0, count($this->product->getFeatures())); + self::assertEquals(0, count($this->product->getFeatures())); } public function testDoesNotSaveAnInverseSideSet(): void @@ -89,14 +89,14 @@ public function testEagerLoadsOneToManyAssociation(): void $features = $product->getFeatures(); - $this->assertInstanceOf(ECommerceFeature::class, $features[0]); - $this->assertNotInstanceOf(Proxy::class, $features[0]->getProduct()); - $this->assertSame($product, $features[0]->getProduct()); - $this->assertEquals('Model writing tutorial', $features[0]->getDescription()); - $this->assertInstanceOf(ECommerceFeature::class, $features[1]); - $this->assertSame($product, $features[1]->getProduct()); - $this->assertNotInstanceOf(Proxy::class, $features[1]->getProduct()); - $this->assertEquals('Annotations examples', $features[1]->getDescription()); + self::assertInstanceOf(ECommerceFeature::class, $features[0]); + self::assertNotInstanceOf(Proxy::class, $features[0]->getProduct()); + self::assertSame($product, $features[0]->getProduct()); + self::assertEquals('Model writing tutorial', $features[0]->getDescription()); + self::assertInstanceOf(ECommerceFeature::class, $features[1]); + self::assertSame($product, $features[1]->getProduct()); + self::assertNotInstanceOf(Proxy::class, $features[1]->getProduct()); + self::assertEquals('Annotations examples', $features[1]->getDescription()); } public function testLazyLoadsObjectsOnTheOwningSide(): void @@ -108,14 +108,14 @@ public function testLazyLoadsObjectsOnTheOwningSide(): void $product = $result[0]; $features = $product->getFeatures(); - $this->assertFalse($features->isInitialized()); - $this->assertInstanceOf(ECommerceFeature::class, $features[0]); - $this->assertTrue($features->isInitialized()); - $this->assertSame($product, $features[0]->getProduct()); - $this->assertEquals('Model writing tutorial', $features[0]->getDescription()); - $this->assertInstanceOf(ECommerceFeature::class, $features[1]); - $this->assertSame($product, $features[1]->getProduct()); - $this->assertEquals('Annotations examples', $features[1]->getDescription()); + self::assertFalse($features->isInitialized()); + self::assertInstanceOf(ECommerceFeature::class, $features[0]); + self::assertTrue($features->isInitialized()); + self::assertSame($product, $features[0]->getProduct()); + self::assertEquals('Model writing tutorial', $features[0]->getDescription()); + self::assertInstanceOf(ECommerceFeature::class, $features[1]); + self::assertSame($product, $features[1]->getProduct()); + self::assertEquals('Annotations examples', $features[1]->getDescription()); } public function testLazyLoadsObjectsOnTheInverseSide(): void @@ -126,11 +126,11 @@ public function testLazyLoadsObjectsOnTheInverseSide(): void $features = $query->getResult(); $product = $features[0]->getProduct(); - $this->assertInstanceOf(Proxy::class, $product); - $this->assertInstanceOf(ECommerceProduct::class, $product); - $this->assertFalse($product->__isInitialized__); - $this->assertSame('Doctrine Cookbook', $product->getName()); - $this->assertTrue($product->__isInitialized__); + self::assertInstanceOf(Proxy::class, $product); + self::assertInstanceOf(ECommerceProduct::class, $product); + self::assertFalse($product->__isInitialized__); + self::assertSame('Doctrine Cookbook', $product->getName()); + self::assertTrue($product->__isInitialized__); } public function testLazyLoadsObjectsOnTheInverseSide2(): void @@ -142,11 +142,11 @@ public function testLazyLoadsObjectsOnTheInverseSide2(): void $features = $query->getResult(); $product = $features[0]->getProduct(); - $this->assertNotInstanceOf(Proxy::class, $product); - $this->assertInstanceOf(ECommerceProduct::class, $product); - $this->assertSame('Doctrine Cookbook', $product->getName()); + self::assertNotInstanceOf(Proxy::class, $product); + self::assertInstanceOf(ECommerceProduct::class, $product); + self::assertSame('Doctrine Cookbook', $product->getName()); - $this->assertFalse($product->getFeatures()->isInitialized()); + self::assertFalse($product->getFeatures()->isInitialized()); // This would trigger lazy-load //$this->assertEquals(2, $product->getFeatures()->count()); @@ -160,7 +160,7 @@ public function testJoinFromOwningSide(): void { $query = $this->_em->createQuery('select f,p from Doctrine\Tests\Models\ECommerce\ECommerceFeature f join f.product p'); $features = $query->getResult(); - $this->assertEquals(0, count($features)); + self::assertEquals(0, count($features)); } /** @@ -177,13 +177,13 @@ public function testMatching(): void Criteria::expr()->eq('description', 'Model writing tutorial') )); - $this->assertInstanceOf(Collection::class, $results); - $this->assertEquals(1, count($results)); + self::assertInstanceOf(Collection::class, $results); + self::assertEquals(1, count($results)); $results = $features->matching(new Criteria()); - $this->assertInstanceOf(Collection::class, $results); - $this->assertEquals(2, count($results)); + self::assertInstanceOf(Collection::class, $results); + self::assertEquals(2, count($results)); } /** @@ -205,7 +205,7 @@ public function testMatchingOnDirtyCollection(): void Criteria::expr()->eq('description', 'Model writing tutorial') )); - $this->assertEquals(2, count($results)); + self::assertEquals(2, count($results)); } public function testMatchingBis(): void @@ -223,13 +223,13 @@ public function testMatchingBis(): void Criteria::expr()->eq('description', 'Third feature') )); - $this->assertInstanceOf(Collection::class, $results); - $this->assertCount(1, $results); + self::assertInstanceOf(Collection::class, $results); + self::assertCount(1, $results); $results = $features->matching(new Criteria()); - $this->assertInstanceOf(Collection::class, $results); - $this->assertCount(3, $results); + self::assertInstanceOf(Collection::class, $results); + self::assertCount(3, $results); } private function createFixture(): void @@ -248,6 +248,6 @@ public function assertFeatureForeignKeyIs($value, ECommerceFeature $feature): vo 'SELECT product_id FROM ecommerce_features WHERE id=?', [$feature->getId()] )->fetchColumn(); - $this->assertEquals($value, $foreignKey); + self::assertEquals($value, $foreignKey); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/OneToManyOrphanRemovalTest.php b/tests/Doctrine/Tests/ORM/Functional/OneToManyOrphanRemovalTest.php index 220928d9383..1d807be45ac 100644 --- a/tests/Doctrine/Tests/ORM/Functional/OneToManyOrphanRemovalTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/OneToManyOrphanRemovalTest.php @@ -56,12 +56,12 @@ public function testOrphanRemoval(): void $query = $this->_em->createQuery('SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u'); $result = $query->getResult(); - $this->assertEquals(0, count($result), 'CmsUser should be removed by EntityManager'); + self::assertEquals(0, count($result), 'CmsUser should be removed by EntityManager'); $query = $this->_em->createQuery('SELECT p FROM Doctrine\Tests\Models\CMS\CmsPhonenumber p'); $result = $query->getResult(); - $this->assertEquals(0, count($result), 'CmsPhonenumber should be removed by orphanRemoval'); + self::assertEquals(0, count($result), 'CmsPhonenumber should be removed by orphanRemoval'); } /** @@ -79,7 +79,7 @@ public function testOrphanRemovalRemoveFromCollection(): void $query = $this->_em->createQuery('SELECT p FROM Doctrine\Tests\Models\CMS\CmsPhonenumber p'); $result = $query->getResult(); - $this->assertEquals(1, count($result), 'CmsPhonenumber should be removed by orphanRemoval'); + self::assertEquals(1, count($result), 'CmsPhonenumber should be removed by orphanRemoval'); } /** @@ -99,7 +99,7 @@ public function testOrphanRemovalClearCollectionAndReAdd(): void $query = $this->_em->createQuery('SELECT p FROM Doctrine\Tests\Models\CMS\CmsPhonenumber p'); $result = $query->getResult(); - $this->assertEquals(1, count($result), 'CmsPhonenumber should be removed by orphanRemoval'); + self::assertEquals(1, count($result), 'CmsPhonenumber should be removed by orphanRemoval'); } /** @@ -120,7 +120,7 @@ public function testOrphanRemovalClearCollectionAndAddNew(): void $query = $this->_em->createQuery('SELECT p FROM Doctrine\Tests\Models\CMS\CmsPhonenumber p'); $result = $query->getResult(); - $this->assertEquals(1, count($result), 'Old CmsPhonenumbers should be removed by orphanRemoval and new one added'); + self::assertEquals(1, count($result), 'Old CmsPhonenumbers should be removed by orphanRemoval and new one added'); } /** @@ -136,6 +136,6 @@ public function testOrphanRemovalUnitializedCollection(): void $query = $this->_em->createQuery('SELECT p FROM Doctrine\Tests\Models\CMS\CmsPhonenumber p'); $result = $query->getResult(); - $this->assertEquals(0, count($result), 'CmsPhonenumber should be removed by orphanRemoval'); + self::assertEquals(0, count($result), 'CmsPhonenumber should be removed by orphanRemoval'); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/OneToManySelfReferentialAssociationTest.php b/tests/Doctrine/Tests/ORM/Functional/OneToManySelfReferentialAssociationTest.php index 72261d8ef5e..5ed920b44c7 100644 --- a/tests/Doctrine/Tests/ORM/Functional/OneToManySelfReferentialAssociationTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/OneToManySelfReferentialAssociationTest.php @@ -54,7 +54,7 @@ public function testSavesAnEmptyCollection(): void $this->_em->persist($this->parent); $this->_em->flush(); - $this->assertEquals(0, count($this->parent->getChildren())); + self::assertEquals(0, count($this->parent->getChildren())); } public function testDoesNotSaveAnInverseSideSet(): void @@ -85,16 +85,16 @@ public function testEagerLoadsOneToManyAssociation(): void $query = $this->_em->createQuery('select c1, c2 from Doctrine\Tests\Models\ECommerce\ECommerceCategory c1 join c1.children c2'); $result = $query->getResult(); - $this->assertEquals(1, count($result)); + self::assertEquals(1, count($result)); $parent = $result[0]; $children = $parent->getChildren(); - $this->assertInstanceOf(ECommerceCategory::class, $children[0]); - $this->assertSame($parent, $children[0]->getParent()); - $this->assertEquals(' books', strstr($children[0]->getName(), ' books')); - $this->assertInstanceOf(ECommerceCategory::class, $children[1]); - $this->assertSame($parent, $children[1]->getParent()); - $this->assertEquals(' books', strstr($children[1]->getName(), ' books')); + self::assertInstanceOf(ECommerceCategory::class, $children[0]); + self::assertSame($parent, $children[0]->getParent()); + self::assertEquals(' books', strstr($children[0]->getName(), ' books')); + self::assertInstanceOf(ECommerceCategory::class, $children[1]); + self::assertSame($parent, $children[1]->getParent()); + self::assertEquals(' books', strstr($children[1]->getName(), ' books')); } public function testLazyLoadsOneToManyAssociation(): void @@ -108,12 +108,12 @@ public function testLazyLoadsOneToManyAssociation(): void $parent = $result[0]; $children = $parent->getChildren(); - $this->assertInstanceOf(ECommerceCategory::class, $children[0]); - $this->assertSame($parent, $children[0]->getParent()); - $this->assertEquals(' books', strstr($children[0]->getName(), ' books')); - $this->assertInstanceOf(ECommerceCategory::class, $children[1]); - $this->assertSame($parent, $children[1]->getParent()); - $this->assertEquals(' books', strstr($children[1]->getName(), ' books')); + self::assertInstanceOf(ECommerceCategory::class, $children[0]); + self::assertSame($parent, $children[0]->getParent()); + self::assertEquals(' books', strstr($children[0]->getName(), ' books')); + self::assertInstanceOf(ECommerceCategory::class, $children[1]); + self::assertSame($parent, $children[1]->getParent()); + self::assertEquals(' books', strstr($children[1]->getName(), ' books')); } private function createFixture(): void @@ -129,6 +129,6 @@ private function createFixture(): void public function assertForeignKeyIs($value, ECommerceCategory $child): void { $foreignKey = $this->_em->getConnection()->executeQuery('SELECT parent_id FROM ecommerce_categories WHERE id=?', [$child->getId()])->fetchColumn(); - $this->assertEquals($value, $foreignKey); + self::assertEquals($value, $foreignKey); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/OneToManyUnidirectionalAssociationTest.php b/tests/Doctrine/Tests/ORM/Functional/OneToManyUnidirectionalAssociationTest.php index bbdfc44c2c9..a937597fbf2 100644 --- a/tests/Doctrine/Tests/ORM/Functional/OneToManyUnidirectionalAssociationTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/OneToManyUnidirectionalAssociationTest.php @@ -58,9 +58,9 @@ public function testPersistOwningInverseCascade(): void 'JOIN r.legs l JOIN l.fromLocation f JOIN l.toLocation t' )->getSingleResult(); - $this->assertEquals(1, count($routes->legs)); - $this->assertEquals('Berlin', $routes->legs[0]->fromLocation->name); - $this->assertEquals('Bonn', $routes->legs[0]->toLocation->name); + self::assertEquals(1, count($routes->legs)); + self::assertEquals('Berlin', $routes->legs[0]->fromLocation->name); + self::assertEquals('Bonn', $routes->legs[0]->toLocation->name); } public function testLegsAreUniqueToRoutes(): void @@ -88,6 +88,6 @@ public function testLegsAreUniqueToRoutes(): void $exceptionThrown = true; } - $this->assertTrue($exceptionThrown, 'The underlying database driver throws an exception.'); + self::assertTrue($exceptionThrown, 'The underlying database driver throws an exception.'); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/OneToOneBidirectionalAssociationTest.php b/tests/Doctrine/Tests/ORM/Functional/OneToOneBidirectionalAssociationTest.php index 66e37746a53..962e5bd48a2 100644 --- a/tests/Doctrine/Tests/ORM/Functional/OneToOneBidirectionalAssociationTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/OneToOneBidirectionalAssociationTest.php @@ -68,8 +68,8 @@ public function testEagerLoad(): void $result = $query->getResult(); $customer = $result[0]; - $this->assertInstanceOf(ECommerceCart::class, $customer->getCart()); - $this->assertEquals('paypal', $customer->getCart()->getPayment()); + self::assertInstanceOf(ECommerceCart::class, $customer->getCart()); + self::assertEquals('paypal', $customer->getCart()->getPayment()); } public function testLazyLoadsObjectsOnTheOwningSide(): void @@ -82,8 +82,8 @@ public function testLazyLoadsObjectsOnTheOwningSide(): void $result = $query->getResult(); $cart = $result[0]; - $this->assertInstanceOf(ECommerceCustomer::class, $cart->getCustomer()); - $this->assertEquals('Giorgio', $cart->getCustomer()->getName()); + self::assertInstanceOf(ECommerceCustomer::class, $cart->getCustomer()); + self::assertEquals('Giorgio', $cart->getCustomer()->getName()); } public function testInverseSideIsNeverLazy(): void @@ -96,10 +96,10 @@ public function testInverseSideIsNeverLazy(): void $result = $query->getResult(); $customer = $result[0]; - $this->assertNull($customer->getMentor()); - $this->assertInstanceOf(ECommerceCart::class, $customer->getCart()); - $this->assertNotInstanceOf(Proxy::class, $customer->getCart()); - $this->assertEquals('paypal', $customer->getCart()->getPayment()); + self::assertNull($customer->getMentor()); + self::assertInstanceOf(ECommerceCart::class, $customer->getCart()); + self::assertNotInstanceOf(Proxy::class, $customer->getCart()); + self::assertEquals('paypal', $customer->getCart()->getPayment()); } public function testUpdateWithProxyObject(): void @@ -114,9 +114,9 @@ public function testUpdateWithProxyObject(): void $this->_em->flush(); $this->_em->clear(); - $this->assertInstanceOf(ECommerceCart::class, $cust->getCart()); - $this->assertEquals('Roman', $cust->getName()); - $this->assertSame($cust, $cart->getCustomer()); + self::assertInstanceOf(ECommerceCart::class, $cust->getCart()); + self::assertEquals('Roman', $cust->getName()); + self::assertSame($cust, $cart->getCustomer()); $query = $this->_em->createQuery('select ca from Doctrine\Tests\Models\ECommerce\ECommerceCart ca where ca.id =?1'); $query->setParameter(1, $cart->getId()); @@ -133,8 +133,8 @@ public function testUpdateWithProxyObject(): void $cart3 = $query2->getSingleResult(); - $this->assertInstanceOf(ECommerceCustomer::class, $cart3->getCustomer()); - $this->assertEquals('Roman', $cart3->getCustomer()->getName()); + self::assertInstanceOf(ECommerceCustomer::class, $cart3->getCustomer()); + self::assertEquals('Roman', $cart3->getCustomer()->getName()); } protected function createFixture(): void @@ -154,6 +154,6 @@ protected function createFixture(): void public function assertCartForeignKeyIs($value): void { $foreignKey = $this->_em->getConnection()->executeQuery('SELECT customer_id FROM ecommerce_carts WHERE id=?', [$this->cart->getId()])->fetchColumn(); - $this->assertEquals($value, $foreignKey); + self::assertEquals($value, $foreignKey); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/OneToOneEagerLoadingTest.php b/tests/Doctrine/Tests/ORM/Functional/OneToOneEagerLoadingTest.php index 39ce7b3a4f1..1ba259486de 100644 --- a/tests/Doctrine/Tests/ORM/Functional/OneToOneEagerLoadingTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/OneToOneEagerLoadingTest.php @@ -64,10 +64,10 @@ public function testEagerLoadOneToOneOwningSide(): void $sqlCount = count($this->_sqlLoggerStack->queries); $train = $this->_em->find(get_class($train), $train->id); - $this->assertNotInstanceOf(Proxy::class, $train->driver); - $this->assertEquals('Benjamin', $train->driver->name); + self::assertNotInstanceOf(Proxy::class, $train->driver); + self::assertEquals('Benjamin', $train->driver->name); - $this->assertEquals($sqlCount + 1, count($this->_sqlLoggerStack->queries)); + self::assertEquals($sqlCount + 1, count($this->_sqlLoggerStack->queries)); } /** @@ -84,10 +84,10 @@ public function testEagerLoadOneToOneNullOwningSide(): void $sqlCount = count($this->_sqlLoggerStack->queries); $train = $this->_em->find(get_class($train), $train->id); - $this->assertNotInstanceOf(Proxy::class, $train->driver); - $this->assertNull($train->driver); + self::assertNotInstanceOf(Proxy::class, $train->driver); + self::assertNull($train->driver); - $this->assertEquals($sqlCount + 1, count($this->_sqlLoggerStack->queries)); + self::assertEquals($sqlCount + 1, count($this->_sqlLoggerStack->queries)); } /** @@ -105,10 +105,10 @@ public function testEagerLoadOneToOneInverseSide(): void $sqlCount = count($this->_sqlLoggerStack->queries); $driver = $this->_em->find(get_class($owner), $owner->id); - $this->assertNotInstanceOf(Proxy::class, $owner->train); - $this->assertNotNull($owner->train); + self::assertNotInstanceOf(Proxy::class, $owner->train); + self::assertNotNull($owner->train); - $this->assertEquals($sqlCount + 1, count($this->_sqlLoggerStack->queries)); + self::assertEquals($sqlCount + 1, count($this->_sqlLoggerStack->queries)); } /** @@ -122,15 +122,15 @@ public function testEagerLoadOneToOneNullInverseSide(): void $this->_em->flush(); $this->_em->clear(); - $this->assertNull($driver->train); + self::assertNull($driver->train); $sqlCount = count($this->_sqlLoggerStack->queries); $driver = $this->_em->find(get_class($driver), $driver->id); - $this->assertNotInstanceOf(Proxy::class, $driver->train); - $this->assertNull($driver->train); + self::assertNotInstanceOf(Proxy::class, $driver->train); + self::assertNull($driver->train); - $this->assertEquals($sqlCount + 1, count($this->_sqlLoggerStack->queries)); + self::assertEquals($sqlCount + 1, count($this->_sqlLoggerStack->queries)); } public function testEagerLoadManyToOne(): void @@ -144,8 +144,8 @@ public function testEagerLoadManyToOne(): void $this->_em->clear(); $waggon = $this->_em->find(get_class($waggon), $waggon->id); - $this->assertNotInstanceOf(Proxy::class, $waggon->train); - $this->assertNotNull($waggon->train); + self::assertNotInstanceOf(Proxy::class, $waggon->train); + self::assertNotNull($waggon->train); } /** @@ -236,9 +236,9 @@ public function testEagerLoadingDoesNotBreakRefresh(): void $this->_em->getConnection()->exec('UPDATE TrainOrder SET train_id = NULL'); - $this->assertSame($train, $order->train); + self::assertSame($train, $order->train); $this->_em->refresh($order); - $this->assertTrue($order->train === null, 'Train reference was not refreshed to NULL.'); + self::assertTrue($order->train === null, 'Train reference was not refreshed to NULL.'); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/OneToOneOrphanRemovalTest.php b/tests/Doctrine/Tests/ORM/Functional/OneToOneOrphanRemovalTest.php index 35caf365ede..fd353ecf34a 100644 --- a/tests/Doctrine/Tests/ORM/Functional/OneToOneOrphanRemovalTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/OneToOneOrphanRemovalTest.php @@ -53,12 +53,12 @@ public function testOrphanRemoval(): void $query = $this->_em->createQuery('SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u'); $result = $query->getResult(); - $this->assertEquals(0, count($result), 'CmsUser should be removed by EntityManager'); + self::assertEquals(0, count($result), 'CmsUser should be removed by EntityManager'); $query = $this->_em->createQuery('SELECT a FROM Doctrine\Tests\Models\CMS\CmsAddress a'); $result = $query->getResult(); - $this->assertEquals(0, count($result), 'CmsAddress should be removed by orphanRemoval'); + self::assertEquals(0, count($result), 'CmsAddress should be removed by orphanRemoval'); } public function testOrphanRemovalWhenUnlink(): void @@ -91,6 +91,6 @@ public function testOrphanRemovalWhenUnlink(): void $query = $this->_em->createQuery('SELECT e FROM Doctrine\Tests\Models\CMS\CmsEmail e'); $result = $query->getResult(); - $this->assertEquals(0, count($result), 'CmsEmail should be removed by orphanRemoval'); + self::assertEquals(0, count($result), 'CmsEmail should be removed by orphanRemoval'); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/OneToOneSelfReferentialAssociationTest.php b/tests/Doctrine/Tests/ORM/Functional/OneToOneSelfReferentialAssociationTest.php index de43452ba5e..7028a497045 100644 --- a/tests/Doctrine/Tests/ORM/Functional/OneToOneSelfReferentialAssociationTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/OneToOneSelfReferentialAssociationTest.php @@ -68,7 +68,7 @@ public function testFind(): void $id = $this->createFixture(); $customer = $this->_em->find(ECommerceCustomer::class, $id); - $this->assertNotInstanceOf(Proxy::class, $customer->getMentor()); + self::assertNotInstanceOf(Proxy::class, $customer->getMentor()); } public function testEagerLoadsAssociation(): void @@ -119,24 +119,24 @@ public function testMultiSelfReference(): void $entity2 = $this->_em->find(get_class($entity1), $entity1->getId()); - $this->assertInstanceOf(MultiSelfReference::class, $entity2->getOther1()); - $this->assertInstanceOf(MultiSelfReference::class, $entity2->getOther2()); - $this->assertNull($entity2->getOther1()->getOther1()); - $this->assertNull($entity2->getOther1()->getOther2()); - $this->assertNull($entity2->getOther2()->getOther1()); - $this->assertNull($entity2->getOther2()->getOther2()); + self::assertInstanceOf(MultiSelfReference::class, $entity2->getOther1()); + self::assertInstanceOf(MultiSelfReference::class, $entity2->getOther2()); + self::assertNull($entity2->getOther1()->getOther1()); + self::assertNull($entity2->getOther1()->getOther2()); + self::assertNull($entity2->getOther2()->getOther1()); + self::assertNull($entity2->getOther2()->getOther2()); } public function assertLoadingOfAssociation($customer): void { - $this->assertInstanceOf(ECommerceCustomer::class, $customer->getMentor()); - $this->assertEquals('Obi-wan Kenobi', $customer->getMentor()->getName()); + self::assertInstanceOf(ECommerceCustomer::class, $customer->getMentor()); + self::assertEquals('Obi-wan Kenobi', $customer->getMentor()->getName()); } public function assertForeignKeyIs($value): void { $foreignKey = $this->_em->getConnection()->executeQuery('SELECT mentor_id FROM ecommerce_customers WHERE id=?', [$this->customer->getId()])->fetchColumn(); - $this->assertEquals($value, $foreignKey); + self::assertEquals($value, $foreignKey); } private function createFixture(): int diff --git a/tests/Doctrine/Tests/ORM/Functional/OneToOneSingleTableInheritanceTest.php b/tests/Doctrine/Tests/ORM/Functional/OneToOneSingleTableInheritanceTest.php index b871e688148..e3b4ed621bf 100644 --- a/tests/Doctrine/Tests/ORM/Functional/OneToOneSingleTableInheritanceTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/OneToOneSingleTableInheritanceTest.php @@ -43,9 +43,9 @@ public function testFindFromOneToOneOwningSideJoinedTableInheritance(): void $foundCat = $this->_em->find(Pet::class, $cat->id); assert($foundCat instanceof Cat); - $this->assertInstanceOf(Cat::class, $foundCat); - $this->assertSame($cat->id, $foundCat->id); - $this->assertInstanceOf(LitterBox::class, $foundCat->litterBox); - $this->assertSame($cat->litterBox->id, $foundCat->litterBox->id); + self::assertInstanceOf(Cat::class, $foundCat); + self::assertSame($cat->id, $foundCat->id); + self::assertInstanceOf(LitterBox::class, $foundCat->litterBox); + self::assertSame($cat->litterBox->id, $foundCat->litterBox->id); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/OneToOneUnidirectionalAssociationTest.php b/tests/Doctrine/Tests/ORM/Functional/OneToOneUnidirectionalAssociationTest.php index 03d7a14a411..18deaf3f4c7 100644 --- a/tests/Doctrine/Tests/ORM/Functional/OneToOneUnidirectionalAssociationTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/OneToOneUnidirectionalAssociationTest.php @@ -62,8 +62,8 @@ public function testEagerLoad(): void $result = $query->getResult(); $product = $result[0]; - $this->assertInstanceOf(ECommerceShipping::class, $product->getShipping()); - $this->assertEquals(1, $product->getShipping()->getDays()); + self::assertInstanceOf(ECommerceShipping::class, $product->getShipping()); + self::assertEquals(1, $product->getShipping()->getDays()); } public function testLazyLoadsObjects(): void @@ -76,8 +76,8 @@ public function testLazyLoadsObjects(): void $result = $query->getResult(); $product = $result[0]; - $this->assertInstanceOf(ECommerceShipping::class, $product->getShipping()); - $this->assertEquals(1, $product->getShipping()->getDays()); + self::assertInstanceOf(ECommerceShipping::class, $product->getShipping()); + self::assertEquals(1, $product->getShipping()->getDays()); } public function testDoesNotLazyLoadObjectsIfConfigurationDoesNotAllowIt(): void @@ -90,7 +90,7 @@ public function testDoesNotLazyLoadObjectsIfConfigurationDoesNotAllowIt(): void $result = $query->getResult(); $product = $result[0]; - $this->assertNull($product->getShipping()); + self::assertNull($product->getShipping()); } protected function createFixture(): void @@ -113,7 +113,7 @@ public function assertForeignKeyIs($value): void 'SELECT shipping_id FROM ecommerce_products WHERE id=?', [$this->product->getId()] )->fetchColumn(); - $this->assertEquals($value, $foreignKey); + self::assertEquals($value, $foreignKey); } /** @@ -129,6 +129,6 @@ public function testNullForeignKey(): void $product = $this->_em->find(get_class($product), $product->getId()); - $this->assertNull($product->getShipping()); + self::assertNull($product->getShipping()); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/OrderedCollectionTest.php b/tests/Doctrine/Tests/ORM/Functional/OrderedCollectionTest.php index 0d494630cd1..62a655321f4 100644 --- a/tests/Doctrine/Tests/ORM/Functional/OrderedCollectionTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/OrderedCollectionTest.php @@ -68,9 +68,9 @@ public function testLazyManyToManyCollectionIsRetrievedWithOrderByClause(): void $route = $this->_em->find(RoutingRoute::class, $routeId); - $this->assertEquals(2, count($route->legs)); - $this->assertEquals('Berlin', $route->legs[0]->fromLocation->getName()); - $this->assertEquals('Bonn', $route->legs[1]->fromLocation->getName()); + self::assertEquals(2, count($route->legs)); + self::assertEquals('Berlin', $route->legs[0]->fromLocation->getName()); + self::assertEquals('Bonn', $route->legs[1]->fromLocation->getName()); } public function testLazyOneToManyCollectionIsRetrievedWithOrderByClause(): void @@ -99,9 +99,9 @@ public function testLazyOneToManyCollectionIsRetrievedWithOrderByClause(): void $route = $this->_em->find(RoutingRoute::class, $routeId); - $this->assertEquals(2, count($route->bookings)); - $this->assertEquals('Benjamin', $route->bookings[0]->getPassengerName()); - $this->assertEquals('Guilherme', $route->bookings[1]->getPassengerName()); + self::assertEquals(2, count($route->bookings)); + self::assertEquals('Benjamin', $route->bookings[0]->getPassengerName()); + self::assertEquals('Guilherme', $route->bookings[1]->getPassengerName()); } public function testOrderedResultFromDqlQuery(): void @@ -112,8 +112,8 @@ public function testOrderedResultFromDqlQuery(): void ->setParameter(1, $routeId) ->getSingleResult(); - $this->assertEquals(2, count($route->legs)); - $this->assertEquals('Berlin', $route->legs[0]->fromLocation->getName()); - $this->assertEquals('Bonn', $route->legs[1]->fromLocation->getName()); + self::assertEquals(2, count($route->legs)); + self::assertEquals('Berlin', $route->legs[0]->fromLocation->getName()); + self::assertEquals('Bonn', $route->legs[1]->fromLocation->getName()); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/OrderedJoinedTableInheritanceCollectionTest.php b/tests/Doctrine/Tests/ORM/Functional/OrderedJoinedTableInheritanceCollectionTest.php index 3f52c952420..42949373652 100644 --- a/tests/Doctrine/Tests/ORM/Functional/OrderedJoinedTableInheritanceCollectionTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/OrderedJoinedTableInheritanceCollectionTest.php @@ -66,8 +66,8 @@ public function testOrderdOneToManyCollection(): void { $poofy = $this->_em->createQuery("SELECT p FROM Doctrine\Tests\ORM\Functional\OJTICPet p WHERE p.name = 'Poofy'")->getSingleResult(); - $this->assertEquals('Aari', $poofy->children[0]->getName()); - $this->assertEquals('Zampa', $poofy->children[1]->getName()); + self::assertEquals('Aari', $poofy->children[0]->getName()); + self::assertEquals('Zampa', $poofy->children[1]->getName()); $this->_em->clear(); @@ -76,11 +76,11 @@ public function testOrderdOneToManyCollection(): void ) ->getResult(); - $this->assertEquals(1, count($result)); + self::assertEquals(1, count($result)); $poofy = $result[0]; - $this->assertEquals('Aari', $poofy->children[0]->getName()); - $this->assertEquals('Zampa', $poofy->children[1]->getName()); + self::assertEquals('Aari', $poofy->children[0]->getName()); + self::assertEquals('Zampa', $poofy->children[1]->getName()); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/PaginationTest.php b/tests/Doctrine/Tests/ORM/Functional/PaginationTest.php index af9db728735..7bdfa16cdbe 100644 --- a/tests/Doctrine/Tests/ORM/Functional/PaginationTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/PaginationTest.php @@ -59,7 +59,7 @@ public function testCountSimpleWithoutJoin($useOutputWalkers): void $paginator = new Paginator($query); $paginator->setUseOutputWalkers($useOutputWalkers); - $this->assertCount(9, $paginator); + self::assertCount(9, $paginator); } /** @@ -72,7 +72,7 @@ public function testCountWithFetchJoin($useOutputWalkers): void $paginator = new Paginator($query); $paginator->setUseOutputWalkers($useOutputWalkers); - $this->assertCount(9, $paginator); + self::assertCount(9, $paginator); } public function testCountComplexWithOutputWalker(): void @@ -82,7 +82,7 @@ public function testCountComplexWithOutputWalker(): void $paginator = new Paginator($query); $paginator->setUseOutputWalkers(true); - $this->assertCount(3, $paginator); + self::assertCount(3, $paginator); } public function testCountComplexWithoutOutputWalker(): void @@ -96,7 +96,7 @@ public function testCountComplexWithoutOutputWalker(): void $this->expectException(RuntimeException::class); $this->expectExceptionMessage('Cannot count query that uses a HAVING clause. Use the output walkers for pagination'); - $this->assertCount(3, $paginator); + self::assertCount(3, $paginator); } /** @@ -109,7 +109,7 @@ public function testCountWithComplexScalarOrderBy($useOutputWalkers): void $paginator = new Paginator($query); $paginator->setUseOutputWalkers($useOutputWalkers); - $this->assertCount(9, $paginator); + self::assertCount(9, $paginator); } /** @@ -122,19 +122,19 @@ public function testIterateSimpleWithoutJoin($useOutputWalkers, $fetchJoinCollec $paginator = new Paginator($query, $fetchJoinCollection); $paginator->setUseOutputWalkers($useOutputWalkers); - $this->assertCount(9, $paginator->getIterator()); + self::assertCount(9, $paginator->getIterator()); // Test with limit $query->setMaxResults(3); $paginator = new Paginator($query, $fetchJoinCollection); $paginator->setUseOutputWalkers($useOutputWalkers); - $this->assertCount(3, $paginator->getIterator()); + self::assertCount(3, $paginator->getIterator()); // Test with limit and offset $query->setMaxResults(3)->setFirstResult(4); $paginator = new Paginator($query, $fetchJoinCollection); $paginator->setUseOutputWalkers($useOutputWalkers); - $this->assertCount(3, $paginator->getIterator()); + self::assertCount(3, $paginator->getIterator()); } private function iterateWithOrderAsc($useOutputWalkers, $fetchJoinCollection, $baseDql, $checkField): void @@ -146,9 +146,9 @@ private function iterateWithOrderAsc($useOutputWalkers, $fetchJoinCollection, $b $paginator = new Paginator($query, $fetchJoinCollection); $paginator->setUseOutputWalkers($useOutputWalkers); $iter = $paginator->getIterator(); - $this->assertCount(9, $iter); + self::assertCount(9, $iter); $result = iterator_to_array($iter); - $this->assertEquals($checkField . '0', $result[0]->$checkField); + self::assertEquals($checkField . '0', $result[0]->$checkField); } private function iterateWithOrderAscWithLimit($useOutputWalkers, $fetchJoinCollection, $baseDql, $checkField): void @@ -162,9 +162,9 @@ private function iterateWithOrderAscWithLimit($useOutputWalkers, $fetchJoinColle $paginator = new Paginator($query, $fetchJoinCollection); $paginator->setUseOutputWalkers($useOutputWalkers); $iter = $paginator->getIterator(); - $this->assertCount(3, $iter); + self::assertCount(3, $iter); $result = iterator_to_array($iter); - $this->assertEquals($checkField . '0', $result[0]->$checkField); + self::assertEquals($checkField . '0', $result[0]->$checkField); } private function iterateWithOrderAscWithLimitAndOffset($useOutputWalkers, $fetchJoinCollection, $baseDql, $checkField): void @@ -178,9 +178,9 @@ private function iterateWithOrderAscWithLimitAndOffset($useOutputWalkers, $fetch $paginator = new Paginator($query, $fetchJoinCollection); $paginator->setUseOutputWalkers($useOutputWalkers); $iter = $paginator->getIterator(); - $this->assertCount(3, $iter); + self::assertCount(3, $iter); $result = iterator_to_array($iter); - $this->assertEquals($checkField . '3', $result[0]->$checkField); + self::assertEquals($checkField . '3', $result[0]->$checkField); } private function iterateWithOrderDesc($useOutputWalkers, $fetchJoinCollection, $baseDql, $checkField): void @@ -191,9 +191,9 @@ private function iterateWithOrderDesc($useOutputWalkers, $fetchJoinCollection, $ $paginator = new Paginator($query, $fetchJoinCollection); $paginator->setUseOutputWalkers($useOutputWalkers); $iter = $paginator->getIterator(); - $this->assertCount(9, $iter); + self::assertCount(9, $iter); $result = iterator_to_array($iter); - $this->assertEquals($checkField . '8', $result[0]->$checkField); + self::assertEquals($checkField . '8', $result[0]->$checkField); } private function iterateWithOrderDescWithLimit($useOutputWalkers, $fetchJoinCollection, $baseDql, $checkField): void @@ -206,9 +206,9 @@ private function iterateWithOrderDescWithLimit($useOutputWalkers, $fetchJoinColl $paginator = new Paginator($query, $fetchJoinCollection); $paginator->setUseOutputWalkers($useOutputWalkers); $iter = $paginator->getIterator(); - $this->assertCount(3, $iter); + self::assertCount(3, $iter); $result = iterator_to_array($iter); - $this->assertEquals($checkField . '8', $result[0]->$checkField); + self::assertEquals($checkField . '8', $result[0]->$checkField); } private function iterateWithOrderDescWithLimitAndOffset($useOutputWalkers, $fetchJoinCollection, $baseDql, $checkField): void @@ -221,9 +221,9 @@ private function iterateWithOrderDescWithLimitAndOffset($useOutputWalkers, $fetc $paginator = new Paginator($query, $fetchJoinCollection); $paginator->setUseOutputWalkers($useOutputWalkers); $iter = $paginator->getIterator(); - $this->assertCount(3, $iter); + self::assertCount(3, $iter); $result = iterator_to_array($iter); - $this->assertEquals($checkField . '5', $result[0]->$checkField); + self::assertEquals($checkField . '5', $result[0]->$checkField); } /** @@ -302,7 +302,7 @@ public function testIterateWithFetchJoin($useOutputWalkers): void $paginator = new Paginator($query, true); $paginator->setUseOutputWalkers($useOutputWalkers); - $this->assertCount(9, $paginator->getIterator()); + self::assertCount(9, $paginator->getIterator()); } /** @@ -478,7 +478,7 @@ public function testIterateComplexWithOutputWalker(): void $paginator = new Paginator($query); $paginator->setUseOutputWalkers(true); - $this->assertCount(3, $paginator->getIterator()); + self::assertCount(3, $paginator->getIterator()); } public function testJoinedClassTableInheritance(): void @@ -487,7 +487,7 @@ public function testJoinedClassTableInheritance(): void $query = $this->_em->createQuery($dql); $paginator = new Paginator($query); - $this->assertCount(1, $paginator->getIterator()); + self::assertCount(1, $paginator->getIterator()); } /** @@ -588,7 +588,7 @@ public function testCountWithCountSubqueryInWhereClauseWithOutputWalker(): void $paginator = new Paginator($query, true); $paginator->setUseOutputWalkers(true); - $this->assertCount(9, $paginator); + self::assertCount(9, $paginator); } public function testIterateWithCountSubqueryInWhereClause(): void @@ -600,9 +600,9 @@ public function testIterateWithCountSubqueryInWhereClause(): void $paginator->setUseOutputWalkers(true); $users = iterator_to_array($paginator->getIterator()); - $this->assertCount(9, $users); + self::assertCount(9, $users); foreach ($users as $i => $user) { - $this->assertEquals('username' . (8 - $i), $user->username); + self::assertEquals('username' . (8 - $i), $user->username); } } @@ -634,7 +634,7 @@ public function testPaginationWithColumnAttributeNameDifference(): void $paginator = new Paginator($query); $paginator->getIterator(); - $this->assertCount(9, $paginator->getIterator()); + self::assertCount(9, $paginator->getIterator()); } public function testCloneQuery(): void @@ -645,7 +645,7 @@ public function testCloneQuery(): void $paginator = new Paginator($query); $paginator->getIterator(); - $this->assertTrue($query->getParameters()->isEmpty()); + self::assertTrue($query->getParameters()->isEmpty()); } public function testQueryWalkerIsKept(): void @@ -656,8 +656,8 @@ public function testQueryWalkerIsKept(): void $paginator = new Paginator($query, true); $paginator->setUseOutputWalkers(false); - $this->assertCount(1, $paginator->getIterator()); - $this->assertEquals(1, $paginator->count()); + self::assertCount(1, $paginator->getIterator()); + self::assertEquals(1, $paginator->count()); } /** @@ -698,8 +698,8 @@ public function testCountQueryStripsParametersInSelect(): void $getCountQuery->setAccessible(true); - $this->assertCount(2, $getCountQuery->invoke($paginator)->getParameters()); - $this->assertCount(9, $paginator); + self::assertCount(2, $getCountQuery->invoke($paginator)->getParameters()); + self::assertCount(9, $paginator); $query->setHint(Query::HINT_CUSTOM_OUTPUT_WALKER, Query\SqlWalker::class); @@ -707,8 +707,8 @@ public function testCountQueryStripsParametersInSelect(): void // if select part of query is replaced with count(...) paginator should remove // parameters from query object not used in new query. - $this->assertCount(1, $getCountQuery->invoke($paginator)->getParameters()); - $this->assertCount(9, $paginator); + self::assertCount(1, $getCountQuery->invoke($paginator)->getParameters()); + self::assertCount(9, $paginator); } /** @@ -732,7 +732,7 @@ public function testPaginationWithSubSelectOrderByExpression($useOutputWalker, $ $paginator = new Paginator($query, $fetchJoinCollection); $paginator->setUseOutputWalkers($useOutputWalker); - $this->assertCount(9, $paginator->getIterator()); + self::assertCount(9, $paginator->getIterator()); } public function populate(): void diff --git a/tests/Doctrine/Tests/ORM/Functional/PersistentCollectionCriteriaTest.php b/tests/Doctrine/Tests/ORM/Functional/PersistentCollectionCriteriaTest.php index 0b2febce3e5..f324e78981a 100644 --- a/tests/Doctrine/Tests/ORM/Functional/PersistentCollectionCriteriaTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/PersistentCollectionCriteriaTest.php @@ -78,19 +78,19 @@ public function testCanCountWithoutLoadingPersistentCollection(): void $user = $repository->findOneBy(['name' => 'ngal']); $tweets = $user->tweets->matching(new Criteria()); - $this->assertInstanceOf(LazyCriteriaCollection::class, $tweets); - $this->assertFalse($tweets->isInitialized()); - $this->assertCount(2, $tweets); - $this->assertFalse($tweets->isInitialized()); + self::assertInstanceOf(LazyCriteriaCollection::class, $tweets); + self::assertFalse($tweets->isInitialized()); + self::assertCount(2, $tweets); + self::assertFalse($tweets->isInitialized()); // Make sure it works with constraints $tweets = $user->tweets->matching(new Criteria( Criteria::expr()->eq('content', 'Foo') )); - $this->assertInstanceOf(LazyCriteriaCollection::class, $tweets); - $this->assertFalse($tweets->isInitialized()); - $this->assertCount(1, $tweets); - $this->assertFalse($tweets->isInitialized()); + self::assertInstanceOf(LazyCriteriaCollection::class, $tweets); + self::assertFalse($tweets->isInitialized()); + self::assertCount(1, $tweets); + self::assertFalse($tweets->isInitialized()); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/PersistentCollectionTest.php b/tests/Doctrine/Tests/ORM/Functional/PersistentCollectionTest.php index a6727a1ae45..82da5a0f2e5 100644 --- a/tests/Doctrine/Tests/ORM/Functional/PersistentCollectionTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/PersistentCollectionTest.php @@ -50,7 +50,7 @@ public function testPersist(): void $content = new PersistentCollectionContent('second element'); $collectionHolder->addElement($content); - $this->assertEquals(2, $collectionHolder->getCollection()->count()); + self::assertEquals(2, $collectionHolder->getCollection()->count()); } /** @@ -67,8 +67,8 @@ public function testExtraLazyIsEmptyDoesNotInitializeCollection(): void $collectionHolder = $this->_em->find(PersistentCollectionHolder::class, $collectionHolder->getId()); $collection = $collectionHolder->getRawCollection(); - $this->assertTrue($collection->isEmpty()); - $this->assertFalse($collection->isInitialized()); + self::assertTrue($collection->isEmpty()); + self::assertFalse($collection->isInitialized()); $collectionHolder->addElement(new PersistentCollectionContent()); @@ -78,8 +78,8 @@ public function testExtraLazyIsEmptyDoesNotInitializeCollection(): void $collectionHolder = $this->_em->find(PersistentCollectionHolder::class, $collectionHolder->getId()); $collection = $collectionHolder->getRawCollection(); - $this->assertFalse($collection->isEmpty()); - $this->assertFalse($collection->isInitialized()); + self::assertFalse($collection->isEmpty()); + self::assertFalse($collection->isInitialized()); } /** @@ -99,10 +99,10 @@ public function testMatchingDoesNotModifyTheGivenCriteria(): void $collectionHolder = $this->_em->find(PersistentCollectionHolder::class, $collectionHolder->getId()); $collectionHolder->getCollection()->matching($criteria); - $this->assertEmpty($criteria->getWhereExpression()); - $this->assertEmpty($criteria->getFirstResult()); - $this->assertEmpty($criteria->getMaxResults()); - $this->assertEmpty($criteria->getOrderings()); + self::assertEmpty($criteria->getWhereExpression()); + self::assertEmpty($criteria->getFirstResult()); + self::assertEmpty($criteria->getMaxResults()); + self::assertEmpty($criteria->getOrderings()); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/PersistentObjectTest.php b/tests/Doctrine/Tests/ORM/Functional/PersistentObjectTest.php index 1b50aa5db94..7892603be37 100644 --- a/tests/Doctrine/Tests/ORM/Functional/PersistentObjectTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/PersistentObjectTest.php @@ -59,7 +59,7 @@ public function testFind(): void $entity = $this->_em->find(PersistentEntity::class, $entity->getId()); - $this->assertEquals('test', $entity->getName()); + self::assertEquals('test', $entity->getName()); $entity->setName('foobar'); $this->_em->flush(); @@ -76,7 +76,7 @@ public function testGetReference(): void $entity = $this->_em->getReference(PersistentEntity::class, $entity->getId()); - $this->assertEquals('test', $entity->getName()); + self::assertEquals('test', $entity->getName()); } public function testSetAssociation(): void @@ -90,7 +90,7 @@ public function testSetAssociation(): void $this->_em->clear(); $entity = $this->_em->getReference(PersistentEntity::class, $entity->getId()); - $this->assertSame($entity, $entity->getParent()); + self::assertSame($entity, $entity->getParent()); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/PostFlushEventTest.php b/tests/Doctrine/Tests/ORM/Functional/PostFlushEventTest.php index 3bf1a13c526..2dc289314b5 100644 --- a/tests/Doctrine/Tests/ORM/Functional/PostFlushEventTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/PostFlushEventTest.php @@ -31,7 +31,7 @@ public function testListenerShouldBeNotified(): void { $this->_em->persist($this->createNewValidUser()); $this->_em->flush(); - $this->assertTrue($this->listener->wasNotified); + self::assertTrue($this->listener->wasNotified); } public function testListenerShouldNotBeNotifiedWhenFlushThrowsException(): void @@ -47,8 +47,8 @@ public function testListenerShouldNotBeNotifiedWhenFlushThrowsException(): void $exceptionRaised = true; } - $this->assertTrue($exceptionRaised); - $this->assertFalse($this->listener->wasNotified); + self::assertTrue($exceptionRaised); + self::assertFalse($this->listener->wasNotified); } public function testListenerShouldReceiveEntityManagerThroughArgs(): void @@ -56,7 +56,7 @@ public function testListenerShouldReceiveEntityManagerThroughArgs(): void $this->_em->persist($this->createNewValidUser()); $this->_em->flush(); $receivedEm = $this->listener->receivedArgs->getEntityManager(); - $this->assertSame($this->_em, $receivedEm); + self::assertSame($this->_em, $receivedEm); } private function createNewValidUser(): CmsUser diff --git a/tests/Doctrine/Tests/ORM/Functional/PostLoadEventTest.php b/tests/Doctrine/Tests/ORM/Functional/PostLoadEventTest.php index c1be08c5558..0bf84cbe68c 100644 --- a/tests/Doctrine/Tests/ORM/Functional/PostLoadEventTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/PostLoadEventTest.php @@ -34,9 +34,9 @@ public function testLoadedEntityUsingFindShouldTriggerEvent(): void // CmsUser and CmsAddres, because it's a ToOne inverse side on CmsUser $mockListener - ->expects($this->exactly(2)) + ->expects(self::exactly(2)) ->method('postLoad') - ->will($this->returnValue(true)); + ->will(self::returnValue(true)); $eventManager = $this->_em->getEventManager(); @@ -51,9 +51,9 @@ public function testLoadedEntityUsingQueryShouldTriggerEvent(): void // CmsUser and CmsAddres, because it's a ToOne inverse side on CmsUser $mockListener - ->expects($this->exactly(2)) + ->expects(self::exactly(2)) ->method('postLoad') - ->will($this->returnValue(true)); + ->will(self::returnValue(true)); $eventManager = $this->_em->getEventManager(); @@ -71,9 +71,9 @@ public function testLoadedAssociationToOneShouldTriggerEvent(): void // CmsUser (root), CmsAddress (ToOne inverse side), CmsEmail (joined association) $mockListener - ->expects($this->exactly(3)) + ->expects(self::exactly(3)) ->method('postLoad') - ->will($this->returnValue(true)); + ->will(self::returnValue(true)); $eventManager = $this->_em->getEventManager(); @@ -91,9 +91,9 @@ public function testLoadedAssociationToManyShouldTriggerEvent(): void // CmsUser (root), CmsAddress (ToOne inverse side), 2 CmsPhonenumber (joined association) $mockListener - ->expects($this->exactly(4)) + ->expects(self::exactly(4)) ->method('postLoad') - ->will($this->returnValue(true)); + ->will(self::returnValue(true)); $eventManager = $this->_em->getEventManager(); @@ -113,9 +113,9 @@ public function testLoadedProxyEntityShouldTriggerEvent(): void $mockListener = $this->createMock(PostLoadListener::class); $mockListener - ->expects($this->never()) + ->expects(self::never()) ->method('postLoad') - ->will($this->returnValue(true)); + ->will(self::returnValue(true)); $eventManager->addEventListener([Events::postLoad], $mockListener); @@ -127,9 +127,9 @@ public function testLoadedProxyEntityShouldTriggerEvent(): void $mockListener2 = $this->createMock(PostLoadListener::class); $mockListener2 - ->expects($this->exactly(2)) + ->expects(self::exactly(2)) ->method('postLoad') - ->will($this->returnValue(true)); + ->will(self::returnValue(true)); $eventManager->addEventListener([Events::postLoad], $mockListener2); @@ -145,9 +145,9 @@ public function testLoadedProxyPartialShouldTriggerEvent(): void // CmsUser (partially loaded), CmsAddress (inverse ToOne), 2 CmsPhonenumber $mockListener - ->expects($this->exactly(4)) + ->expects(self::exactly(4)) ->method('postLoad') - ->will($this->returnValue(true)); + ->will(self::returnValue(true)); $eventManager->addEventListener([Events::postLoad], $mockListener); @@ -165,9 +165,9 @@ public function testLoadedProxyAssociationToOneShouldTriggerEvent(): void // CmsEmail (proxy) $mockListener - ->expects($this->exactly(1)) + ->expects(self::exactly(1)) ->method('postLoad') - ->will($this->returnValue(true)); + ->will(self::returnValue(true)); $eventManager = $this->_em->getEventManager(); @@ -186,9 +186,9 @@ public function testLoadedProxyAssociationToManyShouldTriggerEvent(): void // 2 CmsPhonenumber (proxy) $mockListener - ->expects($this->exactly(2)) + ->expects(self::exactly(2)) ->method('postLoad') - ->will($this->returnValue(true)); + ->will(self::returnValue(true)); $eventManager = $this->_em->getEventManager(); @@ -212,8 +212,8 @@ public function testAssociationsArePopulatedWhenEventIsFired(): void $qb->addSelect('email'); $qb->getQuery()->getSingleResult(); - $this->assertTrue($checkerListener->checked, 'postLoad event is not invoked'); - $this->assertTrue($checkerListener->populated, 'Association of email is not populated in postLoad event'); + self::assertTrue($checkerListener->checked, 'postLoad event is not invoked'); + self::assertTrue($checkerListener->populated, 'Association of email is not populated in postLoad event'); } /** @@ -226,8 +226,8 @@ public function testEventRaisedCorrectTimesWhenOtherEntityLoadedInEventHandler() $eventManager->addEventListener([Events::postLoad], $listener); $this->_em->find(CmsUser::class, $this->userId); - $this->assertSame(1, $listener->countHandledEvents(CmsUser::class), CmsUser::class . ' should be handled once!'); - $this->assertSame(1, $listener->countHandledEvents(CmsEmail::class), CmsEmail::class . ' should be handled once!'); + self::assertSame(1, $listener->countHandledEvents(CmsUser::class), CmsUser::class . ' should be handled once!'); + self::assertSame(1, $listener->countHandledEvents(CmsEmail::class), CmsEmail::class . ' should be handled once!'); } private function loadFixture(): void diff --git a/tests/Doctrine/Tests/ORM/Functional/ProxiesLikeEntitiesTest.php b/tests/Doctrine/Tests/ORM/Functional/ProxiesLikeEntitiesTest.php index 1178523cead..e7bc792a6d9 100644 --- a/tests/Doctrine/Tests/ORM/Functional/ProxiesLikeEntitiesTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/ProxiesLikeEntitiesTest.php @@ -70,12 +70,12 @@ public function testPersistUpdate(): void $proxy->name = 'Marco'; $this->_em->persist($proxy); $this->_em->flush(); - $this->assertNotNull($proxy->getId()); + self::assertNotNull($proxy->getId()); $proxy->name = 'Marco Pivetta'; $this->_em->getUnitOfWork() ->computeChangeSet($this->_em->getClassMetadata(CmsUser::class), $proxy); - $this->assertNotEmpty($this->_em->getUnitOfWork()->getEntityChangeSet($proxy)); - $this->assertEquals('Marco Pivetta', $this->_em->find(CmsUser::class, $proxy->getId())->name); + self::assertNotEmpty($this->_em->getUnitOfWork()->getEntityChangeSet($proxy)); + self::assertEquals('Marco Pivetta', $this->_em->find(CmsUser::class, $proxy->getId())->name); $this->_em->remove($proxy); $this->_em->flush(); } @@ -85,12 +85,12 @@ public function testEntityWithIdentifier(): void $userId = $this->user->getId(); $uninitializedProxy = $this->_em->getReference(CmsUser::class, $userId); assert($uninitializedProxy instanceof CmsUserProxy); - $this->assertInstanceOf(CmsUserProxy::class, $uninitializedProxy); + self::assertInstanceOf(CmsUserProxy::class, $uninitializedProxy); $this->_em->persist($uninitializedProxy); $this->_em->flush(); - $this->assertFalse($uninitializedProxy->__isInitialized(), 'Proxy didn\'t get initialized during flush operations'); - $this->assertEquals($userId, $uninitializedProxy->getId()); + self::assertFalse($uninitializedProxy->__isInitialized(), 'Proxy didn\'t get initialized during flush operations'); + self::assertEquals($userId, $uninitializedProxy->getId()); $this->_em->remove($uninitializedProxy); $this->_em->flush(); } @@ -107,7 +107,7 @@ public function testProxyAsDqlParameterPersist(): void ->createQuery('SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u = ?1') ->setParameter(1, $proxy) ->getSingleResult(); - $this->assertSame($this->user->getId(), $result->getId()); + self::assertSame($this->user->getId(), $result->getId()); $this->_em->remove($proxy); $this->_em->flush(); } @@ -118,15 +118,15 @@ public function testProxyAsDqlParameterPersist(): void public function testFindWithProxyName(): void { $result = $this->_em->find(CmsUserProxy::class, $this->user->getId()); - $this->assertSame($this->user->getId(), $result->getId()); + self::assertSame($this->user->getId(), $result->getId()); $this->_em->clear(); $result = $this->_em->getReference(CmsUserProxy::class, $this->user->getId()); - $this->assertSame($this->user->getId(), $result->getId()); + self::assertSame($this->user->getId(), $result->getId()); $this->_em->clear(); $result = $this->_em->getRepository(CmsUserProxy::class)->findOneBy(['username' => $this->user->username]); - $this->assertSame($this->user->getId(), $result->getId()); + self::assertSame($this->user->getId(), $result->getId()); $this->_em->clear(); $result = $this->_em @@ -134,7 +134,7 @@ public function testFindWithProxyName(): void ->setParameter(1, $this->user->getId()) ->getSingleResult(); - $this->assertSame($this->user->getId(), $result->getId()); + self::assertSame($this->user->getId(), $result->getId()); $this->_em->clear(); } diff --git a/tests/Doctrine/Tests/ORM/Functional/QueryBuilderParenthesisTest.php b/tests/Doctrine/Tests/ORM/Functional/QueryBuilderParenthesisTest.php index 4d02714f932..d142a9760e8 100644 --- a/tests/Doctrine/Tests/ORM/Functional/QueryBuilderParenthesisTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/QueryBuilderParenthesisTest.php @@ -46,11 +46,11 @@ public function testParenthesisOnSingleLine(): void $query = $queryBuilder->getQuery(); $results = $query->getResult(); - $this->assertCount(0, $results); + self::assertCount(0, $results); $dql = $query->getDQL(); - $this->assertSame( + self::assertSame( 'SELECT o FROM ' . QueryBuilderParenthesisEntity::class . ' o WHERE o.property3 = :value3 AND (o.property1 = :value1 OR o.property2 = :value2) AND (o.property1 = :value1 or o.property2 = :value2)', $dql ); @@ -71,11 +71,11 @@ public function testParenthesisOnMultiLine(): void $query = $queryBuilder->getQuery(); $results = $query->getResult(); - $this->assertCount(0, $results); + self::assertCount(0, $results); $dql = $query->getDQL(); - $this->assertSame( + self::assertSame( 'SELECT o FROM ' . QueryBuilderParenthesisEntity::class . ' o WHERE o.property3 = :value3 AND (o.property1 = :value1 OR o.property2 = :value2)', $dql diff --git a/tests/Doctrine/Tests/ORM/Functional/QueryCacheTest.php b/tests/Doctrine/Tests/ORM/Functional/QueryCacheTest.php index 6ac78023fda..a564086b20e 100644 --- a/tests/Doctrine/Tests/ORM/Functional/QueryCacheTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/QueryCacheTest.php @@ -27,7 +27,7 @@ class QueryCacheTest extends OrmFunctionalTestCase protected function setUp(): void { if (! class_exists(ArrayCache::class)) { - $this->markTestSkipped('Test only applies with doctrine/cache 1.x'); + self::markTestSkipped('Test only applies with doctrine/cache 1.x'); } $this->cacheDataReflection = new ReflectionProperty(ArrayCache::class, 'data'); @@ -51,12 +51,12 @@ public function testQueryCacheDependsOnHints(): Query $query->setQueryCacheDriver($cache); $query->getResult(); - $this->assertEquals(1, $this->getCacheSize($cache)); + self::assertEquals(1, $this->getCacheSize($cache)); $query->setHint('foo', 'bar'); $query->getResult(); - $this->assertEquals(2, $this->getCacheSize($cache)); + self::assertEquals(2, $this->getCacheSize($cache)); return $query; } @@ -75,7 +75,7 @@ public function testQueryCacheDependsOnFirstResult($query): void $query->setMaxResults(9999); $query->getResult(); - $this->assertEquals($cacheCount + 1, $this->getCacheSize($cache)); + self::assertEquals($cacheCount + 1, $this->getCacheSize($cache)); } /** @@ -91,7 +91,7 @@ public function testQueryCacheDependsOnMaxResults($query): void $query->setMaxResults(10); $query->getResult(); - $this->assertEquals($cacheCount + 1, $this->getCacheSize($cache)); + self::assertEquals($cacheCount + 1, $this->getCacheSize($cache)); } /** @@ -105,7 +105,7 @@ public function testQueryCacheDependsOnHydrationMode($query): void $cacheCount = $this->getCacheSize($cache); $query->getArrayResult(); - $this->assertEquals($cacheCount + 1, $this->getCacheSize($cache)); + self::assertEquals($cacheCount + 1, $this->getCacheSize($cache)); } public function testQueryCacheNoHitSaveParserResult(): void @@ -136,33 +136,33 @@ public function testQueryCacheHitDoesNotSaveParserResult(): void ->setMethods(['execute']) ->getMock(); - $sqlExecMock->expects($this->once()) + $sqlExecMock->expects(self::once()) ->method('execute') - ->will($this->returnValue(10)); + ->will(self::returnValue(10)); $parserResultMock = $this->getMockBuilder(ParserResult::class) ->setMethods(['getSqlExecutor']) ->getMock(); - $parserResultMock->expects($this->once()) + $parserResultMock->expects(self::once()) ->method('getSqlExecutor') - ->will($this->returnValue($sqlExecMock)); + ->will(self::returnValue($sqlExecMock)); $cache = $this->getMockBuilder(CacheProvider::class) ->setMethods(['doFetch', 'doContains', 'doSave', 'doDelete', 'doFlush', 'doGetStats']) ->getMock(); - $cache->expects($this->exactly(2)) + $cache->expects(self::exactly(2)) ->method('doFetch') ->withConsecutive( - [$this->isType('string')], - [$this->isType('string')] + [self::isType('string')], + [self::isType('string')] ) ->willReturnOnConsecutiveCalls( - $this->returnValue(1), - $this->returnValue($parserResultMock) + self::returnValue(1), + self::returnValue($parserResultMock) ); - $cache->expects($this->never()) + $cache->expects(self::never()) ->method('doSave'); $query->setQueryCacheDriver($cache); diff --git a/tests/Doctrine/Tests/ORM/Functional/QueryDqlFunctionTest.php b/tests/Doctrine/Tests/ORM/Functional/QueryDqlFunctionTest.php index 228a474b434..8a188e3a5ad 100644 --- a/tests/Doctrine/Tests/ORM/Functional/QueryDqlFunctionTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/QueryDqlFunctionTest.php @@ -32,7 +32,7 @@ public function testAggregateSum(): void $salarySum = $this->_em->createQuery('SELECT SUM(m.salary) AS salary FROM Doctrine\Tests\Models\Company\CompanyManager m') ->getSingleResult(); - $this->assertEquals(1500000, $salarySum['salary']); + self::assertEquals(1500000, $salarySum['salary']); } public function testAggregateAvg(): void @@ -40,7 +40,7 @@ public function testAggregateAvg(): void $salaryAvg = $this->_em->createQuery('SELECT AVG(m.salary) AS salary FROM Doctrine\Tests\Models\Company\CompanyManager m') ->getSingleResult(); - $this->assertEquals(375000, round((float) $salaryAvg['salary'], 0)); + self::assertEquals(375000, round((float) $salaryAvg['salary'], 0)); } public function testAggregateMin(): void @@ -48,7 +48,7 @@ public function testAggregateMin(): void $salary = $this->_em->createQuery('SELECT MIN(m.salary) AS salary FROM Doctrine\Tests\Models\Company\CompanyManager m') ->getSingleResult(); - $this->assertEquals(100000, $salary['salary']); + self::assertEquals(100000, $salary['salary']); } public function testAggregateMax(): void @@ -56,7 +56,7 @@ public function testAggregateMax(): void $salary = $this->_em->createQuery('SELECT MAX(m.salary) AS salary FROM Doctrine\Tests\Models\Company\CompanyManager m') ->getSingleResult(); - $this->assertEquals(800000, $salary['salary']); + self::assertEquals(800000, $salary['salary']); } public function testAggregateCount(): void @@ -64,7 +64,7 @@ public function testAggregateCount(): void $managerCount = $this->_em->createQuery('SELECT COUNT(m.id) AS managers FROM Doctrine\Tests\Models\Company\CompanyManager m') ->getSingleResult(); - $this->assertEquals(4, $managerCount['managers']); + self::assertEquals(4, $managerCount['managers']); } public function testFunctionAbs(): void @@ -72,11 +72,11 @@ public function testFunctionAbs(): void $result = $this->_em->createQuery('SELECT m, ABS(m.salary * -1) AS abs FROM Doctrine\Tests\Models\Company\CompanyManager m ORDER BY m.salary ASC') ->getResult(); - $this->assertEquals(4, count($result)); - $this->assertEquals(100000, $result[0]['abs']); - $this->assertEquals(200000, $result[1]['abs']); - $this->assertEquals(400000, $result[2]['abs']); - $this->assertEquals(800000, $result[3]['abs']); + self::assertEquals(4, count($result)); + self::assertEquals(100000, $result[0]['abs']); + self::assertEquals(200000, $result[1]['abs']); + self::assertEquals(400000, $result[2]['abs']); + self::assertEquals(800000, $result[3]['abs']); } public function testFunctionConcat(): void @@ -84,11 +84,11 @@ public function testFunctionConcat(): void $arg = $this->_em->createQuery('SELECT m, CONCAT(m.name, m.department) AS namedep FROM Doctrine\Tests\Models\Company\CompanyManager m ORDER BY m.salary ASC') ->getArrayResult(); - $this->assertEquals(4, count($arg)); - $this->assertEquals('Roman B.IT', $arg[0]['namedep']); - $this->assertEquals('Benjamin E.HR', $arg[1]['namedep']); - $this->assertEquals('Guilherme B.Complaint Department', $arg[2]['namedep']); - $this->assertEquals('Jonathan W.Administration', $arg[3]['namedep']); + self::assertEquals(4, count($arg)); + self::assertEquals('Roman B.IT', $arg[0]['namedep']); + self::assertEquals('Benjamin E.HR', $arg[1]['namedep']); + self::assertEquals('Guilherme B.Complaint Department', $arg[2]['namedep']); + self::assertEquals('Jonathan W.Administration', $arg[3]['namedep']); } public function testFunctionLength(): void @@ -96,11 +96,11 @@ public function testFunctionLength(): void $result = $this->_em->createQuery('SELECT m, LENGTH(CONCAT(m.name, m.department)) AS namedeplength FROM Doctrine\Tests\Models\Company\CompanyManager m ORDER BY m.salary ASC') ->getArrayResult(); - $this->assertEquals(4, count($result)); - $this->assertEquals(10, $result[0]['namedeplength']); - $this->assertEquals(13, $result[1]['namedeplength']); - $this->assertEquals(32, $result[2]['namedeplength']); - $this->assertEquals(25, $result[3]['namedeplength']); + self::assertEquals(4, count($result)); + self::assertEquals(10, $result[0]['namedeplength']); + self::assertEquals(13, $result[1]['namedeplength']); + self::assertEquals(32, $result[2]['namedeplength']); + self::assertEquals(25, $result[3]['namedeplength']); } public function testFunctionLocate(): void @@ -111,15 +111,15 @@ public function testFunctionLocate(): void $result = $this->_em->createQuery($dql) ->getArrayResult(); - $this->assertEquals(4, count($result)); - $this->assertEquals(0, $result[0]['loc']); - $this->assertEquals(2, $result[1]['loc']); - $this->assertEquals(6, $result[2]['loc']); - $this->assertEquals(0, $result[3]['loc']); - $this->assertEquals(0, $result[0]['loc2']); - $this->assertEquals(10, $result[1]['loc2']); - $this->assertEquals(9, $result[2]['loc2']); - $this->assertEquals(0, $result[3]['loc2']); + self::assertEquals(4, count($result)); + self::assertEquals(0, $result[0]['loc']); + self::assertEquals(2, $result[1]['loc']); + self::assertEquals(6, $result[2]['loc']); + self::assertEquals(0, $result[3]['loc']); + self::assertEquals(0, $result[0]['loc2']); + self::assertEquals(10, $result[1]['loc2']); + self::assertEquals(9, $result[2]['loc2']); + self::assertEquals(0, $result[3]['loc2']); } public function testFunctionLower(): void @@ -127,11 +127,11 @@ public function testFunctionLower(): void $result = $this->_em->createQuery('SELECT m, LOWER(m.name) AS lowername FROM Doctrine\Tests\Models\Company\CompanyManager m ORDER BY m.salary ASC') ->getArrayResult(); - $this->assertEquals(4, count($result)); - $this->assertEquals('roman b.', $result[0]['lowername']); - $this->assertEquals('benjamin e.', $result[1]['lowername']); - $this->assertEquals('guilherme b.', $result[2]['lowername']); - $this->assertEquals('jonathan w.', $result[3]['lowername']); + self::assertEquals(4, count($result)); + self::assertEquals('roman b.', $result[0]['lowername']); + self::assertEquals('benjamin e.', $result[1]['lowername']); + self::assertEquals('guilherme b.', $result[2]['lowername']); + self::assertEquals('jonathan w.', $result[3]['lowername']); } public function testFunctionMod(): void @@ -139,11 +139,11 @@ public function testFunctionMod(): void $result = $this->_em->createQuery('SELECT m, MOD(m.salary, 3500) AS amod FROM Doctrine\Tests\Models\Company\CompanyManager m ORDER BY m.salary ASC') ->getArrayResult(); - $this->assertEquals(4, count($result)); - $this->assertEquals(2000, $result[0]['amod']); - $this->assertEquals(500, $result[1]['amod']); - $this->assertEquals(1000, $result[2]['amod']); - $this->assertEquals(2000, $result[3]['amod']); + self::assertEquals(4, count($result)); + self::assertEquals(2000, $result[0]['amod']); + self::assertEquals(500, $result[1]['amod']); + self::assertEquals(1000, $result[2]['amod']); + self::assertEquals(2000, $result[3]['amod']); } public function testFunctionSqrt(): void @@ -151,11 +151,11 @@ public function testFunctionSqrt(): void $result = $this->_em->createQuery('SELECT m, SQRT(m.salary) AS sqrtsalary FROM Doctrine\Tests\Models\Company\CompanyManager m ORDER BY m.salary ASC') ->getArrayResult(); - $this->assertEquals(4, count($result)); - $this->assertEquals(316, round((float) $result[0]['sqrtsalary'])); - $this->assertEquals(447, round((float) $result[1]['sqrtsalary'])); - $this->assertEquals(632, round((float) $result[2]['sqrtsalary'])); - $this->assertEquals(894, round((float) $result[3]['sqrtsalary'])); + self::assertEquals(4, count($result)); + self::assertEquals(316, round((float) $result[0]['sqrtsalary'])); + self::assertEquals(447, round((float) $result[1]['sqrtsalary'])); + self::assertEquals(632, round((float) $result[2]['sqrtsalary'])); + self::assertEquals(894, round((float) $result[3]['sqrtsalary'])); } public function testFunctionUpper(): void @@ -163,11 +163,11 @@ public function testFunctionUpper(): void $result = $this->_em->createQuery('SELECT m, UPPER(m.name) AS uppername FROM Doctrine\Tests\Models\Company\CompanyManager m ORDER BY m.salary ASC') ->getArrayResult(); - $this->assertEquals(4, count($result)); - $this->assertEquals('ROMAN B.', $result[0]['uppername']); - $this->assertEquals('BENJAMIN E.', $result[1]['uppername']); - $this->assertEquals('GUILHERME B.', $result[2]['uppername']); - $this->assertEquals('JONATHAN W.', $result[3]['uppername']); + self::assertEquals(4, count($result)); + self::assertEquals('ROMAN B.', $result[0]['uppername']); + self::assertEquals('BENJAMIN E.', $result[1]['uppername']); + self::assertEquals('GUILHERME B.', $result[2]['uppername']); + self::assertEquals('JONATHAN W.', $result[3]['uppername']); } public function testFunctionSubstring(): void @@ -178,16 +178,16 @@ public function testFunctionSubstring(): void $result = $this->_em->createQuery($dql) ->getArrayResult(); - $this->assertEquals(4, count($result)); - $this->assertEquals('Ben', $result[0]['str1']); - $this->assertEquals('Gui', $result[1]['str1']); - $this->assertEquals('Jon', $result[2]['str1']); - $this->assertEquals('Rom', $result[3]['str1']); + self::assertEquals(4, count($result)); + self::assertEquals('Ben', $result[0]['str1']); + self::assertEquals('Gui', $result[1]['str1']); + self::assertEquals('Jon', $result[2]['str1']); + self::assertEquals('Rom', $result[3]['str1']); - $this->assertEquals('amin E.', $result[0]['str2']); - $this->assertEquals('herme B.', $result[1]['str2']); - $this->assertEquals('than W.', $result[2]['str2']); - $this->assertEquals('n B.', $result[3]['str2']); + self::assertEquals('amin E.', $result[0]['str2']); + self::assertEquals('herme B.', $result[1]['str2']); + self::assertEquals('than W.', $result[2]['str2']); + self::assertEquals('n B.', $result[3]['str2']); } public function testFunctionTrim(): void @@ -198,19 +198,19 @@ public function testFunctionTrim(): void $result = $this->_em->createQuery($dql)->getArrayResult(); - $this->assertEquals(4, count($result)); - $this->assertEquals('Roman B', $result[0]['str1']); - $this->assertEquals('Benjamin E', $result[1]['str1']); - $this->assertEquals('Guilherme B', $result[2]['str1']); - $this->assertEquals('Jonathan W', $result[3]['str1']); - $this->assertEquals('Roman B.', $result[0]['str2']); - $this->assertEquals('Benjamin E.', $result[1]['str2']); - $this->assertEquals('Guilherme B.', $result[2]['str2']); - $this->assertEquals('Jonathan W.', $result[3]['str2']); - $this->assertEquals('Roman B.', $result[0]['str3']); - $this->assertEquals('Benjamin E.', $result[1]['str3']); - $this->assertEquals('Guilherme B.', $result[2]['str3']); - $this->assertEquals('Jonathan W.', $result[3]['str3']); + self::assertEquals(4, count($result)); + self::assertEquals('Roman B', $result[0]['str1']); + self::assertEquals('Benjamin E', $result[1]['str1']); + self::assertEquals('Guilherme B', $result[2]['str1']); + self::assertEquals('Jonathan W', $result[3]['str1']); + self::assertEquals('Roman B.', $result[0]['str2']); + self::assertEquals('Benjamin E.', $result[1]['str2']); + self::assertEquals('Guilherme B.', $result[2]['str2']); + self::assertEquals('Jonathan W.', $result[3]['str2']); + self::assertEquals('Roman B.', $result[0]['str3']); + self::assertEquals('Benjamin E.', $result[1]['str3']); + self::assertEquals('Guilherme B.', $result[2]['str3']); + self::assertEquals('Jonathan W.', $result[3]['str3']); } public function testOperatorAdd(): void @@ -218,11 +218,11 @@ public function testOperatorAdd(): void $result = $this->_em->createQuery('SELECT m, m.salary+2500 AS add FROM Doctrine\Tests\Models\Company\CompanyManager m ORDER BY m.salary ASC') ->getResult(); - $this->assertEquals(4, count($result)); - $this->assertEquals(102500, $result[0]['add']); - $this->assertEquals(202500, $result[1]['add']); - $this->assertEquals(402500, $result[2]['add']); - $this->assertEquals(802500, $result[3]['add']); + self::assertEquals(4, count($result)); + self::assertEquals(102500, $result[0]['add']); + self::assertEquals(202500, $result[1]['add']); + self::assertEquals(402500, $result[2]['add']); + self::assertEquals(802500, $result[3]['add']); } public function testOperatorSub(): void @@ -230,11 +230,11 @@ public function testOperatorSub(): void $result = $this->_em->createQuery('SELECT m, m.salary-2500 AS sub FROM Doctrine\Tests\Models\Company\CompanyManager m ORDER BY m.salary ASC') ->getResult(); - $this->assertEquals(4, count($result)); - $this->assertEquals(97500, $result[0]['sub']); - $this->assertEquals(197500, $result[1]['sub']); - $this->assertEquals(397500, $result[2]['sub']); - $this->assertEquals(797500, $result[3]['sub']); + self::assertEquals(4, count($result)); + self::assertEquals(97500, $result[0]['sub']); + self::assertEquals(197500, $result[1]['sub']); + self::assertEquals(397500, $result[2]['sub']); + self::assertEquals(797500, $result[3]['sub']); } public function testOperatorMultiply(): void @@ -242,11 +242,11 @@ public function testOperatorMultiply(): void $result = $this->_em->createQuery('SELECT m, m.salary*2 AS op FROM Doctrine\Tests\Models\Company\CompanyManager m ORDER BY m.salary ASC') ->getResult(); - $this->assertEquals(4, count($result)); - $this->assertEquals(200000, $result[0]['op']); - $this->assertEquals(400000, $result[1]['op']); - $this->assertEquals(800000, $result[2]['op']); - $this->assertEquals(1600000, $result[3]['op']); + self::assertEquals(4, count($result)); + self::assertEquals(200000, $result[0]['op']); + self::assertEquals(400000, $result[1]['op']); + self::assertEquals(800000, $result[2]['op']); + self::assertEquals(1600000, $result[3]['op']); } /** @@ -257,11 +257,11 @@ public function testOperatorDiv(): void $result = $this->_em->createQuery('SELECT m, (m.salary/0.5) AS op FROM Doctrine\Tests\Models\Company\CompanyManager m ORDER BY m.salary ASC') ->getResult(); - $this->assertEquals(4, count($result)); - $this->assertEquals(200000, $result[0]['op']); - $this->assertEquals(400000, $result[1]['op']); - $this->assertEquals(800000, $result[2]['op']); - $this->assertEquals(1600000, $result[3]['op']); + self::assertEquals(4, count($result)); + self::assertEquals(200000, $result[0]['op']); + self::assertEquals(400000, $result[1]['op']); + self::assertEquals(800000, $result[2]['op']); + self::assertEquals(1600000, $result[3]['op']); } public function testConcatFunction(): void @@ -269,11 +269,11 @@ public function testConcatFunction(): void $arg = $this->_em->createQuery('SELECT CONCAT(m.name, m.department) AS namedep FROM Doctrine\Tests\Models\Company\CompanyManager m order by namedep desc') ->getArrayResult(); - $this->assertEquals(4, count($arg)); - $this->assertEquals('Roman B.IT', $arg[0]['namedep']); - $this->assertEquals('Jonathan W.Administration', $arg[1]['namedep']); - $this->assertEquals('Guilherme B.Complaint Department', $arg[2]['namedep']); - $this->assertEquals('Benjamin E.HR', $arg[3]['namedep']); + self::assertEquals(4, count($arg)); + self::assertEquals('Roman B.IT', $arg[0]['namedep']); + self::assertEquals('Jonathan W.Administration', $arg[1]['namedep']); + self::assertEquals('Guilherme B.Complaint Department', $arg[2]['namedep']); + self::assertEquals('Benjamin E.HR', $arg[3]['namedep']); } /** @@ -284,12 +284,12 @@ public function testDateDiff(): void $query = $this->_em->createQuery("SELECT DATE_DIFF(CURRENT_TIMESTAMP(), DATE_ADD(CURRENT_TIMESTAMP(), 10, 'day')) AS diff FROM Doctrine\Tests\Models\Company\CompanyManager m"); $arg = $query->getArrayResult(); - $this->assertEqualsWithDelta(-10, $arg[0]['diff'], 1, 'Should be roughly -10 (or -9)'); + self::assertEqualsWithDelta(-10, $arg[0]['diff'], 1, 'Should be roughly -10 (or -9)'); $query = $this->_em->createQuery("SELECT DATE_DIFF(DATE_ADD(CURRENT_TIMESTAMP(), 10, 'day'), CURRENT_TIMESTAMP()) AS diff FROM Doctrine\Tests\Models\Company\CompanyManager m"); $arg = $query->getArrayResult(); - $this->assertEqualsWithDelta(10, $arg[0]['diff'], 1, 'Should be roughly 10 (or 9)'); + self::assertEqualsWithDelta(10, $arg[0]['diff'], 1, 'Should be roughly 10 (or 9)'); } /** @@ -386,15 +386,15 @@ public function testBitOrComparison(): void 'm.id '; $result = $this->_em->createQuery($dql)->getArrayResult(); - $this->assertEquals(4 | 2, $result[0]['bit_or']); - $this->assertEquals(4 | 2, $result[1]['bit_or']); - $this->assertEquals(4 | 2, $result[2]['bit_or']); - $this->assertEquals(4 | 2, $result[3]['bit_or']); + self::assertEquals(4 | 2, $result[0]['bit_or']); + self::assertEquals(4 | 2, $result[1]['bit_or']); + self::assertEquals(4 | 2, $result[2]['bit_or']); + self::assertEquals(4 | 2, $result[3]['bit_or']); - $this->assertEquals($result[0][0]['salary'] / 100000 | 2, $result[0]['salary_bit_or']); - $this->assertEquals($result[1][0]['salary'] / 100000 | 2, $result[1]['salary_bit_or']); - $this->assertEquals($result[2][0]['salary'] / 100000 | 2, $result[2]['salary_bit_or']); - $this->assertEquals($result[3][0]['salary'] / 100000 | 2, $result[3]['salary_bit_or']); + self::assertEquals($result[0][0]['salary'] / 100000 | 2, $result[0]['salary_bit_or']); + self::assertEquals($result[1][0]['salary'] / 100000 | 2, $result[1]['salary_bit_or']); + self::assertEquals($result[2][0]['salary'] / 100000 | 2, $result[2]['salary_bit_or']); + self::assertEquals($result[3][0]['salary'] / 100000 | 2, $result[3]['salary_bit_or']); } /** @@ -410,15 +410,15 @@ public function testBitAndComparison(): void 'm.id '; $result = $this->_em->createQuery($dql)->getArrayResult(); - $this->assertEquals(4 & 2, $result[0]['bit_and']); - $this->assertEquals(4 & 2, $result[1]['bit_and']); - $this->assertEquals(4 & 2, $result[2]['bit_and']); - $this->assertEquals(4 & 2, $result[3]['bit_and']); + self::assertEquals(4 & 2, $result[0]['bit_and']); + self::assertEquals(4 & 2, $result[1]['bit_and']); + self::assertEquals(4 & 2, $result[2]['bit_and']); + self::assertEquals(4 & 2, $result[3]['bit_and']); - $this->assertEquals($result[0][0]['salary'] / 100000 & 2, $result[0]['salary_bit_and']); - $this->assertEquals($result[1][0]['salary'] / 100000 & 2, $result[1]['salary_bit_and']); - $this->assertEquals($result[2][0]['salary'] / 100000 & 2, $result[2]['salary_bit_and']); - $this->assertEquals($result[3][0]['salary'] / 100000 & 2, $result[3]['salary_bit_and']); + self::assertEquals($result[0][0]['salary'] / 100000 & 2, $result[0]['salary_bit_and']); + self::assertEquals($result[1][0]['salary'] / 100000 & 2, $result[1]['salary_bit_and']); + self::assertEquals($result[2][0]['salary'] / 100000 & 2, $result[2]['salary_bit_and']); + self::assertEquals($result[3][0]['salary'] / 100000 & 2, $result[3]['salary_bit_and']); } protected function generateFixture(): void diff --git a/tests/Doctrine/Tests/ORM/Functional/QueryIterableTest.php b/tests/Doctrine/Tests/ORM/Functional/QueryIterableTest.php index 62b86ae2508..db218882dd0 100644 --- a/tests/Doctrine/Tests/ORM/Functional/QueryIterableTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/QueryIterableTest.php @@ -32,7 +32,7 @@ public function testAlias(): void $users = $query->getResult(); self::assertCount(1, $users); - $this->assertEquals('gblanco', $users[0]['user']->username); + self::assertEquals('gblanco', $users[0]['user']->username); $this->_em->clear(); @@ -62,7 +62,7 @@ public function testAliasInnerJoin(): void $users = $query->getResult(); self::assertCount(1, $users); - $this->assertEquals('gblanco', $users[0]['user']->username); + self::assertEquals('gblanco', $users[0]['user']->username); $this->_em->clear(); diff --git a/tests/Doctrine/Tests/ORM/Functional/QueryTest.php b/tests/Doctrine/Tests/ORM/Functional/QueryTest.php index 9a5215b5af5..4475ec0a1ba 100644 --- a/tests/Doctrine/Tests/ORM/Functional/QueryTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/QueryTest.php @@ -50,30 +50,30 @@ public function testSimpleQueries(): void $result = $query->getResult(); - $this->assertEquals(1, count($result)); - $this->assertInstanceOf(CmsUser::class, $result[0][0]); - $this->assertEquals('Guilherme', $result[0][0]->name); - $this->assertEquals('gblanco', $result[0][0]->username); - $this->assertEquals('developer', $result[0][0]->status); - $this->assertEquals('GUILHERME', $result[0][1]); + self::assertEquals(1, count($result)); + self::assertInstanceOf(CmsUser::class, $result[0][0]); + self::assertEquals('Guilherme', $result[0][0]->name); + self::assertEquals('gblanco', $result[0][0]->username); + self::assertEquals('developer', $result[0][0]->status); + self::assertEquals('GUILHERME', $result[0][1]); $resultArray = $query->getArrayResult(); - $this->assertEquals(1, count($resultArray)); - $this->assertTrue(is_array($resultArray[0][0])); - $this->assertEquals('Guilherme', $resultArray[0][0]['name']); - $this->assertEquals('gblanco', $resultArray[0][0]['username']); - $this->assertEquals('developer', $resultArray[0][0]['status']); - $this->assertEquals('GUILHERME', $resultArray[0][1]); + self::assertEquals(1, count($resultArray)); + self::assertTrue(is_array($resultArray[0][0])); + self::assertEquals('Guilherme', $resultArray[0][0]['name']); + self::assertEquals('gblanco', $resultArray[0][0]['username']); + self::assertEquals('developer', $resultArray[0][0]['status']); + self::assertEquals('GUILHERME', $resultArray[0][1]); $scalarResult = $query->getScalarResult(); - $this->assertEquals(1, count($scalarResult)); - $this->assertEquals('Guilherme', $scalarResult[0]['u_name']); - $this->assertEquals('gblanco', $scalarResult[0]['u_username']); - $this->assertEquals('developer', $scalarResult[0]['u_status']); - $this->assertEquals('GUILHERME', $scalarResult[0][1]); + self::assertEquals(1, count($scalarResult)); + self::assertEquals('Guilherme', $scalarResult[0]['u_name']); + self::assertEquals('gblanco', $scalarResult[0]['u_username']); + self::assertEquals('developer', $scalarResult[0]['u_status']); + self::assertEquals('GUILHERME', $scalarResult[0][1]); $query = $this->_em->createQuery("select upper(u.name) from Doctrine\Tests\Models\CMS\CmsUser u where u.username = 'gblanco'"); - $this->assertEquals('GUILHERME', $query->getSingleScalarResult()); + self::assertEquals('GUILHERME', $query->getSingleScalarResult()); } public function testJoinQueries(): void @@ -102,11 +102,11 @@ public function testJoinQueries(): void $query = $this->_em->createQuery('select u, a from ' . CmsUser::class . ' u join u.articles a ORDER BY a.topic'); $users = $query->getResult(); - $this->assertEquals(1, count($users)); - $this->assertInstanceOf(CmsUser::class, $users[0]); - $this->assertEquals(2, count($users[0]->articles)); - $this->assertEquals('Doctrine 2', $users[0]->articles[0]->topic); - $this->assertEquals('Symfony 2', $users[0]->articles[1]->topic); + self::assertEquals(1, count($users)); + self::assertInstanceOf(CmsUser::class, $users[0]); + self::assertEquals(2, count($users[0]->articles)); + self::assertEquals('Doctrine 2', $users[0]->articles[0]->topic); + self::assertEquals('Symfony 2', $users[0]->articles[1]->topic); } public function testUsingZeroBasedQueryParameterShouldWork(): void @@ -123,7 +123,7 @@ public function testUsingZeroBasedQueryParameterShouldWork(): void $q->setParameter(0, 'jwage'); $user = $q->getSingleResult(); - $this->assertNotNull($user); + self::assertNotNull($user); } public function testUsingUnknownQueryParameterShouldThrowException(): void @@ -274,13 +274,13 @@ public function testIterateResultIterativelyBuildUpUnitOfWork(): void $identityMap = $this->_em->getUnitOfWork()->getIdentityMap(); $identityMapCount = count($identityMap[CmsArticle::class]); - $this->assertTrue($identityMapCount > $iteratedCount); + self::assertTrue($identityMapCount > $iteratedCount); $iteratedCount++; } - $this->assertSame(['Doctrine 2', 'Symfony 2'], $topics); - $this->assertSame(2, $iteratedCount); + self::assertSame(['Doctrine 2', 'Symfony 2'], $topics); + self::assertSame(2, $iteratedCount); $articles = $query->toIterable(); @@ -328,12 +328,12 @@ public function testToIterableWithMultipleSelectElements(): void $result = iterator_to_array($query->toIterable()); - $this->assertCount(2, $result); + self::assertCount(2, $result); foreach ($result as $row) { - $this->assertCount(2, $row); - $this->assertInstanceOf(CmsArticle::class, $row[0]); - $this->assertInstanceOf(CmsUser::class, $row[1]); + self::assertCount(2, $row); + self::assertInstanceOf(CmsArticle::class, $row[0]); + self::assertInstanceOf(CmsUser::class, $row[1]); } } @@ -390,8 +390,8 @@ public function testIterateResultClearEveryCycle(): void $iteratedCount++; } - $this->assertSame(['Doctrine 2', 'Symfony 2'], $topics); - $this->assertSame(2, $iteratedCount); + self::assertSame(['Doctrine 2', 'Symfony 2'], $topics); + self::assertSame(2, $iteratedCount); $this->_em->flush(); } @@ -472,18 +472,18 @@ public function testModifiedLimitQuery(): void ->setMaxResults(2) ->getResult(); - $this->assertEquals(2, count($data)); - $this->assertEquals('gblanco1', $data[0]->username); - $this->assertEquals('gblanco2', $data[1]->username); + self::assertEquals(2, count($data)); + self::assertEquals('gblanco1', $data[0]->username); + self::assertEquals('gblanco2', $data[1]->username); $data = $this->_em->createQuery('SELECT u FROM ' . CmsUser::class . ' u') ->setFirstResult(3) ->setMaxResults(2) ->getResult(); - $this->assertEquals(2, count($data)); - $this->assertEquals('gblanco3', $data[0]->username); - $this->assertEquals('gblanco4', $data[1]->username); + self::assertEquals(2, count($data)); + self::assertEquals('gblanco3', $data[0]->username); + self::assertEquals('gblanco4', $data[1]->username); $data = $this->_em->createQuery('SELECT u FROM ' . CmsUser::class . ' u') ->setFirstResult(3) @@ -497,10 +497,10 @@ public function testSupportsQueriesWithEntityNamespaces(): void try { $query = $this->_em->createQuery('UPDATE CMS:CmsUser u SET u.name = ?1'); - $this->assertEquals('UPDATE cms_users SET name = ?', $query->getSQL()); + self::assertEquals('UPDATE cms_users SET name = ?', $query->getSQL()); $query->free(); } catch (Exception $e) { - $this->fail($e->getMessage()); + self::fail($e->getMessage()); } $this->_em->getConfiguration()->setEntityNamespaces([]); @@ -529,11 +529,11 @@ public function testEntityParameters(): void ->setParameter('topic', 'dr. dolittle'); $result = $q->getResult(); - $this->assertEquals(1, count($result)); - $this->assertInstanceOf(CmsArticle::class, $result[0]); - $this->assertEquals('dr. dolittle', $result[0]->topic); - $this->assertInstanceOf(Proxy::class, $result[0]->user); - $this->assertFalse($result[0]->user->__isInitialized__); + self::assertEquals(1, count($result)); + self::assertInstanceOf(CmsArticle::class, $result[0]); + self::assertEquals('dr. dolittle', $result[0]->topic); + self::assertInstanceOf(Proxy::class, $result[0]->user); + self::assertFalse($result[0]->user->__isInitialized__); } /** @@ -561,9 +561,9 @@ public function testEnableFetchEagerMode(): void ->setFetchMode(CmsArticle::class, 'user', ClassMetadata::FETCH_EAGER) ->getResult(); - $this->assertEquals(10, count($articles)); + self::assertEquals(10, count($articles)); foreach ($articles as $article) { - $this->assertNotInstanceOf(Proxy::class, $article); + self::assertNotInstanceOf(Proxy::class, $article); } } @@ -583,12 +583,12 @@ public function testgetOneOrNullResult(): void $query = $this->_em->createQuery('select u from ' . CmsUser::class . " u where u.username = 'gblanco'"); $fetchedUser = $query->getOneOrNullResult(); - $this->assertInstanceOf(CmsUser::class, $fetchedUser); - $this->assertEquals('gblanco', $fetchedUser->username); + self::assertInstanceOf(CmsUser::class, $fetchedUser); + self::assertEquals('gblanco', $fetchedUser->username); $query = $this->_em->createQuery('select u.username from ' . CmsUser::class . " u where u.username = 'gblanco'"); $fetchedUsername = $query->getOneOrNullResult(Query::HYDRATE_SINGLE_SCALAR); - $this->assertEquals('gblanco', $fetchedUsername); + self::assertEquals('gblanco', $fetchedUsername); } /** @@ -622,10 +622,10 @@ public function testgetOneOrNullResultSeveralRows(): void public function testgetOneOrNullResultNoRows(): void { $query = $this->_em->createQuery('select u from Doctrine\Tests\Models\CMS\CmsUser u'); - $this->assertNull($query->getOneOrNullResult()); + self::assertNull($query->getOneOrNullResult()); $query = $this->_em->createQuery("select u.username from Doctrine\Tests\Models\CMS\CmsUser u where u.username = 'gblanco'"); - $this->assertNull($query->getOneOrNullResult(Query::HYDRATE_SCALAR)); + self::assertNull($query->getOneOrNullResult(Query::HYDRATE_SCALAR)); } /** @@ -663,7 +663,7 @@ public function testParameterOrder(): void )); $result = $query->getResult(); - $this->assertEquals(3, count($result)); + self::assertEquals(3, count($result)); } public function testDqlWithAutoInferOfParameters(): void @@ -694,7 +694,7 @@ public function testDqlWithAutoInferOfParameters(): void $users = $query->execute(); - $this->assertEquals(2, count($users)); + self::assertEquals(2, count($users)); } public function testQueryBuilderWithStringWhereClauseContainingOrAndConditionalPrimary(): void @@ -708,7 +708,7 @@ public function testQueryBuilderWithStringWhereClauseContainingOrAndConditionalP $query = $qb->getQuery(); $users = $query->execute(); - $this->assertEquals(0, count($users)); + self::assertEquals(0, count($users)); } public function testQueryWithArrayOfEntitiesAsParameter(): void @@ -740,7 +740,7 @@ public function testQueryWithArrayOfEntitiesAsParameter(): void $users = $query->execute(); - $this->assertEquals(2, count($users)); + self::assertEquals(2, count($users)); } public function testQueryWithHiddenAsSelectExpression(): void @@ -769,8 +769,8 @@ public function testQueryWithHiddenAsSelectExpression(): void $query = $this->_em->createQuery('SELECT u, (SELECT COUNT(u2.id) FROM Doctrine\Tests\Models\CMS\CmsUser u2) AS HIDDEN total FROM Doctrine\Tests\Models\CMS\CmsUser u'); $users = $query->execute(); - $this->assertEquals(3, count($users)); - $this->assertInstanceOf(CmsUser::class, $users[0]); + self::assertEquals(3, count($users)); + self::assertInstanceOf(CmsUser::class, $users[0]); } /** @@ -790,7 +790,7 @@ public function testSetParameterBindingSingleIdentifierObject(): void $q = $this->_em->createQuery('SELECT DISTINCT u from Doctrine\Tests\Models\CMS\CmsUser u WHERE u.id = ?1'); $q->setParameter(1, $userC); - $this->assertEquals($userC, $q->getParameter(1)->getValue()); + self::assertEquals($userC, $q->getParameter(1)->getValue()); // Parameter is not converted before, but it should be converted during execution. Test should not fail here $q->getResult(); @@ -832,18 +832,18 @@ public function testSetCollectionParameterBindingSingleIdentifierObject(): void $q->setParameter('users', $userCollection); $users = $q->execute(); - $this->assertEquals(3, count($users)); - $this->assertInstanceOf(CmsUser::class, $users[0]); - $this->assertInstanceOf(CmsUser::class, $users[1]); - $this->assertInstanceOf(CmsUser::class, $users[2]); + self::assertEquals(3, count($users)); + self::assertInstanceOf(CmsUser::class, $users[0]); + self::assertInstanceOf(CmsUser::class, $users[1]); + self::assertInstanceOf(CmsUser::class, $users[2]); $resultUser1 = $users[0]; $resultUser2 = $users[1]; $resultUser3 = $users[2]; - $this->assertEquals($u1->username, $resultUser1->username); - $this->assertEquals($u2->username, $resultUser2->username); - $this->assertEquals($u3->username, $resultUser3->username); + self::assertEquals($u1->username, $resultUser1->username); + self::assertEquals($u2->username, $resultUser2->username); + self::assertEquals($u3->username, $resultUser3->username); } /** @@ -863,9 +863,9 @@ public function testUnexpectedResultException(): void try { $this->_em->createQuery($dql)->getSingleResult(); - $this->fail('Expected exception "\Doctrine\ORM\NoResultException".'); + self::fail('Expected exception "\Doctrine\ORM\NoResultException".'); } catch (UnexpectedResultException $exc) { - $this->assertInstanceOf('\Doctrine\ORM\NoResultException', $exc); + self::assertInstanceOf('\Doctrine\ORM\NoResultException', $exc); } $this->_em->persist($u1); @@ -875,9 +875,9 @@ public function testUnexpectedResultException(): void try { $this->_em->createQuery($dql)->getSingleResult(); - $this->fail('Expected exception "\Doctrine\ORM\NonUniqueResultException".'); + self::fail('Expected exception "\Doctrine\ORM\NonUniqueResultException".'); } catch (UnexpectedResultException $exc) { - $this->assertInstanceOf('\Doctrine\ORM\NonUniqueResultException', $exc); + self::assertInstanceOf('\Doctrine\ORM\NonUniqueResultException', $exc); } } @@ -909,9 +909,9 @@ public function testMultipleJoinComponentsUsingInnerJoin(): void '); $users = $query->execute(); - $this->assertEquals(2, count($users)); - $this->assertInstanceOf(CmsUser::class, $users[0]); - $this->assertInstanceOf(CmsPhonenumber::class, $users[1]); + self::assertEquals(2, count($users)); + self::assertInstanceOf(CmsUser::class, $users[0]); + self::assertInstanceOf(CmsPhonenumber::class, $users[1]); } public function testMultipleJoinComponentsUsingLeftJoin(): void @@ -942,10 +942,10 @@ public function testMultipleJoinComponentsUsingLeftJoin(): void '); $users = $query->execute(); - $this->assertEquals(4, count($users)); - $this->assertInstanceOf(CmsUser::class, $users[0]); - $this->assertInstanceOf(CmsPhonenumber::class, $users[1]); - $this->assertInstanceOf(CmsUser::class, $users[2]); - $this->assertNull($users[3]); + self::assertEquals(4, count($users)); + self::assertInstanceOf(CmsUser::class, $users[0]); + self::assertInstanceOf(CmsPhonenumber::class, $users[1]); + self::assertInstanceOf(CmsUser::class, $users[2]); + self::assertNull($users[3]); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/ReadOnlyTest.php b/tests/Doctrine/Tests/ORM/Functional/ReadOnlyTest.php index 834b37d3e22..5743e40f61e 100644 --- a/tests/Doctrine/Tests/ORM/Functional/ReadOnlyTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/ReadOnlyTest.php @@ -48,8 +48,8 @@ public function testReadOnlyEntityNeverChangeTracked(): void $this->_em->clear(); $dbReadOnly = $this->_em->find(ReadOnlyEntity::class, $readOnly->id); - $this->assertEquals('Test1', $dbReadOnly->name); - $this->assertEquals(1234, $dbReadOnly->numericValue); + self::assertEquals('Test1', $dbReadOnly->name); + self::assertEquals(1234, $dbReadOnly->numericValue); } /** @@ -64,7 +64,7 @@ public function testClearReadOnly(): void $this->_em->clear(); - $this->assertFalse($this->_em->getUnitOfWork()->isReadOnly($readOnly)); + self::assertFalse($this->_em->getUnitOfWork()->isReadOnly($readOnly)); } /** @@ -79,7 +79,7 @@ public function testClearEntitiesReadOnly(): void $this->_em->clear(get_class($readOnly)); - $this->assertFalse($this->_em->getUnitOfWork()->isReadOnly($readOnly)); + self::assertFalse($this->_em->getUnitOfWork()->isReadOnly($readOnly)); } public function testReadOnlyQueryHint(): void @@ -99,7 +99,7 @@ public function testReadOnlyQueryHint(): void $user = $query->getSingleResult(); - $this->assertTrue($this->_em->getUnitOfWork()->isReadOnly($user)); + self::assertTrue($this->_em->getUnitOfWork()->isReadOnly($user)); } public function testNotReadOnlyIfObjectWasProxyBefore(): void @@ -121,7 +121,7 @@ public function testNotReadOnlyIfObjectWasProxyBefore(): void $user = $query->getSingleResult(); - $this->assertFalse($this->_em->getUnitOfWork()->isReadOnly($user)); + self::assertFalse($this->_em->getUnitOfWork()->isReadOnly($user)); } public function testNotReadOnlyIfObjectWasKnownBefore(): void @@ -143,7 +143,7 @@ public function testNotReadOnlyIfObjectWasKnownBefore(): void $user = $query->getSingleResult(); - $this->assertFalse($this->_em->getUnitOfWork()->isReadOnly($user)); + self::assertFalse($this->_em->getUnitOfWork()->isReadOnly($user)); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/ReferenceProxyTest.php b/tests/Doctrine/Tests/ORM/Functional/ReferenceProxyTest.php index 97a58c512e6..2a852c34eea 100644 --- a/tests/Doctrine/Tests/ORM/Functional/ReferenceProxyTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/ReferenceProxyTest.php @@ -68,7 +68,7 @@ public function testLazyLoadsFieldValuesFromDatabase(): void $id = $this->createProduct(); $productProxy = $this->_em->getReference(ECommerceProduct::class, ['id' => $id]); - $this->assertEquals('Doctrine Cookbook', $productProxy->getName()); + self::assertEquals('Doctrine Cookbook', $productProxy->getName()); } /** @@ -81,7 +81,7 @@ public function testAccessMetatadaForProxy(): void $entity = $this->_em->getReference(ECommerceProduct::class, $id); $class = $this->_em->getClassMetadata(get_class($entity)); - $this->assertEquals(ECommerceProduct::class, $class->name); + self::assertEquals(ECommerceProduct::class, $class->name); } /** @@ -94,8 +94,8 @@ public function testReferenceFind(): void $entity = $this->_em->getReference(ECommerceProduct::class, $id); $entity2 = $this->_em->find(ECommerceProduct::class, $id); - $this->assertSame($entity, $entity2); - $this->assertEquals('Doctrine Cookbook', $entity2->getName()); + self::assertSame($entity, $entity2); + self::assertEquals('Doctrine Cookbook', $entity2->getName()); } /** @@ -111,16 +111,16 @@ public function testCloneProxy(): void $clone = clone $entity; assert($clone instanceof ECommerceProduct); - $this->assertEquals($id, $entity->getId()); - $this->assertEquals('Doctrine Cookbook', $entity->getName()); + self::assertEquals($id, $entity->getId()); + self::assertEquals('Doctrine Cookbook', $entity->getName()); - $this->assertFalse($this->_em->contains($clone), 'Cloning a reference proxy should return an unmanaged/detached entity.'); - $this->assertEquals($id, $clone->getId(), 'Cloning a reference proxy should return same id.'); - $this->assertEquals('Doctrine Cookbook', $clone->getName(), 'Cloning a reference proxy should return same product name.'); + self::assertFalse($this->_em->contains($clone), 'Cloning a reference proxy should return an unmanaged/detached entity.'); + self::assertEquals($id, $clone->getId(), 'Cloning a reference proxy should return same id.'); + self::assertEquals('Doctrine Cookbook', $clone->getName(), 'Cloning a reference proxy should return same product name.'); // domain logic, Product::__clone sets isCloned public property - $this->assertTrue($clone->isCloned); - $this->assertFalse($entity->isCloned); + self::assertTrue($clone->isCloned); + self::assertFalse($entity->isCloned); } /** @@ -133,9 +133,9 @@ public function testInitializeProxy(): void $entity = $this->_em->getReference(ECommerceProduct::class, $id); assert($entity instanceof ECommerceProduct); - $this->assertFalse($entity->__isInitialized__, 'Pre-Condition: Object is unitialized proxy.'); + self::assertFalse($entity->__isInitialized__, 'Pre-Condition: Object is unitialized proxy.'); $this->_em->getUnitOfWork()->initializeObject($entity); - $this->assertTrue($entity->__isInitialized__, 'Should be initialized after called UnitOfWork::initializeObject()'); + self::assertTrue($entity->__isInitialized__, 'Should be initialized after called UnitOfWork::initializeObject()'); } /** @@ -153,7 +153,7 @@ public function testInitializeChangeAndFlushProxy(): void $this->_em->clear(); $entity = $this->_em->getReference(ECommerceProduct::class, $id); - $this->assertEquals('Doctrine 2 Cookbook', $entity->getName()); + self::assertEquals('Doctrine 2 Cookbook', $entity->getName()); } /** @@ -166,11 +166,11 @@ public function testWakeupCalledOnProxy(): void $entity = $this->_em->getReference(ECommerceProduct::class, $id); assert($entity instanceof ECommerceProduct); - $this->assertFalse($entity->wakeUp); + self::assertFalse($entity->wakeUp); $entity->setName('Doctrine 2 Cookbook'); - $this->assertTrue($entity->wakeUp, 'Loading the proxy should call __wakeup().'); + self::assertTrue($entity->wakeUp, 'Loading the proxy should call __wakeup().'); } public function testDoNotInitializeProxyOnGettingTheIdentifier(): void @@ -180,9 +180,9 @@ public function testDoNotInitializeProxyOnGettingTheIdentifier(): void $entity = $this->_em->getReference(ECommerceProduct::class, $id); assert($entity instanceof ECommerceProduct); - $this->assertFalse($entity->__isInitialized__, 'Pre-Condition: Object is unitialized proxy.'); - $this->assertEquals($id, $entity->getId()); - $this->assertFalse($entity->__isInitialized__, "Getting the identifier doesn't initialize the proxy."); + self::assertFalse($entity->__isInitialized__, 'Pre-Condition: Object is unitialized proxy.'); + self::assertEquals($id, $entity->getId()); + self::assertFalse($entity->__isInitialized__, "Getting the identifier doesn't initialize the proxy."); } /** @@ -195,9 +195,9 @@ public function testDoNotInitializeProxyOnGettingTheIdentifierDDC1625(): void $entity = $this->_em->getReference(CompanyAuction::class, $id); assert($entity instanceof CompanyAuction); - $this->assertFalse($entity->__isInitialized__, 'Pre-Condition: Object is unitialized proxy.'); - $this->assertEquals($id, $entity->getId()); - $this->assertFalse($entity->__isInitialized__, "Getting the identifier doesn't initialize the proxy when extending."); + self::assertFalse($entity->__isInitialized__, 'Pre-Condition: Object is unitialized proxy.'); + self::assertEquals($id, $entity->getId()); + self::assertFalse($entity->__isInitialized__, "Getting the identifier doesn't initialize the proxy when extending."); } public function testDoNotInitializeProxyOnGettingTheIdentifierAndReturnTheRightType(): void @@ -217,10 +217,10 @@ public function testDoNotInitializeProxyOnGettingTheIdentifierAndReturnTheRightT $product = $this->_em->getRepository(ECommerceProduct::class)->find($product->getId()); $entity = $product->getShipping(); - $this->assertFalse($entity->__isInitialized__, 'Pre-Condition: Object is unitialized proxy.'); - $this->assertEquals($id, $entity->getId()); - $this->assertSame($id, $entity->getId(), "Check that the id's are the same value, and type."); - $this->assertFalse($entity->__isInitialized__, "Getting the identifier doesn't initialize the proxy."); + self::assertFalse($entity->__isInitialized__, 'Pre-Condition: Object is unitialized proxy.'); + self::assertEquals($id, $entity->getId()); + self::assertSame($id, $entity->getId(), "Check that the id's are the same value, and type."); + self::assertFalse($entity->__isInitialized__, "Getting the identifier doesn't initialize the proxy."); } public function testInitializeProxyOnGettingSomethingOtherThanTheIdentifier(): void @@ -230,9 +230,9 @@ public function testInitializeProxyOnGettingSomethingOtherThanTheIdentifier(): v $entity = $this->_em->getReference(ECommerceProduct::class, $id); assert($entity instanceof ECommerceProduct); - $this->assertFalse($entity->__isInitialized__, 'Pre-Condition: Object is unitialized proxy.'); - $this->assertEquals('Doctrine Cookbook', $entity->getName()); - $this->assertTrue($entity->__isInitialized__, 'Getting something other than the identifier initializes the proxy.'); + self::assertFalse($entity->__isInitialized__, 'Pre-Condition: Object is unitialized proxy.'); + self::assertEquals('Doctrine Cookbook', $entity->getName()); + self::assertTrue($entity->__isInitialized__, 'Getting something other than the identifier initializes the proxy.'); } /** @@ -246,16 +246,16 @@ public function testCommonPersistenceProxy(): void assert($entity instanceof ECommerceProduct); $className = ClassUtils::getClass($entity); - $this->assertInstanceOf(Proxy::class, $entity); - $this->assertFalse($entity->__isInitialized()); - $this->assertEquals(ECommerceProduct::class, $className); + self::assertInstanceOf(Proxy::class, $entity); + self::assertFalse($entity->__isInitialized()); + self::assertEquals(ECommerceProduct::class, $className); $restName = str_replace($this->_em->getConfiguration()->getProxyNamespace(), '', get_class($entity)); $restName = substr(get_class($entity), strlen($this->_em->getConfiguration()->getProxyNamespace()) + 1); $proxyFileName = $this->_em->getConfiguration()->getProxyDir() . DIRECTORY_SEPARATOR . str_replace('\\', '', $restName) . '.php'; - $this->assertTrue(file_exists($proxyFileName), 'Proxy file name cannot be found generically.'); + self::assertTrue(file_exists($proxyFileName), 'Proxy file name cannot be found generically.'); $entity->__load(); - $this->assertTrue($entity->__isInitialized()); + self::assertTrue($entity->__isInitialized()); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/ResultCacheTest.php b/tests/Doctrine/Tests/ORM/Functional/ResultCacheTest.php index 7ba80b9c482..375b1baa363 100644 --- a/tests/Doctrine/Tests/ORM/Functional/ResultCacheTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/ResultCacheTest.php @@ -30,7 +30,7 @@ class ResultCacheTest extends OrmFunctionalTestCase protected function setUp(): void { if (! class_exists(ArrayCache::class)) { - $this->markTestSkipped('Test only applies with doctrine/cache 1.x'); + self::markTestSkipped('Test only applies with doctrine/cache 1.x'); } $this->cacheDataReflection = new ReflectionProperty(ArrayCache::class, 'data'); @@ -61,13 +61,13 @@ public function testResultCache(): void $query->setResultCacheDriver($cache)->setResultCacheId('my_cache_id'); - $this->assertFalse($cache->contains('my_cache_id')); + self::assertFalse($cache->contains('my_cache_id')); $users = $query->getResult(); - $this->assertTrue($cache->contains('my_cache_id')); - $this->assertEquals(1, count($users)); - $this->assertEquals('Roman', $users[0]->name); + self::assertTrue($cache->contains('my_cache_id')); + self::assertEquals(1, count($users)); + self::assertEquals('Roman', $users[0]->name); $this->_em->clear(); @@ -76,9 +76,9 @@ public function testResultCache(): void $users = $query2->getResult(); - $this->assertTrue($cache->contains('my_cache_id')); - $this->assertEquals(1, count($users)); - $this->assertEquals('Roman', $users[0]->name); + self::assertTrue($cache->contains('my_cache_id')); + self::assertEquals(1, count($users)); + self::assertEquals('Roman', $users[0]->name); } public function testSetResultCacheId(): void @@ -89,11 +89,11 @@ public function testSetResultCacheId(): void $query->setResultCacheDriver($cache); $query->setResultCacheId('testing_result_cache_id'); - $this->assertFalse($cache->contains('testing_result_cache_id')); + self::assertFalse($cache->contains('testing_result_cache_id')); $users = $query->getResult(); - $this->assertTrue($cache->contains('testing_result_cache_id')); + self::assertTrue($cache->contains('testing_result_cache_id')); } public function testUseResultCacheTrue(): void @@ -106,7 +106,7 @@ public function testUseResultCacheTrue(): void $query->setResultCacheId('testing_result_cache_id'); $users = $query->getResult(); - $this->assertTrue($cache->contains('testing_result_cache_id')); + self::assertTrue($cache->contains('testing_result_cache_id')); $this->_em->getConfiguration()->setResultCacheImpl(new ArrayCache()); } @@ -121,7 +121,7 @@ public function testUseResultCacheFalse(): void $query->useResultCache(false); $query->getResult(); - $this->assertFalse($cache->contains('testing_result_cache_id')); + self::assertFalse($cache->contains('testing_result_cache_id')); $this->_em->getConfiguration()->setResultCacheImpl(new ArrayCache()); } @@ -144,7 +144,7 @@ public function testUseResultCacheParams(): void $query->setParameter(1, 2); $query->getResult(); - $this->assertCount( + self::assertCount( $sqlCount + 2, $this->_sqlLoggerStack->queries, 'Two non-cached queries.' @@ -156,7 +156,7 @@ public function testUseResultCacheParams(): void $query->setParameter(1, 2); $query->getResult(); - $this->assertCount( + self::assertCount( $sqlCount + 2, $this->_sqlLoggerStack->queries, 'The next two sql queries should have been cached, but were not.' @@ -173,7 +173,7 @@ public function testEnableResultCache(): void $query->setResultCacheId('testing_result_cache_id'); $query->getResult(); - $this->assertTrue($cache->contains('testing_result_cache_id')); + self::assertTrue($cache->contains('testing_result_cache_id')); $this->_em->getConfiguration()->setResultCacheImpl(new ArrayCache()); } @@ -191,11 +191,11 @@ public function testEnableResultCacheWithIterable(): void $this->_em->clear(); - $this->assertCount( + self::assertCount( $expectedSQLCount, $this->_sqlLoggerStack->queries ); - $this->assertTrue($cache->contains('testing_iterable_result_cache_id')); + self::assertTrue($cache->contains('testing_iterable_result_cache_id')); $query = $this->_em->createQuery('select ux from Doctrine\Tests\Models\CMS\CmsUser ux'); $query->enableResultCache(); @@ -203,7 +203,7 @@ public function testEnableResultCacheWithIterable(): void $query->setResultCacheId('testing_iterable_result_cache_id'); iterator_to_array($query->toIterable()); - $this->assertCount( + self::assertCount( $expectedSQLCount, $this->_sqlLoggerStack->queries, 'Expected query to be cached' @@ -230,7 +230,7 @@ public function testEnableResultCacheParams(): void $query->setParameter(1, 2); $query->getResult(); - $this->assertCount( + self::assertCount( $sqlCount + 2, $this->_sqlLoggerStack->queries, 'Two non-cached queries.' @@ -242,7 +242,7 @@ public function testEnableResultCacheParams(): void $query->setParameter(1, 2); $query->getResult(); - $this->assertCount( + self::assertCount( $sqlCount + 2, $this->_sqlLoggerStack->queries, 'The next two sql queries should have been cached, but were not.' @@ -259,7 +259,7 @@ public function testDisableResultCache(): void $query->disableResultCache(); $query->getResult(); - $this->assertFalse($cache->contains('testing_result_cache_id')); + self::assertFalse($cache->contains('testing_result_cache_id')); $this->_em->getConfiguration()->setResultCacheImpl(new ArrayCache()); } @@ -276,11 +276,11 @@ public function testNativeQueryResultCaching(): NativeQuery $query->setParameter(1, 10); $query->setResultCacheDriver($cache)->enableResultCache(); - $this->assertEquals(0, $this->getCacheSize($cache)); + self::assertEquals(0, $this->getCacheSize($cache)); $query->getResult(); - $this->assertEquals(1, $this->getCacheSize($cache)); + self::assertEquals(1, $this->getCacheSize($cache)); return $query; } @@ -296,7 +296,7 @@ public function testResultCacheNotDependsOnQueryHints(NativeQuery $query): void $query->setHint('foo', 'bar'); $query->getResult(); - $this->assertEquals($cacheCount, $this->getCacheSize($cache)); + self::assertEquals($cacheCount, $this->getCacheSize($cache)); } /** @@ -310,7 +310,7 @@ public function testResultCacheDependsOnParameters(NativeQuery $query): void $query->setParameter(1, 50); $query->getResult(); - $this->assertEquals($cacheCount + 1, $this->getCacheSize($cache)); + self::assertEquals($cacheCount + 1, $this->getCacheSize($cache)); } /** @@ -321,10 +321,10 @@ public function testResultCacheNotDependsOnHydrationMode(NativeQuery $query): vo $cache = $query->getResultCacheDriver(); $cacheCount = $this->getCacheSize($cache); - $this->assertNotEquals(Query::HYDRATE_ARRAY, $query->getHydrationMode()); + self::assertNotEquals(Query::HYDRATE_ARRAY, $query->getHydrationMode()); $query->getArrayResult(); - $this->assertEquals($cacheCount, $this->getCacheSize($cache)); + self::assertEquals($cacheCount, $this->getCacheSize($cache)); } /** @@ -361,8 +361,8 @@ public function testResultCacheWithObjectParameter(): void $articles = $query->getResult(); - $this->assertEquals(1, count($articles)); - $this->assertEquals('baz', $articles[0]->topic); + self::assertEquals(1, count($articles)); + self::assertEquals('baz', $articles[0]->topic); $this->_em->clear(); @@ -373,8 +373,8 @@ public function testResultCacheWithObjectParameter(): void $articles = $query2->getResult(); - $this->assertEquals(1, count($articles)); - $this->assertEquals('baz', $articles[0]->topic); + self::assertEquals(1, count($articles)); + self::assertEquals('baz', $articles[0]->topic); $query3 = $this->_em->createQuery('select a from Doctrine\Tests\Models\CMS\CmsArticle a WHERE a.user = ?1'); $query3->setParameter(1, $user2); @@ -383,6 +383,6 @@ public function testResultCacheWithObjectParameter(): void $articles = $query3->getResult(); - $this->assertEquals(0, count($articles)); + self::assertEquals(0, count($articles)); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/SQLFilterTest.php b/tests/Doctrine/Tests/ORM/Functional/SQLFilterTest.php index c720d4ece20..31aae12fa07 100644 --- a/tests/Doctrine/Tests/ORM/Functional/SQLFilterTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/SQLFilterTest.php @@ -105,8 +105,8 @@ public function testConfigureFilter(): void $config->addFilter('locale', '\Doctrine\Tests\ORM\Functional\MyLocaleFilter'); - $this->assertEquals('\Doctrine\Tests\ORM\Functional\MyLocaleFilter', $config->getFilterClassName('locale')); - $this->assertNull($config->getFilterClassName('foo')); + self::assertEquals('\Doctrine\Tests\ORM\Functional\MyLocaleFilter', $config->getFilterClassName('locale')); + self::assertNull($config->getFilterClassName('foo')); } public function testEntityManagerEnableFilter(): void @@ -116,11 +116,11 @@ public function testEntityManagerEnableFilter(): void // Enable an existing filter $filter = $em->getFilters()->enable('locale'); - $this->assertTrue($filter instanceof MyLocaleFilter); + self::assertTrue($filter instanceof MyLocaleFilter); // Enable the filter again $filter2 = $em->getFilters()->enable('locale'); - $this->assertEquals($filter, $filter2); + self::assertEquals($filter, $filter2); // Enable a non-existing filter $exceptionThrown = false; @@ -130,7 +130,7 @@ public function testEntityManagerEnableFilter(): void $exceptionThrown = true; } - $this->assertTrue($exceptionThrown); + self::assertTrue($exceptionThrown); } public function testEntityManagerEnabledFilters(): void @@ -138,14 +138,14 @@ public function testEntityManagerEnabledFilters(): void $em = $this->getEntityManager(); // No enabled filters - $this->assertEquals([], $em->getFilters()->getEnabledFilters()); + self::assertEquals([], $em->getFilters()->getEnabledFilters()); $this->configureFilters($em); $filter = $em->getFilters()->enable('locale'); $filter = $em->getFilters()->enable('soft_delete'); // Two enabled filters - $this->assertEquals(2, count($em->getFilters()->getEnabledFilters())); + self::assertEquals(2, count($em->getFilters()->getEnabledFilters())); } public function testEntityManagerDisableFilter(): void @@ -157,8 +157,8 @@ public function testEntityManagerDisableFilter(): void $filter = $em->getFilters()->enable('locale'); // Disable it - $this->assertEquals($filter, $em->getFilters()->disable('locale')); - $this->assertEquals(0, count($em->getFilters()->getEnabledFilters())); + self::assertEquals($filter, $em->getFilters()->disable('locale')); + self::assertEquals(0, count($em->getFilters()->getEnabledFilters())); // Disable a non-existing filter $exceptionThrown = false; @@ -168,7 +168,7 @@ public function testEntityManagerDisableFilter(): void $exceptionThrown = true; } - $this->assertTrue($exceptionThrown); + self::assertTrue($exceptionThrown); // Disable a non-enabled filter $exceptionThrown = false; @@ -178,7 +178,7 @@ public function testEntityManagerDisableFilter(): void $exceptionThrown = true; } - $this->assertTrue($exceptionThrown); + self::assertTrue($exceptionThrown); } public function testEntityManagerGetFilter(): void @@ -190,7 +190,7 @@ public function testEntityManagerGetFilter(): void $filter = $em->getFilters()->enable('locale'); // Get the filter - $this->assertEquals($filter, $em->getFilters()->getFilter('locale')); + self::assertEquals($filter, $em->getFilters()->getFilter('locale')); // Get a non-enabled filter $exceptionThrown = false; @@ -200,7 +200,7 @@ public function testEntityManagerGetFilter(): void $exceptionThrown = true; } - $this->assertTrue($exceptionThrown); + self::assertTrue($exceptionThrown); } /** @@ -213,14 +213,14 @@ public function testEntityManagerIsFilterEnabled(): void // Check for an enabled filter $em->getFilters()->enable('locale'); - $this->assertTrue($em->getFilters()->isEnabled('locale')); + self::assertTrue($em->getFilters()->isEnabled('locale')); // Check for a disabled filter $em->getFilters()->disable('locale'); - $this->assertFalse($em->getFilters()->isEnabled('locale')); + self::assertFalse($em->getFilters()->isEnabled('locale')); // Check a non-existing filter - $this->assertFalse($em->getFilters()->isEnabled('foo_filter')); + self::assertFalse($em->getFilters()->isEnabled('foo_filter')); } protected function configureFilters($em): void @@ -249,9 +249,9 @@ protected function addMockFilterCollection(EntityManagerInterface $em): FilterCo ->disableOriginalConstructor() ->getMock(); - $em->expects($this->any()) + $em->expects(self::any()) ->method('getFilters') - ->will($this->returnValue($filterCollection)); + ->will(self::returnValue($filterCollection)); return $filterCollection; } @@ -260,26 +260,26 @@ public function testSQLFilterGetSetParameter(): void { // Setup mock connection $conn = $this->getMockConnection(); - $conn->expects($this->once()) + $conn->expects(self::once()) ->method('quote') - ->with($this->equalTo('en')) - ->will($this->returnValue("'en'")); + ->with(self::equalTo('en')) + ->will(self::returnValue("'en'")); $em = $this->getMockEntityManager(); - $em->expects($this->once()) + $em->expects(self::once()) ->method('getConnection') - ->will($this->returnValue($conn)); + ->will(self::returnValue($conn)); $filterCollection = $this->addMockFilterCollection($em); $filterCollection - ->expects($this->once()) + ->expects(self::once()) ->method('setFiltersStateDirty'); $filter = new MyLocaleFilter($em); $filter->setParameter('locale', 'en', Types::STRING); - $this->assertEquals("'en'", $filter->getParameter('locale')); + self::assertEquals("'en'", $filter->getParameter('locale')); } /** @@ -292,42 +292,42 @@ public function testSQLFilterGetConnection(): void $conn = $this->getMockConnection(); $em = $this->getMockEntityManager(); - $em->expects($this->once()) + $em->expects(self::once()) ->method('getConnection') - ->will($this->returnValue($conn)); + ->will(self::returnValue($conn)); $filter = new MyLocaleFilter($em); $reflMethod = new ReflectionMethod(SQLFilter::class, 'getConnection'); $reflMethod->setAccessible(true); - $this->assertSame($conn, $reflMethod->invoke($filter)); + self::assertSame($conn, $reflMethod->invoke($filter)); } public function testSQLFilterSetParameterInfersType(): void { // Setup mock connection $conn = $this->getMockConnection(); - $conn->expects($this->once()) + $conn->expects(self::once()) ->method('quote') - ->with($this->equalTo('en')) - ->will($this->returnValue("'en'")); + ->with(self::equalTo('en')) + ->will(self::returnValue("'en'")); $em = $this->getMockEntityManager(); - $em->expects($this->once()) + $em->expects(self::once()) ->method('getConnection') - ->will($this->returnValue($conn)); + ->will(self::returnValue($conn)); $filterCollection = $this->addMockFilterCollection($em); $filterCollection - ->expects($this->once()) + ->expects(self::once()) ->method('setFiltersStateDirty'); $filter = new MyLocaleFilter($em); $filter->setParameter('locale', 'en'); - $this->assertEquals("'en'", $filter->getParameter('locale')); + self::assertEquals("'en'", $filter->getParameter('locale')); } public function testSQLFilterSetArrayParameterInfersType(): void @@ -335,24 +335,24 @@ public function testSQLFilterSetArrayParameterInfersType(): void // Setup mock connection $conn = $this->getMockConnection(); $conn->method('quote') - ->will($this->returnCallback(static function ($value) { + ->will(self::returnCallback(static function ($value) { return "'" . $value . "'"; })); $em = $this->getMockEntityManager(); $em->method('getConnection') - ->will($this->returnValue($conn)); + ->will(self::returnValue($conn)); $filterCollection = $this->addMockFilterCollection($em); $filterCollection - ->expects($this->once()) + ->expects(self::once()) ->method('setFiltersStateDirty'); $filter = new MyLocaleFilter($em); $filter->setParameterList('locale', ['en', 'es']); - $this->assertEquals("'en','es'", $filter->getParameterList('locale')); + self::assertEquals("'en','es'", $filter->getParameterList('locale')); } public function testSQLFilterAddConstraint(): void @@ -366,11 +366,11 @@ public function testSQLFilterAddConstraint(): void // Test for an entity that gets extra filter data $targetEntity->name = 'MyEntity\SoftDeleteNewsItem'; - $this->assertEquals('t1_.deleted = 0', $filter->addFilterConstraint($targetEntity, 't1_')); + self::assertEquals('t1_.deleted = 0', $filter->addFilterConstraint($targetEntity, 't1_')); // Test for an entity that doesn't get extra filter data $targetEntity->name = 'MyEntity\NoSoftDeleteNewsItem'; - $this->assertEquals('', $filter->addFilterConstraint($targetEntity, 't1_')); + self::assertEquals('', $filter->addFilterConstraint($targetEntity, 't1_')); } public function testSQLFilterToString(): void @@ -391,14 +391,14 @@ public function testSQLFilterToString(): void 'locale' => ['value' => 'en', 'type' => Types::STRING, 'is_list' => false], ]; - $this->assertEquals(serialize($parameters), '' . $filter); - $this->assertEquals('' . $filter, '' . $filter2); + self::assertEquals(serialize($parameters), '' . $filter); + self::assertEquals('' . $filter, '' . $filter2); } public function testQueryCacheDependsOnFilters(): void { if (! class_exists(ArrayCache::class)) { - $this->markTestSkipped('Test only applies with doctrine/cache 1.x'); + self::markTestSkipped('Test only applies with doctrine/cache 1.x'); } $cacheDataReflection = new ReflectionProperty(ArrayCache::class, 'data'); @@ -410,18 +410,18 @@ public function testQueryCacheDependsOnFilters(): void $query->setQueryCacheDriver($cache); $query->getResult(); - $this->assertEquals(1, count($cacheDataReflection->getValue($cache))); + self::assertEquals(1, count($cacheDataReflection->getValue($cache))); $conf = $this->_em->getConfiguration(); $conf->addFilter('locale', '\Doctrine\Tests\ORM\Functional\MyLocaleFilter'); $this->_em->getFilters()->enable('locale'); $query->getResult(); - $this->assertEquals(2, count($cacheDataReflection->getValue($cache))); + self::assertEquals(2, count($cacheDataReflection->getValue($cache))); // Another time doesn't add another cache entry $query->getResult(); - $this->assertEquals(2, count($cacheDataReflection->getValue($cache))); + self::assertEquals(2, count($cacheDataReflection->getValue($cache))); } public function testQueryGenerationDependsOnFilters(): void @@ -434,47 +434,47 @@ public function testQueryGenerationDependsOnFilters(): void $this->_em->getFilters()->enable('country') ->setParameterList('country', ['en'], Types::STRING); - $this->assertNotEquals($firstSQLQuery, $query->getSQL()); + self::assertNotEquals($firstSQLQuery, $query->getSQL()); } public function testRepositoryFind(): void { $this->loadFixtureData(); - $this->assertNotNull($this->_em->getRepository(CmsGroup::class)->find($this->groupId)); - $this->assertNotNull($this->_em->getRepository(CmsGroup::class)->find($this->groupId2)); + self::assertNotNull($this->_em->getRepository(CmsGroup::class)->find($this->groupId)); + self::assertNotNull($this->_em->getRepository(CmsGroup::class)->find($this->groupId2)); $this->useCMSGroupPrefixFilter(); $this->_em->clear(); - $this->assertNotNull($this->_em->getRepository(CmsGroup::class)->find($this->groupId)); - $this->assertNull($this->_em->getRepository(CmsGroup::class)->find($this->groupId2)); + self::assertNotNull($this->_em->getRepository(CmsGroup::class)->find($this->groupId)); + self::assertNull($this->_em->getRepository(CmsGroup::class)->find($this->groupId2)); } public function testRepositoryFindAll(): void { $this->loadFixtureData(); - $this->assertCount(2, $this->_em->getRepository(CmsGroup::class)->findAll()); + self::assertCount(2, $this->_em->getRepository(CmsGroup::class)->findAll()); $this->useCMSGroupPrefixFilter(); $this->_em->clear(); - $this->assertCount(1, $this->_em->getRepository(CmsGroup::class)->findAll()); + self::assertCount(1, $this->_em->getRepository(CmsGroup::class)->findAll()); } public function testRepositoryFindBy(): void { $this->loadFixtureData(); - $this->assertCount(1, $this->_em->getRepository(CmsGroup::class)->findBy( + self::assertCount(1, $this->_em->getRepository(CmsGroup::class)->findBy( ['id' => $this->groupId2] )); $this->useCMSGroupPrefixFilter(); $this->_em->clear(); - $this->assertCount(0, $this->_em->getRepository(CmsGroup::class)->findBy( + self::assertCount(0, $this->_em->getRepository(CmsGroup::class)->findBy( ['id' => $this->groupId2] )); } @@ -483,26 +483,26 @@ public function testRepositoryFindByX(): void { $this->loadFixtureData(); - $this->assertCount(1, $this->_em->getRepository(CmsGroup::class)->findById($this->groupId2)); + self::assertCount(1, $this->_em->getRepository(CmsGroup::class)->findById($this->groupId2)); $this->useCMSGroupPrefixFilter(); $this->_em->clear(); - $this->assertCount(0, $this->_em->getRepository(CmsGroup::class)->findById($this->groupId2)); + self::assertCount(0, $this->_em->getRepository(CmsGroup::class)->findById($this->groupId2)); } public function testRepositoryFindOneBy(): void { $this->loadFixtureData(); - $this->assertNotNull($this->_em->getRepository(CmsGroup::class)->findOneBy( + self::assertNotNull($this->_em->getRepository(CmsGroup::class)->findOneBy( ['id' => $this->groupId2] )); $this->useCMSGroupPrefixFilter(); $this->_em->clear(); - $this->assertNull($this->_em->getRepository(CmsGroup::class)->findOneBy( + self::assertNull($this->_em->getRepository(CmsGroup::class)->findOneBy( ['id' => $this->groupId2] )); } @@ -511,12 +511,12 @@ public function testRepositoryFindOneByX(): void { $this->loadFixtureData(); - $this->assertNotNull($this->_em->getRepository(CmsGroup::class)->findOneById($this->groupId2)); + self::assertNotNull($this->_em->getRepository(CmsGroup::class)->findOneById($this->groupId2)); $this->useCMSGroupPrefixFilter(); $this->_em->clear(); - $this->assertNull($this->_em->getRepository(CmsGroup::class)->findOneById($this->groupId2)); + self::assertNull($this->_em->getRepository(CmsGroup::class)->findOneById($this->groupId2)); } public function testToOneFilter(): void @@ -527,18 +527,18 @@ public function testToOneFilter(): void $query = $this->_em->createQuery('select ux, ua from Doctrine\Tests\Models\CMS\CmsUser ux JOIN ux.address ua'); // We get two users before enabling the filter - $this->assertEquals(2, count($query->getResult())); + self::assertEquals(2, count($query->getResult())); $conf = $this->_em->getConfiguration(); $conf->addFilter('country', '\Doctrine\Tests\ORM\Functional\CMSCountryFilter'); $this->_em->getFilters()->enable('country')->setParameterList('country', ['Germany'], Types::STRING); // We get one user after enabling the filter - $this->assertEquals(1, count($query->getResult())); + self::assertEquals(1, count($query->getResult())); $this->_em->getFilters()->enable('country')->setParameterList('country', ['Germany', 'France'], Types::STRING); - $this->assertEquals(2, count($query->getResult())); + self::assertEquals(2, count($query->getResult())); } public function testManyToManyFilter(): void @@ -547,14 +547,14 @@ public function testManyToManyFilter(): void $query = $this->_em->createQuery('select ux, ug from Doctrine\Tests\Models\CMS\CmsUser ux JOIN ux.groups ug'); // We get two users before enabling the filter - $this->assertEquals(2, count($query->getResult())); + self::assertEquals(2, count($query->getResult())); $conf = $this->_em->getConfiguration(); $conf->addFilter('group_prefix', '\Doctrine\Tests\ORM\Functional\CMSGroupPrefixFilter'); $this->_em->getFilters()->enable('group_prefix')->setParameter('prefix', 'bar_%', Types::STRING); // We get one user after enabling the filter - $this->assertEquals(1, count($query->getResult())); + self::assertEquals(1, count($query->getResult())); } public function testWhereFilter(): void @@ -563,14 +563,14 @@ public function testWhereFilter(): void $query = $this->_em->createQuery('select ug from Doctrine\Tests\Models\CMS\CmsGroup ug WHERE 1=1'); // We get two users before enabling the filter - $this->assertEquals(2, count($query->getResult())); + self::assertEquals(2, count($query->getResult())); $conf = $this->_em->getConfiguration(); $conf->addFilter('group_prefix', '\Doctrine\Tests\ORM\Functional\CMSGroupPrefixFilter'); $this->_em->getFilters()->enable('group_prefix')->setParameter('prefix', 'bar_%', Types::STRING); // We get one user after enabling the filter - $this->assertEquals(1, count($query->getResult())); + self::assertEquals(1, count($query->getResult())); } public function testWhereOrFilter(): void @@ -579,14 +579,14 @@ public function testWhereOrFilter(): void $query = $this->_em->createQuery('select ug from Doctrine\Tests\Models\CMS\CmsGroup ug WHERE 1=1 OR 1=1'); // We get two users before enabling the filter - $this->assertEquals(2, count($query->getResult())); + self::assertEquals(2, count($query->getResult())); $conf = $this->_em->getConfiguration(); $conf->addFilter('group_prefix', '\Doctrine\Tests\ORM\Functional\CMSGroupPrefixFilter'); $this->_em->getFilters()->enable('group_prefix')->setParameter('prefix', 'bar_%', Types::STRING); // We get one user after enabling the filter - $this->assertEquals(1, count($query->getResult())); + self::assertEquals(1, count($query->getResult())); } private function loadLazyFixtureData(): void @@ -609,12 +609,12 @@ public function testOneToManyExtraLazyCountWithFilter(): void $this->loadLazyFixtureData(); $user = $this->_em->find(CmsUser::class, $this->userId); - $this->assertFalse($user->articles->isInitialized()); - $this->assertEquals(2, count($user->articles)); + self::assertFalse($user->articles->isInitialized()); + self::assertEquals(2, count($user->articles)); $this->useCMSArticleTopicFilter(); - $this->assertEquals(1, count($user->articles)); + self::assertEquals(1, count($user->articles)); } public function testOneToManyExtraLazyContainsWithFilter(): void @@ -623,12 +623,12 @@ public function testOneToManyExtraLazyContainsWithFilter(): void $user = $this->_em->find(CmsUser::class, $this->userId); $filteredArticle = $this->_em->find(CmsArticle::class, $this->articleId2); - $this->assertFalse($user->articles->isInitialized()); - $this->assertTrue($user->articles->contains($filteredArticle)); + self::assertFalse($user->articles->isInitialized()); + self::assertTrue($user->articles->contains($filteredArticle)); $this->useCMSArticleTopicFilter(); - $this->assertFalse($user->articles->contains($filteredArticle)); + self::assertFalse($user->articles->contains($filteredArticle)); } public function testOneToManyExtraLazySliceWithFilter(): void @@ -636,12 +636,12 @@ public function testOneToManyExtraLazySliceWithFilter(): void $this->loadLazyFixtureData(); $user = $this->_em->find(CmsUser::class, $this->userId); - $this->assertFalse($user->articles->isInitialized()); - $this->assertEquals(2, count($user->articles->slice(0, 10))); + self::assertFalse($user->articles->isInitialized()); + self::assertEquals(2, count($user->articles->slice(0, 10))); $this->useCMSArticleTopicFilter(); - $this->assertEquals(1, count($user->articles->slice(0, 10))); + self::assertEquals(1, count($user->articles->slice(0, 10))); } private function useCMSGroupPrefixFilter(): void @@ -657,12 +657,12 @@ public function testManyToManyExtraLazyCountWithFilter(): void $user = $this->_em->find(CmsUser::class, $this->userId2); - $this->assertFalse($user->groups->isInitialized()); - $this->assertEquals(2, count($user->groups)); + self::assertFalse($user->groups->isInitialized()); + self::assertEquals(2, count($user->groups)); $this->useCMSGroupPrefixFilter(); - $this->assertEquals(1, count($user->groups)); + self::assertEquals(1, count($user->groups)); } public function testManyToManyExtraLazyContainsWithFilter(): void @@ -671,12 +671,12 @@ public function testManyToManyExtraLazyContainsWithFilter(): void $user = $this->_em->find(CmsUser::class, $this->userId2); $filteredArticle = $this->_em->find(CmsGroup::class, $this->groupId2); - $this->assertFalse($user->groups->isInitialized()); - $this->assertTrue($user->groups->contains($filteredArticle)); + self::assertFalse($user->groups->isInitialized()); + self::assertTrue($user->groups->contains($filteredArticle)); $this->useCMSGroupPrefixFilter(); - $this->assertFalse($user->groups->contains($filteredArticle)); + self::assertFalse($user->groups->contains($filteredArticle)); } public function testManyToManyExtraLazySliceWithFilter(): void @@ -684,12 +684,12 @@ public function testManyToManyExtraLazySliceWithFilter(): void $this->loadLazyFixtureData(); $user = $this->_em->find(CmsUser::class, $this->userId2); - $this->assertFalse($user->groups->isInitialized()); - $this->assertEquals(2, count($user->groups->slice(0, 10))); + self::assertFalse($user->groups->isInitialized()); + self::assertEquals(2, count($user->groups->slice(0, 10))); $this->useCMSGroupPrefixFilter(); - $this->assertEquals(1, count($user->groups->slice(0, 10))); + self::assertEquals(1, count($user->groups->slice(0, 10))); } private function loadFixtureData(): void @@ -760,34 +760,34 @@ public function testJoinSubclassPersisterFilterOnlyOnRootTableWhenFetchingSubEnt { $this->loadCompanyJoinedSubclassFixtureData(); // Persister - $this->assertEquals(2, count($this->_em->getRepository(CompanyManager::class)->findAll())); + self::assertEquals(2, count($this->_em->getRepository(CompanyManager::class)->findAll())); // SQLWalker - $this->assertEquals(2, count($this->_em->createQuery('SELECT cm FROM Doctrine\Tests\Models\Company\CompanyManager cm')->getResult())); + self::assertEquals(2, count($this->_em->createQuery('SELECT cm FROM Doctrine\Tests\Models\Company\CompanyManager cm')->getResult())); // Enable the filter $this->usePersonNameFilter('Guilh%'); $managers = $this->_em->getRepository(CompanyManager::class)->findAll(); - $this->assertEquals(1, count($managers)); - $this->assertEquals('Guilherme', $managers[0]->getName()); + self::assertEquals(1, count($managers)); + self::assertEquals('Guilherme', $managers[0]->getName()); - $this->assertEquals(1, count($this->_em->createQuery('SELECT cm FROM Doctrine\Tests\Models\Company\CompanyManager cm')->getResult())); + self::assertEquals(1, count($this->_em->createQuery('SELECT cm FROM Doctrine\Tests\Models\Company\CompanyManager cm')->getResult())); } public function testJoinSubclassPersisterFilterOnlyOnRootTableWhenFetchingRootEntity(): void { $this->loadCompanyJoinedSubclassFixtureData(); - $this->assertEquals(3, count($this->_em->getRepository(CompanyPerson::class)->findAll())); - $this->assertEquals(3, count($this->_em->createQuery('SELECT cp FROM Doctrine\Tests\Models\Company\CompanyPerson cp')->getResult())); + self::assertEquals(3, count($this->_em->getRepository(CompanyPerson::class)->findAll())); + self::assertEquals(3, count($this->_em->createQuery('SELECT cp FROM Doctrine\Tests\Models\Company\CompanyPerson cp')->getResult())); // Enable the filter $this->usePersonNameFilter('Guilh%'); $persons = $this->_em->getRepository(CompanyPerson::class)->findAll(); - $this->assertEquals(1, count($persons)); - $this->assertEquals('Guilherme', $persons[0]->getName()); + self::assertEquals(1, count($persons)); + self::assertEquals('Guilherme', $persons[0]->getName()); - $this->assertEquals(1, count($this->_em->createQuery('SELECT cp FROM Doctrine\Tests\Models\Company\CompanyPerson cp')->getResult())); + self::assertEquals(1, count($this->_em->createQuery('SELECT cp FROM Doctrine\Tests\Models\Company\CompanyPerson cp')->getResult())); } private function loadCompanyJoinedSubclassFixtureData(): void @@ -818,9 +818,9 @@ public function testSingleTableInheritanceFilterOnlyOnRootTableWhenFetchingSubEn { $this->loadCompanySingleTableInheritanceFixtureData(); // Persister - $this->assertEquals(2, count($this->_em->getRepository(CompanyFlexUltraContract::class)->findAll())); + self::assertEquals(2, count($this->_em->getRepository(CompanyFlexUltraContract::class)->findAll())); // SQLWalker - $this->assertEquals(2, count($this->_em->createQuery('SELECT cfc FROM Doctrine\Tests\Models\Company\CompanyFlexUltraContract cfc')->getResult())); + self::assertEquals(2, count($this->_em->createQuery('SELECT cfc FROM Doctrine\Tests\Models\Company\CompanyFlexUltraContract cfc')->getResult())); // Enable the filter $conf = $this->_em->getConfiguration(); @@ -829,15 +829,15 @@ public function testSingleTableInheritanceFilterOnlyOnRootTableWhenFetchingSubEn ->enable('completed_contract') ->setParameter('completed', true, Types::BOOLEAN); - $this->assertEquals(1, count($this->_em->getRepository(CompanyFlexUltraContract::class)->findAll())); - $this->assertEquals(1, count($this->_em->createQuery('SELECT cfc FROM Doctrine\Tests\Models\Company\CompanyFlexUltraContract cfc')->getResult())); + self::assertEquals(1, count($this->_em->getRepository(CompanyFlexUltraContract::class)->findAll())); + self::assertEquals(1, count($this->_em->createQuery('SELECT cfc FROM Doctrine\Tests\Models\Company\CompanyFlexUltraContract cfc')->getResult())); } public function testSingleTableInheritanceFilterOnlyOnRootTableWhenFetchingRootEntity(): void { $this->loadCompanySingleTableInheritanceFixtureData(); - $this->assertEquals(4, count($this->_em->getRepository(CompanyFlexContract::class)->findAll())); - $this->assertEquals(4, count($this->_em->createQuery('SELECT cfc FROM Doctrine\Tests\Models\Company\CompanyFlexContract cfc')->getResult())); + self::assertEquals(4, count($this->_em->getRepository(CompanyFlexContract::class)->findAll())); + self::assertEquals(4, count($this->_em->createQuery('SELECT cfc FROM Doctrine\Tests\Models\Company\CompanyFlexContract cfc')->getResult())); // Enable the filter $conf = $this->_em->getConfiguration(); @@ -846,8 +846,8 @@ public function testSingleTableInheritanceFilterOnlyOnRootTableWhenFetchingRootE ->enable('completed_contract') ->setParameter('completed', true, Types::BOOLEAN); - $this->assertEquals(2, count($this->_em->getRepository(CompanyFlexContract::class)->findAll())); - $this->assertEquals(2, count($this->_em->createQuery('SELECT cfc FROM Doctrine\Tests\Models\Company\CompanyFlexContract cfc')->getResult())); + self::assertEquals(2, count($this->_em->getRepository(CompanyFlexContract::class)->findAll())); + self::assertEquals(2, count($this->_em->createQuery('SELECT cfc FROM Doctrine\Tests\Models\Company\CompanyFlexContract cfc')->getResult())); } private function loadCompanySingleTableInheritanceFixtureData(): void @@ -912,14 +912,14 @@ public function testManyToManyExtraLazyCountWithFilterOnSTI(): void $manager = $this->_em->find(CompanyManager::class, $this->managerId); - $this->assertFalse($manager->managedContracts->isInitialized()); - $this->assertEquals(4, count($manager->managedContracts)); + self::assertFalse($manager->managedContracts->isInitialized()); + self::assertEquals(4, count($manager->managedContracts)); // Enable the filter $this->useCompletedContractFilter(); - $this->assertFalse($manager->managedContracts->isInitialized()); - $this->assertEquals(2, count($manager->managedContracts)); + self::assertFalse($manager->managedContracts->isInitialized()); + self::assertEquals(2, count($manager->managedContracts)); } public function testManyToManyExtraLazyContainsWithFilterOnSTI(): void @@ -930,16 +930,16 @@ public function testManyToManyExtraLazyContainsWithFilterOnSTI(): void $contract1 = $this->_em->find(CompanyContract::class, $this->contractId1); $contract2 = $this->_em->find(CompanyContract::class, $this->contractId2); - $this->assertFalse($manager->managedContracts->isInitialized()); - $this->assertTrue($manager->managedContracts->contains($contract1)); - $this->assertTrue($manager->managedContracts->contains($contract2)); + self::assertFalse($manager->managedContracts->isInitialized()); + self::assertTrue($manager->managedContracts->contains($contract1)); + self::assertTrue($manager->managedContracts->contains($contract2)); // Enable the filter $this->useCompletedContractFilter(); - $this->assertFalse($manager->managedContracts->isInitialized()); - $this->assertFalse($manager->managedContracts->contains($contract1)); - $this->assertTrue($manager->managedContracts->contains($contract2)); + self::assertFalse($manager->managedContracts->isInitialized()); + self::assertFalse($manager->managedContracts->contains($contract1)); + self::assertTrue($manager->managedContracts->contains($contract2)); } public function testManyToManyExtraLazySliceWithFilterOnSTI(): void @@ -948,14 +948,14 @@ public function testManyToManyExtraLazySliceWithFilterOnSTI(): void $manager = $this->_em->find(CompanyManager::class, $this->managerId); - $this->assertFalse($manager->managedContracts->isInitialized()); - $this->assertEquals(4, count($manager->managedContracts->slice(0, 10))); + self::assertFalse($manager->managedContracts->isInitialized()); + self::assertEquals(4, count($manager->managedContracts->slice(0, 10))); // Enable the filter $this->useCompletedContractFilter(); - $this->assertFalse($manager->managedContracts->isInitialized()); - $this->assertEquals(2, count($manager->managedContracts->slice(0, 10))); + self::assertFalse($manager->managedContracts->isInitialized()); + self::assertEquals(2, count($manager->managedContracts->slice(0, 10))); } private function usePersonNameFilter($name): void @@ -974,14 +974,14 @@ public function testManyToManyExtraLazyCountWithFilterOnCTI(): void $contract = $this->_em->find(CompanyFlexUltraContract::class, $this->contractId1); - $this->assertFalse($contract->managers->isInitialized()); - $this->assertEquals(2, count($contract->managers)); + self::assertFalse($contract->managers->isInitialized()); + self::assertEquals(2, count($contract->managers)); // Enable the filter $this->usePersonNameFilter('Benjamin'); - $this->assertFalse($contract->managers->isInitialized()); - $this->assertEquals(1, count($contract->managers)); + self::assertFalse($contract->managers->isInitialized()); + self::assertEquals(1, count($contract->managers)); } public function testManyToManyExtraLazyContainsWithFilterOnCTI(): void @@ -992,16 +992,16 @@ public function testManyToManyExtraLazyContainsWithFilterOnCTI(): void $manager1 = $this->_em->find(CompanyManager::class, $this->managerId); $manager2 = $this->_em->find(CompanyManager::class, $this->managerId2); - $this->assertFalse($contract->managers->isInitialized()); - $this->assertTrue($contract->managers->contains($manager1)); - $this->assertTrue($contract->managers->contains($manager2)); + self::assertFalse($contract->managers->isInitialized()); + self::assertTrue($contract->managers->contains($manager1)); + self::assertTrue($contract->managers->contains($manager2)); // Enable the filter $this->usePersonNameFilter('Benjamin'); - $this->assertFalse($contract->managers->isInitialized()); - $this->assertFalse($contract->managers->contains($manager1)); - $this->assertTrue($contract->managers->contains($manager2)); + self::assertFalse($contract->managers->isInitialized()); + self::assertFalse($contract->managers->contains($manager1)); + self::assertTrue($contract->managers->contains($manager2)); } public function testManyToManyExtraLazySliceWithFilterOnCTI(): void @@ -1010,14 +1010,14 @@ public function testManyToManyExtraLazySliceWithFilterOnCTI(): void $contract = $this->_em->find(CompanyFlexUltraContract::class, $this->contractId1); - $this->assertFalse($contract->managers->isInitialized()); - $this->assertEquals(2, count($contract->managers->slice(0, 10))); + self::assertFalse($contract->managers->isInitialized()); + self::assertEquals(2, count($contract->managers->slice(0, 10))); // Enable the filter $this->usePersonNameFilter('Benjamin'); - $this->assertFalse($contract->managers->isInitialized()); - $this->assertEquals(1, count($contract->managers->slice(0, 10))); + self::assertFalse($contract->managers->isInitialized()); + self::assertEquals(1, count($contract->managers->slice(0, 10))); } public function testOneToManyExtraLazyCountWithFilterOnSTI(): void @@ -1026,14 +1026,14 @@ public function testOneToManyExtraLazyCountWithFilterOnSTI(): void $manager = $this->_em->find(CompanyManager::class, $this->managerId); - $this->assertFalse($manager->soldContracts->isInitialized()); - $this->assertEquals(2, count($manager->soldContracts)); + self::assertFalse($manager->soldContracts->isInitialized()); + self::assertEquals(2, count($manager->soldContracts)); // Enable the filter $this->useCompletedContractFilter(); - $this->assertFalse($manager->soldContracts->isInitialized()); - $this->assertEquals(1, count($manager->soldContracts)); + self::assertFalse($manager->soldContracts->isInitialized()); + self::assertEquals(1, count($manager->soldContracts)); } public function testOneToManyExtraLazyContainsWithFilterOnSTI(): void @@ -1044,16 +1044,16 @@ public function testOneToManyExtraLazyContainsWithFilterOnSTI(): void $contract1 = $this->_em->find(CompanyContract::class, $this->contractId1); $contract2 = $this->_em->find(CompanyContract::class, $this->contractId2); - $this->assertFalse($manager->soldContracts->isInitialized()); - $this->assertTrue($manager->soldContracts->contains($contract1)); - $this->assertTrue($manager->soldContracts->contains($contract2)); + self::assertFalse($manager->soldContracts->isInitialized()); + self::assertTrue($manager->soldContracts->contains($contract1)); + self::assertTrue($manager->soldContracts->contains($contract2)); // Enable the filter $this->useCompletedContractFilter(); - $this->assertFalse($manager->soldContracts->isInitialized()); - $this->assertFalse($manager->soldContracts->contains($contract1)); - $this->assertTrue($manager->soldContracts->contains($contract2)); + self::assertFalse($manager->soldContracts->isInitialized()); + self::assertFalse($manager->soldContracts->contains($contract1)); + self::assertTrue($manager->soldContracts->contains($contract2)); } public function testOneToManyExtraLazySliceWithFilterOnSTI(): void @@ -1062,14 +1062,14 @@ public function testOneToManyExtraLazySliceWithFilterOnSTI(): void $manager = $this->_em->find(CompanyManager::class, $this->managerId); - $this->assertFalse($manager->soldContracts->isInitialized()); - $this->assertEquals(2, count($manager->soldContracts->slice(0, 10))); + self::assertFalse($manager->soldContracts->isInitialized()); + self::assertEquals(2, count($manager->soldContracts->slice(0, 10))); // Enable the filter $this->useCompletedContractFilter(); - $this->assertFalse($manager->soldContracts->isInitialized()); - $this->assertEquals(1, count($manager->soldContracts->slice(0, 10))); + self::assertFalse($manager->soldContracts->isInitialized()); + self::assertEquals(1, count($manager->soldContracts->slice(0, 10))); } private function loadCompanyOrganizationEventJoinedSubclassFixtureData(): void @@ -1110,14 +1110,14 @@ public function testOneToManyExtraLazyCountWithFilterOnCTI(): void $organization = $this->_em->find(CompanyOrganization::class, $this->organizationId); - $this->assertFalse($organization->events->isInitialized()); - $this->assertEquals(2, count($organization->events)); + self::assertFalse($organization->events->isInitialized()); + self::assertEquals(2, count($organization->events)); // Enable the filter $this->useCompanyEventIdFilter(); - $this->assertFalse($organization->events->isInitialized()); - $this->assertEquals(1, count($organization->events)); + self::assertFalse($organization->events->isInitialized()); + self::assertEquals(1, count($organization->events)); } public function testOneToManyExtraLazyContainsWithFilterOnCTI(): void @@ -1129,16 +1129,16 @@ public function testOneToManyExtraLazyContainsWithFilterOnCTI(): void $event1 = $this->_em->find(CompanyEvent::class, $this->eventId1); $event2 = $this->_em->find(CompanyEvent::class, $this->eventId2); - $this->assertFalse($organization->events->isInitialized()); - $this->assertTrue($organization->events->contains($event1)); - $this->assertTrue($organization->events->contains($event2)); + self::assertFalse($organization->events->isInitialized()); + self::assertTrue($organization->events->contains($event1)); + self::assertTrue($organization->events->contains($event2)); // Enable the filter $this->useCompanyEventIdFilter(); - $this->assertFalse($organization->events->isInitialized()); - $this->assertFalse($organization->events->contains($event1)); - $this->assertTrue($organization->events->contains($event2)); + self::assertFalse($organization->events->isInitialized()); + self::assertFalse($organization->events->contains($event1)); + self::assertTrue($organization->events->contains($event2)); } public function testOneToManyExtraLazySliceWithFilterOnCTI(): void @@ -1147,14 +1147,14 @@ public function testOneToManyExtraLazySliceWithFilterOnCTI(): void $organization = $this->_em->find(CompanyOrganization::class, $this->organizationId); - $this->assertFalse($organization->events->isInitialized()); - $this->assertEquals(2, count($organization->events->slice(0, 10))); + self::assertFalse($organization->events->isInitialized()); + self::assertEquals(2, count($organization->events->slice(0, 10))); // Enable the filter $this->useCompanyEventIdFilter(); - $this->assertFalse($organization->events->isInitialized()); - $this->assertEquals(1, count($organization->events->slice(0, 10))); + self::assertFalse($organization->events->isInitialized()); + self::assertEquals(1, count($organization->events->slice(0, 10))); } public function testRetrieveSingleAsListThrowsException(): void diff --git a/tests/Doctrine/Tests/ORM/Functional/SchemaTool/CompanySchemaTest.php b/tests/Doctrine/Tests/ORM/Functional/SchemaTool/CompanySchemaTest.php index 018c2d8b39e..bea3c843bff 100644 --- a/tests/Doctrine/Tests/ORM/Functional/SchemaTool/CompanySchemaTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/SchemaTool/CompanySchemaTest.php @@ -28,7 +28,7 @@ public function testGeneratedSchema(): Schema { $schema = $this->_em->getConnection()->getSchemaManager()->createSchema(); - $this->assertTrue($schema->hasTable('company_contracts')); + self::assertTrue($schema->hasTable('company_contracts')); return $schema; } @@ -42,14 +42,14 @@ public function testSingleTableInheritance(Schema $schema): void $table = $schema->getTable('company_contracts'); // Check nullability constraints - $this->assertTrue($table->getColumn('id')->getNotnull()); - $this->assertTrue($table->getColumn('completed')->getNotnull()); - $this->assertFalse($table->getColumn('salesPerson_id')->getNotnull()); - $this->assertTrue($table->getColumn('discr')->getNotnull()); - $this->assertFalse($table->getColumn('fixPrice')->getNotnull()); - $this->assertFalse($table->getColumn('hoursWorked')->getNotnull()); - $this->assertFalse($table->getColumn('pricePerHour')->getNotnull()); - $this->assertFalse($table->getColumn('maxPrice')->getNotnull()); + self::assertTrue($table->getColumn('id')->getNotnull()); + self::assertTrue($table->getColumn('completed')->getNotnull()); + self::assertFalse($table->getColumn('salesPerson_id')->getNotnull()); + self::assertTrue($table->getColumn('discr')->getNotnull()); + self::assertFalse($table->getColumn('fixPrice')->getNotnull()); + self::assertFalse($table->getColumn('hoursWorked')->getNotnull()); + self::assertFalse($table->getColumn('pricePerHour')->getNotnull()); + self::assertFalse($table->getColumn('maxPrice')->getNotnull()); } /** @@ -58,7 +58,7 @@ public function testSingleTableInheritance(Schema $schema): void public function testDropPartSchemaWithForeignKeys(): void { if (! $this->_em->getConnection()->getDatabasePlatform()->supportsForeignKeyConstraints()) { - $this->markTestSkipped('Foreign Key test'); + self::markTestSkipped('Foreign Key test'); } $sql = $this->_schemaTool->getDropSchemaSQL( @@ -66,6 +66,6 @@ public function testDropPartSchemaWithForeignKeys(): void $this->_em->getClassMetadata(CompanyManager::class), ] ); - $this->assertEquals(4, count($sql)); + self::assertEquals(4, count($sql)); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/SchemaTool/DBAL483Test.php b/tests/Doctrine/Tests/ORM/Functional/SchemaTool/DBAL483Test.php index 10bc5dbce8e..5d954c7f83f 100644 --- a/tests/Doctrine/Tests/ORM/Functional/SchemaTool/DBAL483Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/SchemaTool/DBAL483Test.php @@ -41,7 +41,7 @@ public function testDefaultValueIsComparedCorrectly(): void return strpos($sql, 'DBAL483') !== false; }); - $this->assertEquals(0, count($updateSql)); + self::assertEquals(0, count($updateSql)); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/SchemaTool/DDC214Test.php b/tests/Doctrine/Tests/ORM/Functional/SchemaTool/DDC214Test.php index 103b1d8bc20..1442784a795 100644 --- a/tests/Doctrine/Tests/ORM/Functional/SchemaTool/DDC214Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/SchemaTool/DDC214Test.php @@ -35,7 +35,7 @@ protected function setUp(): void $conn = $this->_em->getConnection(); if (strpos($conn->getDriver()->getName(), 'sqlite') !== false) { - $this->markTestSkipped('SQLite does not support ALTER TABLE statements.'); + self::markTestSkipped('SQLite does not support ALTER TABLE statements.'); } $this->schemaTool = new Tools\SchemaTool($this->_em); @@ -103,6 +103,6 @@ public function assertCreatedSchemaNeedsNoUpdates($classes): void return strpos($sql, 'DROP') === false; }); - $this->assertEquals(0, count($sql), 'SQL: ' . implode(PHP_EOL, $sql)); + self::assertEquals(0, count($sql), 'SQL: ' . implode(PHP_EOL, $sql)); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/SchemaTool/MySqlSchemaToolTest.php b/tests/Doctrine/Tests/ORM/Functional/SchemaTool/MySqlSchemaToolTest.php index 6d5e400ead0..d738ae7c021 100644 --- a/tests/Doctrine/Tests/ORM/Functional/SchemaTool/MySqlSchemaToolTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/SchemaTool/MySqlSchemaToolTest.php @@ -23,7 +23,7 @@ protected function setUp(): void { parent::setUp(); if ($this->_em->getConnection()->getDatabasePlatform()->getName() !== 'mysql') { - $this->markTestSkipped('The ' . self::class . ' requires the use of mysql.'); + self::markTestSkipped('The ' . self::class . ' requires the use of mysql.'); } } @@ -42,23 +42,23 @@ public function testGetCreateSchemaSql(): void $sql = $tool->getCreateSchemaSql($classes); $collation = $this->getColumnCollationDeclarationSQL('utf8_unicode_ci'); - $this->assertEquals('CREATE TABLE cms_groups (id INT AUTO_INCREMENT NOT NULL, name VARCHAR(50) NOT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 ' . $collation . ' ENGINE = InnoDB', $sql[0]); - $this->assertEquals('CREATE TABLE cms_users (id INT AUTO_INCREMENT NOT NULL, email_id INT DEFAULT NULL, status VARCHAR(50) DEFAULT NULL, username VARCHAR(255) NOT NULL, name VARCHAR(255) NOT NULL, UNIQUE INDEX UNIQ_3AF03EC5F85E0677 (username), UNIQUE INDEX UNIQ_3AF03EC5A832C1C9 (email_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 ' . $collation . ' ENGINE = InnoDB', $sql[1]); - $this->assertEquals('CREATE TABLE cms_users_groups (user_id INT NOT NULL, group_id INT NOT NULL, INDEX IDX_7EA9409AA76ED395 (user_id), INDEX IDX_7EA9409AFE54D947 (group_id), PRIMARY KEY(user_id, group_id)) DEFAULT CHARACTER SET utf8 ' . $collation . ' ENGINE = InnoDB', $sql[2]); - $this->assertEquals('CREATE TABLE cms_users_tags (user_id INT NOT NULL, tag_id INT NOT NULL, INDEX IDX_93F5A1ADA76ED395 (user_id), INDEX IDX_93F5A1ADBAD26311 (tag_id), PRIMARY KEY(user_id, tag_id)) DEFAULT CHARACTER SET utf8 ' . $collation . ' ENGINE = InnoDB', $sql[3]); - $this->assertEquals('CREATE TABLE cms_tags (id INT AUTO_INCREMENT NOT NULL, tag_name VARCHAR(50) DEFAULT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 ' . $collation . ' ENGINE = InnoDB', $sql[4]); - $this->assertEquals('CREATE TABLE cms_addresses (id INT AUTO_INCREMENT NOT NULL, user_id INT DEFAULT NULL, country VARCHAR(50) NOT NULL, zip VARCHAR(50) NOT NULL, city VARCHAR(50) NOT NULL, UNIQUE INDEX UNIQ_ACAC157BA76ED395 (user_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 ' . $collation . ' ENGINE = InnoDB', $sql[5]); - $this->assertEquals('CREATE TABLE cms_emails (id INT AUTO_INCREMENT NOT NULL, email VARCHAR(250) NOT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 ' . $collation . ' ENGINE = InnoDB', $sql[6]); - $this->assertEquals('CREATE TABLE cms_phonenumbers (phonenumber VARCHAR(50) NOT NULL, user_id INT DEFAULT NULL, INDEX IDX_F21F790FA76ED395 (user_id), PRIMARY KEY(phonenumber)) DEFAULT CHARACTER SET utf8 ' . $collation . ' ENGINE = InnoDB', $sql[7]); - $this->assertEquals('ALTER TABLE cms_users ADD CONSTRAINT FK_3AF03EC5A832C1C9 FOREIGN KEY (email_id) REFERENCES cms_emails (id)', $sql[8]); - $this->assertEquals('ALTER TABLE cms_users_groups ADD CONSTRAINT FK_7EA9409AA76ED395 FOREIGN KEY (user_id) REFERENCES cms_users (id)', $sql[9]); - $this->assertEquals('ALTER TABLE cms_users_groups ADD CONSTRAINT FK_7EA9409AFE54D947 FOREIGN KEY (group_id) REFERENCES cms_groups (id)', $sql[10]); - $this->assertEquals('ALTER TABLE cms_users_tags ADD CONSTRAINT FK_93F5A1ADA76ED395 FOREIGN KEY (user_id) REFERENCES cms_users (id)', $sql[11]); - $this->assertEquals('ALTER TABLE cms_users_tags ADD CONSTRAINT FK_93F5A1ADBAD26311 FOREIGN KEY (tag_id) REFERENCES cms_tags (id)', $sql[12]); - $this->assertEquals('ALTER TABLE cms_addresses ADD CONSTRAINT FK_ACAC157BA76ED395 FOREIGN KEY (user_id) REFERENCES cms_users (id)', $sql[13]); - $this->assertEquals('ALTER TABLE cms_phonenumbers ADD CONSTRAINT FK_F21F790FA76ED395 FOREIGN KEY (user_id) REFERENCES cms_users (id)', $sql[14]); - - $this->assertEquals(15, count($sql)); + self::assertEquals('CREATE TABLE cms_groups (id INT AUTO_INCREMENT NOT NULL, name VARCHAR(50) NOT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 ' . $collation . ' ENGINE = InnoDB', $sql[0]); + self::assertEquals('CREATE TABLE cms_users (id INT AUTO_INCREMENT NOT NULL, email_id INT DEFAULT NULL, status VARCHAR(50) DEFAULT NULL, username VARCHAR(255) NOT NULL, name VARCHAR(255) NOT NULL, UNIQUE INDEX UNIQ_3AF03EC5F85E0677 (username), UNIQUE INDEX UNIQ_3AF03EC5A832C1C9 (email_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 ' . $collation . ' ENGINE = InnoDB', $sql[1]); + self::assertEquals('CREATE TABLE cms_users_groups (user_id INT NOT NULL, group_id INT NOT NULL, INDEX IDX_7EA9409AA76ED395 (user_id), INDEX IDX_7EA9409AFE54D947 (group_id), PRIMARY KEY(user_id, group_id)) DEFAULT CHARACTER SET utf8 ' . $collation . ' ENGINE = InnoDB', $sql[2]); + self::assertEquals('CREATE TABLE cms_users_tags (user_id INT NOT NULL, tag_id INT NOT NULL, INDEX IDX_93F5A1ADA76ED395 (user_id), INDEX IDX_93F5A1ADBAD26311 (tag_id), PRIMARY KEY(user_id, tag_id)) DEFAULT CHARACTER SET utf8 ' . $collation . ' ENGINE = InnoDB', $sql[3]); + self::assertEquals('CREATE TABLE cms_tags (id INT AUTO_INCREMENT NOT NULL, tag_name VARCHAR(50) DEFAULT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 ' . $collation . ' ENGINE = InnoDB', $sql[4]); + self::assertEquals('CREATE TABLE cms_addresses (id INT AUTO_INCREMENT NOT NULL, user_id INT DEFAULT NULL, country VARCHAR(50) NOT NULL, zip VARCHAR(50) NOT NULL, city VARCHAR(50) NOT NULL, UNIQUE INDEX UNIQ_ACAC157BA76ED395 (user_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 ' . $collation . ' ENGINE = InnoDB', $sql[5]); + self::assertEquals('CREATE TABLE cms_emails (id INT AUTO_INCREMENT NOT NULL, email VARCHAR(250) NOT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 ' . $collation . ' ENGINE = InnoDB', $sql[6]); + self::assertEquals('CREATE TABLE cms_phonenumbers (phonenumber VARCHAR(50) NOT NULL, user_id INT DEFAULT NULL, INDEX IDX_F21F790FA76ED395 (user_id), PRIMARY KEY(phonenumber)) DEFAULT CHARACTER SET utf8 ' . $collation . ' ENGINE = InnoDB', $sql[7]); + self::assertEquals('ALTER TABLE cms_users ADD CONSTRAINT FK_3AF03EC5A832C1C9 FOREIGN KEY (email_id) REFERENCES cms_emails (id)', $sql[8]); + self::assertEquals('ALTER TABLE cms_users_groups ADD CONSTRAINT FK_7EA9409AA76ED395 FOREIGN KEY (user_id) REFERENCES cms_users (id)', $sql[9]); + self::assertEquals('ALTER TABLE cms_users_groups ADD CONSTRAINT FK_7EA9409AFE54D947 FOREIGN KEY (group_id) REFERENCES cms_groups (id)', $sql[10]); + self::assertEquals('ALTER TABLE cms_users_tags ADD CONSTRAINT FK_93F5A1ADA76ED395 FOREIGN KEY (user_id) REFERENCES cms_users (id)', $sql[11]); + self::assertEquals('ALTER TABLE cms_users_tags ADD CONSTRAINT FK_93F5A1ADBAD26311 FOREIGN KEY (tag_id) REFERENCES cms_tags (id)', $sql[12]); + self::assertEquals('ALTER TABLE cms_addresses ADD CONSTRAINT FK_ACAC157BA76ED395 FOREIGN KEY (user_id) REFERENCES cms_users (id)', $sql[13]); + self::assertEquals('ALTER TABLE cms_phonenumbers ADD CONSTRAINT FK_F21F790FA76ED395 FOREIGN KEY (user_id) REFERENCES cms_users (id)', $sql[14]); + + self::assertEquals(15, count($sql)); } private function getColumnCollationDeclarationSQL(string $collation): string @@ -78,8 +78,8 @@ public function testGetCreateSchemaSql2(): void $sql = $tool->getCreateSchemaSql($classes); $collation = $this->getColumnCollationDeclarationSQL('utf8_unicode_ci'); - $this->assertEquals(1, count($sql)); - $this->assertEquals('CREATE TABLE decimal_model (id INT AUTO_INCREMENT NOT NULL, `decimal` NUMERIC(5, 2) NOT NULL, `high_scale` NUMERIC(14, 4) NOT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 ' . $collation . ' ENGINE = InnoDB', $sql[0]); + self::assertEquals(1, count($sql)); + self::assertEquals('CREATE TABLE decimal_model (id INT AUTO_INCREMENT NOT NULL, `decimal` NUMERIC(5, 2) NOT NULL, `high_scale` NUMERIC(14, 4) NOT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 ' . $collation . ' ENGINE = InnoDB', $sql[0]); } public function testGetCreateSchemaSql3(): void @@ -90,8 +90,8 @@ public function testGetCreateSchemaSql3(): void $sql = $tool->getCreateSchemaSql($classes); $collation = $this->getColumnCollationDeclarationSQL('utf8_unicode_ci'); - $this->assertEquals(1, count($sql)); - $this->assertEquals('CREATE TABLE boolean_model (id INT AUTO_INCREMENT NOT NULL, booleanField TINYINT(1) NOT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 ' . $collation . ' ENGINE = InnoDB', $sql[0]); + self::assertEquals(1, count($sql)); + self::assertEquals('CREATE TABLE boolean_model (id INT AUTO_INCREMENT NOT NULL, booleanField TINYINT(1) NOT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 ' . $collation . ' ENGINE = InnoDB', $sql[0]); } /** @@ -104,7 +104,7 @@ public function testGetCreateSchemaSql4(): void $tool = new SchemaTool($this->_em); $sql = $tool->getCreateSchemaSql($classes); - $this->assertEquals(0, count($sql)); + self::assertEquals(0, count($sql)); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/SchemaTool/PostgreSqlSchemaToolTest.php b/tests/Doctrine/Tests/ORM/Functional/SchemaTool/PostgreSqlSchemaToolTest.php index 6a4569ef2f5..3e400ce7cd0 100644 --- a/tests/Doctrine/Tests/ORM/Functional/SchemaTool/PostgreSqlSchemaToolTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/SchemaTool/PostgreSqlSchemaToolTest.php @@ -28,7 +28,7 @@ protected function setUp(): void parent::setUp(); if ($this->_em->getConnection()->getDatabasePlatform()->getName() !== 'postgresql') { - $this->markTestSkipped('The ' . self::class . ' requires the use of postgresql.'); + self::markTestSkipped('The ' . self::class . ' requires the use of postgresql.'); } } @@ -36,7 +36,7 @@ public function testPostgresMetadataSequenceIncrementedBy10(): void { $address = $this->_em->getClassMetadata(Models\CMS\CmsAddress::class); - $this->assertEquals(1, $address->sequenceGeneratorDefinition['allocationSize']); + self::assertEquals(1, $address->sequenceGeneratorDefinition['allocationSize']); } public function testGetCreateSchemaSql(): void @@ -51,31 +51,31 @@ public function testGetCreateSchemaSql(): void $sql = $tool->getCreateSchemaSql($classes); $sqlCount = count($sql); - $this->assertEquals('CREATE TABLE cms_addresses (id INT NOT NULL, user_id INT DEFAULT NULL, country VARCHAR(50) NOT NULL, zip VARCHAR(50) NOT NULL, city VARCHAR(50) NOT NULL, PRIMARY KEY(id))', array_shift($sql)); - $this->assertEquals('CREATE UNIQUE INDEX UNIQ_ACAC157BA76ED395 ON cms_addresses (user_id)', array_shift($sql)); - $this->assertEquals('CREATE TABLE cms_users (id INT NOT NULL, email_id INT DEFAULT NULL, status VARCHAR(50) DEFAULT NULL, username VARCHAR(255) NOT NULL, name VARCHAR(255) NOT NULL, PRIMARY KEY(id))', array_shift($sql)); - $this->assertEquals('CREATE UNIQUE INDEX UNIQ_3AF03EC5F85E0677 ON cms_users (username)', array_shift($sql)); - $this->assertEquals('CREATE UNIQUE INDEX UNIQ_3AF03EC5A832C1C9 ON cms_users (email_id)', array_shift($sql)); - $this->assertEquals('CREATE TABLE cms_users_groups (user_id INT NOT NULL, group_id INT NOT NULL, PRIMARY KEY(user_id, group_id))', array_shift($sql)); - $this->assertEquals('CREATE INDEX IDX_7EA9409AA76ED395 ON cms_users_groups (user_id)', array_shift($sql)); - $this->assertEquals('CREATE INDEX IDX_7EA9409AFE54D947 ON cms_users_groups (group_id)', array_shift($sql)); - $this->assertEquals('CREATE TABLE cms_users_tags (user_id INT NOT NULL, tag_id INT NOT NULL, PRIMARY KEY(user_id, tag_id))', array_shift($sql)); - $this->assertEquals('CREATE INDEX IDX_93F5A1ADA76ED395 ON cms_users_tags (user_id)', array_shift($sql)); - $this->assertEquals('CREATE INDEX IDX_93F5A1ADBAD26311 ON cms_users_tags (tag_id)', array_shift($sql)); - $this->assertEquals('CREATE TABLE cms_phonenumbers (phonenumber VARCHAR(50) NOT NULL, user_id INT DEFAULT NULL, PRIMARY KEY(phonenumber))', array_shift($sql)); - $this->assertEquals('CREATE INDEX IDX_F21F790FA76ED395 ON cms_phonenumbers (user_id)', array_shift($sql)); - $this->assertEquals('CREATE SEQUENCE cms_addresses_id_seq INCREMENT BY 1 MINVALUE 1 START 1', array_shift($sql)); - $this->assertEquals('CREATE SEQUENCE cms_users_id_seq INCREMENT BY 1 MINVALUE 1 START 1', array_shift($sql)); - $this->assertEquals('ALTER TABLE cms_addresses ADD CONSTRAINT FK_ACAC157BA76ED395 FOREIGN KEY (user_id) REFERENCES cms_users (id) NOT DEFERRABLE INITIALLY IMMEDIATE', array_shift($sql)); - $this->assertEquals('ALTER TABLE cms_users ADD CONSTRAINT FK_3AF03EC5A832C1C9 FOREIGN KEY (email_id) REFERENCES cms_emails (id) NOT DEFERRABLE INITIALLY IMMEDIATE', array_shift($sql)); - $this->assertEquals('ALTER TABLE cms_users_groups ADD CONSTRAINT FK_7EA9409AA76ED395 FOREIGN KEY (user_id) REFERENCES cms_users (id) NOT DEFERRABLE INITIALLY IMMEDIATE', array_shift($sql)); - $this->assertEquals('ALTER TABLE cms_users_groups ADD CONSTRAINT FK_7EA9409AFE54D947 FOREIGN KEY (group_id) REFERENCES cms_groups (id) NOT DEFERRABLE INITIALLY IMMEDIATE', array_shift($sql)); - $this->assertEquals('ALTER TABLE cms_users_tags ADD CONSTRAINT FK_93F5A1ADA76ED395 FOREIGN KEY (user_id) REFERENCES cms_users (id) NOT DEFERRABLE INITIALLY IMMEDIATE', array_shift($sql)); - $this->assertEquals('ALTER TABLE cms_users_tags ADD CONSTRAINT FK_93F5A1ADBAD26311 FOREIGN KEY (tag_id) REFERENCES cms_tags (id) NOT DEFERRABLE INITIALLY IMMEDIATE', array_shift($sql)); - $this->assertEquals('ALTER TABLE cms_phonenumbers ADD CONSTRAINT FK_F21F790FA76ED395 FOREIGN KEY (user_id) REFERENCES cms_users (id) NOT DEFERRABLE INITIALLY IMMEDIATE', array_shift($sql)); - - $this->assertEquals([], $sql, 'SQL Array should be empty now.'); - $this->assertEquals(22, $sqlCount, 'Total of 22 queries should be executed'); + self::assertEquals('CREATE TABLE cms_addresses (id INT NOT NULL, user_id INT DEFAULT NULL, country VARCHAR(50) NOT NULL, zip VARCHAR(50) NOT NULL, city VARCHAR(50) NOT NULL, PRIMARY KEY(id))', array_shift($sql)); + self::assertEquals('CREATE UNIQUE INDEX UNIQ_ACAC157BA76ED395 ON cms_addresses (user_id)', array_shift($sql)); + self::assertEquals('CREATE TABLE cms_users (id INT NOT NULL, email_id INT DEFAULT NULL, status VARCHAR(50) DEFAULT NULL, username VARCHAR(255) NOT NULL, name VARCHAR(255) NOT NULL, PRIMARY KEY(id))', array_shift($sql)); + self::assertEquals('CREATE UNIQUE INDEX UNIQ_3AF03EC5F85E0677 ON cms_users (username)', array_shift($sql)); + self::assertEquals('CREATE UNIQUE INDEX UNIQ_3AF03EC5A832C1C9 ON cms_users (email_id)', array_shift($sql)); + self::assertEquals('CREATE TABLE cms_users_groups (user_id INT NOT NULL, group_id INT NOT NULL, PRIMARY KEY(user_id, group_id))', array_shift($sql)); + self::assertEquals('CREATE INDEX IDX_7EA9409AA76ED395 ON cms_users_groups (user_id)', array_shift($sql)); + self::assertEquals('CREATE INDEX IDX_7EA9409AFE54D947 ON cms_users_groups (group_id)', array_shift($sql)); + self::assertEquals('CREATE TABLE cms_users_tags (user_id INT NOT NULL, tag_id INT NOT NULL, PRIMARY KEY(user_id, tag_id))', array_shift($sql)); + self::assertEquals('CREATE INDEX IDX_93F5A1ADA76ED395 ON cms_users_tags (user_id)', array_shift($sql)); + self::assertEquals('CREATE INDEX IDX_93F5A1ADBAD26311 ON cms_users_tags (tag_id)', array_shift($sql)); + self::assertEquals('CREATE TABLE cms_phonenumbers (phonenumber VARCHAR(50) NOT NULL, user_id INT DEFAULT NULL, PRIMARY KEY(phonenumber))', array_shift($sql)); + self::assertEquals('CREATE INDEX IDX_F21F790FA76ED395 ON cms_phonenumbers (user_id)', array_shift($sql)); + self::assertEquals('CREATE SEQUENCE cms_addresses_id_seq INCREMENT BY 1 MINVALUE 1 START 1', array_shift($sql)); + self::assertEquals('CREATE SEQUENCE cms_users_id_seq INCREMENT BY 1 MINVALUE 1 START 1', array_shift($sql)); + self::assertEquals('ALTER TABLE cms_addresses ADD CONSTRAINT FK_ACAC157BA76ED395 FOREIGN KEY (user_id) REFERENCES cms_users (id) NOT DEFERRABLE INITIALLY IMMEDIATE', array_shift($sql)); + self::assertEquals('ALTER TABLE cms_users ADD CONSTRAINT FK_3AF03EC5A832C1C9 FOREIGN KEY (email_id) REFERENCES cms_emails (id) NOT DEFERRABLE INITIALLY IMMEDIATE', array_shift($sql)); + self::assertEquals('ALTER TABLE cms_users_groups ADD CONSTRAINT FK_7EA9409AA76ED395 FOREIGN KEY (user_id) REFERENCES cms_users (id) NOT DEFERRABLE INITIALLY IMMEDIATE', array_shift($sql)); + self::assertEquals('ALTER TABLE cms_users_groups ADD CONSTRAINT FK_7EA9409AFE54D947 FOREIGN KEY (group_id) REFERENCES cms_groups (id) NOT DEFERRABLE INITIALLY IMMEDIATE', array_shift($sql)); + self::assertEquals('ALTER TABLE cms_users_tags ADD CONSTRAINT FK_93F5A1ADA76ED395 FOREIGN KEY (user_id) REFERENCES cms_users (id) NOT DEFERRABLE INITIALLY IMMEDIATE', array_shift($sql)); + self::assertEquals('ALTER TABLE cms_users_tags ADD CONSTRAINT FK_93F5A1ADBAD26311 FOREIGN KEY (tag_id) REFERENCES cms_tags (id) NOT DEFERRABLE INITIALLY IMMEDIATE', array_shift($sql)); + self::assertEquals('ALTER TABLE cms_phonenumbers ADD CONSTRAINT FK_F21F790FA76ED395 FOREIGN KEY (user_id) REFERENCES cms_users (id) NOT DEFERRABLE INITIALLY IMMEDIATE', array_shift($sql)); + + self::assertEquals([], $sql, 'SQL Array should be empty now.'); + self::assertEquals(22, $sqlCount, 'Total of 22 queries should be executed'); } public function testGetCreateSchemaSql2(): void @@ -85,10 +85,10 @@ public function testGetCreateSchemaSql2(): void $tool = new SchemaTool($this->_em); $sql = $tool->getCreateSchemaSql($classes); - $this->assertEquals(2, count($sql)); + self::assertEquals(2, count($sql)); - $this->assertEquals('CREATE TABLE decimal_model (id INT NOT NULL, "decimal" NUMERIC(5, 2) NOT NULL, "high_scale" NUMERIC(14, 4) NOT NULL, PRIMARY KEY(id))', $sql[0]); - $this->assertEquals('CREATE SEQUENCE decimal_model_id_seq INCREMENT BY 1 MINVALUE 1 START 1', $sql[1]); + self::assertEquals('CREATE TABLE decimal_model (id INT NOT NULL, "decimal" NUMERIC(5, 2) NOT NULL, "high_scale" NUMERIC(14, 4) NOT NULL, PRIMARY KEY(id))', $sql[0]); + self::assertEquals('CREATE SEQUENCE decimal_model_id_seq INCREMENT BY 1 MINVALUE 1 START 1', $sql[1]); } public function testGetCreateSchemaSql3(): void @@ -98,9 +98,9 @@ public function testGetCreateSchemaSql3(): void $tool = new SchemaTool($this->_em); $sql = $tool->getCreateSchemaSql($classes); - $this->assertEquals(2, count($sql)); - $this->assertEquals('CREATE TABLE boolean_model (id INT NOT NULL, booleanField BOOLEAN NOT NULL, PRIMARY KEY(id))', $sql[0]); - $this->assertEquals('CREATE SEQUENCE boolean_model_id_seq INCREMENT BY 1 MINVALUE 1 START 1', $sql[1]); + self::assertEquals(2, count($sql)); + self::assertEquals('CREATE TABLE boolean_model (id INT NOT NULL, booleanField BOOLEAN NOT NULL, PRIMARY KEY(id))', $sql[0]); + self::assertEquals('CREATE SEQUENCE boolean_model_id_seq INCREMENT BY 1 MINVALUE 1 START 1', $sql[1]); } public function testGetDropSchemaSql(): void @@ -114,7 +114,7 @@ public function testGetDropSchemaSql(): void $tool = new SchemaTool($this->_em); $sql = $tool->getDropSchemaSQL($classes); - $this->assertEquals(17, count($sql)); + self::assertEquals(17, count($sql)); $dropSequenceSQLs = 0; @@ -124,7 +124,7 @@ public function testGetDropSchemaSql(): void } } - $this->assertEquals(4, $dropSequenceSQLs, 'Expect 4 sequences to be dropped.'); + self::assertEquals(4, $dropSequenceSQLs, 'Expect 4 sequences to be dropped.'); } /** @@ -145,7 +145,7 @@ public function testUpdateSchemaWithPostgreSQLSchema(): void return strpos($sql, 'DROP SEQUENCE stonewood.') === 0; }); - $this->assertCount(0, $sql, implode("\n", $sql)); + self::assertCount(0, $sql, implode("\n", $sql)); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/SchemaValidatorTest.php b/tests/Doctrine/Tests/ORM/Functional/SchemaValidatorTest.php index 2cd6f4c5f24..7ca51439525 100644 --- a/tests/Doctrine/Tests/ORM/Functional/SchemaValidatorTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/SchemaValidatorTest.php @@ -74,7 +74,7 @@ public function testValidateModelSets(string $modelSet): void foreach ($classes as $class) { $ce = $validator->validateClass($class); - $this->assertEmpty($ce, 'Invalid Modelset: ' . $modelSet . ' class ' . $class->name . ': ' . implode("\n", $ce)); + self::assertEmpty($ce, 'Invalid Modelset: ' . $modelSet . ' class ' . $class->name . ': ' . implode("\n", $ce)); } } } diff --git a/tests/Doctrine/Tests/ORM/Functional/SecondLevelCacheCompositePrimaryKeyTest.php b/tests/Doctrine/Tests/ORM/Functional/SecondLevelCacheCompositePrimaryKeyTest.php index 95855ff499c..b1b7118523c 100644 --- a/tests/Doctrine/Tests/ORM/Functional/SecondLevelCacheCompositePrimaryKeyTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/SecondLevelCacheCompositePrimaryKeyTest.php @@ -34,29 +34,29 @@ public function testPutAndLoadCompositPrimaryKeyEntities(): void $flight->setDeparture(new DateTime('tomorrow')); - $this->assertTrue($this->cache->containsEntity(City::class, $this->cities[0]->getId())); - $this->assertTrue($this->cache->containsEntity(City::class, $this->cities[1]->getId())); + self::assertTrue($this->cache->containsEntity(City::class, $this->cities[0]->getId())); + self::assertTrue($this->cache->containsEntity(City::class, $this->cities[1]->getId())); $this->_em->persist($flight); $this->_em->flush(); $this->_em->clear(); - $this->assertTrue($this->cache->containsEntity(Flight::class, $id)); - $this->assertTrue($this->cache->containsEntity(City::class, $this->cities[0]->getId())); - $this->assertTrue($this->cache->containsEntity(City::class, $this->cities[1]->getId())); + self::assertTrue($this->cache->containsEntity(Flight::class, $id)); + self::assertTrue($this->cache->containsEntity(City::class, $this->cities[0]->getId())); + self::assertTrue($this->cache->containsEntity(City::class, $this->cities[1]->getId())); $queryCount = $this->getCurrentQueryCount(); $flight = $this->_em->find(Flight::class, $id); $leavingFrom = $flight->getLeavingFrom(); $goingTo = $flight->getGoingTo(); - $this->assertInstanceOf(Flight::class, $flight); - $this->assertInstanceOf(City::class, $goingTo); - $this->assertInstanceOf(City::class, $leavingFrom); + self::assertInstanceOf(Flight::class, $flight); + self::assertInstanceOf(City::class, $goingTo); + self::assertInstanceOf(City::class, $leavingFrom); - $this->assertEquals($goingTo->getId(), $goingToId); - $this->assertEquals($leavingFrom->getId(), $leavingFromId); - $this->assertEquals($queryCount, $this->getCurrentQueryCount()); + self::assertEquals($goingTo->getId(), $goingToId); + self::assertEquals($leavingFrom->getId(), $leavingFromId); + self::assertEquals($queryCount, $this->getCurrentQueryCount()); } public function testRemoveCompositPrimaryKeyEntities(): void @@ -80,25 +80,25 @@ public function testRemoveCompositPrimaryKeyEntities(): void $flight->setDeparture(new DateTime('tomorrow')); - $this->assertTrue($this->cache->containsEntity(City::class, $this->cities[0]->getId())); - $this->assertTrue($this->cache->containsEntity(City::class, $this->cities[1]->getId())); + self::assertTrue($this->cache->containsEntity(City::class, $this->cities[0]->getId())); + self::assertTrue($this->cache->containsEntity(City::class, $this->cities[1]->getId())); $this->_em->persist($flight); $this->_em->flush(); - $this->assertTrue($this->cache->containsEntity(Flight::class, $id)); - $this->assertTrue($this->cache->containsEntity(City::class, $this->cities[0]->getId())); - $this->assertTrue($this->cache->containsEntity(City::class, $this->cities[1]->getId())); + self::assertTrue($this->cache->containsEntity(Flight::class, $id)); + self::assertTrue($this->cache->containsEntity(City::class, $this->cities[0]->getId())); + self::assertTrue($this->cache->containsEntity(City::class, $this->cities[1]->getId())); $this->_em->remove($flight); $this->_em->flush(); $this->_em->clear(); - $this->assertFalse($this->cache->containsEntity(Flight::class, $id)); - $this->assertTrue($this->cache->containsEntity(City::class, $this->cities[0]->getId())); - $this->assertTrue($this->cache->containsEntity(City::class, $this->cities[1]->getId())); + self::assertFalse($this->cache->containsEntity(Flight::class, $id)); + self::assertTrue($this->cache->containsEntity(City::class, $this->cities[0]->getId())); + self::assertTrue($this->cache->containsEntity(City::class, $this->cities[1]->getId())); - $this->assertNull($this->_em->find(Flight::class, $id)); + self::assertNull($this->_em->find(Flight::class, $id)); } public function testUpdateCompositPrimaryKeyEntities(): void @@ -124,31 +124,31 @@ public function testUpdateCompositPrimaryKeyEntities(): void $flight->setDeparture($now); - $this->assertTrue($this->cache->containsEntity(City::class, $this->cities[0]->getId())); - $this->assertTrue($this->cache->containsEntity(City::class, $this->cities[1]->getId())); + self::assertTrue($this->cache->containsEntity(City::class, $this->cities[0]->getId())); + self::assertTrue($this->cache->containsEntity(City::class, $this->cities[1]->getId())); $this->_em->persist($flight); $this->_em->flush(); $this->_em->clear(); - $this->assertTrue($this->cache->containsEntity(Flight::class, $id)); - $this->assertTrue($this->cache->containsEntity(City::class, $this->cities[0]->getId())); - $this->assertTrue($this->cache->containsEntity(City::class, $this->cities[1]->getId())); + self::assertTrue($this->cache->containsEntity(Flight::class, $id)); + self::assertTrue($this->cache->containsEntity(City::class, $this->cities[0]->getId())); + self::assertTrue($this->cache->containsEntity(City::class, $this->cities[1]->getId())); $queryCount = $this->getCurrentQueryCount(); $flight = $this->_em->find(Flight::class, $id); $leavingFrom = $flight->getLeavingFrom(); $goingTo = $flight->getGoingTo(); - $this->assertInstanceOf(Flight::class, $flight); - $this->assertInstanceOf(City::class, $goingTo); - $this->assertInstanceOf(City::class, $leavingFrom); + self::assertInstanceOf(Flight::class, $flight); + self::assertInstanceOf(City::class, $goingTo); + self::assertInstanceOf(City::class, $leavingFrom); - $this->assertEquals($goingTo->getId(), $goingToId); - $this->assertEquals($flight->getDeparture(), $now); - $this->assertEquals($leavingFrom->getId(), $leavingFromId); - $this->assertEquals($leavingFrom->getId(), $leavingFromId); - $this->assertEquals($queryCount, $this->getCurrentQueryCount()); + self::assertEquals($goingTo->getId(), $goingToId); + self::assertEquals($flight->getDeparture(), $now); + self::assertEquals($leavingFrom->getId(), $leavingFromId); + self::assertEquals($leavingFrom->getId(), $leavingFromId); + self::assertEquals($queryCount, $this->getCurrentQueryCount()); $flight->setDeparture($tomorrow); @@ -156,23 +156,23 @@ public function testUpdateCompositPrimaryKeyEntities(): void $this->_em->flush(); $this->_em->clear(); - $this->assertTrue($this->cache->containsEntity(Flight::class, $id)); - $this->assertTrue($this->cache->containsEntity(City::class, $this->cities[0]->getId())); - $this->assertTrue($this->cache->containsEntity(City::class, $this->cities[1]->getId())); + self::assertTrue($this->cache->containsEntity(Flight::class, $id)); + self::assertTrue($this->cache->containsEntity(City::class, $this->cities[0]->getId())); + self::assertTrue($this->cache->containsEntity(City::class, $this->cities[1]->getId())); $queryCount = $this->getCurrentQueryCount(); $flight = $this->_em->find(Flight::class, $id); $leavingFrom = $flight->getLeavingFrom(); $goingTo = $flight->getGoingTo(); - $this->assertInstanceOf(Flight::class, $flight); - $this->assertInstanceOf(City::class, $goingTo); - $this->assertInstanceOf(City::class, $leavingFrom); + self::assertInstanceOf(Flight::class, $flight); + self::assertInstanceOf(City::class, $goingTo); + self::assertInstanceOf(City::class, $leavingFrom); - $this->assertEquals($goingTo->getId(), $goingToId); - $this->assertEquals($flight->getDeparture(), $tomorrow); - $this->assertEquals($leavingFrom->getId(), $leavingFromId); - $this->assertEquals($leavingFrom->getId(), $leavingFromId); - $this->assertEquals($queryCount, $this->getCurrentQueryCount()); + self::assertEquals($goingTo->getId(), $goingToId); + self::assertEquals($flight->getDeparture(), $tomorrow); + self::assertEquals($leavingFrom->getId(), $leavingFromId); + self::assertEquals($leavingFrom->getId(), $leavingFromId); + self::assertEquals($queryCount, $this->getCurrentQueryCount()); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/SecondLevelCacheCompositePrimaryKeyWithAssociationsTest.php b/tests/Doctrine/Tests/ORM/Functional/SecondLevelCacheCompositePrimaryKeyWithAssociationsTest.php index c8ce9e725b7..00262bf5276 100644 --- a/tests/Doctrine/Tests/ORM/Functional/SecondLevelCacheCompositePrimaryKeyWithAssociationsTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/SecondLevelCacheCompositePrimaryKeyWithAssociationsTest.php @@ -58,9 +58,9 @@ public function testFindByReturnsCachedEntity(): void $admin1Rome = $admin1Repo->findOneBy(['country' => 'IT', 'id' => 1]); - $this->assertEquals('Italy', $admin1Rome->country->name); - $this->assertEquals(2, count($admin1Rome->names)); - $this->assertEquals($queries + 3, $this->getCurrentQueryCount()); + self::assertEquals('Italy', $admin1Rome->country->name); + self::assertEquals(2, count($admin1Rome->names)); + self::assertEquals($queries + 3, $this->getCurrentQueryCount()); $this->_em->clear(); @@ -68,9 +68,9 @@ public function testFindByReturnsCachedEntity(): void $admin1Rome = $admin1Repo->findOneBy(['country' => 'IT', 'id' => 1]); - $this->assertEquals('Italy', $admin1Rome->country->name); - $this->assertEquals(2, count($admin1Rome->names)); - $this->assertEquals($queries, $this->getCurrentQueryCount()); + self::assertEquals('Italy', $admin1Rome->country->name); + self::assertEquals(2, count($admin1Rome->names)); + self::assertEquals($queries, $this->getCurrentQueryCount()); } private function evictRegions(): void diff --git a/tests/Doctrine/Tests/ORM/Functional/SecondLevelCacheConcurrentTest.php b/tests/Doctrine/Tests/ORM/Functional/SecondLevelCacheConcurrentTest.php index df8ce56d95b..53619538ecb 100644 --- a/tests/Doctrine/Tests/ORM/Functional/SecondLevelCacheConcurrentTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/SecondLevelCacheConcurrentTest.php @@ -65,18 +65,18 @@ public function testBasicConcurrentEntityReadLock(): void $region = $this->_em->getCache()->getEntityCacheRegion(Country::class); assert($region instanceof ConcurrentRegionMock); - $this->assertTrue($this->cache->containsEntity(Country::class, $countryId)); + self::assertTrue($this->cache->containsEntity(Country::class, $countryId)); $region->setLock($cacheId, Lock::createLockRead()); // another proc lock the entity cache - $this->assertFalse($this->cache->containsEntity(Country::class, $countryId)); + self::assertFalse($this->cache->containsEntity(Country::class, $countryId)); $queryCount = $this->getCurrentQueryCount(); $country = $this->_em->find(Country::class, $countryId); - $this->assertInstanceOf(Country::class, $country); - $this->assertEquals($queryCount + 1, $this->getCurrentQueryCount()); - $this->assertFalse($this->cache->containsEntity(Country::class, $countryId)); + self::assertInstanceOf(Country::class, $country); + self::assertEquals($queryCount + 1, $this->getCurrentQueryCount()); + self::assertFalse($this->cache->containsEntity(Country::class, $countryId)); } public function testBasicConcurrentCollectionReadLock(): void @@ -91,10 +91,10 @@ public function testBasicConcurrentCollectionReadLock(): void $stateId = $this->states[0]->getId(); $state = $this->_em->find(State::class, $stateId); - $this->assertInstanceOf(State::class, $state); - $this->assertInstanceOf(Country::class, $state->getCountry()); - $this->assertNotNull($state->getCountry()->getName()); - $this->assertCount(2, $state->getCities()); + self::assertInstanceOf(State::class, $state); + self::assertInstanceOf(Country::class, $state->getCountry()); + self::assertNotNull($state->getCountry()->getName()); + self::assertCount(2, $state->getCities()); $this->_em->clear(); $this->secondLevelCacheLogger->clearStats(); @@ -104,30 +104,30 @@ public function testBasicConcurrentCollectionReadLock(): void $region = $this->_em->getCache()->getCollectionCacheRegion(State::class, 'cities'); assert($region instanceof ConcurrentRegionMock); - $this->assertTrue($this->cache->containsCollection(State::class, 'cities', $stateId)); + self::assertTrue($this->cache->containsCollection(State::class, 'cities', $stateId)); $region->setLock($cacheId, Lock::createLockRead()); // another proc lock the entity cache - $this->assertFalse($this->cache->containsCollection(State::class, 'cities', $stateId)); + self::assertFalse($this->cache->containsCollection(State::class, 'cities', $stateId)); $queryCount = $this->getCurrentQueryCount(); $state = $this->_em->find(State::class, $stateId); - $this->assertEquals(0, $this->secondLevelCacheLogger->getMissCount()); - $this->assertEquals(1, $this->secondLevelCacheLogger->getHitCount()); + self::assertEquals(0, $this->secondLevelCacheLogger->getMissCount()); + self::assertEquals(1, $this->secondLevelCacheLogger->getHitCount()); - $this->assertEquals(0, $this->secondLevelCacheLogger->getRegionMissCount($this->getEntityRegion(State::class))); - $this->assertEquals(1, $this->secondLevelCacheLogger->getRegionHitCount($this->getEntityRegion(State::class))); + self::assertEquals(0, $this->secondLevelCacheLogger->getRegionMissCount($this->getEntityRegion(State::class))); + self::assertEquals(1, $this->secondLevelCacheLogger->getRegionHitCount($this->getEntityRegion(State::class))); - $this->assertInstanceOf(State::class, $state); - $this->assertCount(2, $state->getCities()); + self::assertInstanceOf(State::class, $state); + self::assertCount(2, $state->getCities()); - $this->assertEquals(1, $this->secondLevelCacheLogger->getMissCount()); - $this->assertEquals(1, $this->secondLevelCacheLogger->getHitCount()); - $this->assertEquals(1, $this->secondLevelCacheLogger->getRegionMissCount($this->getCollectionRegion(State::class, 'cities'))); + self::assertEquals(1, $this->secondLevelCacheLogger->getMissCount()); + self::assertEquals(1, $this->secondLevelCacheLogger->getHitCount()); + self::assertEquals(1, $this->secondLevelCacheLogger->getRegionMissCount($this->getCollectionRegion(State::class, 'cities'))); - $this->assertEquals($queryCount + 1, $this->getCurrentQueryCount()); - $this->assertFalse($this->cache->containsCollection(State::class, 'cities', $stateId)); + self::assertEquals($queryCount + 1, $this->getCurrentQueryCount()); + self::assertFalse($this->cache->containsCollection(State::class, 'cities', $stateId)); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/SecondLevelCacheCriteriaTest.php b/tests/Doctrine/Tests/ORM/Functional/SecondLevelCacheCriteriaTest.php index 8eb498c5900..763d80027a8 100644 --- a/tests/Doctrine/Tests/ORM/Functional/SecondLevelCacheCriteriaTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/SecondLevelCacheCriteriaTest.php @@ -22,7 +22,7 @@ public function testMatchingPut(): void $this->evictRegions(); $this->_em->clear(); - $this->assertFalse($this->cache->containsEntity(Country::class, $this->countries[0]->getId())); + self::assertFalse($this->cache->containsEntity(Country::class, $this->countries[0]->getId())); $repository = $this->_em->getRepository(Country::class); $queryCount = $this->getCurrentQueryCount(); @@ -34,11 +34,11 @@ public function testMatchingPut(): void // Because matching returns lazy collection, we force initialization $result1->toArray(); - $this->assertEquals($queryCount + 1, $this->getCurrentQueryCount()); - $this->assertEquals($this->countries[0]->getId(), $result1[0]->getId()); - $this->assertEquals($this->countries[0]->getName(), $result1[0]->getName()); + self::assertEquals($queryCount + 1, $this->getCurrentQueryCount()); + self::assertEquals($this->countries[0]->getId(), $result1[0]->getId()); + self::assertEquals($this->countries[0]->getName(), $result1[0]->getName()); - $this->assertTrue($this->cache->containsEntity(Country::class, $this->countries[0]->getId())); + self::assertTrue($this->cache->containsEntity(Country::class, $this->countries[0]->getId())); $this->_em->clear(); @@ -46,13 +46,13 @@ public function testMatchingPut(): void Criteria::expr()->eq('name', $name) )); - $this->assertEquals($queryCount + 1, $this->getCurrentQueryCount()); - $this->assertCount(1, $result2); + self::assertEquals($queryCount + 1, $this->getCurrentQueryCount()); + self::assertCount(1, $result2); - $this->assertInstanceOf(Country::class, $result2[0]); + self::assertInstanceOf(Country::class, $result2[0]); - $this->assertEquals($result1[0]->getId(), $result2[0]->getId()); - $this->assertEquals($result1[0]->getName(), $result2[0]->getName()); + self::assertEquals($result1[0]->getId(), $result2[0]->getId()); + self::assertEquals($result1[0]->getName(), $result2[0]->getName()); } public function testRepositoryMatching(): void @@ -62,7 +62,7 @@ public function testRepositoryMatching(): void $this->loadFixturesCountries(); $this->_em->clear(); - $this->assertTrue($this->cache->containsEntity(Country::class, $this->countries[0]->getId())); + self::assertTrue($this->cache->containsEntity(Country::class, $this->countries[0]->getId())); $repository = $this->_em->getRepository(Country::class); $queryCount = $this->getCurrentQueryCount(); @@ -73,10 +73,10 @@ public function testRepositoryMatching(): void // Because matching returns lazy collection, we force initialization $result1->toArray(); - $this->assertCount(1, $result1); - $this->assertEquals($queryCount + 1, $this->getCurrentQueryCount()); - $this->assertEquals($this->countries[0]->getId(), $result1[0]->getId()); - $this->assertEquals($this->countries[0]->getName(), $result1[0]->getName()); + self::assertCount(1, $result1); + self::assertEquals($queryCount + 1, $this->getCurrentQueryCount()); + self::assertEquals($this->countries[0]->getId(), $result1[0]->getId()); + self::assertEquals($this->countries[0]->getName(), $result1[0]->getName()); $this->_em->clear(); @@ -87,13 +87,13 @@ public function testRepositoryMatching(): void // Because matching returns lazy collection, we force initialization $result2->toArray(); - $this->assertEquals($queryCount + 1, $this->getCurrentQueryCount()); - $this->assertCount(1, $result2); + self::assertEquals($queryCount + 1, $this->getCurrentQueryCount()); + self::assertCount(1, $result2); - $this->assertInstanceOf(Country::class, $result2[0]); + self::assertInstanceOf(Country::class, $result2[0]); - $this->assertEquals($this->countries[0]->getId(), $result2[0]->getId()); - $this->assertEquals($this->countries[0]->getName(), $result2[0]->getName()); + self::assertEquals($this->countries[0]->getId(), $result2[0]->getId()); + self::assertEquals($this->countries[0]->getName(), $result2[0]->getName()); $result3 = $repository->matching(new Criteria( Criteria::expr()->eq('name', $this->countries[1]->getName()) @@ -102,25 +102,25 @@ public function testRepositoryMatching(): void // Because matching returns lazy collection, we force initialization $result3->toArray(); - $this->assertEquals($queryCount + 2, $this->getCurrentQueryCount()); - $this->assertCount(1, $result3); + self::assertEquals($queryCount + 2, $this->getCurrentQueryCount()); + self::assertCount(1, $result3); - $this->assertInstanceOf(Country::class, $result3[0]); + self::assertInstanceOf(Country::class, $result3[0]); - $this->assertEquals($this->countries[1]->getId(), $result3[0]->getId()); - $this->assertEquals($this->countries[1]->getName(), $result3[0]->getName()); + self::assertEquals($this->countries[1]->getId(), $result3[0]->getId()); + self::assertEquals($this->countries[1]->getName(), $result3[0]->getName()); $result4 = $repository->matching(new Criteria( Criteria::expr()->eq('name', $this->countries[1]->getName()) )); - $this->assertEquals($queryCount + 2, $this->getCurrentQueryCount()); - $this->assertCount(1, $result4); + self::assertEquals($queryCount + 2, $this->getCurrentQueryCount()); + self::assertCount(1, $result4); - $this->assertInstanceOf(Country::class, $result4[0]); + self::assertInstanceOf(Country::class, $result4[0]); - $this->assertEquals($this->countries[1]->getId(), $result4[0]->getId()); - $this->assertEquals($this->countries[1]->getName(), $result4[0]->getName()); + self::assertEquals($this->countries[1]->getId(), $result4[0]->getId()); + self::assertEquals($this->countries[1]->getName(), $result4[0]->getName()); } public function testCollectionMatching(): void @@ -139,9 +139,9 @@ public function testCollectionMatching(): void Criteria::expr()->eq('name', $itemName) )); - $this->assertEquals($queryCount + 1, $this->getCurrentQueryCount()); - $this->assertInstanceOf(Collection::class, $matching); - $this->assertCount(1, $matching); + self::assertEquals($queryCount + 1, $this->getCurrentQueryCount()); + self::assertInstanceOf(Collection::class, $matching); + self::assertCount(1, $matching); $this->_em->clear(); @@ -152,8 +152,8 @@ public function testCollectionMatching(): void Criteria::expr()->eq('name', $itemName) )); - $this->assertEquals($queryCount, $this->getCurrentQueryCount()); - $this->assertInstanceOf(Collection::class, $matching); - $this->assertCount(1, $matching); + self::assertEquals($queryCount, $this->getCurrentQueryCount()); + self::assertInstanceOf(Collection::class, $matching); + self::assertCount(1, $matching); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/SecondLevelCacheExtraLazyCollectionTest.php b/tests/Doctrine/Tests/ORM/Functional/SecondLevelCacheExtraLazyCollectionTest.php index 1c634a266df..198311ba8f7 100644 --- a/tests/Doctrine/Tests/ORM/Functional/SecondLevelCacheExtraLazyCollectionTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/SecondLevelCacheExtraLazyCollectionTest.php @@ -50,8 +50,8 @@ public function testCacheCountAfterAddThenFlush(): void $owner = $this->_em->find(Travel::class, $ownerId); $ref = $this->_em->find(State::class, $this->states[1]->getId()); - $this->assertTrue($this->cache->containsEntity(Travel::class, $ownerId)); - $this->assertTrue($this->cache->containsCollection(Travel::class, 'visitedCities', $ownerId)); + self::assertTrue($this->cache->containsEntity(Travel::class, $ownerId)); + self::assertTrue($this->cache->containsCollection(Travel::class, 'visitedCities', $ownerId)); $newItem = new City('New City', $ref); $owner->getVisitedCities()->add($newItem); @@ -61,23 +61,23 @@ public function testCacheCountAfterAddThenFlush(): void $queryCount = $this->getCurrentQueryCount(); - $this->assertFalse($owner->getVisitedCities()->isInitialized()); - $this->assertEquals(4, $owner->getVisitedCities()->count()); - $this->assertFalse($owner->getVisitedCities()->isInitialized()); - $this->assertEquals($queryCount, $this->getCurrentQueryCount()); + self::assertFalse($owner->getVisitedCities()->isInitialized()); + self::assertEquals(4, $owner->getVisitedCities()->count()); + self::assertFalse($owner->getVisitedCities()->isInitialized()); + self::assertEquals($queryCount, $this->getCurrentQueryCount()); $this->_em->flush(); - $this->assertFalse($owner->getVisitedCities()->isInitialized()); - $this->assertFalse($this->cache->containsCollection(Travel::class, 'visitedCities', $ownerId)); + self::assertFalse($owner->getVisitedCities()->isInitialized()); + self::assertFalse($this->cache->containsCollection(Travel::class, 'visitedCities', $ownerId)); $this->_em->clear(); $queryCount = $this->getCurrentQueryCount(); $owner = $this->_em->find(Travel::class, $ownerId); - $this->assertEquals(4, $owner->getVisitedCities()->count()); - $this->assertFalse($owner->getVisitedCities()->isInitialized()); - $this->assertEquals($queryCount + 1, $this->getCurrentQueryCount()); + self::assertEquals(4, $owner->getVisitedCities()->count()); + self::assertFalse($owner->getVisitedCities()->isInitialized()); + self::assertEquals($queryCount + 1, $this->getCurrentQueryCount()); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/SecondLevelCacheJoinTableInheritanceTest.php b/tests/Doctrine/Tests/ORM/Functional/SecondLevelCacheJoinTableInheritanceTest.php index 3bb2093d85f..0a79f16e91b 100644 --- a/tests/Doctrine/Tests/ORM/Functional/SecondLevelCacheJoinTableInheritanceTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/SecondLevelCacheJoinTableInheritanceTest.php @@ -24,8 +24,8 @@ public function testUseSameRegion(): void $contactRegion = $this->cache->getEntityCacheRegion(AttractionContactInfo::class); $locationRegion = $this->cache->getEntityCacheRegion(AttractionLocationInfo::class); - $this->assertEquals($infoRegion->getName(), $contactRegion->getName()); - $this->assertEquals($infoRegion->getName(), $locationRegion->getName()); + self::assertEquals($infoRegion->getName(), $contactRegion->getName()); + self::assertEquals($infoRegion->getName(), $locationRegion->getName()); } public function testPutOnPersistJoinTableInheritance(): void @@ -38,10 +38,10 @@ public function testPutOnPersistJoinTableInheritance(): void $this->_em->clear(); - $this->assertTrue($this->cache->containsEntity(AttractionInfo::class, $this->attractionsInfo[0]->getId())); - $this->assertTrue($this->cache->containsEntity(AttractionInfo::class, $this->attractionsInfo[1]->getId())); - $this->assertTrue($this->cache->containsEntity(AttractionInfo::class, $this->attractionsInfo[2]->getId())); - $this->assertTrue($this->cache->containsEntity(AttractionInfo::class, $this->attractionsInfo[3]->getId())); + self::assertTrue($this->cache->containsEntity(AttractionInfo::class, $this->attractionsInfo[0]->getId())); + self::assertTrue($this->cache->containsEntity(AttractionInfo::class, $this->attractionsInfo[1]->getId())); + self::assertTrue($this->cache->containsEntity(AttractionInfo::class, $this->attractionsInfo[2]->getId())); + self::assertTrue($this->cache->containsEntity(AttractionInfo::class, $this->attractionsInfo[3]->getId())); } public function testJoinTableCountaisRootClass(): void @@ -55,8 +55,8 @@ public function testJoinTableCountaisRootClass(): void $this->_em->clear(); foreach ($this->attractionsInfo as $info) { - $this->assertTrue($this->cache->containsEntity(AttractionInfo::class, $info->getId())); - $this->assertTrue($this->cache->containsEntity(get_class($info), $info->getId())); + self::assertTrue($this->cache->containsEntity(AttractionInfo::class, $info->getId())); + self::assertTrue($this->cache->containsEntity(get_class($info), $info->getId())); } } @@ -75,33 +75,33 @@ public function testPutAndLoadJoinTableEntities(): void $entityId1 = $this->attractionsInfo[0]->getId(); $entityId2 = $this->attractionsInfo[1]->getId(); - $this->assertFalse($this->cache->containsEntity(AttractionInfo::class, $entityId1)); - $this->assertFalse($this->cache->containsEntity(AttractionInfo::class, $entityId2)); - $this->assertFalse($this->cache->containsEntity(AttractionContactInfo::class, $entityId1)); - $this->assertFalse($this->cache->containsEntity(AttractionContactInfo::class, $entityId2)); + self::assertFalse($this->cache->containsEntity(AttractionInfo::class, $entityId1)); + self::assertFalse($this->cache->containsEntity(AttractionInfo::class, $entityId2)); + self::assertFalse($this->cache->containsEntity(AttractionContactInfo::class, $entityId1)); + self::assertFalse($this->cache->containsEntity(AttractionContactInfo::class, $entityId2)); $queryCount = $this->getCurrentQueryCount(); $entity1 = $this->_em->find(AttractionInfo::class, $entityId1); $entity2 = $this->_em->find(AttractionInfo::class, $entityId2); //load entity and relation whit sub classes - $this->assertEquals($queryCount + 4, $this->getCurrentQueryCount()); + self::assertEquals($queryCount + 4, $this->getCurrentQueryCount()); - $this->assertTrue($this->cache->containsEntity(AttractionInfo::class, $entityId1)); - $this->assertTrue($this->cache->containsEntity(AttractionInfo::class, $entityId2)); - $this->assertTrue($this->cache->containsEntity(AttractionContactInfo::class, $entityId1)); - $this->assertTrue($this->cache->containsEntity(AttractionContactInfo::class, $entityId2)); + self::assertTrue($this->cache->containsEntity(AttractionInfo::class, $entityId1)); + self::assertTrue($this->cache->containsEntity(AttractionInfo::class, $entityId2)); + self::assertTrue($this->cache->containsEntity(AttractionContactInfo::class, $entityId1)); + self::assertTrue($this->cache->containsEntity(AttractionContactInfo::class, $entityId2)); - $this->assertInstanceOf(AttractionInfo::class, $entity1); - $this->assertInstanceOf(AttractionInfo::class, $entity2); - $this->assertInstanceOf(AttractionContactInfo::class, $entity1); - $this->assertInstanceOf(AttractionContactInfo::class, $entity2); + self::assertInstanceOf(AttractionInfo::class, $entity1); + self::assertInstanceOf(AttractionInfo::class, $entity2); + self::assertInstanceOf(AttractionContactInfo::class, $entity1); + self::assertInstanceOf(AttractionContactInfo::class, $entity2); - $this->assertEquals($this->attractionsInfo[0]->getId(), $entity1->getId()); - $this->assertEquals($this->attractionsInfo[0]->getFone(), $entity1->getFone()); + self::assertEquals($this->attractionsInfo[0]->getId(), $entity1->getId()); + self::assertEquals($this->attractionsInfo[0]->getFone(), $entity1->getFone()); - $this->assertEquals($this->attractionsInfo[1]->getId(), $entity2->getId()); - $this->assertEquals($this->attractionsInfo[1]->getFone(), $entity2->getFone()); + self::assertEquals($this->attractionsInfo[1]->getId(), $entity2->getId()); + self::assertEquals($this->attractionsInfo[1]->getFone(), $entity2->getFone()); $this->_em->clear(); @@ -109,20 +109,20 @@ public function testPutAndLoadJoinTableEntities(): void $entity3 = $this->_em->find(AttractionInfo::class, $entityId1); $entity4 = $this->_em->find(AttractionInfo::class, $entityId2); - $this->assertEquals($queryCount, $this->getCurrentQueryCount()); + self::assertEquals($queryCount, $this->getCurrentQueryCount()); - $this->assertInstanceOf(AttractionInfo::class, $entity3); - $this->assertInstanceOf(AttractionInfo::class, $entity4); - $this->assertInstanceOf(AttractionContactInfo::class, $entity3); - $this->assertInstanceOf(AttractionContactInfo::class, $entity4); + self::assertInstanceOf(AttractionInfo::class, $entity3); + self::assertInstanceOf(AttractionInfo::class, $entity4); + self::assertInstanceOf(AttractionContactInfo::class, $entity3); + self::assertInstanceOf(AttractionContactInfo::class, $entity4); - $this->assertNotSame($entity1, $entity3); - $this->assertEquals($entity1->getId(), $entity3->getId()); - $this->assertEquals($entity1->getFone(), $entity3->getFone()); + self::assertNotSame($entity1, $entity3); + self::assertEquals($entity1->getId(), $entity3->getId()); + self::assertEquals($entity1->getFone(), $entity3->getFone()); - $this->assertNotSame($entity2, $entity4); - $this->assertEquals($entity2->getId(), $entity4->getId()); - $this->assertEquals($entity2->getFone(), $entity4->getFone()); + self::assertNotSame($entity2, $entity4); + self::assertEquals($entity2->getId(), $entity4->getId()); + self::assertEquals($entity2->getFone(), $entity4->getFone()); } public function testQueryCacheFindAllJoinTableEntities(): void @@ -141,8 +141,8 @@ public function testQueryCacheFindAllJoinTableEntities(): void ->setCacheable(true) ->getResult(); - $this->assertCount(count($this->attractionsInfo), $result1); - $this->assertEquals($queryCount + 1, $this->getCurrentQueryCount()); + self::assertCount(count($this->attractionsInfo), $result1); + self::assertEquals($queryCount + 1, $this->getCurrentQueryCount()); $this->_em->clear(); @@ -150,11 +150,11 @@ public function testQueryCacheFindAllJoinTableEntities(): void ->setCacheable(true) ->getResult(); - $this->assertCount(count($this->attractionsInfo), $result2); - $this->assertEquals($queryCount + 1, $this->getCurrentQueryCount()); + self::assertCount(count($this->attractionsInfo), $result2); + self::assertEquals($queryCount + 1, $this->getCurrentQueryCount()); foreach ($result2 as $entity) { - $this->assertInstanceOf(AttractionInfo::class, $entity); + self::assertInstanceOf(AttractionInfo::class, $entity); } } @@ -170,29 +170,29 @@ public function testOneToManyRelationJoinTable(): void $entity = $this->_em->find(Attraction::class, $this->attractions[0]->getId()); - $this->assertInstanceOf(Attraction::class, $entity); - $this->assertInstanceOf(PersistentCollection::class, $entity->getInfos()); - $this->assertCount(1, $entity->getInfos()); + self::assertInstanceOf(Attraction::class, $entity); + self::assertInstanceOf(PersistentCollection::class, $entity->getInfos()); + self::assertCount(1, $entity->getInfos()); $ownerId = $this->attractions[0]->getId(); $queryCount = $this->getCurrentQueryCount(); - $this->assertTrue($this->cache->containsEntity(Attraction::class, $ownerId)); - $this->assertTrue($this->cache->containsCollection(Attraction::class, 'infos', $ownerId)); + self::assertTrue($this->cache->containsEntity(Attraction::class, $ownerId)); + self::assertTrue($this->cache->containsCollection(Attraction::class, 'infos', $ownerId)); - $this->assertInstanceOf(AttractionContactInfo::class, $entity->getInfos()->get(0)); - $this->assertEquals($this->attractionsInfo[0]->getFone(), $entity->getInfos()->get(0)->getFone()); + self::assertInstanceOf(AttractionContactInfo::class, $entity->getInfos()->get(0)); + self::assertEquals($this->attractionsInfo[0]->getFone(), $entity->getInfos()->get(0)->getFone()); $this->_em->clear(); $entity = $this->_em->find(Attraction::class, $this->attractions[0]->getId()); - $this->assertInstanceOf(Attraction::class, $entity); - $this->assertInstanceOf(PersistentCollection::class, $entity->getInfos()); - $this->assertCount(1, $entity->getInfos()); + self::assertInstanceOf(Attraction::class, $entity); + self::assertInstanceOf(PersistentCollection::class, $entity->getInfos()); + self::assertCount(1, $entity->getInfos()); - $this->assertInstanceOf(AttractionContactInfo::class, $entity->getInfos()->get(0)); - $this->assertEquals($this->attractionsInfo[0]->getFone(), $entity->getInfos()->get(0)->getFone()); + self::assertInstanceOf(AttractionContactInfo::class, $entity->getInfos()->get(0)); + self::assertEquals($this->attractionsInfo[0]->getFone(), $entity->getInfos()->get(0)->getFone()); } public function testQueryCacheShouldBeEvictedOnTimestampUpdate(): void @@ -212,8 +212,8 @@ public function testQueryCacheShouldBeEvictedOnTimestampUpdate(): void ->setCacheable(true) ->getResult(); - $this->assertCount(count($this->attractionsInfo), $result1); - $this->assertEquals($queryCount + 5, $this->getCurrentQueryCount()); + self::assertCount(count($this->attractionsInfo), $result1); + self::assertEquals($queryCount + 5, $this->getCurrentQueryCount()); $contact = new AttractionContactInfo( '1234-1234', @@ -230,11 +230,11 @@ public function testQueryCacheShouldBeEvictedOnTimestampUpdate(): void ->setCacheable(true) ->getResult(); - $this->assertCount(count($this->attractionsInfo) + 1, $result2); - $this->assertEquals($queryCount + 6, $this->getCurrentQueryCount()); + self::assertCount(count($this->attractionsInfo) + 1, $result2); + self::assertEquals($queryCount + 6, $this->getCurrentQueryCount()); foreach ($result2 as $entity) { - $this->assertInstanceOf(AttractionInfo::class, $entity); + self::assertInstanceOf(AttractionInfo::class, $entity); } } } diff --git a/tests/Doctrine/Tests/ORM/Functional/SecondLevelCacheManyToManyTest.php b/tests/Doctrine/Tests/ORM/Functional/SecondLevelCacheManyToManyTest.php index 61a6eaa4301..2cbf5403207 100644 --- a/tests/Doctrine/Tests/ORM/Functional/SecondLevelCacheManyToManyTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/SecondLevelCacheManyToManyTest.php @@ -26,16 +26,16 @@ public function testShouldPutManyToManyCollectionOwningSideOnPersist(): void $this->loadFixturesTravels(); $this->_em->clear(); - $this->assertTrue($this->cache->containsEntity(Travel::class, $this->travels[0]->getId())); - $this->assertTrue($this->cache->containsEntity(Travel::class, $this->travels[1]->getId())); + self::assertTrue($this->cache->containsEntity(Travel::class, $this->travels[0]->getId())); + self::assertTrue($this->cache->containsEntity(Travel::class, $this->travels[1]->getId())); - $this->assertTrue($this->cache->containsCollection(Travel::class, 'visitedCities', $this->travels[0]->getId())); - $this->assertTrue($this->cache->containsCollection(Travel::class, 'visitedCities', $this->travels[1]->getId())); + self::assertTrue($this->cache->containsCollection(Travel::class, 'visitedCities', $this->travels[0]->getId())); + self::assertTrue($this->cache->containsCollection(Travel::class, 'visitedCities', $this->travels[1]->getId())); - $this->assertTrue($this->cache->containsEntity(City::class, $this->cities[0]->getId())); - $this->assertTrue($this->cache->containsEntity(City::class, $this->cities[1]->getId())); - $this->assertTrue($this->cache->containsEntity(City::class, $this->cities[2]->getId())); - $this->assertTrue($this->cache->containsEntity(City::class, $this->cities[3]->getId())); + self::assertTrue($this->cache->containsEntity(City::class, $this->cities[0]->getId())); + self::assertTrue($this->cache->containsEntity(City::class, $this->cities[1]->getId())); + self::assertTrue($this->cache->containsEntity(City::class, $this->cities[2]->getId())); + self::assertTrue($this->cache->containsEntity(City::class, $this->cities[3]->getId())); } public function testPutAndLoadManyToManyRelation(): void @@ -55,51 +55,51 @@ public function testPutAndLoadManyToManyRelation(): void $this->secondLevelCacheLogger->clearStats(); - $this->assertFalse($this->cache->containsEntity(Travel::class, $this->travels[0]->getId())); - $this->assertFalse($this->cache->containsEntity(Travel::class, $this->travels[1]->getId())); + self::assertFalse($this->cache->containsEntity(Travel::class, $this->travels[0]->getId())); + self::assertFalse($this->cache->containsEntity(Travel::class, $this->travels[1]->getId())); - $this->assertFalse($this->cache->containsCollection(Travel::class, 'visitedCities', $this->travels[0]->getId())); - $this->assertFalse($this->cache->containsCollection(Travel::class, 'visitedCities', $this->travels[1]->getId())); + self::assertFalse($this->cache->containsCollection(Travel::class, 'visitedCities', $this->travels[0]->getId())); + self::assertFalse($this->cache->containsCollection(Travel::class, 'visitedCities', $this->travels[1]->getId())); - $this->assertFalse($this->cache->containsEntity(City::class, $this->cities[0]->getId())); - $this->assertFalse($this->cache->containsEntity(City::class, $this->cities[1]->getId())); - $this->assertFalse($this->cache->containsEntity(City::class, $this->cities[2]->getId())); - $this->assertFalse($this->cache->containsEntity(City::class, $this->cities[3]->getId())); + self::assertFalse($this->cache->containsEntity(City::class, $this->cities[0]->getId())); + self::assertFalse($this->cache->containsEntity(City::class, $this->cities[1]->getId())); + self::assertFalse($this->cache->containsEntity(City::class, $this->cities[2]->getId())); + self::assertFalse($this->cache->containsEntity(City::class, $this->cities[3]->getId())); $t1 = $this->_em->find(Travel::class, $this->travels[0]->getId()); $t2 = $this->_em->find(Travel::class, $this->travels[1]->getId()); - $this->assertEquals(2, $this->secondLevelCacheLogger->getPutCount()); - $this->assertEquals(2, $this->secondLevelCacheLogger->getMissCount()); - $this->assertEquals(2, $this->secondLevelCacheLogger->getRegionPutCount($this->getEntityRegion(Travel::class))); - $this->assertEquals(2, $this->secondLevelCacheLogger->getRegionMissCount($this->getEntityRegion(Travel::class))); + self::assertEquals(2, $this->secondLevelCacheLogger->getPutCount()); + self::assertEquals(2, $this->secondLevelCacheLogger->getMissCount()); + self::assertEquals(2, $this->secondLevelCacheLogger->getRegionPutCount($this->getEntityRegion(Travel::class))); + self::assertEquals(2, $this->secondLevelCacheLogger->getRegionMissCount($this->getEntityRegion(Travel::class))); //trigger lazy load - $this->assertCount(3, $t1->getVisitedCities()); - $this->assertCount(2, $t2->getVisitedCities()); + self::assertCount(3, $t1->getVisitedCities()); + self::assertCount(2, $t2->getVisitedCities()); - $this->assertEquals(4, $this->secondLevelCacheLogger->getPutCount()); - $this->assertEquals(4, $this->secondLevelCacheLogger->getMissCount()); - $this->assertEquals(2, $this->secondLevelCacheLogger->getRegionPutCount($this->getCollectionRegion(Travel::class, 'visitedCities'))); - $this->assertEquals(2, $this->secondLevelCacheLogger->getRegionMissCount($this->getCollectionRegion(Travel::class, 'visitedCities'))); + self::assertEquals(4, $this->secondLevelCacheLogger->getPutCount()); + self::assertEquals(4, $this->secondLevelCacheLogger->getMissCount()); + self::assertEquals(2, $this->secondLevelCacheLogger->getRegionPutCount($this->getCollectionRegion(Travel::class, 'visitedCities'))); + self::assertEquals(2, $this->secondLevelCacheLogger->getRegionMissCount($this->getCollectionRegion(Travel::class, 'visitedCities'))); - $this->assertInstanceOf(City::class, $t1->getVisitedCities()->get(0)); - $this->assertInstanceOf(City::class, $t1->getVisitedCities()->get(1)); - $this->assertInstanceOf(City::class, $t1->getVisitedCities()->get(2)); + self::assertInstanceOf(City::class, $t1->getVisitedCities()->get(0)); + self::assertInstanceOf(City::class, $t1->getVisitedCities()->get(1)); + self::assertInstanceOf(City::class, $t1->getVisitedCities()->get(2)); - $this->assertInstanceOf(City::class, $t2->getVisitedCities()->get(0)); - $this->assertInstanceOf(City::class, $t2->getVisitedCities()->get(1)); + self::assertInstanceOf(City::class, $t2->getVisitedCities()->get(0)); + self::assertInstanceOf(City::class, $t2->getVisitedCities()->get(1)); - $this->assertTrue($this->cache->containsEntity(Travel::class, $this->travels[0]->getId())); - $this->assertTrue($this->cache->containsEntity(Travel::class, $this->travels[1]->getId())); + self::assertTrue($this->cache->containsEntity(Travel::class, $this->travels[0]->getId())); + self::assertTrue($this->cache->containsEntity(Travel::class, $this->travels[1]->getId())); - $this->assertTrue($this->cache->containsCollection(Travel::class, 'visitedCities', $this->travels[0]->getId())); - $this->assertTrue($this->cache->containsCollection(Travel::class, 'visitedCities', $this->travels[1]->getId())); + self::assertTrue($this->cache->containsCollection(Travel::class, 'visitedCities', $this->travels[0]->getId())); + self::assertTrue($this->cache->containsCollection(Travel::class, 'visitedCities', $this->travels[1]->getId())); - $this->assertTrue($this->cache->containsEntity(City::class, $this->cities[0]->getId())); - $this->assertTrue($this->cache->containsEntity(City::class, $this->cities[1]->getId())); - $this->assertTrue($this->cache->containsEntity(City::class, $this->cities[2]->getId())); - $this->assertTrue($this->cache->containsEntity(City::class, $this->cities[3]->getId())); + self::assertTrue($this->cache->containsEntity(City::class, $this->cities[0]->getId())); + self::assertTrue($this->cache->containsEntity(City::class, $this->cities[1]->getId())); + self::assertTrue($this->cache->containsEntity(City::class, $this->cities[2]->getId())); + self::assertTrue($this->cache->containsEntity(City::class, $this->cities[3]->getId())); $this->_em->clear(); $this->secondLevelCacheLogger->clearStats(); @@ -110,42 +110,42 @@ public function testPutAndLoadManyToManyRelation(): void $t4 = $this->_em->find(Travel::class, $this->travels[1]->getId()); //trigger lazy load from cache - $this->assertCount(3, $t3->getVisitedCities()); - $this->assertCount(2, $t4->getVisitedCities()); + self::assertCount(3, $t3->getVisitedCities()); + self::assertCount(2, $t4->getVisitedCities()); - $this->assertInstanceOf(City::class, $t3->getVisitedCities()->get(0)); - $this->assertInstanceOf(City::class, $t3->getVisitedCities()->get(1)); - $this->assertInstanceOf(City::class, $t3->getVisitedCities()->get(2)); + self::assertInstanceOf(City::class, $t3->getVisitedCities()->get(0)); + self::assertInstanceOf(City::class, $t3->getVisitedCities()->get(1)); + self::assertInstanceOf(City::class, $t3->getVisitedCities()->get(2)); - $this->assertInstanceOf(City::class, $t4->getVisitedCities()->get(0)); - $this->assertInstanceOf(City::class, $t4->getVisitedCities()->get(1)); + self::assertInstanceOf(City::class, $t4->getVisitedCities()->get(0)); + self::assertInstanceOf(City::class, $t4->getVisitedCities()->get(1)); - $this->assertEquals(4, $this->secondLevelCacheLogger->getHitCount()); - $this->assertEquals(2, $this->secondLevelCacheLogger->getRegionHitCount($this->getEntityRegion(Travel::class))); - $this->assertEquals(2, $this->secondLevelCacheLogger->getRegionHitCount($this->getCollectionRegion(Travel::class, 'visitedCities'))); + self::assertEquals(4, $this->secondLevelCacheLogger->getHitCount()); + self::assertEquals(2, $this->secondLevelCacheLogger->getRegionHitCount($this->getEntityRegion(Travel::class))); + self::assertEquals(2, $this->secondLevelCacheLogger->getRegionHitCount($this->getCollectionRegion(Travel::class, 'visitedCities'))); - $this->assertNotSame($t1->getVisitedCities()->get(0), $t3->getVisitedCities()->get(0)); - $this->assertEquals($t1->getVisitedCities()->get(0)->getId(), $t3->getVisitedCities()->get(0)->getId()); - $this->assertEquals($t1->getVisitedCities()->get(0)->getName(), $t3->getVisitedCities()->get(0)->getName()); + self::assertNotSame($t1->getVisitedCities()->get(0), $t3->getVisitedCities()->get(0)); + self::assertEquals($t1->getVisitedCities()->get(0)->getId(), $t3->getVisitedCities()->get(0)->getId()); + self::assertEquals($t1->getVisitedCities()->get(0)->getName(), $t3->getVisitedCities()->get(0)->getName()); - $this->assertNotSame($t1->getVisitedCities()->get(1), $t3->getVisitedCities()->get(1)); - $this->assertEquals($t1->getVisitedCities()->get(1)->getId(), $t3->getVisitedCities()->get(1)->getId()); - $this->assertEquals($t1->getVisitedCities()->get(1)->getName(), $t3->getVisitedCities()->get(1)->getName()); + self::assertNotSame($t1->getVisitedCities()->get(1), $t3->getVisitedCities()->get(1)); + self::assertEquals($t1->getVisitedCities()->get(1)->getId(), $t3->getVisitedCities()->get(1)->getId()); + self::assertEquals($t1->getVisitedCities()->get(1)->getName(), $t3->getVisitedCities()->get(1)->getName()); - $this->assertNotSame($t1->getVisitedCities()->get(2), $t3->getVisitedCities()->get(2)); - $this->assertEquals($t1->getVisitedCities()->get(2)->getId(), $t3->getVisitedCities()->get(2)->getId()); - $this->assertEquals($t1->getVisitedCities()->get(2)->getName(), $t3->getVisitedCities()->get(2)->getName()); + self::assertNotSame($t1->getVisitedCities()->get(2), $t3->getVisitedCities()->get(2)); + self::assertEquals($t1->getVisitedCities()->get(2)->getId(), $t3->getVisitedCities()->get(2)->getId()); + self::assertEquals($t1->getVisitedCities()->get(2)->getName(), $t3->getVisitedCities()->get(2)->getName()); - $this->assertNotSame($t2->getVisitedCities()->get(0), $t4->getVisitedCities()->get(0)); - $this->assertEquals($t2->getVisitedCities()->get(0)->getId(), $t4->getVisitedCities()->get(0)->getId()); - $this->assertEquals($t2->getVisitedCities()->get(0)->getName(), $t4->getVisitedCities()->get(0)->getName()); + self::assertNotSame($t2->getVisitedCities()->get(0), $t4->getVisitedCities()->get(0)); + self::assertEquals($t2->getVisitedCities()->get(0)->getId(), $t4->getVisitedCities()->get(0)->getId()); + self::assertEquals($t2->getVisitedCities()->get(0)->getName(), $t4->getVisitedCities()->get(0)->getName()); - $this->assertNotSame($t2->getVisitedCities()->get(1), $t4->getVisitedCities()->get(1)); - $this->assertEquals($t2->getVisitedCities()->get(1)->getId(), $t4->getVisitedCities()->get(1)->getId()); - $this->assertEquals($t2->getVisitedCities()->get(1)->getName(), $t4->getVisitedCities()->get(1)->getName()); + self::assertNotSame($t2->getVisitedCities()->get(1), $t4->getVisitedCities()->get(1)); + self::assertEquals($t2->getVisitedCities()->get(1)->getId(), $t4->getVisitedCities()->get(1)->getId()); + self::assertEquals($t2->getVisitedCities()->get(1)->getName(), $t4->getVisitedCities()->get(1)->getName()); - $this->assertEquals(4, $this->secondLevelCacheLogger->getHitCount()); - $this->assertEquals($queryCount, $this->getCurrentQueryCount()); + self::assertEquals(4, $this->secondLevelCacheLogger->getHitCount()); + self::assertEquals($queryCount, $this->getCurrentQueryCount()); } public function testStoreManyToManyAssociationWhitCascade(): void @@ -174,19 +174,19 @@ public function testStoreManyToManyAssociationWhitCascade(): void $this->_em->flush(); $this->_em->clear(); - $this->assertTrue($this->cache->containsEntity(Travel::class, $travel->getId())); - $this->assertTrue($this->cache->containsEntity(Traveler::class, $traveler->getId())); - $this->assertTrue($this->cache->containsEntity(City::class, $this->cities[0]->getId())); - $this->assertTrue($this->cache->containsEntity(City::class, $this->cities[1]->getId())); - $this->assertTrue($this->cache->containsEntity(City::class, $this->cities[3]->getId())); - $this->assertTrue($this->cache->containsCollection(Travel::class, 'visitedCities', $travel->getId())); + self::assertTrue($this->cache->containsEntity(Travel::class, $travel->getId())); + self::assertTrue($this->cache->containsEntity(Traveler::class, $traveler->getId())); + self::assertTrue($this->cache->containsEntity(City::class, $this->cities[0]->getId())); + self::assertTrue($this->cache->containsEntity(City::class, $this->cities[1]->getId())); + self::assertTrue($this->cache->containsEntity(City::class, $this->cities[3]->getId())); + self::assertTrue($this->cache->containsCollection(Travel::class, 'visitedCities', $travel->getId())); $queryCount1 = $this->getCurrentQueryCount(); $t1 = $this->_em->find(Travel::class, $travel->getId()); - $this->assertInstanceOf(Travel::class, $t1); - $this->assertCount(3, $t1->getVisitedCities()); - $this->assertEquals($queryCount1, $this->getCurrentQueryCount()); + self::assertInstanceOf(Travel::class, $t1); + self::assertCount(3, $t1->getVisitedCities()); + self::assertEquals($queryCount1, $this->getCurrentQueryCount()); } public function testReadOnlyCollection(): void @@ -204,12 +204,12 @@ public function testReadOnlyCollection(): void $this->_em->clear(); - $this->assertTrue($this->cache->containsEntity(Travel::class, $this->travels[0]->getId())); - $this->assertTrue($this->cache->containsCollection(Travel::class, 'visitedCities', $this->travels[0]->getId())); + self::assertTrue($this->cache->containsEntity(Travel::class, $this->travels[0]->getId())); + self::assertTrue($this->cache->containsCollection(Travel::class, 'visitedCities', $this->travels[0]->getId())); $travel = $this->_em->find(Travel::class, $this->travels[0]->getId()); - $this->assertCount(3, $travel->getVisitedCities()); + self::assertCount(3, $travel->getVisitedCities()); $travel->getVisitedCities()->remove(0); @@ -233,15 +233,15 @@ public function testManyToManyWithEmptyRelation(): void $entitiId = $this->travels[2]->getId(); //empty travel $entity = $this->_em->find(Travel::class, $entitiId); - $this->assertEquals(0, $entity->getVisitedCities()->count()); - $this->assertEquals($queryCount + 2, $this->getCurrentQueryCount()); + self::assertEquals(0, $entity->getVisitedCities()->count()); + self::assertEquals($queryCount + 2, $this->getCurrentQueryCount()); $this->_em->clear(); $entity = $this->_em->find(Travel::class, $entitiId); $queryCount = $this->getCurrentQueryCount(); - $this->assertEquals(0, $entity->getVisitedCities()->count()); - $this->assertEquals($queryCount, $this->getCurrentQueryCount()); + self::assertEquals(0, $entity->getVisitedCities()->count()); + self::assertEquals($queryCount, $this->getCurrentQueryCount()); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/SecondLevelCacheManyToOneTest.php b/tests/Doctrine/Tests/ORM/Functional/SecondLevelCacheManyToOneTest.php index 3a0aec32660..0424dcc2d9e 100644 --- a/tests/Doctrine/Tests/ORM/Functional/SecondLevelCacheManyToOneTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/SecondLevelCacheManyToOneTest.php @@ -23,10 +23,10 @@ public function testPutOnPersist(): void $this->loadFixturesStates(); $this->_em->clear(); - $this->assertTrue($this->cache->containsEntity(Country::class, $this->states[0]->getCountry()->getId())); - $this->assertTrue($this->cache->containsEntity(Country::class, $this->states[1]->getCountry()->getId())); - $this->assertTrue($this->cache->containsEntity(State::class, $this->states[0]->getId())); - $this->assertTrue($this->cache->containsEntity(State::class, $this->states[1]->getId())); + self::assertTrue($this->cache->containsEntity(Country::class, $this->states[0]->getCountry()->getId())); + self::assertTrue($this->cache->containsEntity(Country::class, $this->states[1]->getCountry()->getId())); + self::assertTrue($this->cache->containsEntity(State::class, $this->states[0]->getId())); + self::assertTrue($this->cache->containsEntity(State::class, $this->states[1]->getId())); } public function testPutAndLoadManyToOneRelation(): void @@ -38,37 +38,37 @@ public function testPutAndLoadManyToOneRelation(): void $this->cache->evictEntityRegion(State::class); $this->cache->evictEntityRegion(Country::class); - $this->assertFalse($this->cache->containsEntity(State::class, $this->states[0]->getId())); - $this->assertFalse($this->cache->containsEntity(State::class, $this->states[1]->getId())); - $this->assertFalse($this->cache->containsEntity(Country::class, $this->states[0]->getCountry()->getId())); - $this->assertFalse($this->cache->containsEntity(Country::class, $this->states[1]->getCountry()->getId())); + self::assertFalse($this->cache->containsEntity(State::class, $this->states[0]->getId())); + self::assertFalse($this->cache->containsEntity(State::class, $this->states[1]->getId())); + self::assertFalse($this->cache->containsEntity(Country::class, $this->states[0]->getCountry()->getId())); + self::assertFalse($this->cache->containsEntity(Country::class, $this->states[1]->getCountry()->getId())); $c1 = $this->_em->find(State::class, $this->states[0]->getId()); $c2 = $this->_em->find(State::class, $this->states[1]->getId()); //trigger lazy load - $this->assertNotNull($c1->getCountry()->getName()); - $this->assertNotNull($c2->getCountry()->getName()); + self::assertNotNull($c1->getCountry()->getName()); + self::assertNotNull($c2->getCountry()->getName()); - $this->assertTrue($this->cache->containsEntity(Country::class, $this->states[0]->getCountry()->getId())); - $this->assertTrue($this->cache->containsEntity(Country::class, $this->states[1]->getCountry()->getId())); - $this->assertTrue($this->cache->containsEntity(State::class, $this->states[0]->getId())); - $this->assertTrue($this->cache->containsEntity(State::class, $this->states[1]->getId())); + self::assertTrue($this->cache->containsEntity(Country::class, $this->states[0]->getCountry()->getId())); + self::assertTrue($this->cache->containsEntity(Country::class, $this->states[1]->getCountry()->getId())); + self::assertTrue($this->cache->containsEntity(State::class, $this->states[0]->getId())); + self::assertTrue($this->cache->containsEntity(State::class, $this->states[1]->getId())); - $this->assertInstanceOf(State::class, $c1); - $this->assertInstanceOf(State::class, $c2); - $this->assertInstanceOf(Country::class, $c1->getCountry()); - $this->assertInstanceOf(Country::class, $c2->getCountry()); + self::assertInstanceOf(State::class, $c1); + self::assertInstanceOf(State::class, $c2); + self::assertInstanceOf(Country::class, $c1->getCountry()); + self::assertInstanceOf(Country::class, $c2->getCountry()); - $this->assertEquals($this->states[0]->getId(), $c1->getId()); - $this->assertEquals($this->states[0]->getName(), $c1->getName()); - $this->assertEquals($this->states[0]->getCountry()->getId(), $c1->getCountry()->getId()); - $this->assertEquals($this->states[0]->getCountry()->getName(), $c1->getCountry()->getName()); + self::assertEquals($this->states[0]->getId(), $c1->getId()); + self::assertEquals($this->states[0]->getName(), $c1->getName()); + self::assertEquals($this->states[0]->getCountry()->getId(), $c1->getCountry()->getId()); + self::assertEquals($this->states[0]->getCountry()->getName(), $c1->getCountry()->getName()); - $this->assertEquals($this->states[1]->getId(), $c2->getId()); - $this->assertEquals($this->states[1]->getName(), $c2->getName()); - $this->assertEquals($this->states[1]->getCountry()->getId(), $c2->getCountry()->getId()); - $this->assertEquals($this->states[1]->getCountry()->getName(), $c2->getCountry()->getName()); + self::assertEquals($this->states[1]->getId(), $c2->getId()); + self::assertEquals($this->states[1]->getName(), $c2->getName()); + self::assertEquals($this->states[1]->getCountry()->getId(), $c2->getCountry()->getId()); + self::assertEquals($this->states[1]->getCountry()->getName(), $c2->getCountry()->getName()); $this->_em->clear(); @@ -77,28 +77,28 @@ public function testPutAndLoadManyToOneRelation(): void $c3 = $this->_em->find(State::class, $this->states[0]->getId()); $c4 = $this->_em->find(State::class, $this->states[1]->getId()); - $this->assertEquals($queryCount, $this->getCurrentQueryCount()); + self::assertEquals($queryCount, $this->getCurrentQueryCount()); //trigger lazy load from cache - $this->assertNotNull($c3->getCountry()->getName()); - $this->assertNotNull($c4->getCountry()->getName()); + self::assertNotNull($c3->getCountry()->getName()); + self::assertNotNull($c4->getCountry()->getName()); - $this->assertInstanceOf(State::class, $c3); - $this->assertInstanceOf(State::class, $c4); - $this->assertInstanceOf(Country::class, $c3->getCountry()); - $this->assertInstanceOf(Country::class, $c4->getCountry()); + self::assertInstanceOf(State::class, $c3); + self::assertInstanceOf(State::class, $c4); + self::assertInstanceOf(Country::class, $c3->getCountry()); + self::assertInstanceOf(Country::class, $c4->getCountry()); - $this->assertEquals($c1->getId(), $c3->getId()); - $this->assertEquals($c1->getName(), $c3->getName()); + self::assertEquals($c1->getId(), $c3->getId()); + self::assertEquals($c1->getName(), $c3->getName()); - $this->assertEquals($c2->getId(), $c4->getId()); - $this->assertEquals($c2->getName(), $c4->getName()); + self::assertEquals($c2->getId(), $c4->getId()); + self::assertEquals($c2->getName(), $c4->getName()); - $this->assertEquals($this->states[0]->getCountry()->getId(), $c3->getCountry()->getId()); - $this->assertEquals($this->states[0]->getCountry()->getName(), $c3->getCountry()->getName()); + self::assertEquals($this->states[0]->getCountry()->getId(), $c3->getCountry()->getId()); + self::assertEquals($this->states[0]->getCountry()->getName(), $c3->getCountry()->getName()); - $this->assertEquals($this->states[1]->getCountry()->getId(), $c4->getCountry()->getId()); - $this->assertEquals($this->states[1]->getCountry()->getName(), $c4->getCountry()->getName()); + self::assertEquals($this->states[1]->getCountry()->getId(), $c4->getCountry()->getId()); + self::assertEquals($this->states[1]->getCountry()->getName(), $c4->getCountry()->getName()); } public function testInverseSidePutShouldEvictCollection(): void @@ -128,11 +128,11 @@ public function testInverseSidePutShouldEvictCollection(): void $queryCount = $this->getCurrentQueryCount(); // Association was cleared from EM - $this->assertNotEquals($prev, $state->getCities()); + self::assertNotEquals($prev, $state->getCities()); // New association has one more item (cache was evicted) - $this->assertEquals($count + 1, $state->getCities()->count()); - $this->assertEquals($queryCount, $this->getCurrentQueryCount()); + self::assertEquals($count + 1, $state->getCities()->count()); + self::assertEquals($queryCount, $this->getCurrentQueryCount()); } public function testShouldNotReloadWhenAssociationIsMissing(): void @@ -147,15 +147,15 @@ public function testShouldNotReloadWhenAssociationIsMissing(): void $countryId1 = $this->states[0]->getCountry()->getId(); $countryId2 = $this->states[3]->getCountry()->getId(); - $this->assertTrue($this->cache->containsEntity(Country::class, $countryId1)); - $this->assertTrue($this->cache->containsEntity(Country::class, $countryId2)); - $this->assertTrue($this->cache->containsEntity(State::class, $stateId1)); - $this->assertTrue($this->cache->containsEntity(State::class, $stateId2)); + self::assertTrue($this->cache->containsEntity(Country::class, $countryId1)); + self::assertTrue($this->cache->containsEntity(Country::class, $countryId2)); + self::assertTrue($this->cache->containsEntity(State::class, $stateId1)); + self::assertTrue($this->cache->containsEntity(State::class, $stateId2)); $this->cache->evictEntityRegion(Country::class); - $this->assertFalse($this->cache->containsEntity(Country::class, $countryId1)); - $this->assertFalse($this->cache->containsEntity(Country::class, $countryId2)); + self::assertFalse($this->cache->containsEntity(Country::class, $countryId1)); + self::assertFalse($this->cache->containsEntity(Country::class, $countryId2)); $this->_em->clear(); @@ -164,27 +164,27 @@ public function testShouldNotReloadWhenAssociationIsMissing(): void $state1 = $this->_em->find(State::class, $stateId1); $state2 = $this->_em->find(State::class, $stateId2); - $this->assertEquals($queryCount, $this->getCurrentQueryCount()); + self::assertEquals($queryCount, $this->getCurrentQueryCount()); - $this->assertInstanceOf(State::class, $state1); - $this->assertInstanceOf(State::class, $state2); - $this->assertInstanceOf(Country::class, $state1->getCountry()); - $this->assertInstanceOf(Country::class, $state2->getCountry()); + self::assertInstanceOf(State::class, $state1); + self::assertInstanceOf(State::class, $state2); + self::assertInstanceOf(Country::class, $state1->getCountry()); + self::assertInstanceOf(Country::class, $state2->getCountry()); $queryCount = $this->getCurrentQueryCount(); - $this->assertNotNull($state1->getCountry()->getName()); - $this->assertNotNull($state2->getCountry()->getName()); - $this->assertEquals($countryId1, $state1->getCountry()->getId()); - $this->assertEquals($countryId2, $state2->getCountry()->getId()); + self::assertNotNull($state1->getCountry()->getName()); + self::assertNotNull($state2->getCountry()->getName()); + self::assertEquals($countryId1, $state1->getCountry()->getId()); + self::assertEquals($countryId2, $state2->getCountry()->getId()); - $this->assertEquals($queryCount + 2, $this->getCurrentQueryCount()); + self::assertEquals($queryCount + 2, $this->getCurrentQueryCount()); } public function testPutAndLoadNonCacheableManyToOne(): void { - $this->assertNull($this->cache->getEntityCacheRegion(Action::class)); - $this->assertInstanceOf(Region::class, $this->cache->getEntityCacheRegion(Token::class)); + self::assertNull($this->cache->getEntityCacheRegion(Action::class)); + self::assertInstanceOf(Region::class, $this->cache->getEntityCacheRegion(Token::class)); $token = new Token('token-hash'); $action = new Action('exec'); @@ -195,26 +195,26 @@ public function testPutAndLoadNonCacheableManyToOne(): void $this->_em->flush(); $this->_em->clear(); - $this->assertTrue($this->cache->containsEntity(Token::class, $token->token)); - $this->assertFalse($this->cache->containsEntity(Token::class, $action->name)); + self::assertTrue($this->cache->containsEntity(Token::class, $token->token)); + self::assertFalse($this->cache->containsEntity(Token::class, $action->name)); $queryCount = $this->getCurrentQueryCount(); $entity = $this->_em->find(Token::class, $token->token); - $this->assertInstanceOf(Token::class, $entity); - $this->assertEquals('token-hash', $entity->token); + self::assertInstanceOf(Token::class, $entity); + self::assertEquals('token-hash', $entity->token); - $this->assertInstanceOf(Action::class, $entity->getAction()); - $this->assertEquals('exec', $entity->getAction()->name); + self::assertInstanceOf(Action::class, $entity->getAction()); + self::assertEquals('exec', $entity->getAction()->name); - $this->assertEquals($queryCount, $this->getCurrentQueryCount()); + self::assertEquals($queryCount, $this->getCurrentQueryCount()); } public function testPutAndLoadNonCacheableCompositeManyToOne(): void { - $this->assertNull($this->cache->getEntityCacheRegion(Action::class)); - $this->assertNull($this->cache->getEntityCacheRegion(ComplexAction::class)); - $this->assertInstanceOf(Region::class, $this->cache->getEntityCacheRegion(Token::class)); + self::assertNull($this->cache->getEntityCacheRegion(Action::class)); + self::assertNull($this->cache->getEntityCacheRegion(ComplexAction::class)); + self::assertInstanceOf(Region::class, $this->cache->getEntityCacheRegion(Token::class)); $token = new Token('token-hash'); @@ -233,10 +233,10 @@ public function testPutAndLoadNonCacheableCompositeManyToOne(): void $this->_em->flush(); $this->_em->clear(); - $this->assertTrue($this->cache->containsEntity(Token::class, $token->token)); - $this->assertFalse($this->cache->containsEntity(Action::class, $action1->name)); - $this->assertFalse($this->cache->containsEntity(Action::class, $action2->name)); - $this->assertFalse($this->cache->containsEntity(Action::class, $action3->name)); + self::assertTrue($this->cache->containsEntity(Token::class, $token->token)); + self::assertFalse($this->cache->containsEntity(Action::class, $action1->name)); + self::assertFalse($this->cache->containsEntity(Action::class, $action2->name)); + self::assertFalse($this->cache->containsEntity(Action::class, $action3->name)); $queryCount = $this->getCurrentQueryCount(); /** @@ -244,22 +244,22 @@ public function testPutAndLoadNonCacheableCompositeManyToOne(): void */ $entity = $this->_em->find(Token::class, $token->token); - $this->assertInstanceOf(Token::class, $entity); - $this->assertEquals('token-hash', $entity->token); + self::assertInstanceOf(Token::class, $entity); + self::assertEquals('token-hash', $entity->token); - $this->assertEquals($queryCount, $this->getCurrentQueryCount()); + self::assertEquals($queryCount, $this->getCurrentQueryCount()); - $this->assertInstanceOf(Action::class, $entity->getAction()); - $this->assertInstanceOf(ComplexAction::class, $entity->getComplexAction()); - $this->assertEquals($queryCount, $this->getCurrentQueryCount()); + self::assertInstanceOf(Action::class, $entity->getAction()); + self::assertInstanceOf(ComplexAction::class, $entity->getComplexAction()); + self::assertEquals($queryCount, $this->getCurrentQueryCount()); - $this->assertInstanceOf(Action::class, $entity->getComplexAction()->getAction1()); - $this->assertInstanceOf(Action::class, $entity->getComplexAction()->getAction2()); - $this->assertEquals($queryCount + 1, $this->getCurrentQueryCount()); + self::assertInstanceOf(Action::class, $entity->getComplexAction()->getAction1()); + self::assertInstanceOf(Action::class, $entity->getComplexAction()->getAction2()); + self::assertEquals($queryCount + 1, $this->getCurrentQueryCount()); - $this->assertEquals('login', $entity->getComplexAction()->getAction1()->name); - $this->assertEquals($queryCount + 1, $this->getCurrentQueryCount()); - $this->assertEquals('rememberme', $entity->getComplexAction()->getAction2()->name); - $this->assertEquals($queryCount + 1, $this->getCurrentQueryCount()); + self::assertEquals('login', $entity->getComplexAction()->getAction1()->name); + self::assertEquals($queryCount + 1, $this->getCurrentQueryCount()); + self::assertEquals('rememberme', $entity->getComplexAction()->getAction2()->name); + self::assertEquals($queryCount + 1, $this->getCurrentQueryCount()); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/SecondLevelCacheOneToManyTest.php b/tests/Doctrine/Tests/ORM/Functional/SecondLevelCacheOneToManyTest.php index 732d17b99ba..f5cf5b5fefd 100644 --- a/tests/Doctrine/Tests/ORM/Functional/SecondLevelCacheOneToManyTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/SecondLevelCacheOneToManyTest.php @@ -27,10 +27,10 @@ public function testShouldPutCollectionInverseSideOnPersist(): void $this->_em->clear(); - $this->assertTrue($this->cache->containsEntity(State::class, $this->states[0]->getId())); - $this->assertTrue($this->cache->containsEntity(State::class, $this->states[1]->getId())); - $this->assertTrue($this->cache->containsCollection(State::class, 'cities', $this->states[0]->getId())); - $this->assertTrue($this->cache->containsCollection(State::class, 'cities', $this->states[1]->getId())); + self::assertTrue($this->cache->containsEntity(State::class, $this->states[0]->getId())); + self::assertTrue($this->cache->containsEntity(State::class, $this->states[1]->getId())); + self::assertTrue($this->cache->containsCollection(State::class, 'cities', $this->states[0]->getId())); + self::assertTrue($this->cache->containsCollection(State::class, 'cities', $this->states[1]->getId())); } public function testPutAndLoadOneToManyRelation(): void @@ -45,50 +45,50 @@ public function testPutAndLoadOneToManyRelation(): void $this->cache->evictEntityRegion(City::class); $this->cache->evictCollectionRegion(State::class, 'cities'); - $this->assertFalse($this->cache->containsEntity(State::class, $this->states[0]->getId())); - $this->assertFalse($this->cache->containsEntity(State::class, $this->states[1]->getId())); + self::assertFalse($this->cache->containsEntity(State::class, $this->states[0]->getId())); + self::assertFalse($this->cache->containsEntity(State::class, $this->states[1]->getId())); - $this->assertFalse($this->cache->containsCollection(State::class, 'cities', $this->states[0]->getId())); - $this->assertFalse($this->cache->containsCollection(State::class, 'cities', $this->states[1]->getId())); + self::assertFalse($this->cache->containsCollection(State::class, 'cities', $this->states[0]->getId())); + self::assertFalse($this->cache->containsCollection(State::class, 'cities', $this->states[1]->getId())); - $this->assertFalse($this->cache->containsEntity(City::class, $this->states[0]->getCities()->get(0)->getId())); - $this->assertFalse($this->cache->containsEntity(City::class, $this->states[0]->getCities()->get(1)->getId())); - $this->assertFalse($this->cache->containsEntity(City::class, $this->states[1]->getCities()->get(0)->getId())); - $this->assertFalse($this->cache->containsEntity(City::class, $this->states[1]->getCities()->get(1)->getId())); + self::assertFalse($this->cache->containsEntity(City::class, $this->states[0]->getCities()->get(0)->getId())); + self::assertFalse($this->cache->containsEntity(City::class, $this->states[0]->getCities()->get(1)->getId())); + self::assertFalse($this->cache->containsEntity(City::class, $this->states[1]->getCities()->get(0)->getId())); + self::assertFalse($this->cache->containsEntity(City::class, $this->states[1]->getCities()->get(1)->getId())); $s1 = $this->_em->find(State::class, $this->states[0]->getId()); $s2 = $this->_em->find(State::class, $this->states[1]->getId()); - $this->assertEquals(2, $this->secondLevelCacheLogger->getPutCount()); - $this->assertEquals(2, $this->secondLevelCacheLogger->getMissCount()); - $this->assertEquals(2, $this->secondLevelCacheLogger->getRegionPutCount($this->getEntityRegion(State::class))); - $this->assertEquals(2, $this->secondLevelCacheLogger->getRegionMissCount($this->getEntityRegion(State::class))); + self::assertEquals(2, $this->secondLevelCacheLogger->getPutCount()); + self::assertEquals(2, $this->secondLevelCacheLogger->getMissCount()); + self::assertEquals(2, $this->secondLevelCacheLogger->getRegionPutCount($this->getEntityRegion(State::class))); + self::assertEquals(2, $this->secondLevelCacheLogger->getRegionMissCount($this->getEntityRegion(State::class))); //trigger lazy load - $this->assertCount(2, $s1->getCities()); - $this->assertCount(2, $s2->getCities()); + self::assertCount(2, $s1->getCities()); + self::assertCount(2, $s2->getCities()); - $this->assertEquals(4, $this->secondLevelCacheLogger->getPutCount()); - $this->assertEquals(4, $this->secondLevelCacheLogger->getMissCount()); - $this->assertEquals(2, $this->secondLevelCacheLogger->getRegionPutCount($this->getCollectionRegion(State::class, 'cities'))); - $this->assertEquals(2, $this->secondLevelCacheLogger->getRegionMissCount($this->getCollectionRegion(State::class, 'cities'))); + self::assertEquals(4, $this->secondLevelCacheLogger->getPutCount()); + self::assertEquals(4, $this->secondLevelCacheLogger->getMissCount()); + self::assertEquals(2, $this->secondLevelCacheLogger->getRegionPutCount($this->getCollectionRegion(State::class, 'cities'))); + self::assertEquals(2, $this->secondLevelCacheLogger->getRegionMissCount($this->getCollectionRegion(State::class, 'cities'))); - $this->assertInstanceOf(City::class, $s1->getCities()->get(0)); - $this->assertInstanceOf(City::class, $s1->getCities()->get(1)); + self::assertInstanceOf(City::class, $s1->getCities()->get(0)); + self::assertInstanceOf(City::class, $s1->getCities()->get(1)); - $this->assertInstanceOf(City::class, $s2->getCities()->get(0)); - $this->assertInstanceOf(City::class, $s2->getCities()->get(1)); + self::assertInstanceOf(City::class, $s2->getCities()->get(0)); + self::assertInstanceOf(City::class, $s2->getCities()->get(1)); - $this->assertTrue($this->cache->containsEntity(State::class, $this->states[0]->getId())); - $this->assertTrue($this->cache->containsEntity(State::class, $this->states[1]->getId())); + self::assertTrue($this->cache->containsEntity(State::class, $this->states[0]->getId())); + self::assertTrue($this->cache->containsEntity(State::class, $this->states[1]->getId())); - $this->assertTrue($this->cache->containsCollection(State::class, 'cities', $this->states[0]->getId())); - $this->assertTrue($this->cache->containsCollection(State::class, 'cities', $this->states[1]->getId())); + self::assertTrue($this->cache->containsCollection(State::class, 'cities', $this->states[0]->getId())); + self::assertTrue($this->cache->containsCollection(State::class, 'cities', $this->states[1]->getId())); - $this->assertTrue($this->cache->containsEntity(City::class, $this->states[0]->getCities()->get(0)->getId())); - $this->assertTrue($this->cache->containsEntity(City::class, $this->states[0]->getCities()->get(1)->getId())); - $this->assertTrue($this->cache->containsEntity(City::class, $this->states[1]->getCities()->get(0)->getId())); - $this->assertTrue($this->cache->containsEntity(City::class, $this->states[1]->getCities()->get(1)->getId())); + self::assertTrue($this->cache->containsEntity(City::class, $this->states[0]->getCities()->get(0)->getId())); + self::assertTrue($this->cache->containsEntity(City::class, $this->states[0]->getCities()->get(1)->getId())); + self::assertTrue($this->cache->containsEntity(City::class, $this->states[1]->getCities()->get(0)->getId())); + self::assertTrue($this->cache->containsEntity(City::class, $this->states[1]->getCities()->get(1)->getId())); $this->_em->clear(); $this->secondLevelCacheLogger->clearStats(); @@ -99,36 +99,36 @@ public function testPutAndLoadOneToManyRelation(): void $s4 = $this->_em->find(State::class, $this->states[1]->getId()); //trigger lazy load from cache - $this->assertCount(2, $s3->getCities()); - $this->assertCount(2, $s4->getCities()); + self::assertCount(2, $s3->getCities()); + self::assertCount(2, $s4->getCities()); - $this->assertEquals(4, $this->secondLevelCacheLogger->getHitCount()); - $this->assertEquals(2, $this->secondLevelCacheLogger->getRegionHitCount($this->getEntityRegion(State::class))); - $this->assertEquals(2, $this->secondLevelCacheLogger->getRegionHitCount($this->getCollectionRegion(State::class, 'cities'))); + self::assertEquals(4, $this->secondLevelCacheLogger->getHitCount()); + self::assertEquals(2, $this->secondLevelCacheLogger->getRegionHitCount($this->getEntityRegion(State::class))); + self::assertEquals(2, $this->secondLevelCacheLogger->getRegionHitCount($this->getCollectionRegion(State::class, 'cities'))); - $this->assertInstanceOf(City::class, $s3->getCities()->get(0)); - $this->assertInstanceOf(City::class, $s3->getCities()->get(1)); - $this->assertInstanceOf(City::class, $s4->getCities()->get(0)); - $this->assertInstanceOf(City::class, $s4->getCities()->get(1)); + self::assertInstanceOf(City::class, $s3->getCities()->get(0)); + self::assertInstanceOf(City::class, $s3->getCities()->get(1)); + self::assertInstanceOf(City::class, $s4->getCities()->get(0)); + self::assertInstanceOf(City::class, $s4->getCities()->get(1)); - $this->assertNotSame($s1->getCities()->get(0), $s3->getCities()->get(0)); - $this->assertEquals($s1->getCities()->get(0)->getId(), $s3->getCities()->get(0)->getId()); - $this->assertEquals($s1->getCities()->get(0)->getName(), $s3->getCities()->get(0)->getName()); + self::assertNotSame($s1->getCities()->get(0), $s3->getCities()->get(0)); + self::assertEquals($s1->getCities()->get(0)->getId(), $s3->getCities()->get(0)->getId()); + self::assertEquals($s1->getCities()->get(0)->getName(), $s3->getCities()->get(0)->getName()); - $this->assertNotSame($s1->getCities()->get(1), $s3->getCities()->get(1)); - $this->assertEquals($s1->getCities()->get(1)->getId(), $s3->getCities()->get(1)->getId()); - $this->assertEquals($s1->getCities()->get(1)->getName(), $s3->getCities()->get(1)->getName()); + self::assertNotSame($s1->getCities()->get(1), $s3->getCities()->get(1)); + self::assertEquals($s1->getCities()->get(1)->getId(), $s3->getCities()->get(1)->getId()); + self::assertEquals($s1->getCities()->get(1)->getName(), $s3->getCities()->get(1)->getName()); - $this->assertNotSame($s2->getCities()->get(0), $s4->getCities()->get(0)); - $this->assertEquals($s2->getCities()->get(0)->getId(), $s4->getCities()->get(0)->getId()); - $this->assertEquals($s2->getCities()->get(0)->getName(), $s4->getCities()->get(0)->getName()); + self::assertNotSame($s2->getCities()->get(0), $s4->getCities()->get(0)); + self::assertEquals($s2->getCities()->get(0)->getId(), $s4->getCities()->get(0)->getId()); + self::assertEquals($s2->getCities()->get(0)->getName(), $s4->getCities()->get(0)->getName()); - $this->assertNotSame($s2->getCities()->get(1), $s4->getCities()->get(1)); - $this->assertEquals($s2->getCities()->get(1)->getId(), $s4->getCities()->get(1)->getId()); - $this->assertEquals($s2->getCities()->get(1)->getName(), $s4->getCities()->get(1)->getName()); + self::assertNotSame($s2->getCities()->get(1), $s4->getCities()->get(1)); + self::assertEquals($s2->getCities()->get(1)->getId(), $s4->getCities()->get(1)->getId()); + self::assertEquals($s2->getCities()->get(1)->getName(), $s4->getCities()->get(1)->getName()); - $this->assertEquals(4, $this->secondLevelCacheLogger->getHitCount()); - $this->assertEquals($queryCount, $this->getCurrentQueryCount()); + self::assertEquals(4, $this->secondLevelCacheLogger->getHitCount()); + self::assertEquals($queryCount, $this->getCurrentQueryCount()); } public function testLoadOneToManyCollectionFromDatabaseWhenEntityMissing(): void @@ -139,12 +139,12 @@ public function testLoadOneToManyCollectionFromDatabaseWhenEntityMissing(): void $this->_em->clear(); //trigger lazy load from database - $this->assertCount(2, $this->_em->find(State::class, $this->states[0]->getId())->getCities()); + self::assertCount(2, $this->_em->find(State::class, $this->states[0]->getId())->getCities()); - $this->assertTrue($this->cache->containsEntity(State::class, $this->states[0]->getId())); - $this->assertTrue($this->cache->containsCollection(State::class, 'cities', $this->states[0]->getId())); - $this->assertTrue($this->cache->containsEntity(City::class, $this->states[0]->getCities()->get(0)->getId())); - $this->assertTrue($this->cache->containsEntity(City::class, $this->states[0]->getCities()->get(1)->getId())); + self::assertTrue($this->cache->containsEntity(State::class, $this->states[0]->getId())); + self::assertTrue($this->cache->containsCollection(State::class, 'cities', $this->states[0]->getId())); + self::assertTrue($this->cache->containsEntity(City::class, $this->states[0]->getCities()->get(0)->getId())); + self::assertTrue($this->cache->containsEntity(City::class, $this->states[0]->getCities()->get(1)->getId())); $queryCount = $this->getCurrentQueryCount(); $stateId = $this->states[0]->getId(); @@ -152,23 +152,23 @@ public function testLoadOneToManyCollectionFromDatabaseWhenEntityMissing(): void $cityId = $this->states[0]->getCities()->get(1)->getId(); //trigger lazy load from cache - $this->assertCount(2, $state->getCities()); - $this->assertEquals($queryCount, $this->getCurrentQueryCount()); - $this->assertTrue($this->cache->containsEntity(City::class, $cityId)); + self::assertCount(2, $state->getCities()); + self::assertEquals($queryCount, $this->getCurrentQueryCount()); + self::assertTrue($this->cache->containsEntity(City::class, $cityId)); $this->cache->evictEntity(City::class, $cityId); - $this->assertFalse($this->cache->containsEntity(City::class, $cityId)); - $this->assertTrue($this->cache->containsEntity(State::class, $stateId)); - $this->assertTrue($this->cache->containsCollection(State::class, 'cities', $stateId)); + self::assertFalse($this->cache->containsEntity(City::class, $cityId)); + self::assertTrue($this->cache->containsEntity(State::class, $stateId)); + self::assertTrue($this->cache->containsCollection(State::class, 'cities', $stateId)); $this->_em->clear(); $state = $this->_em->find(State::class, $stateId); //trigger lazy load from database - $this->assertCount(2, $state->getCities()); - $this->assertEquals($queryCount + 1, $this->getCurrentQueryCount()); + self::assertCount(2, $state->getCities()); + self::assertEquals($queryCount + 1, $this->getCurrentQueryCount()); } public function testShoudNotPutOneToManyRelationOnPersist(): void @@ -182,8 +182,8 @@ public function testShoudNotPutOneToManyRelationOnPersist(): void $this->_em->flush(); $this->_em->clear(); - $this->assertTrue($this->cache->containsEntity(State::class, $state->getId())); - $this->assertFalse($this->cache->containsCollection(State::class, 'cities', $state->getId())); + self::assertTrue($this->cache->containsEntity(State::class, $state->getId())); + self::assertFalse($this->cache->containsCollection(State::class, 'cities', $state->getId())); } public function testOneToManyRemove(): void @@ -199,28 +199,28 @@ public function testOneToManyRemove(): void $this->cache->evictEntityRegion(City::class); $this->cache->evictCollectionRegion(State::class, 'cities'); - $this->assertFalse($this->cache->containsEntity(State::class, $this->states[0]->getId())); - $this->assertFalse($this->cache->containsCollection(State::class, 'cities', $this->states[0]->getId())); - $this->assertFalse($this->cache->containsEntity(City::class, $this->states[0]->getCities()->get(0)->getId())); - $this->assertFalse($this->cache->containsEntity(City::class, $this->states[0]->getCities()->get(1)->getId())); + self::assertFalse($this->cache->containsEntity(State::class, $this->states[0]->getId())); + self::assertFalse($this->cache->containsCollection(State::class, 'cities', $this->states[0]->getId())); + self::assertFalse($this->cache->containsEntity(City::class, $this->states[0]->getCities()->get(0)->getId())); + self::assertFalse($this->cache->containsEntity(City::class, $this->states[0]->getCities()->get(1)->getId())); $entity = $this->_em->find(State::class, $this->states[0]->getId()); - $this->assertEquals(1, $this->secondLevelCacheLogger->getPutCount()); - $this->assertEquals(1, $this->secondLevelCacheLogger->getMissCount()); - $this->assertEquals(1, $this->secondLevelCacheLogger->getRegionPutCount($this->getEntityRegion(State::class))); - $this->assertEquals(1, $this->secondLevelCacheLogger->getRegionMissCount($this->getEntityRegion(State::class))); + self::assertEquals(1, $this->secondLevelCacheLogger->getPutCount()); + self::assertEquals(1, $this->secondLevelCacheLogger->getMissCount()); + self::assertEquals(1, $this->secondLevelCacheLogger->getRegionPutCount($this->getEntityRegion(State::class))); + self::assertEquals(1, $this->secondLevelCacheLogger->getRegionMissCount($this->getEntityRegion(State::class))); //trigger lazy load - $this->assertCount(2, $entity->getCities()); + self::assertCount(2, $entity->getCities()); - $this->assertEquals(2, $this->secondLevelCacheLogger->getPutCount()); - $this->assertEquals(2, $this->secondLevelCacheLogger->getMissCount()); - $this->assertEquals(1, $this->secondLevelCacheLogger->getRegionPutCount($this->getCollectionRegion(State::class, 'cities'))); - $this->assertEquals(1, $this->secondLevelCacheLogger->getRegionMissCount($this->getCollectionRegion(State::class, 'cities'))); + self::assertEquals(2, $this->secondLevelCacheLogger->getPutCount()); + self::assertEquals(2, $this->secondLevelCacheLogger->getMissCount()); + self::assertEquals(1, $this->secondLevelCacheLogger->getRegionPutCount($this->getCollectionRegion(State::class, 'cities'))); + self::assertEquals(1, $this->secondLevelCacheLogger->getRegionMissCount($this->getCollectionRegion(State::class, 'cities'))); - $this->assertInstanceOf(City::class, $entity->getCities()->get(0)); - $this->assertInstanceOf(City::class, $entity->getCities()->get(1)); + self::assertInstanceOf(City::class, $entity->getCities()->get(0)); + self::assertInstanceOf(City::class, $entity->getCities()->get(1)); $this->_em->clear(); $this->secondLevelCacheLogger->clearStats(); @@ -229,23 +229,23 @@ public function testOneToManyRemove(): void $state = $this->_em->find(State::class, $this->states[0]->getId()); //trigger lazy load from cache - $this->assertCount(2, $state->getCities()); + self::assertCount(2, $state->getCities()); - $this->assertEquals(2, $this->secondLevelCacheLogger->getHitCount()); - $this->assertEquals(1, $this->secondLevelCacheLogger->getRegionHitCount($this->getEntityRegion(State::class))); - $this->assertEquals(1, $this->secondLevelCacheLogger->getRegionHitCount($this->getCollectionRegion(State::class, 'cities'))); + self::assertEquals(2, $this->secondLevelCacheLogger->getHitCount()); + self::assertEquals(1, $this->secondLevelCacheLogger->getRegionHitCount($this->getEntityRegion(State::class))); + self::assertEquals(1, $this->secondLevelCacheLogger->getRegionHitCount($this->getCollectionRegion(State::class, 'cities'))); $city0 = $state->getCities()->get(0); $city1 = $state->getCities()->get(1); - $this->assertInstanceOf(City::class, $city0); - $this->assertInstanceOf(City::class, $city1); + self::assertInstanceOf(City::class, $city0); + self::assertInstanceOf(City::class, $city1); - $this->assertEquals($entity->getCities()->get(0)->getName(), $city0->getName()); - $this->assertEquals($entity->getCities()->get(1)->getName(), $city1->getName()); + self::assertEquals($entity->getCities()->get(0)->getName(), $city0->getName()); + self::assertEquals($entity->getCities()->get(1)->getName(), $city1->getName()); - $this->assertEquals(2, $this->secondLevelCacheLogger->getHitCount()); - $this->assertEquals($queryCount, $this->getCurrentQueryCount()); + self::assertEquals(2, $this->secondLevelCacheLogger->getHitCount()); + self::assertEquals($queryCount, $this->getCurrentQueryCount()); $state->getCities()->removeElement($city0); @@ -260,17 +260,17 @@ public function testOneToManyRemove(): void $state = $this->_em->find(State::class, $this->states[0]->getId()); //trigger lazy load from cache - $this->assertCount(1, $state->getCities()); + self::assertCount(1, $state->getCities()); $city1 = $state->getCities()->get(0); - $this->assertInstanceOf(City::class, $city1); - $this->assertEquals($entity->getCities()->get(1)->getName(), $city1->getName()); + self::assertInstanceOf(City::class, $city1); + self::assertEquals($entity->getCities()->get(1)->getName(), $city1->getName()); - $this->assertEquals(2, $this->secondLevelCacheLogger->getHitCount()); - $this->assertEquals(1, $this->secondLevelCacheLogger->getRegionHitCount($this->getEntityRegion(State::class))); - $this->assertEquals(1, $this->secondLevelCacheLogger->getRegionHitCount($this->getCollectionRegion(State::class, 'cities'))); + self::assertEquals(2, $this->secondLevelCacheLogger->getHitCount()); + self::assertEquals(1, $this->secondLevelCacheLogger->getRegionHitCount($this->getEntityRegion(State::class))); + self::assertEquals(1, $this->secondLevelCacheLogger->getRegionHitCount($this->getCollectionRegion(State::class, 'cities'))); - $this->assertEquals($queryCount, $this->getCurrentQueryCount()); + self::assertEquals($queryCount, $this->getCurrentQueryCount()); $state->getCities()->remove(0); @@ -284,11 +284,11 @@ public function testOneToManyRemove(): void $queryCount = $this->getCurrentQueryCount(); $state = $this->_em->find(State::class, $this->states[0]->getId()); - $this->assertCount(0, $state->getCities()); + self::assertCount(0, $state->getCities()); - $this->assertEquals(2, $this->secondLevelCacheLogger->getHitCount()); - $this->assertEquals(1, $this->secondLevelCacheLogger->getRegionHitCount($this->getEntityRegion(State::class))); - $this->assertEquals(1, $this->secondLevelCacheLogger->getRegionHitCount($this->getCollectionRegion(State::class, 'cities'))); + self::assertEquals(2, $this->secondLevelCacheLogger->getHitCount()); + self::assertEquals(1, $this->secondLevelCacheLogger->getRegionHitCount($this->getEntityRegion(State::class))); + self::assertEquals(1, $this->secondLevelCacheLogger->getRegionHitCount($this->getCollectionRegion(State::class, 'cities'))); } public function testOneToManyWithEmptyRelation(): void @@ -307,16 +307,16 @@ public function testOneToManyWithEmptyRelation(): void $queryCount = $this->getCurrentQueryCount(); $entity = $this->_em->find(State::class, $entitiId); - $this->assertEquals(0, $entity->getCities()->count()); - $this->assertEquals($queryCount + 2, $this->getCurrentQueryCount()); + self::assertEquals(0, $entity->getCities()->count()); + self::assertEquals($queryCount + 2, $this->getCurrentQueryCount()); $this->_em->clear(); $queryCount = $this->getCurrentQueryCount(); $entity = $this->_em->find(State::class, $entitiId); - $this->assertEquals(0, $entity->getCities()->count()); - $this->assertEquals($queryCount, $this->getCurrentQueryCount()); + self::assertEquals(0, $entity->getCities()->count()); + self::assertEquals($queryCount, $this->getCurrentQueryCount()); } public function testOneToManyCount(): void @@ -335,16 +335,16 @@ public function testOneToManyCount(): void $queryCount = $this->getCurrentQueryCount(); $entity = $this->_em->find(State::class, $entityId); - $this->assertEquals(2, $entity->getCities()->count()); - $this->assertEquals($queryCount + 2, $this->getCurrentQueryCount()); + self::assertEquals(2, $entity->getCities()->count()); + self::assertEquals($queryCount + 2, $this->getCurrentQueryCount()); $this->_em->clear(); $queryCount = $this->getCurrentQueryCount(); $entity = $this->_em->find(State::class, $entityId); - $this->assertEquals(2, $entity->getCities()->count()); - $this->assertEquals($queryCount, $this->getCurrentQueryCount()); + self::assertEquals(2, $entity->getCities()->count()); + self::assertEquals($queryCount, $this->getCurrentQueryCount()); } public function testCacheInitializeCollectionWithNewObjects(): void @@ -363,22 +363,22 @@ public function testCacheInitializeCollectionWithNewObjects(): void $this->_em->flush(); $this->_em->clear(); - $this->assertCount(3, $traveler->getTravels()); + self::assertCount(3, $traveler->getTravels()); $travelerId = $traveler->getId(); $queryCount = $this->getCurrentQueryCount(); $entity = $this->_em->find(Traveler::class, $travelerId); - $this->assertEquals($queryCount, $this->getCurrentQueryCount()); - $this->assertFalse($entity->getTravels()->isInitialized()); + self::assertEquals($queryCount, $this->getCurrentQueryCount()); + self::assertFalse($entity->getTravels()->isInitialized()); $newItem = new Travel($entity); $entity->getTravels()->add($newItem); - $this->assertFalse($entity->getTravels()->isInitialized()); - $this->assertCount(4, $entity->getTravels()); - $this->assertTrue($entity->getTravels()->isInitialized()); - $this->assertEquals($queryCount, $this->getCurrentQueryCount()); + self::assertFalse($entity->getTravels()->isInitialized()); + self::assertCount(4, $entity->getTravels()); + self::assertTrue($entity->getTravels()->isInitialized()); + self::assertEquals($queryCount, $this->getCurrentQueryCount()); $this->_em->flush(); $this->_em->clear(); @@ -389,13 +389,13 @@ public function testCacheInitializeCollectionWithNewObjects(): void ); $result = $this->_em->createQuery($query)->getSingleResult(); - $this->assertEquals(4, $result->getTravels()->count()); + self::assertEquals(4, $result->getTravels()->count()); } public function testPutAndLoadNonCacheableOneToMany(): void { - $this->assertNull($this->cache->getEntityCacheRegion(Login::class)); - $this->assertInstanceOf(Region::class, $this->cache->getEntityCacheRegion(Token::class)); + self::assertNull($this->cache->getEntityCacheRegion(Login::class)); + self::assertInstanceOf(Region::class, $this->cache->getEntityCacheRegion(Token::class)); $l1 = new Login('session1'); $l2 = new Login('session2'); @@ -407,17 +407,17 @@ public function testPutAndLoadNonCacheableOneToMany(): void $this->_em->flush(); $this->_em->clear(); - $this->assertTrue($this->cache->containsEntity(Token::class, $token->token)); + self::assertTrue($this->cache->containsEntity(Token::class, $token->token)); $queryCount = $this->getCurrentQueryCount(); $entity = $this->_em->find(Token::class, $token->token); - $this->assertInstanceOf(Token::class, $entity); - $this->assertEquals('token-hash', $entity->token); - $this->assertEquals($queryCount, $this->getCurrentQueryCount()); + self::assertInstanceOf(Token::class, $entity); + self::assertEquals('token-hash', $entity->token); + self::assertEquals($queryCount, $this->getCurrentQueryCount()); - $this->assertCount(2, $entity->logins); - $this->assertEquals($queryCount + 1, $this->getCurrentQueryCount()); + self::assertCount(2, $entity->logins); + self::assertEquals($queryCount + 1, $this->getCurrentQueryCount()); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/SecondLevelCacheOneToOneTest.php b/tests/Doctrine/Tests/ORM/Functional/SecondLevelCacheOneToOneTest.php index 68d270f99a7..7d177d4385b 100644 --- a/tests/Doctrine/Tests/ORM/Functional/SecondLevelCacheOneToOneTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/SecondLevelCacheOneToOneTest.php @@ -30,10 +30,10 @@ public function testPutOneToOneOnUnidirectionalPersist(): void $entity1 = $this->travelersWithProfile[0]; $entity2 = $this->travelersWithProfile[1]; - $this->assertTrue($this->cache->containsEntity(Traveler::class, $entity1->getId())); - $this->assertTrue($this->cache->containsEntity(Traveler::class, $entity2->getId())); - $this->assertTrue($this->cache->containsEntity(TravelerProfile::class, $entity1->getProfile()->getId())); - $this->assertTrue($this->cache->containsEntity(TravelerProfile::class, $entity2->getProfile()->getId())); + self::assertTrue($this->cache->containsEntity(Traveler::class, $entity1->getId())); + self::assertTrue($this->cache->containsEntity(Traveler::class, $entity2->getId())); + self::assertTrue($this->cache->containsEntity(TravelerProfile::class, $entity1->getProfile()->getId())); + self::assertTrue($this->cache->containsEntity(TravelerProfile::class, $entity2->getProfile()->getId())); } public function testPutOneToOneOnBidirectionalPersist(): void @@ -49,12 +49,12 @@ public function testPutOneToOneOnBidirectionalPersist(): void $entity1 = $this->travelersWithProfile[0]; $entity2 = $this->travelersWithProfile[1]; - $this->assertTrue($this->cache->containsEntity(Traveler::class, $entity1->getId())); - $this->assertTrue($this->cache->containsEntity(Traveler::class, $entity2->getId())); - $this->assertTrue($this->cache->containsEntity(TravelerProfile::class, $entity1->getProfile()->getId())); - $this->assertTrue($this->cache->containsEntity(TravelerProfile::class, $entity2->getProfile()->getId())); - $this->assertTrue($this->cache->containsEntity(TravelerProfileInfo::class, $entity1->getProfile()->getInfo()->getId())); - $this->assertTrue($this->cache->containsEntity(TravelerProfileInfo::class, $entity2->getProfile()->getInfo()->getId())); + self::assertTrue($this->cache->containsEntity(Traveler::class, $entity1->getId())); + self::assertTrue($this->cache->containsEntity(Traveler::class, $entity2->getId())); + self::assertTrue($this->cache->containsEntity(TravelerProfile::class, $entity1->getProfile()->getId())); + self::assertTrue($this->cache->containsEntity(TravelerProfile::class, $entity2->getProfile()->getId())); + self::assertTrue($this->cache->containsEntity(TravelerProfileInfo::class, $entity1->getProfile()->getInfo()->getId())); + self::assertTrue($this->cache->containsEntity(TravelerProfileInfo::class, $entity2->getProfile()->getInfo()->getId())); } public function testPutAndLoadOneToOneUnidirectionalRelation(): void @@ -73,40 +73,40 @@ public function testPutAndLoadOneToOneUnidirectionalRelation(): void $entity1 = $this->travelersWithProfile[0]; $entity2 = $this->travelersWithProfile[1]; - $this->assertFalse($this->cache->containsEntity(Traveler::class, $entity1->getId())); - $this->assertFalse($this->cache->containsEntity(Traveler::class, $entity2->getId())); - $this->assertFalse($this->cache->containsEntity(TravelerProfile::class, $entity1->getProfile()->getId())); - $this->assertFalse($this->cache->containsEntity(TravelerProfile::class, $entity2->getProfile()->getId())); + self::assertFalse($this->cache->containsEntity(Traveler::class, $entity1->getId())); + self::assertFalse($this->cache->containsEntity(Traveler::class, $entity2->getId())); + self::assertFalse($this->cache->containsEntity(TravelerProfile::class, $entity1->getProfile()->getId())); + self::assertFalse($this->cache->containsEntity(TravelerProfile::class, $entity2->getProfile()->getId())); $t1 = $this->_em->find(Traveler::class, $entity1->getId()); $t2 = $this->_em->find(Traveler::class, $entity2->getId()); - $this->assertTrue($this->cache->containsEntity(Traveler::class, $entity1->getId())); - $this->assertTrue($this->cache->containsEntity(Traveler::class, $entity2->getId())); + self::assertTrue($this->cache->containsEntity(Traveler::class, $entity1->getId())); + self::assertTrue($this->cache->containsEntity(Traveler::class, $entity2->getId())); // The inverse side its not cached - $this->assertFalse($this->cache->containsEntity(TravelerProfile::class, $entity1->getProfile()->getId())); - $this->assertFalse($this->cache->containsEntity(TravelerProfile::class, $entity2->getProfile()->getId())); + self::assertFalse($this->cache->containsEntity(TravelerProfile::class, $entity1->getProfile()->getId())); + self::assertFalse($this->cache->containsEntity(TravelerProfile::class, $entity2->getProfile()->getId())); - $this->assertInstanceOf(Traveler::class, $t1); - $this->assertInstanceOf(Traveler::class, $t2); - $this->assertInstanceOf(TravelerProfile::class, $t1->getProfile()); - $this->assertInstanceOf(TravelerProfile::class, $t2->getProfile()); + self::assertInstanceOf(Traveler::class, $t1); + self::assertInstanceOf(Traveler::class, $t2); + self::assertInstanceOf(TravelerProfile::class, $t1->getProfile()); + self::assertInstanceOf(TravelerProfile::class, $t2->getProfile()); - $this->assertEquals($entity1->getId(), $t1->getId()); - $this->assertEquals($entity1->getName(), $t1->getName()); - $this->assertEquals($entity1->getProfile()->getId(), $t1->getProfile()->getId()); - $this->assertEquals($entity1->getProfile()->getName(), $t1->getProfile()->getName()); + self::assertEquals($entity1->getId(), $t1->getId()); + self::assertEquals($entity1->getName(), $t1->getName()); + self::assertEquals($entity1->getProfile()->getId(), $t1->getProfile()->getId()); + self::assertEquals($entity1->getProfile()->getName(), $t1->getProfile()->getName()); - $this->assertEquals($entity2->getId(), $t2->getId()); - $this->assertEquals($entity2->getName(), $t2->getName()); - $this->assertEquals($entity2->getProfile()->getId(), $t2->getProfile()->getId()); - $this->assertEquals($entity2->getProfile()->getName(), $t2->getProfile()->getName()); + self::assertEquals($entity2->getId(), $t2->getId()); + self::assertEquals($entity2->getName(), $t2->getName()); + self::assertEquals($entity2->getProfile()->getId(), $t2->getProfile()->getId()); + self::assertEquals($entity2->getProfile()->getName(), $t2->getProfile()->getName()); // its all cached now - $this->assertTrue($this->cache->containsEntity(Traveler::class, $entity1->getId())); - $this->assertTrue($this->cache->containsEntity(Traveler::class, $entity2->getId())); - $this->assertTrue($this->cache->containsEntity(TravelerProfile::class, $entity1->getProfile()->getId())); - $this->assertTrue($this->cache->containsEntity(TravelerProfile::class, $entity1->getProfile()->getId())); + self::assertTrue($this->cache->containsEntity(Traveler::class, $entity1->getId())); + self::assertTrue($this->cache->containsEntity(Traveler::class, $entity2->getId())); + self::assertTrue($this->cache->containsEntity(TravelerProfile::class, $entity1->getProfile()->getId())); + self::assertTrue($this->cache->containsEntity(TravelerProfile::class, $entity1->getProfile()->getId())); $this->_em->clear(); @@ -115,18 +115,18 @@ public function testPutAndLoadOneToOneUnidirectionalRelation(): void $t3 = $this->_em->find(Traveler::class, $entity1->getId()); $t4 = $this->_em->find(Traveler::class, $entity2->getId()); - $this->assertInstanceOf(Traveler::class, $t3); - $this->assertInstanceOf(Traveler::class, $t4); - $this->assertInstanceOf(TravelerProfile::class, $t3->getProfile()); - $this->assertInstanceOf(TravelerProfile::class, $t4->getProfile()); + self::assertInstanceOf(Traveler::class, $t3); + self::assertInstanceOf(Traveler::class, $t4); + self::assertInstanceOf(TravelerProfile::class, $t3->getProfile()); + self::assertInstanceOf(TravelerProfile::class, $t4->getProfile()); - $this->assertEquals($entity1->getProfile()->getId(), $t3->getProfile()->getId()); - $this->assertEquals($entity2->getProfile()->getId(), $t4->getProfile()->getId()); + self::assertEquals($entity1->getProfile()->getId(), $t3->getProfile()->getId()); + self::assertEquals($entity2->getProfile()->getId(), $t4->getProfile()->getId()); - $this->assertEquals($entity1->getProfile()->getName(), $t3->getProfile()->getName()); - $this->assertEquals($entity2->getProfile()->getName(), $t4->getProfile()->getName()); + self::assertEquals($entity1->getProfile()->getName(), $t3->getProfile()->getName()); + self::assertEquals($entity2->getProfile()->getName(), $t4->getProfile()->getName()); - $this->assertEquals($queryCount, $this->getCurrentQueryCount()); + self::assertEquals($queryCount, $this->getCurrentQueryCount()); } public function testPutAndLoadOneToOneBidirectionalRelation(): void @@ -146,28 +146,28 @@ public function testPutAndLoadOneToOneBidirectionalRelation(): void $entity1 = $this->travelersWithProfile[0]->getProfile(); $entity2 = $this->travelersWithProfile[1]->getProfile(); - $this->assertFalse($this->cache->containsEntity(TravelerProfile::class, $entity1->getId())); - $this->assertFalse($this->cache->containsEntity(TravelerProfile::class, $entity2->getId())); - $this->assertFalse($this->cache->containsEntity(TravelerProfileInfo::class, $entity1->getInfo()->getId())); - $this->assertFalse($this->cache->containsEntity(TravelerProfileInfo::class, $entity2->getInfo()->getId())); + self::assertFalse($this->cache->containsEntity(TravelerProfile::class, $entity1->getId())); + self::assertFalse($this->cache->containsEntity(TravelerProfile::class, $entity2->getId())); + self::assertFalse($this->cache->containsEntity(TravelerProfileInfo::class, $entity1->getInfo()->getId())); + self::assertFalse($this->cache->containsEntity(TravelerProfileInfo::class, $entity2->getInfo()->getId())); $p1 = $this->_em->find(TravelerProfile::class, $entity1->getId()); $p2 = $this->_em->find(TravelerProfile::class, $entity2->getId()); - $this->assertEquals($entity1->getId(), $p1->getId()); - $this->assertEquals($entity1->getName(), $p1->getName()); - $this->assertEquals($entity1->getInfo()->getId(), $p1->getInfo()->getId()); - $this->assertEquals($entity1->getInfo()->getDescription(), $p1->getInfo()->getDescription()); + self::assertEquals($entity1->getId(), $p1->getId()); + self::assertEquals($entity1->getName(), $p1->getName()); + self::assertEquals($entity1->getInfo()->getId(), $p1->getInfo()->getId()); + self::assertEquals($entity1->getInfo()->getDescription(), $p1->getInfo()->getDescription()); - $this->assertEquals($entity2->getId(), $p2->getId()); - $this->assertEquals($entity2->getName(), $p2->getName()); - $this->assertEquals($entity2->getInfo()->getId(), $p2->getInfo()->getId()); - $this->assertEquals($entity2->getInfo()->getDescription(), $p2->getInfo()->getDescription()); + self::assertEquals($entity2->getId(), $p2->getId()); + self::assertEquals($entity2->getName(), $p2->getName()); + self::assertEquals($entity2->getInfo()->getId(), $p2->getInfo()->getId()); + self::assertEquals($entity2->getInfo()->getDescription(), $p2->getInfo()->getDescription()); - $this->assertTrue($this->cache->containsEntity(TravelerProfile::class, $entity1->getId())); - $this->assertTrue($this->cache->containsEntity(TravelerProfile::class, $entity2->getId())); - $this->assertTrue($this->cache->containsEntity(TravelerProfileInfo::class, $entity1->getInfo()->getId())); - $this->assertTrue($this->cache->containsEntity(TravelerProfileInfo::class, $entity2->getInfo()->getId())); + self::assertTrue($this->cache->containsEntity(TravelerProfile::class, $entity1->getId())); + self::assertTrue($this->cache->containsEntity(TravelerProfile::class, $entity2->getId())); + self::assertTrue($this->cache->containsEntity(TravelerProfileInfo::class, $entity1->getInfo()->getId())); + self::assertTrue($this->cache->containsEntity(TravelerProfileInfo::class, $entity2->getInfo()->getId())); $this->_em->clear(); @@ -176,22 +176,22 @@ public function testPutAndLoadOneToOneBidirectionalRelation(): void $p3 = $this->_em->find(TravelerProfile::class, $entity1->getId()); $p4 = $this->_em->find(TravelerProfile::class, $entity2->getId()); - $this->assertInstanceOf(TravelerProfile::class, $p3); - $this->assertInstanceOf(TravelerProfile::class, $p4); - $this->assertInstanceOf(TravelerProfileInfo::class, $p3->getInfo()); - $this->assertInstanceOf(TravelerProfileInfo::class, $p4->getInfo()); + self::assertInstanceOf(TravelerProfile::class, $p3); + self::assertInstanceOf(TravelerProfile::class, $p4); + self::assertInstanceOf(TravelerProfileInfo::class, $p3->getInfo()); + self::assertInstanceOf(TravelerProfileInfo::class, $p4->getInfo()); - $this->assertEquals($entity1->getId(), $p3->getId()); - $this->assertEquals($entity1->getName(), $p3->getName()); - $this->assertEquals($entity1->getInfo()->getId(), $p3->getInfo()->getId()); - $this->assertEquals($entity1->getInfo()->getDescription(), $p3->getInfo()->getDescription()); + self::assertEquals($entity1->getId(), $p3->getId()); + self::assertEquals($entity1->getName(), $p3->getName()); + self::assertEquals($entity1->getInfo()->getId(), $p3->getInfo()->getId()); + self::assertEquals($entity1->getInfo()->getDescription(), $p3->getInfo()->getDescription()); - $this->assertEquals($entity2->getId(), $p4->getId()); - $this->assertEquals($entity2->getName(), $p4->getName()); - $this->assertEquals($entity2->getInfo()->getId(), $p4->getInfo()->getId()); - $this->assertEquals($entity2->getInfo()->getDescription(), $p4->getInfo()->getDescription()); + self::assertEquals($entity2->getId(), $p4->getId()); + self::assertEquals($entity2->getName(), $p4->getName()); + self::assertEquals($entity2->getInfo()->getId(), $p4->getInfo()->getId()); + self::assertEquals($entity2->getInfo()->getDescription(), $p4->getInfo()->getDescription()); - $this->assertEquals($queryCount, $this->getCurrentQueryCount()); + self::assertEquals($queryCount, $this->getCurrentQueryCount()); } public function testInverseSidePutAndLoadOneToOneBidirectionalRelation(): void @@ -206,29 +206,29 @@ public function testInverseSidePutAndLoadOneToOneBidirectionalRelation(): void $entity1 = $this->addresses[0]->person; $entity2 = $this->addresses[1]->person; - $this->assertFalse($this->cache->containsEntity(Person::class, $entity1->id)); - $this->assertFalse($this->cache->containsEntity(Person::class, $entity2->id)); - $this->assertFalse($this->cache->containsEntity(Address::class, $entity1->address->id)); - $this->assertFalse($this->cache->containsEntity(Address::class, $entity2->address->id)); + self::assertFalse($this->cache->containsEntity(Person::class, $entity1->id)); + self::assertFalse($this->cache->containsEntity(Person::class, $entity2->id)); + self::assertFalse($this->cache->containsEntity(Address::class, $entity1->address->id)); + self::assertFalse($this->cache->containsEntity(Address::class, $entity2->address->id)); $p1 = $this->_em->find(Person::class, $entity1->id); $p2 = $this->_em->find(Person::class, $entity2->id); - $this->assertEquals($entity1->id, $p1->id); - $this->assertEquals($entity1->name, $p1->name); - $this->assertEquals($entity1->address->id, $p1->address->id); - $this->assertEquals($entity1->address->location, $p1->address->location); + self::assertEquals($entity1->id, $p1->id); + self::assertEquals($entity1->name, $p1->name); + self::assertEquals($entity1->address->id, $p1->address->id); + self::assertEquals($entity1->address->location, $p1->address->location); - $this->assertEquals($entity2->id, $p2->id); - $this->assertEquals($entity2->name, $p2->name); - $this->assertEquals($entity2->address->id, $p2->address->id); - $this->assertEquals($entity2->address->location, $p2->address->location); + self::assertEquals($entity2->id, $p2->id); + self::assertEquals($entity2->name, $p2->name); + self::assertEquals($entity2->address->id, $p2->address->id); + self::assertEquals($entity2->address->location, $p2->address->location); - $this->assertTrue($this->cache->containsEntity(Person::class, $entity1->id)); - $this->assertTrue($this->cache->containsEntity(Person::class, $entity2->id)); + self::assertTrue($this->cache->containsEntity(Person::class, $entity1->id)); + self::assertTrue($this->cache->containsEntity(Person::class, $entity2->id)); // The inverse side its not cached - $this->assertFalse($this->cache->containsEntity(Address::class, $entity1->address->id)); - $this->assertFalse($this->cache->containsEntity(Address::class, $entity2->address->id)); + self::assertFalse($this->cache->containsEntity(Address::class, $entity1->address->id)); + self::assertFalse($this->cache->containsEntity(Address::class, $entity2->address->id)); $this->_em->clear(); @@ -237,28 +237,28 @@ public function testInverseSidePutAndLoadOneToOneBidirectionalRelation(): void $p3 = $this->_em->find(Person::class, $entity1->id); $p4 = $this->_em->find(Person::class, $entity2->id); - $this->assertInstanceOf(Person::class, $p3); - $this->assertInstanceOf(Person::class, $p4); - $this->assertInstanceOf(Address::class, $p3->address); - $this->assertInstanceOf(Address::class, $p4->address); + self::assertInstanceOf(Person::class, $p3); + self::assertInstanceOf(Person::class, $p4); + self::assertInstanceOf(Address::class, $p3->address); + self::assertInstanceOf(Address::class, $p4->address); - $this->assertEquals($entity1->id, $p3->id); - $this->assertEquals($entity1->name, $p3->name); - $this->assertEquals($entity1->address->id, $p3->address->id); - $this->assertEquals($entity1->address->location, $p3->address->location); + self::assertEquals($entity1->id, $p3->id); + self::assertEquals($entity1->name, $p3->name); + self::assertEquals($entity1->address->id, $p3->address->id); + self::assertEquals($entity1->address->location, $p3->address->location); - $this->assertEquals($entity2->id, $p4->id); - $this->assertEquals($entity2->name, $p4->name); - $this->assertEquals($entity2->address->id, $p4->address->id); - $this->assertEquals($entity2->address->location, $p4->address->location); + self::assertEquals($entity2->id, $p4->id); + self::assertEquals($entity2->name, $p4->name); + self::assertEquals($entity2->address->id, $p4->address->id); + self::assertEquals($entity2->address->location, $p4->address->location); - $this->assertEquals($queryCount + 2, $this->getCurrentQueryCount()); + self::assertEquals($queryCount + 2, $this->getCurrentQueryCount()); } public function testPutAndLoadNonCacheableOneToOne(): void { - $this->assertNull($this->cache->getEntityCacheRegion(Client::class)); - $this->assertInstanceOf(Region::class, $this->cache->getEntityCacheRegion(Token::class)); + self::assertNull($this->cache->getEntityCacheRegion(Client::class)); + self::assertInstanceOf(Region::class, $this->cache->getEntityCacheRegion(Token::class)); $client = new Client('FabioBatSilva'); $token = new Token('token-hash', $client); @@ -270,17 +270,17 @@ public function testPutAndLoadNonCacheableOneToOne(): void $queryCount = $this->getCurrentQueryCount(); - $this->assertTrue($this->cache->containsEntity(Token::class, $token->token)); - $this->assertFalse($this->cache->containsEntity(Client::class, $client->id)); + self::assertTrue($this->cache->containsEntity(Token::class, $token->token)); + self::assertFalse($this->cache->containsEntity(Client::class, $client->id)); $entity = $this->_em->find(Token::class, $token->token); - $this->assertInstanceOf(Token::class, $entity); - $this->assertInstanceOf(Client::class, $entity->getClient()); - $this->assertEquals('token-hash', $entity->token); - $this->assertEquals($queryCount, $this->getCurrentQueryCount()); + self::assertInstanceOf(Token::class, $entity); + self::assertInstanceOf(Client::class, $entity->getClient()); + self::assertEquals('token-hash', $entity->token); + self::assertEquals($queryCount, $this->getCurrentQueryCount()); - $this->assertEquals('FabioBatSilva', $entity->getClient()->name); - $this->assertEquals($queryCount + 1, $this->getCurrentQueryCount()); + self::assertEquals('FabioBatSilva', $entity->getClient()->name); + self::assertEquals($queryCount + 1, $this->getCurrentQueryCount()); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/SecondLevelCacheQueryCacheTest.php b/tests/Doctrine/Tests/ORM/Functional/SecondLevelCacheQueryCacheTest.php index 970eefb8b93..6a320330467 100644 --- a/tests/Doctrine/Tests/ORM/Functional/SecondLevelCacheQueryCacheTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/SecondLevelCacheQueryCacheTest.php @@ -32,24 +32,24 @@ public function testBasicQueryCache(): void $this->secondLevelCacheLogger->clearStats(); $this->_em->clear(); - $this->assertTrue($this->cache->containsEntity(Country::class, $this->countries[0]->getId())); - $this->assertTrue($this->cache->containsEntity(Country::class, $this->countries[1]->getId())); + self::assertTrue($this->cache->containsEntity(Country::class, $this->countries[0]->getId())); + self::assertTrue($this->cache->containsEntity(Country::class, $this->countries[1]->getId())); $queryCount = $this->getCurrentQueryCount(); $dql = 'SELECT c FROM Doctrine\Tests\Models\Cache\Country c'; $result1 = $this->_em->createQuery($dql)->setCacheable(true)->getResult(); - $this->assertCount(2, $result1); - $this->assertEquals($queryCount + 1, $this->getCurrentQueryCount()); - $this->assertEquals($this->countries[0]->getId(), $result1[0]->getId()); - $this->assertEquals($this->countries[1]->getId(), $result1[1]->getId()); - $this->assertEquals($this->countries[0]->getName(), $result1[0]->getName()); - $this->assertEquals($this->countries[1]->getName(), $result1[1]->getName()); + self::assertCount(2, $result1); + self::assertEquals($queryCount + 1, $this->getCurrentQueryCount()); + self::assertEquals($this->countries[0]->getId(), $result1[0]->getId()); + self::assertEquals($this->countries[1]->getId(), $result1[1]->getId()); + self::assertEquals($this->countries[0]->getName(), $result1[0]->getName()); + self::assertEquals($this->countries[1]->getName(), $result1[1]->getName()); - $this->assertEquals(1, $this->secondLevelCacheLogger->getPutCount()); - $this->assertEquals(1, $this->secondLevelCacheLogger->getMissCount()); - $this->assertEquals(1, $this->secondLevelCacheLogger->getRegionPutCount($this->getDefaultQueryRegionName())); - $this->assertEquals(1, $this->secondLevelCacheLogger->getRegionMissCount($this->getDefaultQueryRegionName())); + self::assertEquals(1, $this->secondLevelCacheLogger->getPutCount()); + self::assertEquals(1, $this->secondLevelCacheLogger->getMissCount()); + self::assertEquals(1, $this->secondLevelCacheLogger->getRegionPutCount($this->getDefaultQueryRegionName())); + self::assertEquals(1, $this->secondLevelCacheLogger->getRegionMissCount($this->getDefaultQueryRegionName())); $this->_em->clear(); @@ -57,33 +57,33 @@ public function testBasicQueryCache(): void ->setCacheable(true) ->getResult(); - $this->assertEquals($queryCount + 1, $this->getCurrentQueryCount()); - $this->assertCount(2, $result2); + self::assertEquals($queryCount + 1, $this->getCurrentQueryCount()); + self::assertCount(2, $result2); - $this->assertEquals(1, $this->secondLevelCacheLogger->getPutCount()); - $this->assertEquals(3, $this->secondLevelCacheLogger->getHitCount()); - $this->assertEquals(1, $this->secondLevelCacheLogger->getMissCount()); + self::assertEquals(1, $this->secondLevelCacheLogger->getPutCount()); + self::assertEquals(3, $this->secondLevelCacheLogger->getHitCount()); + self::assertEquals(1, $this->secondLevelCacheLogger->getMissCount()); - $this->assertEquals(1, $this->secondLevelCacheLogger->getRegionPutCount($this->getDefaultQueryRegionName())); - $this->assertEquals(1, $this->secondLevelCacheLogger->getRegionHitCount($this->getDefaultQueryRegionName())); - $this->assertEquals(1, $this->secondLevelCacheLogger->getRegionMissCount($this->getDefaultQueryRegionName())); + self::assertEquals(1, $this->secondLevelCacheLogger->getRegionPutCount($this->getDefaultQueryRegionName())); + self::assertEquals(1, $this->secondLevelCacheLogger->getRegionHitCount($this->getDefaultQueryRegionName())); + self::assertEquals(1, $this->secondLevelCacheLogger->getRegionMissCount($this->getDefaultQueryRegionName())); - $this->assertInstanceOf(Country::class, $result2[0]); - $this->assertInstanceOf(Country::class, $result2[1]); + self::assertInstanceOf(Country::class, $result2[0]); + self::assertInstanceOf(Country::class, $result2[1]); - $this->assertEquals($result1[0]->getId(), $result2[0]->getId()); - $this->assertEquals($result1[1]->getId(), $result2[1]->getId()); + self::assertEquals($result1[0]->getId(), $result2[0]->getId()); + self::assertEquals($result1[1]->getId(), $result2[1]->getId()); - $this->assertEquals($result1[0]->getName(), $result2[0]->getName()); - $this->assertEquals($result1[1]->getName(), $result2[1]->getName()); + self::assertEquals($result1[0]->getName(), $result2[0]->getName()); + self::assertEquals($result1[1]->getName(), $result2[1]->getName()); - $this->assertEquals(1, $this->secondLevelCacheLogger->getPutCount()); - $this->assertEquals(3, $this->secondLevelCacheLogger->getHitCount()); - $this->assertEquals(1, $this->secondLevelCacheLogger->getMissCount()); + self::assertEquals(1, $this->secondLevelCacheLogger->getPutCount()); + self::assertEquals(3, $this->secondLevelCacheLogger->getHitCount()); + self::assertEquals(1, $this->secondLevelCacheLogger->getMissCount()); - $this->assertEquals(1, $this->secondLevelCacheLogger->getRegionPutCount($this->getDefaultQueryRegionName())); - $this->assertEquals(1, $this->secondLevelCacheLogger->getRegionHitCount($this->getDefaultQueryRegionName())); - $this->assertEquals(1, $this->secondLevelCacheLogger->getRegionMissCount($this->getDefaultQueryRegionName())); + self::assertEquals(1, $this->secondLevelCacheLogger->getRegionPutCount($this->getDefaultQueryRegionName())); + self::assertEquals(1, $this->secondLevelCacheLogger->getRegionHitCount($this->getDefaultQueryRegionName())); + self::assertEquals(1, $this->secondLevelCacheLogger->getRegionMissCount($this->getDefaultQueryRegionName())); } public function testQueryCacheModeGet(): void @@ -95,8 +95,8 @@ public function testQueryCacheModeGet(): void $this->secondLevelCacheLogger->clearStats(); $this->_em->clear(); - $this->assertFalse($this->cache->containsEntity(Country::class, $this->countries[0]->getId())); - $this->assertFalse($this->cache->containsEntity(Country::class, $this->countries[1]->getId())); + self::assertFalse($this->cache->containsEntity(Country::class, $this->countries[0]->getId())); + self::assertFalse($this->cache->containsEntity(Country::class, $this->countries[1]->getId())); $queryCount = $this->getCurrentQueryCount(); $dql = 'SELECT c FROM Doctrine\Tests\Models\Cache\Country c'; @@ -105,25 +105,25 @@ public function testQueryCacheModeGet(): void ->setCacheable(true); // MODE_GET should never add items to the cache. - $this->assertCount(2, $queryGet->getResult()); - $this->assertEquals($queryCount + 1, $this->getCurrentQueryCount()); + self::assertCount(2, $queryGet->getResult()); + self::assertEquals($queryCount + 1, $this->getCurrentQueryCount()); - $this->assertCount(2, $queryGet->getResult()); - $this->assertEquals($queryCount + 2, $this->getCurrentQueryCount()); + self::assertCount(2, $queryGet->getResult()); + self::assertEquals($queryCount + 2, $this->getCurrentQueryCount()); $result = $this->_em->createQuery($dql) ->setCacheable(true) ->getResult(); - $this->assertCount(2, $result); - $this->assertEquals($queryCount + 3, $this->getCurrentQueryCount()); + self::assertCount(2, $result); + self::assertEquals($queryCount + 3, $this->getCurrentQueryCount()); - $this->assertTrue($this->cache->containsEntity(Country::class, $this->countries[0]->getId())); - $this->assertTrue($this->cache->containsEntity(Country::class, $this->countries[1]->getId())); + self::assertTrue($this->cache->containsEntity(Country::class, $this->countries[0]->getId())); + self::assertTrue($this->cache->containsEntity(Country::class, $this->countries[1]->getId())); // MODE_GET should read items if exists. - $this->assertCount(2, $queryGet->getResult()); - $this->assertEquals($queryCount + 3, $this->getCurrentQueryCount()); + self::assertCount(2, $queryGet->getResult()); + self::assertEquals($queryCount + 3, $this->getCurrentQueryCount()); } public function testQueryCacheModePut(): void @@ -135,8 +135,8 @@ public function testQueryCacheModePut(): void $this->secondLevelCacheLogger->clearStats(); $this->_em->clear(); - $this->assertFalse($this->cache->containsEntity(Country::class, $this->countries[0]->getId())); - $this->assertFalse($this->cache->containsEntity(Country::class, $this->countries[1]->getId())); + self::assertFalse($this->cache->containsEntity(Country::class, $this->countries[0]->getId())); + self::assertFalse($this->cache->containsEntity(Country::class, $this->countries[1]->getId())); $queryCount = $this->getCurrentQueryCount(); $dql = 'SELECT c FROM Doctrine\Tests\Models\Cache\Country c'; @@ -144,26 +144,26 @@ public function testQueryCacheModePut(): void ->setCacheable(true) ->getResult(); - $this->assertTrue($this->cache->containsEntity(Country::class, $this->countries[0]->getId())); - $this->assertTrue($this->cache->containsEntity(Country::class, $this->countries[1]->getId())); + self::assertTrue($this->cache->containsEntity(Country::class, $this->countries[0]->getId())); + self::assertTrue($this->cache->containsEntity(Country::class, $this->countries[1]->getId())); - $this->assertCount(2, $result); - $this->assertEquals($queryCount + 1, $this->getCurrentQueryCount()); + self::assertCount(2, $result); + self::assertEquals($queryCount + 1, $this->getCurrentQueryCount()); $queryPut = $this->_em->createQuery($dql) ->setCacheMode(Cache::MODE_PUT) ->setCacheable(true); // MODE_PUT should never read itens from cache. - $this->assertCount(2, $queryPut->getResult()); - $this->assertEquals($queryCount + 2, $this->getCurrentQueryCount()); - $this->assertTrue($this->cache->containsEntity(Country::class, $this->countries[0]->getId())); - $this->assertTrue($this->cache->containsEntity(Country::class, $this->countries[1]->getId())); - - $this->assertCount(2, $queryPut->getResult()); - $this->assertEquals($queryCount + 3, $this->getCurrentQueryCount()); - $this->assertTrue($this->cache->containsEntity(Country::class, $this->countries[0]->getId())); - $this->assertTrue($this->cache->containsEntity(Country::class, $this->countries[1]->getId())); + self::assertCount(2, $queryPut->getResult()); + self::assertEquals($queryCount + 2, $this->getCurrentQueryCount()); + self::assertTrue($this->cache->containsEntity(Country::class, $this->countries[0]->getId())); + self::assertTrue($this->cache->containsEntity(Country::class, $this->countries[1]->getId())); + + self::assertCount(2, $queryPut->getResult()); + self::assertEquals($queryCount + 3, $this->getCurrentQueryCount()); + self::assertTrue($this->cache->containsEntity(Country::class, $this->countries[0]->getId())); + self::assertTrue($this->cache->containsEntity(Country::class, $this->countries[1]->getId())); } public function testQueryCacheModeRefresh(): void @@ -175,8 +175,8 @@ public function testQueryCacheModeRefresh(): void $this->secondLevelCacheLogger->clearStats(); $this->_em->clear(); - $this->assertFalse($this->cache->containsEntity(Country::class, $this->countries[0]->getId())); - $this->assertFalse($this->cache->containsEntity(Country::class, $this->countries[1]->getId())); + self::assertFalse($this->cache->containsEntity(Country::class, $this->countries[0]->getId())); + self::assertFalse($this->cache->containsEntity(Country::class, $this->countries[1]->getId())); $region = $this->cache->getEntityCacheRegion(Country::class); $queryCount = $this->getCurrentQueryCount(); @@ -185,11 +185,11 @@ public function testQueryCacheModeRefresh(): void ->setCacheable(true) ->getResult(); - $this->assertTrue($this->cache->containsEntity(Country::class, $this->countries[0]->getId())); - $this->assertTrue($this->cache->containsEntity(Country::class, $this->countries[1]->getId())); + self::assertTrue($this->cache->containsEntity(Country::class, $this->countries[0]->getId())); + self::assertTrue($this->cache->containsEntity(Country::class, $this->countries[1]->getId())); - $this->assertCount(2, $result); - $this->assertEquals($queryCount + 1, $this->getCurrentQueryCount()); + self::assertCount(2, $result); + self::assertEquals($queryCount + 1, $this->getCurrentQueryCount()); $countryId1 = $this->countries[0]->getId(); $countryId2 = $this->countries[1]->getId(); @@ -211,18 +211,18 @@ public function testQueryCacheModeRefresh(): void // MODE_REFRESH should never read itens from cache. $result1 = $queryRefresh->getResult(); - $this->assertCount(2, $result1); - $this->assertEquals($countryName1, $result1[0]->getName()); - $this->assertEquals($countryName2, $result1[1]->getName()); - $this->assertEquals($queryCount + 2, $this->getCurrentQueryCount()); + self::assertCount(2, $result1); + self::assertEquals($countryName1, $result1[0]->getName()); + self::assertEquals($countryName2, $result1[1]->getName()); + self::assertEquals($queryCount + 2, $this->getCurrentQueryCount()); $this->_em->clear(); $result2 = $queryRefresh->getResult(); - $this->assertCount(2, $result2); - $this->assertEquals($countryName1, $result2[0]->getName()); - $this->assertEquals($countryName2, $result2[1]->getName()); - $this->assertEquals($queryCount + 3, $this->getCurrentQueryCount()); + self::assertCount(2, $result2); + self::assertEquals($countryName1, $result2[0]->getName()); + self::assertEquals($countryName2, $result2[1]->getName()); + self::assertEquals($queryCount + 3, $this->getCurrentQueryCount()); } public function testBasicQueryCachePutEntityCache(): void @@ -238,21 +238,21 @@ public function testBasicQueryCachePutEntityCache(): void $dql = 'SELECT c FROM Doctrine\Tests\Models\Cache\Country c'; $result1 = $this->_em->createQuery($dql)->setCacheable(true)->getResult(); - $this->assertCount(2, $result1); - $this->assertEquals($queryCount + 1, $this->getCurrentQueryCount()); - $this->assertEquals($this->countries[0]->getId(), $result1[0]->getId()); - $this->assertEquals($this->countries[1]->getId(), $result1[1]->getId()); - $this->assertEquals($this->countries[0]->getName(), $result1[0]->getName()); - $this->assertEquals($this->countries[1]->getName(), $result1[1]->getName()); + self::assertCount(2, $result1); + self::assertEquals($queryCount + 1, $this->getCurrentQueryCount()); + self::assertEquals($this->countries[0]->getId(), $result1[0]->getId()); + self::assertEquals($this->countries[1]->getId(), $result1[1]->getId()); + self::assertEquals($this->countries[0]->getName(), $result1[0]->getName()); + self::assertEquals($this->countries[1]->getName(), $result1[1]->getName()); - $this->assertTrue($this->cache->containsEntity(Country::class, $this->countries[0]->getId())); - $this->assertTrue($this->cache->containsEntity(Country::class, $this->countries[1]->getId())); + self::assertTrue($this->cache->containsEntity(Country::class, $this->countries[0]->getId())); + self::assertTrue($this->cache->containsEntity(Country::class, $this->countries[1]->getId())); - $this->assertEquals(3, $this->secondLevelCacheLogger->getPutCount()); - $this->assertEquals(1, $this->secondLevelCacheLogger->getMissCount()); - $this->assertEquals(1, $this->secondLevelCacheLogger->getRegionPutCount($this->getDefaultQueryRegionName())); - $this->assertEquals(1, $this->secondLevelCacheLogger->getRegionMissCount($this->getDefaultQueryRegionName())); - $this->assertEquals(2, $this->secondLevelCacheLogger->getRegionPutCount($this->getEntityRegion(Country::class))); + self::assertEquals(3, $this->secondLevelCacheLogger->getPutCount()); + self::assertEquals(1, $this->secondLevelCacheLogger->getMissCount()); + self::assertEquals(1, $this->secondLevelCacheLogger->getRegionPutCount($this->getDefaultQueryRegionName())); + self::assertEquals(1, $this->secondLevelCacheLogger->getRegionMissCount($this->getDefaultQueryRegionName())); + self::assertEquals(2, $this->secondLevelCacheLogger->getRegionPutCount($this->getEntityRegion(Country::class))); $this->_em->clear(); @@ -260,33 +260,33 @@ public function testBasicQueryCachePutEntityCache(): void ->setCacheable(true) ->getResult(); - $this->assertEquals($queryCount + 1, $this->getCurrentQueryCount()); - $this->assertCount(2, $result2); + self::assertEquals($queryCount + 1, $this->getCurrentQueryCount()); + self::assertCount(2, $result2); - $this->assertEquals(3, $this->secondLevelCacheLogger->getPutCount()); - $this->assertEquals(3, $this->secondLevelCacheLogger->getHitCount()); - $this->assertEquals(1, $this->secondLevelCacheLogger->getMissCount()); + self::assertEquals(3, $this->secondLevelCacheLogger->getPutCount()); + self::assertEquals(3, $this->secondLevelCacheLogger->getHitCount()); + self::assertEquals(1, $this->secondLevelCacheLogger->getMissCount()); - $this->assertEquals(1, $this->secondLevelCacheLogger->getRegionPutCount($this->getDefaultQueryRegionName())); - $this->assertEquals(1, $this->secondLevelCacheLogger->getRegionHitCount($this->getDefaultQueryRegionName())); - $this->assertEquals(1, $this->secondLevelCacheLogger->getRegionMissCount($this->getDefaultQueryRegionName())); + self::assertEquals(1, $this->secondLevelCacheLogger->getRegionPutCount($this->getDefaultQueryRegionName())); + self::assertEquals(1, $this->secondLevelCacheLogger->getRegionHitCount($this->getDefaultQueryRegionName())); + self::assertEquals(1, $this->secondLevelCacheLogger->getRegionMissCount($this->getDefaultQueryRegionName())); - $this->assertInstanceOf(Country::class, $result2[0]); - $this->assertInstanceOf(Country::class, $result2[1]); + self::assertInstanceOf(Country::class, $result2[0]); + self::assertInstanceOf(Country::class, $result2[1]); - $this->assertEquals($result1[0]->getId(), $result2[0]->getId()); - $this->assertEquals($result1[1]->getId(), $result2[1]->getId()); + self::assertEquals($result1[0]->getId(), $result2[0]->getId()); + self::assertEquals($result1[1]->getId(), $result2[1]->getId()); - $this->assertEquals($result1[0]->getName(), $result2[0]->getName()); - $this->assertEquals($result1[1]->getName(), $result2[1]->getName()); + self::assertEquals($result1[0]->getName(), $result2[0]->getName()); + self::assertEquals($result1[1]->getName(), $result2[1]->getName()); - $this->assertEquals(3, $this->secondLevelCacheLogger->getPutCount()); - $this->assertEquals(3, $this->secondLevelCacheLogger->getHitCount()); - $this->assertEquals(1, $this->secondLevelCacheLogger->getMissCount()); + self::assertEquals(3, $this->secondLevelCacheLogger->getPutCount()); + self::assertEquals(3, $this->secondLevelCacheLogger->getHitCount()); + self::assertEquals(1, $this->secondLevelCacheLogger->getMissCount()); - $this->assertEquals(1, $this->secondLevelCacheLogger->getRegionPutCount($this->getDefaultQueryRegionName())); - $this->assertEquals(1, $this->secondLevelCacheLogger->getRegionHitCount($this->getDefaultQueryRegionName())); - $this->assertEquals(1, $this->secondLevelCacheLogger->getRegionMissCount($this->getDefaultQueryRegionName())); + self::assertEquals(1, $this->secondLevelCacheLogger->getRegionPutCount($this->getDefaultQueryRegionName())); + self::assertEquals(1, $this->secondLevelCacheLogger->getRegionHitCount($this->getDefaultQueryRegionName())); + self::assertEquals(1, $this->secondLevelCacheLogger->getRegionMissCount($this->getDefaultQueryRegionName())); } /** @@ -314,37 +314,37 @@ public function testMultipleNestedDQLAliases(): void ->setCacheable(true) ->getResult(); - $this->assertCount(2, $result1); - $this->assertEquals($queryCount + 1, $this->getCurrentQueryCount()); + self::assertCount(2, $result1); + self::assertEquals($queryCount + 1, $this->getCurrentQueryCount()); - $this->assertTrue($this->cache->containsEntity(State::class, $this->states[0]->getId())); - $this->assertTrue($this->cache->containsEntity(State::class, $this->states[1]->getId())); + self::assertTrue($this->cache->containsEntity(State::class, $this->states[0]->getId())); + self::assertTrue($this->cache->containsEntity(State::class, $this->states[1]->getId())); - $this->assertTrue($this->cache->containsEntity(City::class, $this->cities[0]->getId())); - $this->assertTrue($this->cache->containsEntity(City::class, $this->cities[1]->getId())); - $this->assertTrue($this->cache->containsEntity(City::class, $this->cities[2]->getId())); - $this->assertTrue($this->cache->containsEntity(City::class, $this->cities[3]->getId())); + self::assertTrue($this->cache->containsEntity(City::class, $this->cities[0]->getId())); + self::assertTrue($this->cache->containsEntity(City::class, $this->cities[1]->getId())); + self::assertTrue($this->cache->containsEntity(City::class, $this->cities[2]->getId())); + self::assertTrue($this->cache->containsEntity(City::class, $this->cities[3]->getId())); - $this->assertTrue($this->cache->containsEntity(Attraction::class, $this->attractions[0]->getId())); - $this->assertTrue($this->cache->containsEntity(Attraction::class, $this->attractions[1]->getId())); - $this->assertTrue($this->cache->containsEntity(Attraction::class, $this->attractions[2]->getId())); - $this->assertTrue($this->cache->containsEntity(Attraction::class, $this->attractions[3]->getId())); + self::assertTrue($this->cache->containsEntity(Attraction::class, $this->attractions[0]->getId())); + self::assertTrue($this->cache->containsEntity(Attraction::class, $this->attractions[1]->getId())); + self::assertTrue($this->cache->containsEntity(Attraction::class, $this->attractions[2]->getId())); + self::assertTrue($this->cache->containsEntity(Attraction::class, $this->attractions[3]->getId())); - $this->assertInstanceOf(State::class, $result1[0]); - $this->assertInstanceOf(State::class, $result1[1]); + self::assertInstanceOf(State::class, $result1[0]); + self::assertInstanceOf(State::class, $result1[1]); - $this->assertCount(2, $result1[0]->getCities()); - $this->assertCount(2, $result1[1]->getCities()); + self::assertCount(2, $result1[0]->getCities()); + self::assertCount(2, $result1[1]->getCities()); - $this->assertInstanceOf(City::class, $result1[0]->getCities()->get(0)); - $this->assertInstanceOf(City::class, $result1[0]->getCities()->get(1)); - $this->assertInstanceOf(City::class, $result1[1]->getCities()->get(0)); - $this->assertInstanceOf(City::class, $result1[1]->getCities()->get(1)); + self::assertInstanceOf(City::class, $result1[0]->getCities()->get(0)); + self::assertInstanceOf(City::class, $result1[0]->getCities()->get(1)); + self::assertInstanceOf(City::class, $result1[1]->getCities()->get(0)); + self::assertInstanceOf(City::class, $result1[1]->getCities()->get(1)); - $this->assertCount(2, $result1[0]->getCities()->get(0)->getAttractions()); - $this->assertCount(2, $result1[0]->getCities()->get(1)->getAttractions()); - $this->assertCount(2, $result1[1]->getCities()->get(0)->getAttractions()); - $this->assertCount(1, $result1[1]->getCities()->get(1)->getAttractions()); + self::assertCount(2, $result1[0]->getCities()->get(0)->getAttractions()); + self::assertCount(2, $result1[0]->getCities()->get(1)->getAttractions()); + self::assertCount(2, $result1[1]->getCities()->get(0)->getAttractions()); + self::assertCount(1, $result1[1]->getCities()->get(1)->getAttractions()); $this->_em->clear(); @@ -352,24 +352,24 @@ public function testMultipleNestedDQLAliases(): void ->setCacheable(true) ->getResult(); - $this->assertCount(2, $result2); - $this->assertEquals($queryCount + 1, $this->getCurrentQueryCount()); + self::assertCount(2, $result2); + self::assertEquals($queryCount + 1, $this->getCurrentQueryCount()); - $this->assertInstanceOf(State::class, $result2[0]); - $this->assertInstanceOf(State::class, $result2[1]); + self::assertInstanceOf(State::class, $result2[0]); + self::assertInstanceOf(State::class, $result2[1]); - $this->assertCount(2, $result2[0]->getCities()); - $this->assertCount(2, $result2[1]->getCities()); + self::assertCount(2, $result2[0]->getCities()); + self::assertCount(2, $result2[1]->getCities()); - $this->assertInstanceOf(City::class, $result2[0]->getCities()->get(0)); - $this->assertInstanceOf(City::class, $result2[0]->getCities()->get(1)); - $this->assertInstanceOf(City::class, $result2[1]->getCities()->get(0)); - $this->assertInstanceOf(City::class, $result2[1]->getCities()->get(1)); + self::assertInstanceOf(City::class, $result2[0]->getCities()->get(0)); + self::assertInstanceOf(City::class, $result2[0]->getCities()->get(1)); + self::assertInstanceOf(City::class, $result2[1]->getCities()->get(0)); + self::assertInstanceOf(City::class, $result2[1]->getCities()->get(1)); - $this->assertCount(2, $result2[0]->getCities()->get(0)->getAttractions()); - $this->assertCount(2, $result2[0]->getCities()->get(1)->getAttractions()); - $this->assertCount(2, $result2[1]->getCities()->get(0)->getAttractions()); - $this->assertCount(1, $result2[1]->getCities()->get(1)->getAttractions()); + self::assertCount(2, $result2[0]->getCities()->get(0)->getAttractions()); + self::assertCount(2, $result2[0]->getCities()->get(1)->getAttractions()); + self::assertCount(2, $result2[1]->getCities()->get(0)->getAttractions()); + self::assertCount(1, $result2[1]->getCities()->get(1)->getAttractions()); } public function testBasicQueryParams(): void @@ -379,8 +379,8 @@ public function testBasicQueryParams(): void $this->loadFixturesCountries(); $this->_em->clear(); - $this->assertTrue($this->cache->containsEntity(Country::class, $this->countries[0]->getId())); - $this->assertTrue($this->cache->containsEntity(Country::class, $this->countries[1]->getId())); + self::assertTrue($this->cache->containsEntity(Country::class, $this->countries[0]->getId())); + self::assertTrue($this->cache->containsEntity(Country::class, $this->countries[1]->getId())); $queryCount = $this->getCurrentQueryCount(); $name = $this->countries[0]->getName(); @@ -390,9 +390,9 @@ public function testBasicQueryParams(): void ->setParameter('name', $name) ->getResult(); - $this->assertEquals($queryCount + 1, $this->getCurrentQueryCount()); - $this->assertEquals($this->countries[0]->getId(), $result1[0]->getId()); - $this->assertEquals($this->countries[0]->getName(), $result1[0]->getName()); + self::assertEquals($queryCount + 1, $this->getCurrentQueryCount()); + self::assertEquals($this->countries[0]->getId(), $result1[0]->getId()); + self::assertEquals($this->countries[0]->getName(), $result1[0]->getName()); $this->_em->clear(); @@ -400,13 +400,13 @@ public function testBasicQueryParams(): void ->setParameter('name', $name) ->getResult(); - $this->assertEquals($queryCount + 1, $this->getCurrentQueryCount()); - $this->assertCount(1, $result2); + self::assertEquals($queryCount + 1, $this->getCurrentQueryCount()); + self::assertCount(1, $result2); - $this->assertInstanceOf(Country::class, $result2[0]); + self::assertInstanceOf(Country::class, $result2[0]); - $this->assertEquals($result1[0]->getId(), $result2[0]->getId()); - $this->assertEquals($result1[0]->getName(), $result2[0]->getName()); + self::assertEquals($result1[0]->getId(), $result2[0]->getId()); + self::assertEquals($result1[0]->getName(), $result2[0]->getName()); } public function testLoadFromDatabaseWhenEntityMissing(): void @@ -416,27 +416,27 @@ public function testLoadFromDatabaseWhenEntityMissing(): void $this->loadFixturesCountries(); $this->_em->clear(); - $this->assertTrue($this->cache->containsEntity(Country::class, $this->countries[0]->getId())); - $this->assertTrue($this->cache->containsEntity(Country::class, $this->countries[1]->getId())); + self::assertTrue($this->cache->containsEntity(Country::class, $this->countries[0]->getId())); + self::assertTrue($this->cache->containsEntity(Country::class, $this->countries[1]->getId())); $queryCount = $this->getCurrentQueryCount(); $dql = 'SELECT c FROM Doctrine\Tests\Models\Cache\Country c'; $result1 = $this->_em->createQuery($dql)->setCacheable(true)->getResult(); - $this->assertCount(2, $result1); - $this->assertEquals($queryCount + 1, $this->getCurrentQueryCount()); - $this->assertEquals($this->countries[0]->getId(), $result1[0]->getId()); - $this->assertEquals($this->countries[1]->getId(), $result1[1]->getId()); - $this->assertEquals($this->countries[0]->getName(), $result1[0]->getName()); - $this->assertEquals($this->countries[1]->getName(), $result1[1]->getName()); + self::assertCount(2, $result1); + self::assertEquals($queryCount + 1, $this->getCurrentQueryCount()); + self::assertEquals($this->countries[0]->getId(), $result1[0]->getId()); + self::assertEquals($this->countries[1]->getId(), $result1[1]->getId()); + self::assertEquals($this->countries[0]->getName(), $result1[0]->getName()); + self::assertEquals($this->countries[1]->getName(), $result1[1]->getName()); - $this->assertEquals(3, $this->secondLevelCacheLogger->getPutCount()); - $this->assertEquals(1, $this->secondLevelCacheLogger->getMissCount()); - $this->assertEquals(1, $this->secondLevelCacheLogger->getRegionPutCount($this->getDefaultQueryRegionName())); - $this->assertEquals(1, $this->secondLevelCacheLogger->getRegionMissCount($this->getDefaultQueryRegionName())); + self::assertEquals(3, $this->secondLevelCacheLogger->getPutCount()); + self::assertEquals(1, $this->secondLevelCacheLogger->getMissCount()); + self::assertEquals(1, $this->secondLevelCacheLogger->getRegionPutCount($this->getDefaultQueryRegionName())); + self::assertEquals(1, $this->secondLevelCacheLogger->getRegionMissCount($this->getDefaultQueryRegionName())); $this->cache->evictEntity(Country::class, $result1[0]->getId()); - $this->assertFalse($this->cache->containsEntity(Country::class, $result1[0]->getId())); + self::assertFalse($this->cache->containsEntity(Country::class, $result1[0]->getId())); $this->_em->clear(); @@ -444,24 +444,24 @@ public function testLoadFromDatabaseWhenEntityMissing(): void ->setCacheable(true) ->getResult(); - $this->assertEquals($queryCount + 2, $this->getCurrentQueryCount()); - $this->assertCount(2, $result2); + self::assertEquals($queryCount + 2, $this->getCurrentQueryCount()); + self::assertCount(2, $result2); - $this->assertEquals(5, $this->secondLevelCacheLogger->getPutCount()); - $this->assertEquals(3, $this->secondLevelCacheLogger->getMissCount()); - $this->assertEquals(2, $this->secondLevelCacheLogger->getRegionPutCount($this->getDefaultQueryRegionName())); - $this->assertEquals(2, $this->secondLevelCacheLogger->getRegionMissCount($this->getDefaultQueryRegionName())); + self::assertEquals(5, $this->secondLevelCacheLogger->getPutCount()); + self::assertEquals(3, $this->secondLevelCacheLogger->getMissCount()); + self::assertEquals(2, $this->secondLevelCacheLogger->getRegionPutCount($this->getDefaultQueryRegionName())); + self::assertEquals(2, $this->secondLevelCacheLogger->getRegionMissCount($this->getDefaultQueryRegionName())); - $this->assertInstanceOf(Country::class, $result2[0]); - $this->assertInstanceOf(Country::class, $result2[1]); + self::assertInstanceOf(Country::class, $result2[0]); + self::assertInstanceOf(Country::class, $result2[1]); - $this->assertEquals($result1[0]->getId(), $result2[0]->getId()); - $this->assertEquals($result1[1]->getId(), $result2[1]->getId()); + self::assertEquals($result1[0]->getId(), $result2[0]->getId()); + self::assertEquals($result1[1]->getId(), $result2[1]->getId()); - $this->assertEquals($result1[0]->getName(), $result2[0]->getName()); - $this->assertEquals($result1[1]->getName(), $result2[1]->getName()); + self::assertEquals($result1[0]->getName(), $result2[0]->getName()); + self::assertEquals($result1[1]->getName(), $result2[1]->getName()); - $this->assertEquals($queryCount + 2, $this->getCurrentQueryCount()); + self::assertEquals($queryCount + 2, $this->getCurrentQueryCount()); } public function testBasicQueryFetchJoinsOneToMany(): void @@ -479,26 +479,26 @@ public function testBasicQueryFetchJoinsOneToMany(): void ->setCacheable(true) ->getResult(); - $this->assertEquals($queryCount + 1, $this->getCurrentQueryCount()); - $this->assertInstanceOf(State::class, $result1[0]); - $this->assertInstanceOf(State::class, $result1[1]); - $this->assertCount(2, $result1[0]->getCities()); - $this->assertCount(2, $result1[1]->getCities()); + self::assertEquals($queryCount + 1, $this->getCurrentQueryCount()); + self::assertInstanceOf(State::class, $result1[0]); + self::assertInstanceOf(State::class, $result1[1]); + self::assertCount(2, $result1[0]->getCities()); + self::assertCount(2, $result1[1]->getCities()); - $this->assertInstanceOf(City::class, $result1[0]->getCities()->get(0)); - $this->assertInstanceOf(City::class, $result1[0]->getCities()->get(1)); - $this->assertInstanceOf(City::class, $result1[1]->getCities()->get(0)); - $this->assertInstanceOf(City::class, $result1[1]->getCities()->get(1)); + self::assertInstanceOf(City::class, $result1[0]->getCities()->get(0)); + self::assertInstanceOf(City::class, $result1[0]->getCities()->get(1)); + self::assertInstanceOf(City::class, $result1[1]->getCities()->get(0)); + self::assertInstanceOf(City::class, $result1[1]->getCities()->get(1)); - $this->assertNotNull($result1[0]->getCities()->get(0)->getId()); - $this->assertNotNull($result1[0]->getCities()->get(1)->getId()); - $this->assertNotNull($result1[1]->getCities()->get(0)->getId()); - $this->assertNotNull($result1[1]->getCities()->get(1)->getId()); + self::assertNotNull($result1[0]->getCities()->get(0)->getId()); + self::assertNotNull($result1[0]->getCities()->get(1)->getId()); + self::assertNotNull($result1[1]->getCities()->get(0)->getId()); + self::assertNotNull($result1[1]->getCities()->get(1)->getId()); - $this->assertNotNull($result1[0]->getCities()->get(0)->getName()); - $this->assertNotNull($result1[0]->getCities()->get(1)->getName()); - $this->assertNotNull($result1[1]->getCities()->get(0)->getName()); - $this->assertNotNull($result1[1]->getCities()->get(1)->getName()); + self::assertNotNull($result1[0]->getCities()->get(0)->getName()); + self::assertNotNull($result1[0]->getCities()->get(1)->getName()); + self::assertNotNull($result1[1]->getCities()->get(0)->getName()); + self::assertNotNull($result1[1]->getCities()->get(1)->getName()); $this->_em->clear(); @@ -506,27 +506,27 @@ public function testBasicQueryFetchJoinsOneToMany(): void ->setCacheable(true) ->getResult(); - $this->assertInstanceOf(State::class, $result2[0]); - $this->assertInstanceOf(State::class, $result2[1]); - $this->assertCount(2, $result2[0]->getCities()); - $this->assertCount(2, $result2[1]->getCities()); + self::assertInstanceOf(State::class, $result2[0]); + self::assertInstanceOf(State::class, $result2[1]); + self::assertCount(2, $result2[0]->getCities()); + self::assertCount(2, $result2[1]->getCities()); - $this->assertInstanceOf(City::class, $result2[0]->getCities()->get(0)); - $this->assertInstanceOf(City::class, $result2[0]->getCities()->get(1)); - $this->assertInstanceOf(City::class, $result2[1]->getCities()->get(0)); - $this->assertInstanceOf(City::class, $result2[1]->getCities()->get(1)); + self::assertInstanceOf(City::class, $result2[0]->getCities()->get(0)); + self::assertInstanceOf(City::class, $result2[0]->getCities()->get(1)); + self::assertInstanceOf(City::class, $result2[1]->getCities()->get(0)); + self::assertInstanceOf(City::class, $result2[1]->getCities()->get(1)); - $this->assertNotNull($result2[0]->getCities()->get(0)->getId()); - $this->assertNotNull($result2[0]->getCities()->get(1)->getId()); - $this->assertNotNull($result2[1]->getCities()->get(0)->getId()); - $this->assertNotNull($result2[1]->getCities()->get(1)->getId()); + self::assertNotNull($result2[0]->getCities()->get(0)->getId()); + self::assertNotNull($result2[0]->getCities()->get(1)->getId()); + self::assertNotNull($result2[1]->getCities()->get(0)->getId()); + self::assertNotNull($result2[1]->getCities()->get(1)->getId()); - $this->assertNotNull($result2[0]->getCities()->get(0)->getName()); - $this->assertNotNull($result2[0]->getCities()->get(1)->getName()); - $this->assertNotNull($result2[1]->getCities()->get(0)->getName()); - $this->assertNotNull($result2[1]->getCities()->get(1)->getName()); + self::assertNotNull($result2[0]->getCities()->get(0)->getName()); + self::assertNotNull($result2[0]->getCities()->get(1)->getName()); + self::assertNotNull($result2[1]->getCities()->get(0)->getName()); + self::assertNotNull($result2[1]->getCities()->get(1)->getName()); - $this->assertEquals($queryCount + 1, $this->getCurrentQueryCount()); + self::assertEquals($queryCount + 1, $this->getCurrentQueryCount()); } public function testBasicQueryFetchJoinsManyToOne(): void @@ -545,25 +545,25 @@ public function testBasicQueryFetchJoinsManyToOne(): void ->setCacheable(true) ->getResult(); - $this->assertCount(4, $result1); - $this->assertInstanceOf(City::class, $result1[0]); - $this->assertInstanceOf(City::class, $result1[1]); - $this->assertInstanceOf(State::class, $result1[0]->getState()); - $this->assertInstanceOf(State::class, $result1[1]->getState()); + self::assertCount(4, $result1); + self::assertInstanceOf(City::class, $result1[0]); + self::assertInstanceOf(City::class, $result1[1]); + self::assertInstanceOf(State::class, $result1[0]->getState()); + self::assertInstanceOf(State::class, $result1[1]->getState()); - $this->assertTrue($this->cache->containsEntity(City::class, $result1[0]->getId())); - $this->assertTrue($this->cache->containsEntity(City::class, $result1[1]->getId())); - $this->assertTrue($this->cache->containsEntity(State::class, $result1[0]->getState()->getId())); - $this->assertTrue($this->cache->containsEntity(State::class, $result1[1]->getState()->getId())); + self::assertTrue($this->cache->containsEntity(City::class, $result1[0]->getId())); + self::assertTrue($this->cache->containsEntity(City::class, $result1[1]->getId())); + self::assertTrue($this->cache->containsEntity(State::class, $result1[0]->getState()->getId())); + self::assertTrue($this->cache->containsEntity(State::class, $result1[1]->getState()->getId())); - $this->assertEquals(7, $this->secondLevelCacheLogger->getPutCount()); - $this->assertEquals(1, $this->secondLevelCacheLogger->getMissCount()); - $this->assertEquals(1, $this->secondLevelCacheLogger->getRegionPutCount($this->getDefaultQueryRegionName())); - $this->assertEquals(1, $this->secondLevelCacheLogger->getRegionMissCount($this->getDefaultQueryRegionName())); - $this->assertEquals(2, $this->secondLevelCacheLogger->getRegionPutCount($this->getEntityRegion(State::class))); - $this->assertEquals(4, $this->secondLevelCacheLogger->getRegionPutCount($this->getEntityRegion(City::class))); + self::assertEquals(7, $this->secondLevelCacheLogger->getPutCount()); + self::assertEquals(1, $this->secondLevelCacheLogger->getMissCount()); + self::assertEquals(1, $this->secondLevelCacheLogger->getRegionPutCount($this->getDefaultQueryRegionName())); + self::assertEquals(1, $this->secondLevelCacheLogger->getRegionMissCount($this->getDefaultQueryRegionName())); + self::assertEquals(2, $this->secondLevelCacheLogger->getRegionPutCount($this->getEntityRegion(State::class))); + self::assertEquals(4, $this->secondLevelCacheLogger->getRegionPutCount($this->getEntityRegion(City::class))); - $this->assertEquals($queryCount + 1, $this->getCurrentQueryCount()); + self::assertEquals($queryCount + 1, $this->getCurrentQueryCount()); $this->_em->clear(); $this->secondLevelCacheLogger->clearStats(); @@ -572,28 +572,28 @@ public function testBasicQueryFetchJoinsManyToOne(): void ->setCacheable(true) ->getResult(); - $this->assertCount(4, $result1); - $this->assertInstanceOf(City::class, $result2[0]); - $this->assertInstanceOf(City::class, $result2[1]); - $this->assertInstanceOf(State::class, $result2[0]->getState()); - $this->assertInstanceOf(State::class, $result2[1]->getState()); + self::assertCount(4, $result1); + self::assertInstanceOf(City::class, $result2[0]); + self::assertInstanceOf(City::class, $result2[1]); + self::assertInstanceOf(State::class, $result2[0]->getState()); + self::assertInstanceOf(State::class, $result2[1]->getState()); - $this->assertNotNull($result2[0]->getId()); - $this->assertNotNull($result2[0]->getId()); - $this->assertNotNull($result2[1]->getState()->getId()); - $this->assertNotNull($result2[1]->getState()->getId()); + self::assertNotNull($result2[0]->getId()); + self::assertNotNull($result2[0]->getId()); + self::assertNotNull($result2[1]->getState()->getId()); + self::assertNotNull($result2[1]->getState()->getId()); - $this->assertNotNull($result2[0]->getName()); - $this->assertNotNull($result2[0]->getName()); - $this->assertNotNull($result2[1]->getState()->getName()); - $this->assertNotNull($result2[1]->getState()->getName()); + self::assertNotNull($result2[0]->getName()); + self::assertNotNull($result2[0]->getName()); + self::assertNotNull($result2[1]->getState()->getName()); + self::assertNotNull($result2[1]->getState()->getName()); - $this->assertEquals($result1[0]->getName(), $result2[0]->getName()); - $this->assertEquals($result1[1]->getName(), $result2[1]->getName()); - $this->assertEquals($result1[0]->getState()->getName(), $result2[0]->getState()->getName()); - $this->assertEquals($result1[1]->getState()->getName(), $result2[1]->getState()->getName()); + self::assertEquals($result1[0]->getName(), $result2[0]->getName()); + self::assertEquals($result1[1]->getName(), $result2[1]->getName()); + self::assertEquals($result1[0]->getState()->getName(), $result2[0]->getState()->getName()); + self::assertEquals($result1[1]->getState()->getName(), $result2[1]->getState()->getName()); - $this->assertEquals($queryCount + 1, $this->getCurrentQueryCount()); + self::assertEquals($queryCount + 1, $this->getCurrentQueryCount()); } public function testReloadQueryIfToOneIsNotFound(): void @@ -612,17 +612,17 @@ public function testReloadQueryIfToOneIsNotFound(): void ->setCacheable(true) ->getResult(); - $this->assertCount(4, $result1); - $this->assertInstanceOf(City::class, $result1[0]); - $this->assertInstanceOf(City::class, $result1[1]); - $this->assertInstanceOf(State::class, $result1[0]->getState()); - $this->assertInstanceOf(State::class, $result1[1]->getState()); + self::assertCount(4, $result1); + self::assertInstanceOf(City::class, $result1[0]); + self::assertInstanceOf(City::class, $result1[1]); + self::assertInstanceOf(State::class, $result1[0]->getState()); + self::assertInstanceOf(State::class, $result1[1]->getState()); - $this->assertTrue($this->cache->containsEntity(City::class, $result1[0]->getId())); - $this->assertTrue($this->cache->containsEntity(City::class, $result1[1]->getId())); - $this->assertTrue($this->cache->containsEntity(State::class, $result1[0]->getState()->getId())); - $this->assertTrue($this->cache->containsEntity(State::class, $result1[1]->getState()->getId())); - $this->assertEquals($queryCount + 1, $this->getCurrentQueryCount()); + self::assertTrue($this->cache->containsEntity(City::class, $result1[0]->getId())); + self::assertTrue($this->cache->containsEntity(City::class, $result1[1]->getId())); + self::assertTrue($this->cache->containsEntity(State::class, $result1[0]->getState()->getId())); + self::assertTrue($this->cache->containsEntity(State::class, $result1[1]->getState()->getId())); + self::assertEquals($queryCount + 1, $this->getCurrentQueryCount()); $this->_em->clear(); @@ -632,13 +632,13 @@ public function testReloadQueryIfToOneIsNotFound(): void ->setCacheable(true) ->getResult(); - $this->assertCount(4, $result1); - $this->assertInstanceOf(City::class, $result2[0]); - $this->assertInstanceOf(City::class, $result2[1]); - $this->assertInstanceOf(State::class, $result2[0]->getState()); - $this->assertInstanceOf(State::class, $result2[1]->getState()); + self::assertCount(4, $result1); + self::assertInstanceOf(City::class, $result2[0]); + self::assertInstanceOf(City::class, $result2[1]); + self::assertInstanceOf(State::class, $result2[0]->getState()); + self::assertInstanceOf(State::class, $result2[1]->getState()); - $this->assertEquals($queryCount + 2, $this->getCurrentQueryCount()); + self::assertEquals($queryCount + 2, $this->getCurrentQueryCount()); } public function testReloadQueryIfToManyAssociationItemIsNotFound(): void @@ -656,16 +656,16 @@ public function testReloadQueryIfToManyAssociationItemIsNotFound(): void ->setCacheable(true) ->getResult(); - $this->assertEquals($queryCount + 1, $this->getCurrentQueryCount()); - $this->assertInstanceOf(State::class, $result1[0]); - $this->assertInstanceOf(State::class, $result1[1]); - $this->assertCount(2, $result1[0]->getCities()); - $this->assertCount(2, $result1[1]->getCities()); + self::assertEquals($queryCount + 1, $this->getCurrentQueryCount()); + self::assertInstanceOf(State::class, $result1[0]); + self::assertInstanceOf(State::class, $result1[1]); + self::assertCount(2, $result1[0]->getCities()); + self::assertCount(2, $result1[1]->getCities()); - $this->assertInstanceOf(City::class, $result1[0]->getCities()->get(0)); - $this->assertInstanceOf(City::class, $result1[0]->getCities()->get(1)); - $this->assertInstanceOf(City::class, $result1[1]->getCities()->get(0)); - $this->assertInstanceOf(City::class, $result1[1]->getCities()->get(1)); + self::assertInstanceOf(City::class, $result1[0]->getCities()->get(0)); + self::assertInstanceOf(City::class, $result1[0]->getCities()->get(1)); + self::assertInstanceOf(City::class, $result1[1]->getCities()->get(0)); + self::assertInstanceOf(City::class, $result1[1]->getCities()->get(1)); $this->_em->clear(); @@ -675,17 +675,17 @@ public function testReloadQueryIfToManyAssociationItemIsNotFound(): void ->setCacheable(true) ->getResult(); - $this->assertInstanceOf(State::class, $result2[0]); - $this->assertInstanceOf(State::class, $result2[1]); - $this->assertCount(2, $result2[0]->getCities()); - $this->assertCount(2, $result2[1]->getCities()); + self::assertInstanceOf(State::class, $result2[0]); + self::assertInstanceOf(State::class, $result2[1]); + self::assertCount(2, $result2[0]->getCities()); + self::assertCount(2, $result2[1]->getCities()); - $this->assertInstanceOf(City::class, $result2[0]->getCities()->get(0)); - $this->assertInstanceOf(City::class, $result2[0]->getCities()->get(1)); - $this->assertInstanceOf(City::class, $result2[1]->getCities()->get(0)); - $this->assertInstanceOf(City::class, $result2[1]->getCities()->get(1)); + self::assertInstanceOf(City::class, $result2[0]->getCities()->get(0)); + self::assertInstanceOf(City::class, $result2[0]->getCities()->get(1)); + self::assertInstanceOf(City::class, $result2[1]->getCities()->get(0)); + self::assertInstanceOf(City::class, $result2[1]->getCities()->get(1)); - $this->assertEquals($queryCount + 2, $this->getCurrentQueryCount()); + self::assertEquals($queryCount + 2, $this->getCurrentQueryCount()); } public function testBasicNativeQueryCache(): void @@ -696,8 +696,8 @@ public function testBasicNativeQueryCache(): void $this->secondLevelCacheLogger->clearStats(); $this->_em->clear(); - $this->assertTrue($this->cache->containsEntity(Country::class, $this->countries[0]->getId())); - $this->assertTrue($this->cache->containsEntity(Country::class, $this->countries[1]->getId())); + self::assertTrue($this->cache->containsEntity(Country::class, $this->countries[0]->getId())); + self::assertTrue($this->cache->containsEntity(Country::class, $this->countries[1]->getId())); $rsm = new ResultSetMapping(); $rsm->addEntityResult(Country::class, 'c'); @@ -708,17 +708,17 @@ public function testBasicNativeQueryCache(): void $sql = 'SELECT id, name FROM cache_country'; $result1 = $this->_em->createNativeQuery($sql, $rsm)->setCacheable(true)->getResult(); - $this->assertCount(2, $result1); - $this->assertEquals($queryCount + 1, $this->getCurrentQueryCount()); - $this->assertEquals($this->countries[0]->getId(), $result1[0]->getId()); - $this->assertEquals($this->countries[1]->getId(), $result1[1]->getId()); - $this->assertEquals($this->countries[0]->getName(), $result1[0]->getName()); - $this->assertEquals($this->countries[1]->getName(), $result1[1]->getName()); + self::assertCount(2, $result1); + self::assertEquals($queryCount + 1, $this->getCurrentQueryCount()); + self::assertEquals($this->countries[0]->getId(), $result1[0]->getId()); + self::assertEquals($this->countries[1]->getId(), $result1[1]->getId()); + self::assertEquals($this->countries[0]->getName(), $result1[0]->getName()); + self::assertEquals($this->countries[1]->getName(), $result1[1]->getName()); - $this->assertEquals(1, $this->secondLevelCacheLogger->getPutCount()); - $this->assertEquals(1, $this->secondLevelCacheLogger->getMissCount()); - $this->assertEquals(1, $this->secondLevelCacheLogger->getRegionPutCount($this->getDefaultQueryRegionName())); - $this->assertEquals(1, $this->secondLevelCacheLogger->getRegionMissCount($this->getDefaultQueryRegionName())); + self::assertEquals(1, $this->secondLevelCacheLogger->getPutCount()); + self::assertEquals(1, $this->secondLevelCacheLogger->getMissCount()); + self::assertEquals(1, $this->secondLevelCacheLogger->getRegionPutCount($this->getDefaultQueryRegionName())); + self::assertEquals(1, $this->secondLevelCacheLogger->getRegionMissCount($this->getDefaultQueryRegionName())); $this->_em->clear(); @@ -726,33 +726,33 @@ public function testBasicNativeQueryCache(): void ->setCacheable(true) ->getResult(); - $this->assertEquals($queryCount + 1, $this->getCurrentQueryCount()); - $this->assertCount(2, $result2); + self::assertEquals($queryCount + 1, $this->getCurrentQueryCount()); + self::assertCount(2, $result2); - $this->assertEquals(1, $this->secondLevelCacheLogger->getPutCount()); - $this->assertEquals(3, $this->secondLevelCacheLogger->getHitCount()); - $this->assertEquals(1, $this->secondLevelCacheLogger->getMissCount()); + self::assertEquals(1, $this->secondLevelCacheLogger->getPutCount()); + self::assertEquals(3, $this->secondLevelCacheLogger->getHitCount()); + self::assertEquals(1, $this->secondLevelCacheLogger->getMissCount()); - $this->assertEquals(1, $this->secondLevelCacheLogger->getRegionPutCount($this->getDefaultQueryRegionName())); - $this->assertEquals(1, $this->secondLevelCacheLogger->getRegionHitCount($this->getDefaultQueryRegionName())); - $this->assertEquals(1, $this->secondLevelCacheLogger->getRegionMissCount($this->getDefaultQueryRegionName())); + self::assertEquals(1, $this->secondLevelCacheLogger->getRegionPutCount($this->getDefaultQueryRegionName())); + self::assertEquals(1, $this->secondLevelCacheLogger->getRegionHitCount($this->getDefaultQueryRegionName())); + self::assertEquals(1, $this->secondLevelCacheLogger->getRegionMissCount($this->getDefaultQueryRegionName())); - $this->assertInstanceOf(Country::class, $result2[0]); - $this->assertInstanceOf(Country::class, $result2[1]); + self::assertInstanceOf(Country::class, $result2[0]); + self::assertInstanceOf(Country::class, $result2[1]); - $this->assertEquals($result1[0]->getId(), $result2[0]->getId()); - $this->assertEquals($result1[1]->getId(), $result2[1]->getId()); + self::assertEquals($result1[0]->getId(), $result2[0]->getId()); + self::assertEquals($result1[1]->getId(), $result2[1]->getId()); - $this->assertEquals($result1[0]->getName(), $result2[0]->getName()); - $this->assertEquals($result1[1]->getName(), $result2[1]->getName()); + self::assertEquals($result1[0]->getName(), $result2[0]->getName()); + self::assertEquals($result1[1]->getName(), $result2[1]->getName()); - $this->assertEquals(1, $this->secondLevelCacheLogger->getPutCount()); - $this->assertEquals(3, $this->secondLevelCacheLogger->getHitCount()); - $this->assertEquals(1, $this->secondLevelCacheLogger->getMissCount()); + self::assertEquals(1, $this->secondLevelCacheLogger->getPutCount()); + self::assertEquals(3, $this->secondLevelCacheLogger->getHitCount()); + self::assertEquals(1, $this->secondLevelCacheLogger->getMissCount()); - $this->assertEquals(1, $this->secondLevelCacheLogger->getRegionPutCount($this->getDefaultQueryRegionName())); - $this->assertEquals(1, $this->secondLevelCacheLogger->getRegionHitCount($this->getDefaultQueryRegionName())); - $this->assertEquals(1, $this->secondLevelCacheLogger->getRegionMissCount($this->getDefaultQueryRegionName())); + self::assertEquals(1, $this->secondLevelCacheLogger->getRegionPutCount($this->getDefaultQueryRegionName())); + self::assertEquals(1, $this->secondLevelCacheLogger->getRegionHitCount($this->getDefaultQueryRegionName())); + self::assertEquals(1, $this->secondLevelCacheLogger->getRegionMissCount($this->getDefaultQueryRegionName())); } public function testQueryDependsOnFirstAndMaxResultResult(): void @@ -771,9 +771,9 @@ public function testQueryDependsOnFirstAndMaxResultResult(): void ->setMaxResults(1) ->getResult(); - $this->assertEquals($queryCount + 1, $this->getCurrentQueryCount()); - $this->assertEquals(1, $this->secondLevelCacheLogger->getPutCount()); - $this->assertEquals(1, $this->secondLevelCacheLogger->getMissCount()); + self::assertEquals($queryCount + 1, $this->getCurrentQueryCount()); + self::assertEquals(1, $this->secondLevelCacheLogger->getPutCount()); + self::assertEquals(1, $this->secondLevelCacheLogger->getMissCount()); $this->_em->clear(); @@ -783,9 +783,9 @@ public function testQueryDependsOnFirstAndMaxResultResult(): void ->setMaxResults(1) ->getResult(); - $this->assertEquals($queryCount + 2, $this->getCurrentQueryCount()); - $this->assertEquals(2, $this->secondLevelCacheLogger->getPutCount()); - $this->assertEquals(2, $this->secondLevelCacheLogger->getMissCount()); + self::assertEquals($queryCount + 2, $this->getCurrentQueryCount()); + self::assertEquals(2, $this->secondLevelCacheLogger->getPutCount()); + self::assertEquals(2, $this->secondLevelCacheLogger->getMissCount()); $this->_em->clear(); @@ -793,9 +793,9 @@ public function testQueryDependsOnFirstAndMaxResultResult(): void ->setCacheable(true) ->getResult(); - $this->assertEquals($queryCount + 3, $this->getCurrentQueryCount()); - $this->assertEquals(3, $this->secondLevelCacheLogger->getPutCount()); - $this->assertEquals(3, $this->secondLevelCacheLogger->getMissCount()); + self::assertEquals($queryCount + 3, $this->getCurrentQueryCount()); + self::assertEquals(3, $this->secondLevelCacheLogger->getPutCount()); + self::assertEquals(3, $this->secondLevelCacheLogger->getMissCount()); } public function testQueryCacheLifetime(): void @@ -820,10 +820,10 @@ public function testQueryCacheLifetime(): void ->setLifetime(3600) ->getResult(); - $this->assertNotEmpty($result1); - $this->assertEquals($queryCount + 1, $this->getCurrentQueryCount()); - $this->assertEquals(1, $this->secondLevelCacheLogger->getPutCount()); - $this->assertEquals(1, $this->secondLevelCacheLogger->getMissCount()); + self::assertNotEmpty($result1); + self::assertEquals($queryCount + 1, $this->getCurrentQueryCount()); + self::assertEquals(1, $this->secondLevelCacheLogger->getPutCount()); + self::assertEquals(1, $this->secondLevelCacheLogger->getMissCount()); $this->_em->clear(); @@ -832,7 +832,7 @@ public function testQueryCacheLifetime(): void ->getRegion() ->get($key); - $this->assertInstanceOf(Cache\QueryCacheEntry::class, $entry); + self::assertInstanceOf(Cache\QueryCacheEntry::class, $entry); $entry->time /= 2; $this->cache->getQueryCache() @@ -844,10 +844,10 @@ public function testQueryCacheLifetime(): void ->setLifetime(3600) ->getResult(); - $this->assertNotEmpty($result2); - $this->assertEquals($queryCount + 2, $this->getCurrentQueryCount()); - $this->assertEquals(2, $this->secondLevelCacheLogger->getPutCount()); - $this->assertEquals(2, $this->secondLevelCacheLogger->getMissCount()); + self::assertNotEmpty($result2); + self::assertEquals($queryCount + 2, $this->getCurrentQueryCount()); + self::assertEquals(2, $this->secondLevelCacheLogger->getPutCount()); + self::assertEquals(2, $this->secondLevelCacheLogger->getMissCount()); } public function testQueryCacheRegion(): void @@ -867,54 +867,54 @@ public function testQueryCacheRegion(): void ->setCacheRegion('foo_region') ->getResult(); - $this->assertNotEmpty($result1); - $this->assertEquals($queryCount + 1, $this->getCurrentQueryCount()); - $this->assertEquals(0, $this->secondLevelCacheLogger->getHitCount()); - $this->assertEquals(1, $this->secondLevelCacheLogger->getPutCount()); - $this->assertEquals(1, $this->secondLevelCacheLogger->getMissCount()); - $this->assertEquals(1, $this->secondLevelCacheLogger->getRegionPutCount('foo_region')); - $this->assertEquals(1, $this->secondLevelCacheLogger->getRegionMissCount('foo_region')); + self::assertNotEmpty($result1); + self::assertEquals($queryCount + 1, $this->getCurrentQueryCount()); + self::assertEquals(0, $this->secondLevelCacheLogger->getHitCount()); + self::assertEquals(1, $this->secondLevelCacheLogger->getPutCount()); + self::assertEquals(1, $this->secondLevelCacheLogger->getMissCount()); + self::assertEquals(1, $this->secondLevelCacheLogger->getRegionPutCount('foo_region')); + self::assertEquals(1, $this->secondLevelCacheLogger->getRegionMissCount('foo_region')); $query2 = clone $query; $result2 = $query2->setCacheable(true) ->setCacheRegion('bar_region') ->getResult(); - $this->assertNotEmpty($result2); - $this->assertEquals($queryCount + 2, $this->getCurrentQueryCount()); - $this->assertEquals(0, $this->secondLevelCacheLogger->getHitCount()); - $this->assertEquals(2, $this->secondLevelCacheLogger->getPutCount()); - $this->assertEquals(2, $this->secondLevelCacheLogger->getMissCount()); - $this->assertEquals(1, $this->secondLevelCacheLogger->getRegionPutCount('bar_region')); - $this->assertEquals(1, $this->secondLevelCacheLogger->getRegionMissCount('bar_region')); + self::assertNotEmpty($result2); + self::assertEquals($queryCount + 2, $this->getCurrentQueryCount()); + self::assertEquals(0, $this->secondLevelCacheLogger->getHitCount()); + self::assertEquals(2, $this->secondLevelCacheLogger->getPutCount()); + self::assertEquals(2, $this->secondLevelCacheLogger->getMissCount()); + self::assertEquals(1, $this->secondLevelCacheLogger->getRegionPutCount('bar_region')); + self::assertEquals(1, $this->secondLevelCacheLogger->getRegionMissCount('bar_region')); $query3 = clone $query; $result3 = $query3->setCacheable(true) ->setCacheRegion('foo_region') ->getResult(); - $this->assertNotEmpty($result3); - $this->assertEquals($queryCount + 2, $this->getCurrentQueryCount()); - $this->assertEquals(3, $this->secondLevelCacheLogger->getHitCount()); - $this->assertEquals(2, $this->secondLevelCacheLogger->getPutCount()); - $this->assertEquals(2, $this->secondLevelCacheLogger->getMissCount()); - $this->assertEquals(1, $this->secondLevelCacheLogger->getRegionHitCount('foo_region')); - $this->assertEquals(1, $this->secondLevelCacheLogger->getRegionPutCount('foo_region')); - $this->assertEquals(1, $this->secondLevelCacheLogger->getRegionMissCount('foo_region')); + self::assertNotEmpty($result3); + self::assertEquals($queryCount + 2, $this->getCurrentQueryCount()); + self::assertEquals(3, $this->secondLevelCacheLogger->getHitCount()); + self::assertEquals(2, $this->secondLevelCacheLogger->getPutCount()); + self::assertEquals(2, $this->secondLevelCacheLogger->getMissCount()); + self::assertEquals(1, $this->secondLevelCacheLogger->getRegionHitCount('foo_region')); + self::assertEquals(1, $this->secondLevelCacheLogger->getRegionPutCount('foo_region')); + self::assertEquals(1, $this->secondLevelCacheLogger->getRegionMissCount('foo_region')); $query4 = clone $query; $result4 = $query4->setCacheable(true) ->setCacheRegion('bar_region') ->getResult(); - $this->assertNotEmpty($result3); - $this->assertEquals($queryCount + 2, $this->getCurrentQueryCount()); - $this->assertEquals(6, $this->secondLevelCacheLogger->getHitCount()); - $this->assertEquals(2, $this->secondLevelCacheLogger->getPutCount()); - $this->assertEquals(2, $this->secondLevelCacheLogger->getMissCount()); - $this->assertEquals(1, $this->secondLevelCacheLogger->getRegionHitCount('bar_region')); - $this->assertEquals(1, $this->secondLevelCacheLogger->getRegionPutCount('bar_region')); - $this->assertEquals(1, $this->secondLevelCacheLogger->getRegionMissCount('bar_region')); + self::assertNotEmpty($result3); + self::assertEquals($queryCount + 2, $this->getCurrentQueryCount()); + self::assertEquals(6, $this->secondLevelCacheLogger->getHitCount()); + self::assertEquals(2, $this->secondLevelCacheLogger->getPutCount()); + self::assertEquals(2, $this->secondLevelCacheLogger->getMissCount()); + self::assertEquals(1, $this->secondLevelCacheLogger->getRegionHitCount('bar_region')); + self::assertEquals(1, $this->secondLevelCacheLogger->getRegionPutCount('bar_region')); + self::assertEquals(1, $this->secondLevelCacheLogger->getRegionMissCount('bar_region')); } public function testResolveAssociationCacheEntry(): void @@ -938,13 +938,13 @@ public function testResolveAssociationCacheEntry(): void ->setMaxResults(1) ->getSingleResult(); - $this->assertNotNull($state1); - $this->assertNotNull($state1->getCountry()); - $this->assertEquals($queryCount + 1, $this->getCurrentQueryCount()); - $this->assertInstanceOf(State::class, $state1); - $this->assertInstanceOf(Proxy::class, $state1->getCountry()); - $this->assertEquals($countryName, $state1->getCountry()->getName()); - $this->assertEquals($stateId, $state1->getId()); + self::assertNotNull($state1); + self::assertNotNull($state1->getCountry()); + self::assertEquals($queryCount + 1, $this->getCurrentQueryCount()); + self::assertInstanceOf(State::class, $state1); + self::assertInstanceOf(Proxy::class, $state1->getCountry()); + self::assertEquals($countryName, $state1->getCountry()->getName()); + self::assertEquals($stateId, $state1->getId()); $this->_em->clear(); @@ -956,13 +956,13 @@ public function testResolveAssociationCacheEntry(): void ->setMaxResults(1) ->getSingleResult(); - $this->assertNotNull($state2); - $this->assertNotNull($state2->getCountry()); - $this->assertEquals($queryCount, $this->getCurrentQueryCount()); - $this->assertInstanceOf(State::class, $state2); - $this->assertInstanceOf(Proxy::class, $state2->getCountry()); - $this->assertEquals($countryName, $state2->getCountry()->getName()); - $this->assertEquals($stateId, $state2->getId()); + self::assertNotNull($state2); + self::assertNotNull($state2->getCountry()); + self::assertEquals($queryCount, $this->getCurrentQueryCount()); + self::assertInstanceOf(State::class, $state2); + self::assertInstanceOf(Proxy::class, $state2->getCountry()); + self::assertEquals($countryName, $state2->getCountry()->getName()); + self::assertEquals($stateId, $state2->getId()); } public function testResolveToOneAssociationCacheEntry(): void @@ -987,11 +987,11 @@ public function testResolveToOneAssociationCacheEntry(): void ->setMaxResults(1) ->getSingleResult(); - $this->assertEquals($queryCount + 1, $this->getCurrentQueryCount()); - $this->assertInstanceOf(City::class, $city1); - $this->assertInstanceOf(State::class, $city1->getState()); - $this->assertInstanceOf(City::class, $city1->getState()->getCities()->get(0)); - $this->assertInstanceOf(State::class, $city1->getState()->getCities()->get(0)->getState()); + self::assertEquals($queryCount + 1, $this->getCurrentQueryCount()); + self::assertInstanceOf(City::class, $city1); + self::assertInstanceOf(State::class, $city1->getState()); + self::assertInstanceOf(City::class, $city1->getState()->getCities()->get(0)); + self::assertInstanceOf(State::class, $city1->getState()->getCities()->get(0)->getState()); $this->_em->clear(); @@ -1003,11 +1003,11 @@ public function testResolveToOneAssociationCacheEntry(): void ->setMaxResults(1) ->getSingleResult(); - $this->assertEquals($queryCount, $this->getCurrentQueryCount()); - $this->assertInstanceOf(City::class, $city2); - $this->assertInstanceOf(State::class, $city2->getState()); - $this->assertInstanceOf(City::class, $city2->getState()->getCities()->get(0)); - $this->assertInstanceOf(State::class, $city2->getState()->getCities()->get(0)->getState()); + self::assertEquals($queryCount, $this->getCurrentQueryCount()); + self::assertInstanceOf(City::class, $city2); + self::assertInstanceOf(State::class, $city2->getState()); + self::assertInstanceOf(City::class, $city2->getState()->getCities()->get(0)); + self::assertInstanceOf(State::class, $city2->getState()->getCities()->get(0)->getState()); } public function testResolveToManyAssociationCacheEntry(): void @@ -1032,12 +1032,12 @@ public function testResolveToManyAssociationCacheEntry(): void ->setMaxResults(1) ->getSingleResult(); - $this->assertEquals($queryCount + 1, $this->getCurrentQueryCount()); - $this->assertInstanceOf(State::class, $state1); - $this->assertInstanceOf(Proxy::class, $state1->getCountry()); - $this->assertInstanceOf(City::class, $state1->getCities()->get(0)); - $this->assertInstanceOf(State::class, $state1->getCities()->get(0)->getState()); - $this->assertSame($state1, $state1->getCities()->get(0)->getState()); + self::assertEquals($queryCount + 1, $this->getCurrentQueryCount()); + self::assertInstanceOf(State::class, $state1); + self::assertInstanceOf(Proxy::class, $state1->getCountry()); + self::assertInstanceOf(City::class, $state1->getCities()->get(0)); + self::assertInstanceOf(State::class, $state1->getCities()->get(0)->getState()); + self::assertSame($state1, $state1->getCities()->get(0)->getState()); $this->_em->clear(); @@ -1049,12 +1049,12 @@ public function testResolveToManyAssociationCacheEntry(): void ->setMaxResults(1) ->getSingleResult(); - $this->assertEquals($queryCount, $this->getCurrentQueryCount()); - $this->assertInstanceOf(State::class, $state2); - $this->assertInstanceOf(Proxy::class, $state2->getCountry()); - $this->assertInstanceOf(City::class, $state2->getCities()->get(0)); - $this->assertInstanceOf(State::class, $state2->getCities()->get(0)->getState()); - $this->assertSame($state2, $state2->getCities()->get(0)->getState()); + self::assertEquals($queryCount, $this->getCurrentQueryCount()); + self::assertInstanceOf(State::class, $state2); + self::assertInstanceOf(Proxy::class, $state2->getCountry()); + self::assertInstanceOf(City::class, $state2->getCities()->get(0)); + self::assertInstanceOf(State::class, $state2->getCities()->get(0)->getState()); + self::assertSame($state2, $state2->getCities()->get(0)->getState()); } public function testHintClearEntityRegionUpdateStatement(): void @@ -1062,15 +1062,15 @@ public function testHintClearEntityRegionUpdateStatement(): void $this->evictRegions(); $this->loadFixturesCountries(); - $this->assertTrue($this->cache->containsEntity(Country::class, $this->countries[0]->getId())); - $this->assertTrue($this->cache->containsEntity(Country::class, $this->countries[1]->getId())); + self::assertTrue($this->cache->containsEntity(Country::class, $this->countries[0]->getId())); + self::assertTrue($this->cache->containsEntity(Country::class, $this->countries[1]->getId())); $this->_em->createQuery('DELETE Doctrine\Tests\Models\Cache\Country u WHERE u.id = 4') ->setHint(Query::HINT_CACHE_EVICT, true) ->execute(); - $this->assertFalse($this->cache->containsEntity(Country::class, $this->countries[0]->getId())); - $this->assertFalse($this->cache->containsEntity(Country::class, $this->countries[1]->getId())); + self::assertFalse($this->cache->containsEntity(Country::class, $this->countries[0]->getId())); + self::assertFalse($this->cache->containsEntity(Country::class, $this->countries[1]->getId())); } public function testHintClearEntityRegionDeleteStatement(): void @@ -1078,15 +1078,15 @@ public function testHintClearEntityRegionDeleteStatement(): void $this->evictRegions(); $this->loadFixturesCountries(); - $this->assertTrue($this->cache->containsEntity(Country::class, $this->countries[0]->getId())); - $this->assertTrue($this->cache->containsEntity(Country::class, $this->countries[1]->getId())); + self::assertTrue($this->cache->containsEntity(Country::class, $this->countries[0]->getId())); + self::assertTrue($this->cache->containsEntity(Country::class, $this->countries[1]->getId())); $this->_em->createQuery("UPDATE Doctrine\Tests\Models\Cache\Country u SET u.name = 'foo' WHERE u.id = 1") ->setHint(Query::HINT_CACHE_EVICT, true) ->execute(); - $this->assertFalse($this->cache->containsEntity(Country::class, $this->countries[0]->getId())); - $this->assertFalse($this->cache->containsEntity(Country::class, $this->countries[1]->getId())); + self::assertFalse($this->cache->containsEntity(Country::class, $this->countries[0]->getId())); + self::assertFalse($this->cache->containsEntity(Country::class, $this->countries[1]->getId())); } public function testCacheablePartialQueryException(): void @@ -1144,8 +1144,8 @@ public function testQueryCacheShouldBeEvictedOnTimestampUpdate(): void ->setCacheable(true) ->getResult(); - $this->assertCount(2, $result1); - $this->assertEquals($queryCount + 1, $this->getCurrentQueryCount()); + self::assertCount(2, $result1); + self::assertEquals($queryCount + 1, $this->getCurrentQueryCount()); $this->_em->persist(new Country('France')); $this->_em->flush(); @@ -1157,11 +1157,11 @@ public function testQueryCacheShouldBeEvictedOnTimestampUpdate(): void ->setCacheable(true) ->getResult(); - $this->assertCount(3, $result2); - $this->assertEquals($queryCount + 1, $this->getCurrentQueryCount()); + self::assertCount(3, $result2); + self::assertEquals($queryCount + 1, $this->getCurrentQueryCount()); foreach ($result2 as $entity) { - $this->assertInstanceOf(Country::class, $entity); + self::assertInstanceOf(Country::class, $entity); } } } diff --git a/tests/Doctrine/Tests/ORM/Functional/SecondLevelCacheRepositoryTest.php b/tests/Doctrine/Tests/ORM/Functional/SecondLevelCacheRepositoryTest.php index 7bd11f974a9..426866459ad 100644 --- a/tests/Doctrine/Tests/ORM/Functional/SecondLevelCacheRepositoryTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/SecondLevelCacheRepositoryTest.php @@ -21,22 +21,22 @@ public function testRepositoryCacheFind(): void $this->secondLevelCacheLogger->clearStats(); $this->_em->clear(); - $this->assertTrue($this->cache->containsEntity(Country::class, $this->countries[0]->getId())); - $this->assertTrue($this->cache->containsEntity(Country::class, $this->countries[1]->getId())); + self::assertTrue($this->cache->containsEntity(Country::class, $this->countries[0]->getId())); + self::assertTrue($this->cache->containsEntity(Country::class, $this->countries[1]->getId())); $queryCount = $this->getCurrentQueryCount(); $repository = $this->_em->getRepository(Country::class); $country1 = $repository->find($this->countries[0]->getId()); $country2 = $repository->find($this->countries[1]->getId()); - $this->assertEquals($queryCount, $this->getCurrentQueryCount()); + self::assertEquals($queryCount, $this->getCurrentQueryCount()); - $this->assertInstanceOf(Country::class, $country1); - $this->assertInstanceOf(Country::class, $country2); + self::assertInstanceOf(Country::class, $country1); + self::assertInstanceOf(Country::class, $country2); - $this->assertEquals(2, $this->secondLevelCacheLogger->getHitCount()); - $this->assertEquals(0, $this->secondLevelCacheLogger->getMissCount()); - $this->assertEquals(2, $this->secondLevelCacheLogger->getRegionHitCount($this->getEntityRegion(Country::class))); + self::assertEquals(2, $this->secondLevelCacheLogger->getHitCount()); + self::assertEquals(0, $this->secondLevelCacheLogger->getMissCount()); + self::assertEquals(2, $this->secondLevelCacheLogger->getRegionHitCount($this->getEntityRegion(Country::class))); } public function testRepositoryCacheFindAll(): void @@ -46,28 +46,28 @@ public function testRepositoryCacheFindAll(): void $this->secondLevelCacheLogger->clearStats(); $this->_em->clear(); - $this->assertFalse($this->cache->containsEntity(Country::class, $this->countries[0]->getId())); - $this->assertFalse($this->cache->containsEntity(Country::class, $this->countries[1]->getId())); + self::assertFalse($this->cache->containsEntity(Country::class, $this->countries[0]->getId())); + self::assertFalse($this->cache->containsEntity(Country::class, $this->countries[1]->getId())); $repository = $this->_em->getRepository(Country::class); $queryCount = $this->getCurrentQueryCount(); - $this->assertCount(2, $repository->findAll()); - $this->assertEquals($queryCount + 1, $this->getCurrentQueryCount()); + self::assertCount(2, $repository->findAll()); + self::assertEquals($queryCount + 1, $this->getCurrentQueryCount()); $queryCount = $this->getCurrentQueryCount(); $countries = $repository->findAll(); - $this->assertEquals($queryCount, $this->getCurrentQueryCount()); + self::assertEquals($queryCount, $this->getCurrentQueryCount()); - $this->assertInstanceOf(Country::class, $countries[0]); - $this->assertInstanceOf(Country::class, $countries[1]); + self::assertInstanceOf(Country::class, $countries[0]); + self::assertInstanceOf(Country::class, $countries[1]); - $this->assertEquals(3, $this->secondLevelCacheLogger->getHitCount()); - $this->assertEquals(1, $this->secondLevelCacheLogger->getMissCount()); + self::assertEquals(3, $this->secondLevelCacheLogger->getHitCount()); + self::assertEquals(1, $this->secondLevelCacheLogger->getMissCount()); - $this->assertTrue($this->cache->containsEntity(Country::class, $this->countries[0]->getId())); - $this->assertTrue($this->cache->containsEntity(Country::class, $this->countries[1]->getId())); + self::assertTrue($this->cache->containsEntity(Country::class, $this->countries[0]->getId())); + self::assertTrue($this->cache->containsEntity(Country::class, $this->countries[1]->getId())); } public function testRepositoryCacheFindAllInvalidation(): void @@ -77,23 +77,23 @@ public function testRepositoryCacheFindAllInvalidation(): void $this->secondLevelCacheLogger->clearStats(); $this->_em->clear(); - $this->assertFalse($this->cache->containsEntity(Country::class, $this->countries[0]->getId())); - $this->assertFalse($this->cache->containsEntity(Country::class, $this->countries[1]->getId())); + self::assertFalse($this->cache->containsEntity(Country::class, $this->countries[0]->getId())); + self::assertFalse($this->cache->containsEntity(Country::class, $this->countries[1]->getId())); $repository = $this->_em->getRepository(Country::class); $queryCount = $this->getCurrentQueryCount(); - $this->assertCount(2, $repository->findAll()); - $this->assertEquals($queryCount + 1, $this->getCurrentQueryCount()); + self::assertCount(2, $repository->findAll()); + self::assertEquals($queryCount + 1, $this->getCurrentQueryCount()); $queryCount = $this->getCurrentQueryCount(); $countries = $repository->findAll(); - $this->assertEquals($queryCount, $this->getCurrentQueryCount()); + self::assertEquals($queryCount, $this->getCurrentQueryCount()); - $this->assertCount(2, $countries); - $this->assertInstanceOf(Country::class, $countries[0]); - $this->assertInstanceOf(Country::class, $countries[1]); + self::assertCount(2, $countries); + self::assertInstanceOf(Country::class, $countries[0]); + self::assertInstanceOf(Country::class, $countries[1]); $country = new Country('foo'); @@ -103,8 +103,8 @@ public function testRepositoryCacheFindAllInvalidation(): void $queryCount = $this->getCurrentQueryCount(); - $this->assertCount(3, $repository->findAll()); - $this->assertEquals($queryCount + 1, $this->getCurrentQueryCount()); + self::assertCount(3, $repository->findAll()); + self::assertEquals($queryCount + 1, $this->getCurrentQueryCount()); $country = $repository->find($country->getId()); @@ -114,8 +114,8 @@ public function testRepositoryCacheFindAllInvalidation(): void $queryCount = $this->getCurrentQueryCount(); - $this->assertCount(2, $repository->findAll()); - $this->assertEquals($queryCount + 1, $this->getCurrentQueryCount()); + self::assertCount(2, $repository->findAll()); + self::assertEquals($queryCount + 1, $this->getCurrentQueryCount()); } public function testRepositoryCacheFindBy(): void @@ -125,27 +125,27 @@ public function testRepositoryCacheFindBy(): void $this->secondLevelCacheLogger->clearStats(); $this->_em->clear(); - $this->assertFalse($this->cache->containsEntity(Country::class, $this->countries[0]->getId())); + self::assertFalse($this->cache->containsEntity(Country::class, $this->countries[0]->getId())); $criteria = ['name' => $this->countries[0]->getName()]; $repository = $this->_em->getRepository(Country::class); $queryCount = $this->getCurrentQueryCount(); - $this->assertCount(1, $repository->findBy($criteria)); - $this->assertEquals($queryCount + 1, $this->getCurrentQueryCount()); + self::assertCount(1, $repository->findBy($criteria)); + self::assertEquals($queryCount + 1, $this->getCurrentQueryCount()); $queryCount = $this->getCurrentQueryCount(); $countries = $repository->findBy($criteria); - $this->assertEquals($queryCount, $this->getCurrentQueryCount()); + self::assertEquals($queryCount, $this->getCurrentQueryCount()); - $this->assertCount(1, $countries); - $this->assertInstanceOf(Country::class, $countries[0]); + self::assertCount(1, $countries); + self::assertInstanceOf(Country::class, $countries[0]); - $this->assertEquals(2, $this->secondLevelCacheLogger->getHitCount()); - $this->assertEquals(1, $this->secondLevelCacheLogger->getMissCount()); + self::assertEquals(2, $this->secondLevelCacheLogger->getHitCount()); + self::assertEquals(1, $this->secondLevelCacheLogger->getMissCount()); - $this->assertTrue($this->cache->containsEntity(Country::class, $this->countries[0]->getId())); + self::assertTrue($this->cache->containsEntity(Country::class, $this->countries[0]->getId())); } public function testRepositoryCacheFindOneBy(): void @@ -155,26 +155,26 @@ public function testRepositoryCacheFindOneBy(): void $this->secondLevelCacheLogger->clearStats(); $this->_em->clear(); - $this->assertFalse($this->cache->containsEntity(Country::class, $this->countries[0]->getId())); + self::assertFalse($this->cache->containsEntity(Country::class, $this->countries[0]->getId())); $criteria = ['name' => $this->countries[0]->getName()]; $repository = $this->_em->getRepository(Country::class); $queryCount = $this->getCurrentQueryCount(); - $this->assertNotNull($repository->findOneBy($criteria)); - $this->assertEquals($queryCount + 1, $this->getCurrentQueryCount()); + self::assertNotNull($repository->findOneBy($criteria)); + self::assertEquals($queryCount + 1, $this->getCurrentQueryCount()); $queryCount = $this->getCurrentQueryCount(); $country = $repository->findOneBy($criteria); - $this->assertEquals($queryCount, $this->getCurrentQueryCount()); + self::assertEquals($queryCount, $this->getCurrentQueryCount()); - $this->assertInstanceOf(Country::class, $country); + self::assertInstanceOf(Country::class, $country); - $this->assertEquals(2, $this->secondLevelCacheLogger->getHitCount()); - $this->assertEquals(1, $this->secondLevelCacheLogger->getMissCount()); + self::assertEquals(2, $this->secondLevelCacheLogger->getHitCount()); + self::assertEquals(1, $this->secondLevelCacheLogger->getMissCount()); - $this->assertTrue($this->cache->containsEntity(Country::class, $this->countries[0]->getId())); + self::assertTrue($this->cache->containsEntity(Country::class, $this->countries[0]->getId())); } public function testRepositoryCacheFindAllToOneAssociation(): void @@ -192,29 +192,29 @@ public function testRepositoryCacheFindAllToOneAssociation(): void $queryCount = $this->getCurrentQueryCount(); $entities = $repository->findAll(); - $this->assertCount(4, $entities); - $this->assertEquals($queryCount + 1, $this->getCurrentQueryCount()); + self::assertCount(4, $entities); + self::assertEquals($queryCount + 1, $this->getCurrentQueryCount()); - $this->assertInstanceOf(State::class, $entities[0]); - $this->assertInstanceOf(State::class, $entities[1]); - $this->assertInstanceOf(Country::class, $entities[0]->getCountry()); - $this->assertInstanceOf(Country::class, $entities[0]->getCountry()); - $this->assertInstanceOf(Proxy::class, $entities[0]->getCountry()); - $this->assertInstanceOf(Proxy::class, $entities[1]->getCountry()); + self::assertInstanceOf(State::class, $entities[0]); + self::assertInstanceOf(State::class, $entities[1]); + self::assertInstanceOf(Country::class, $entities[0]->getCountry()); + self::assertInstanceOf(Country::class, $entities[0]->getCountry()); + self::assertInstanceOf(Proxy::class, $entities[0]->getCountry()); + self::assertInstanceOf(Proxy::class, $entities[1]->getCountry()); // load from cache $queryCount = $this->getCurrentQueryCount(); $entities = $repository->findAll(); - $this->assertCount(4, $entities); - $this->assertEquals($queryCount, $this->getCurrentQueryCount()); + self::assertCount(4, $entities); + self::assertEquals($queryCount, $this->getCurrentQueryCount()); - $this->assertInstanceOf(State::class, $entities[0]); - $this->assertInstanceOf(State::class, $entities[1]); - $this->assertInstanceOf(Country::class, $entities[0]->getCountry()); - $this->assertInstanceOf(Country::class, $entities[1]->getCountry()); - $this->assertInstanceOf(Proxy::class, $entities[0]->getCountry()); - $this->assertInstanceOf(Proxy::class, $entities[1]->getCountry()); + self::assertInstanceOf(State::class, $entities[0]); + self::assertInstanceOf(State::class, $entities[1]); + self::assertInstanceOf(Country::class, $entities[0]->getCountry()); + self::assertInstanceOf(Country::class, $entities[1]->getCountry()); + self::assertInstanceOf(Proxy::class, $entities[0]->getCountry()); + self::assertInstanceOf(Proxy::class, $entities[1]->getCountry()); // invalidate cache $this->_em->persist(new State('foo', $this->_em->find(Country::class, $this->countries[0]->getId()))); @@ -225,28 +225,28 @@ public function testRepositoryCacheFindAllToOneAssociation(): void $queryCount = $this->getCurrentQueryCount(); $entities = $repository->findAll(); - $this->assertCount(5, $entities); - $this->assertEquals($queryCount + 1, $this->getCurrentQueryCount()); + self::assertCount(5, $entities); + self::assertEquals($queryCount + 1, $this->getCurrentQueryCount()); - $this->assertInstanceOf(State::class, $entities[0]); - $this->assertInstanceOf(State::class, $entities[1]); - $this->assertInstanceOf(Country::class, $entities[0]->getCountry()); - $this->assertInstanceOf(Country::class, $entities[1]->getCountry()); - $this->assertInstanceOf(Proxy::class, $entities[0]->getCountry()); - $this->assertInstanceOf(Proxy::class, $entities[1]->getCountry()); + self::assertInstanceOf(State::class, $entities[0]); + self::assertInstanceOf(State::class, $entities[1]); + self::assertInstanceOf(Country::class, $entities[0]->getCountry()); + self::assertInstanceOf(Country::class, $entities[1]->getCountry()); + self::assertInstanceOf(Proxy::class, $entities[0]->getCountry()); + self::assertInstanceOf(Proxy::class, $entities[1]->getCountry()); // load from cache $queryCount = $this->getCurrentQueryCount(); $entities = $repository->findAll(); - $this->assertCount(5, $entities); - $this->assertEquals($queryCount, $this->getCurrentQueryCount()); + self::assertCount(5, $entities); + self::assertEquals($queryCount, $this->getCurrentQueryCount()); - $this->assertInstanceOf(State::class, $entities[0]); - $this->assertInstanceOf(State::class, $entities[1]); - $this->assertInstanceOf(Country::class, $entities[0]->getCountry()); - $this->assertInstanceOf(Country::class, $entities[1]->getCountry()); - $this->assertInstanceOf(Proxy::class, $entities[0]->getCountry()); - $this->assertInstanceOf(Proxy::class, $entities[1]->getCountry()); + self::assertInstanceOf(State::class, $entities[0]); + self::assertInstanceOf(State::class, $entities[1]); + self::assertInstanceOf(Country::class, $entities[0]->getCountry()); + self::assertInstanceOf(Country::class, $entities[1]->getCountry()); + self::assertInstanceOf(Proxy::class, $entities[0]->getCountry()); + self::assertInstanceOf(Proxy::class, $entities[1]->getCountry()); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/SecondLevelCacheSingleTableInheritanceTest.php b/tests/Doctrine/Tests/ORM/Functional/SecondLevelCacheSingleTableInheritanceTest.php index 841621eca5d..836be9ad746 100644 --- a/tests/Doctrine/Tests/ORM/Functional/SecondLevelCacheSingleTableInheritanceTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/SecondLevelCacheSingleTableInheritanceTest.php @@ -26,9 +26,9 @@ public function testUseSameRegion(): void $beachRegion = $this->cache->getEntityCacheRegion(Beach::class); $barRegion = $this->cache->getEntityCacheRegion(Bar::class); - $this->assertEquals($attractionRegion->getName(), $restaurantRegion->getName()); - $this->assertEquals($attractionRegion->getName(), $beachRegion->getName()); - $this->assertEquals($attractionRegion->getName(), $barRegion->getName()); + self::assertEquals($attractionRegion->getName(), $restaurantRegion->getName()); + self::assertEquals($attractionRegion->getName(), $beachRegion->getName()); + self::assertEquals($attractionRegion->getName(), $barRegion->getName()); } public function testPutOnPersistSingleTableInheritance(): void @@ -40,8 +40,8 @@ public function testPutOnPersistSingleTableInheritance(): void $this->_em->clear(); - $this->assertTrue($this->cache->containsEntity(Bar::class, $this->attractions[0]->getId())); - $this->assertTrue($this->cache->containsEntity(Bar::class, $this->attractions[1]->getId())); + self::assertTrue($this->cache->containsEntity(Bar::class, $this->attractions[0]->getId())); + self::assertTrue($this->cache->containsEntity(Bar::class, $this->attractions[1]->getId())); } public function testCountaisRootClass(): void @@ -54,8 +54,8 @@ public function testCountaisRootClass(): void $this->_em->clear(); foreach ($this->attractions as $attraction) { - $this->assertTrue($this->cache->containsEntity(Attraction::class, $attraction->getId())); - $this->assertTrue($this->cache->containsEntity(get_class($attraction), $attraction->getId())); + self::assertTrue($this->cache->containsEntity(Attraction::class, $attraction->getId())); + self::assertTrue($this->cache->containsEntity(get_class($attraction), $attraction->getId())); } } @@ -73,29 +73,29 @@ public function testPutAndLoadEntities(): void $entityId1 = $this->attractions[0]->getId(); $entityId2 = $this->attractions[1]->getId(); - $this->assertFalse($this->cache->containsEntity(Attraction::class, $entityId1)); - $this->assertFalse($this->cache->containsEntity(Attraction::class, $entityId2)); - $this->assertFalse($this->cache->containsEntity(Bar::class, $entityId1)); - $this->assertFalse($this->cache->containsEntity(Bar::class, $entityId2)); + self::assertFalse($this->cache->containsEntity(Attraction::class, $entityId1)); + self::assertFalse($this->cache->containsEntity(Attraction::class, $entityId2)); + self::assertFalse($this->cache->containsEntity(Bar::class, $entityId1)); + self::assertFalse($this->cache->containsEntity(Bar::class, $entityId2)); $entity1 = $this->_em->find(Attraction::class, $entityId1); $entity2 = $this->_em->find(Attraction::class, $entityId2); - $this->assertTrue($this->cache->containsEntity(Attraction::class, $entityId1)); - $this->assertTrue($this->cache->containsEntity(Attraction::class, $entityId2)); - $this->assertTrue($this->cache->containsEntity(Bar::class, $entityId1)); - $this->assertTrue($this->cache->containsEntity(Bar::class, $entityId2)); + self::assertTrue($this->cache->containsEntity(Attraction::class, $entityId1)); + self::assertTrue($this->cache->containsEntity(Attraction::class, $entityId2)); + self::assertTrue($this->cache->containsEntity(Bar::class, $entityId1)); + self::assertTrue($this->cache->containsEntity(Bar::class, $entityId2)); - $this->assertInstanceOf(Attraction::class, $entity1); - $this->assertInstanceOf(Attraction::class, $entity2); - $this->assertInstanceOf(Bar::class, $entity1); - $this->assertInstanceOf(Bar::class, $entity2); + self::assertInstanceOf(Attraction::class, $entity1); + self::assertInstanceOf(Attraction::class, $entity2); + self::assertInstanceOf(Bar::class, $entity1); + self::assertInstanceOf(Bar::class, $entity2); - $this->assertEquals($this->attractions[0]->getId(), $entity1->getId()); - $this->assertEquals($this->attractions[0]->getName(), $entity1->getName()); + self::assertEquals($this->attractions[0]->getId(), $entity1->getId()); + self::assertEquals($this->attractions[0]->getName(), $entity1->getName()); - $this->assertEquals($this->attractions[1]->getId(), $entity2->getId()); - $this->assertEquals($this->attractions[1]->getName(), $entity2->getName()); + self::assertEquals($this->attractions[1]->getId(), $entity2->getId()); + self::assertEquals($this->attractions[1]->getName(), $entity2->getName()); $this->_em->clear(); @@ -104,20 +104,20 @@ public function testPutAndLoadEntities(): void $entity3 = $this->_em->find(Attraction::class, $entityId1); $entity4 = $this->_em->find(Attraction::class, $entityId2); - $this->assertEquals($queryCount, $this->getCurrentQueryCount()); + self::assertEquals($queryCount, $this->getCurrentQueryCount()); - $this->assertInstanceOf(Attraction::class, $entity3); - $this->assertInstanceOf(Attraction::class, $entity4); - $this->assertInstanceOf(Bar::class, $entity3); - $this->assertInstanceOf(Bar::class, $entity4); + self::assertInstanceOf(Attraction::class, $entity3); + self::assertInstanceOf(Attraction::class, $entity4); + self::assertInstanceOf(Bar::class, $entity3); + self::assertInstanceOf(Bar::class, $entity4); - $this->assertNotSame($entity1, $entity3); - $this->assertEquals($entity1->getId(), $entity3->getId()); - $this->assertEquals($entity1->getName(), $entity3->getName()); + self::assertNotSame($entity1, $entity3); + self::assertEquals($entity1->getId(), $entity3->getId()); + self::assertEquals($entity1->getName(), $entity3->getName()); - $this->assertNotSame($entity2, $entity4); - $this->assertEquals($entity2->getId(), $entity4->getId()); - $this->assertEquals($entity2->getName(), $entity4->getName()); + self::assertNotSame($entity2, $entity4); + self::assertEquals($entity2->getId(), $entity4->getId()); + self::assertEquals($entity2->getName(), $entity4->getName()); } public function testQueryCacheFindAll(): void @@ -135,8 +135,8 @@ public function testQueryCacheFindAll(): void ->setCacheable(true) ->getResult(); - $this->assertCount(count($this->attractions), $result1); - $this->assertEquals($queryCount + 1, $this->getCurrentQueryCount()); + self::assertCount(count($this->attractions), $result1); + self::assertEquals($queryCount + 1, $this->getCurrentQueryCount()); $this->_em->clear(); @@ -144,11 +144,11 @@ public function testQueryCacheFindAll(): void ->setCacheable(true) ->getResult(); - $this->assertCount(count($this->attractions), $result2); - $this->assertEquals($queryCount + 1, $this->getCurrentQueryCount()); + self::assertCount(count($this->attractions), $result2); + self::assertEquals($queryCount + 1, $this->getCurrentQueryCount()); foreach ($result2 as $entity) { - $this->assertInstanceOf(Attraction::class, $entity); + self::assertInstanceOf(Attraction::class, $entity); } } @@ -162,12 +162,12 @@ public function testShouldNotPutOneToManyRelationOnPersist(): void $this->_em->clear(); foreach ($this->cities as $city) { - $this->assertTrue($this->cache->containsEntity(City::class, $city->getId())); - $this->assertFalse($this->cache->containsCollection(City::class, 'attractions', $city->getId())); + self::assertTrue($this->cache->containsEntity(City::class, $city->getId())); + self::assertFalse($this->cache->containsCollection(City::class, 'attractions', $city->getId())); } foreach ($this->attractions as $attraction) { - $this->assertTrue($this->cache->containsEntity(Attraction::class, $attraction->getId())); + self::assertTrue($this->cache->containsEntity(Attraction::class, $attraction->getId())); } } @@ -186,35 +186,35 @@ public function testOneToManyRelationSingleTable(): void $entity = $this->_em->find(City::class, $this->cities[0]->getId()); - $this->assertInstanceOf(City::class, $entity); - $this->assertInstanceOf(PersistentCollection::class, $entity->getAttractions()); - $this->assertCount(2, $entity->getAttractions()); + self::assertInstanceOf(City::class, $entity); + self::assertInstanceOf(PersistentCollection::class, $entity->getAttractions()); + self::assertCount(2, $entity->getAttractions()); $ownerId = $this->cities[0]->getId(); $queryCount = $this->getCurrentQueryCount(); - $this->assertTrue($this->cache->containsEntity(City::class, $ownerId)); - $this->assertTrue($this->cache->containsCollection(City::class, 'attractions', $ownerId)); + self::assertTrue($this->cache->containsEntity(City::class, $ownerId)); + self::assertTrue($this->cache->containsCollection(City::class, 'attractions', $ownerId)); - $this->assertInstanceOf(Bar::class, $entity->getAttractions()->get(0)); - $this->assertInstanceOf(Bar::class, $entity->getAttractions()->get(1)); - $this->assertEquals($this->attractions[0]->getName(), $entity->getAttractions()->get(0)->getName()); - $this->assertEquals($this->attractions[1]->getName(), $entity->getAttractions()->get(1)->getName()); + self::assertInstanceOf(Bar::class, $entity->getAttractions()->get(0)); + self::assertInstanceOf(Bar::class, $entity->getAttractions()->get(1)); + self::assertEquals($this->attractions[0]->getName(), $entity->getAttractions()->get(0)->getName()); + self::assertEquals($this->attractions[1]->getName(), $entity->getAttractions()->get(1)->getName()); $this->_em->clear(); $entity = $this->_em->find(City::class, $ownerId); - $this->assertInstanceOf(City::class, $entity); - $this->assertInstanceOf(PersistentCollection::class, $entity->getAttractions()); - $this->assertCount(2, $entity->getAttractions()); + self::assertInstanceOf(City::class, $entity); + self::assertInstanceOf(PersistentCollection::class, $entity->getAttractions()); + self::assertCount(2, $entity->getAttractions()); - $this->assertEquals($queryCount, $this->getCurrentQueryCount()); + self::assertEquals($queryCount, $this->getCurrentQueryCount()); - $this->assertInstanceOf(Bar::class, $entity->getAttractions()->get(0)); - $this->assertInstanceOf(Bar::class, $entity->getAttractions()->get(1)); - $this->assertEquals($this->attractions[0]->getName(), $entity->getAttractions()->get(0)->getName()); - $this->assertEquals($this->attractions[1]->getName(), $entity->getAttractions()->get(1)->getName()); + self::assertInstanceOf(Bar::class, $entity->getAttractions()->get(0)); + self::assertInstanceOf(Bar::class, $entity->getAttractions()->get(1)); + self::assertEquals($this->attractions[0]->getName(), $entity->getAttractions()->get(0)->getName()); + self::assertEquals($this->attractions[1]->getName(), $entity->getAttractions()->get(1)->getName()); } public function testQueryCacheShouldBeEvictedOnTimestampUpdate(): void @@ -232,8 +232,8 @@ public function testQueryCacheShouldBeEvictedOnTimestampUpdate(): void ->setCacheable(true) ->getResult(); - $this->assertCount(count($this->attractions), $result1); - $this->assertEquals($queryCount + 1, $this->getCurrentQueryCount()); + self::assertCount(count($this->attractions), $result1); + self::assertEquals($queryCount + 1, $this->getCurrentQueryCount()); $contact = new Beach( 'Botafogo', @@ -250,11 +250,11 @@ public function testQueryCacheShouldBeEvictedOnTimestampUpdate(): void ->setCacheable(true) ->getResult(); - $this->assertCount(count($this->attractions) + 1, $result2); - $this->assertEquals($queryCount + 1, $this->getCurrentQueryCount()); + self::assertCount(count($this->attractions) + 1, $result2); + self::assertEquals($queryCount + 1, $this->getCurrentQueryCount()); foreach ($result2 as $entity) { - $this->assertInstanceOf(Attraction::class, $entity); + self::assertInstanceOf(Attraction::class, $entity); } } } diff --git a/tests/Doctrine/Tests/ORM/Functional/SecondLevelCacheTest.php b/tests/Doctrine/Tests/ORM/Functional/SecondLevelCacheTest.php index f686f4c8734..e454e0379ed 100644 --- a/tests/Doctrine/Tests/ORM/Functional/SecondLevelCacheTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/SecondLevelCacheTest.php @@ -26,10 +26,10 @@ public function testPutOnPersist(): void $this->loadFixturesCountries(); $this->_em->clear(); - $this->assertTrue($this->cache->containsEntity(Country::class, $this->countries[0]->getId())); - $this->assertTrue($this->cache->containsEntity(Country::class, $this->countries[1]->getId())); - $this->assertEquals(2, $this->secondLevelCacheLogger->getPutCount()); - $this->assertEquals(2, $this->secondLevelCacheLogger->getRegionPutCount($this->getEntityRegion(Country::class))); + self::assertTrue($this->cache->containsEntity(Country::class, $this->countries[0]->getId())); + self::assertTrue($this->cache->containsEntity(Country::class, $this->countries[1]->getId())); + self::assertEquals(2, $this->secondLevelCacheLogger->getPutCount()); + self::assertEquals(2, $this->secondLevelCacheLogger->getRegionPutCount($this->getEntityRegion(Country::class))); } public function testPutAndLoadEntities(): void @@ -37,28 +37,28 @@ public function testPutAndLoadEntities(): void $this->loadFixturesCountries(); $this->_em->clear(); - $this->assertEquals(2, $this->secondLevelCacheLogger->getPutCount()); - $this->assertEquals(2, $this->secondLevelCacheLogger->getRegionPutCount($this->getEntityRegion(Country::class))); + self::assertEquals(2, $this->secondLevelCacheLogger->getPutCount()); + self::assertEquals(2, $this->secondLevelCacheLogger->getRegionPutCount($this->getEntityRegion(Country::class))); $this->cache->evictEntityRegion(Country::class); - $this->assertFalse($this->cache->containsEntity(Country::class, $this->countries[0]->getId())); - $this->assertFalse($this->cache->containsEntity(Country::class, $this->countries[1]->getId())); + self::assertFalse($this->cache->containsEntity(Country::class, $this->countries[0]->getId())); + self::assertFalse($this->cache->containsEntity(Country::class, $this->countries[1]->getId())); $c1 = $this->_em->find(Country::class, $this->countries[0]->getId()); $c2 = $this->_em->find(Country::class, $this->countries[1]->getId()); - $this->assertTrue($this->cache->containsEntity(Country::class, $this->countries[0]->getId())); - $this->assertTrue($this->cache->containsEntity(Country::class, $this->countries[1]->getId())); + self::assertTrue($this->cache->containsEntity(Country::class, $this->countries[0]->getId())); + self::assertTrue($this->cache->containsEntity(Country::class, $this->countries[1]->getId())); - $this->assertInstanceOf(Country::class, $c1); - $this->assertInstanceOf(Country::class, $c2); + self::assertInstanceOf(Country::class, $c1); + self::assertInstanceOf(Country::class, $c2); - $this->assertEquals($this->countries[0]->getId(), $c1->getId()); - $this->assertEquals($this->countries[0]->getName(), $c1->getName()); + self::assertEquals($this->countries[0]->getId(), $c1->getId()); + self::assertEquals($this->countries[0]->getName(), $c1->getName()); - $this->assertEquals($this->countries[1]->getId(), $c2->getId()); - $this->assertEquals($this->countries[1]->getName(), $c2->getName()); + self::assertEquals($this->countries[1]->getId(), $c2->getId()); + self::assertEquals($this->countries[1]->getName(), $c2->getName()); $this->_em->clear(); @@ -67,18 +67,18 @@ public function testPutAndLoadEntities(): void $c3 = $this->_em->find(Country::class, $this->countries[0]->getId()); $c4 = $this->_em->find(Country::class, $this->countries[1]->getId()); - $this->assertEquals($queryCount, $this->getCurrentQueryCount()); - $this->assertEquals(2, $this->secondLevelCacheLogger->getHitCount()); - $this->assertEquals(2, $this->secondLevelCacheLogger->getRegionHitCount($this->getEntityRegion(Country::class))); + self::assertEquals($queryCount, $this->getCurrentQueryCount()); + self::assertEquals(2, $this->secondLevelCacheLogger->getHitCount()); + self::assertEquals(2, $this->secondLevelCacheLogger->getRegionHitCount($this->getEntityRegion(Country::class))); - $this->assertInstanceOf(Country::class, $c3); - $this->assertInstanceOf(Country::class, $c4); + self::assertInstanceOf(Country::class, $c3); + self::assertInstanceOf(Country::class, $c4); - $this->assertEquals($c1->getId(), $c3->getId()); - $this->assertEquals($c1->getName(), $c3->getName()); + self::assertEquals($c1->getId(), $c3->getId()); + self::assertEquals($c1->getName(), $c3->getName()); - $this->assertEquals($c2->getId(), $c4->getId()); - $this->assertEquals($c2->getName(), $c4->getName()); + self::assertEquals($c2->getId(), $c4->getId()); + self::assertEquals($c2->getName(), $c4->getName()); } public function testRemoveEntities(): void @@ -86,45 +86,45 @@ public function testRemoveEntities(): void $this->loadFixturesCountries(); $this->_em->clear(); - $this->assertEquals(2, $this->secondLevelCacheLogger->getPutCount()); + self::assertEquals(2, $this->secondLevelCacheLogger->getPutCount()); $this->cache->evictEntityRegion(Country::class); $this->secondLevelCacheLogger->clearRegionStats($this->getEntityRegion(Country::class)); - $this->assertFalse($this->cache->containsEntity(Country::class, $this->countries[0]->getId())); - $this->assertFalse($this->cache->containsEntity(Country::class, $this->countries[1]->getId())); + self::assertFalse($this->cache->containsEntity(Country::class, $this->countries[0]->getId())); + self::assertFalse($this->cache->containsEntity(Country::class, $this->countries[1]->getId())); $c1 = $this->_em->find(Country::class, $this->countries[0]->getId()); $c2 = $this->_em->find(Country::class, $this->countries[1]->getId()); - $this->assertEquals(2, $this->secondLevelCacheLogger->getPutCount()); - $this->assertEquals(2, $this->secondLevelCacheLogger->getMissCount()); + self::assertEquals(2, $this->secondLevelCacheLogger->getPutCount()); + self::assertEquals(2, $this->secondLevelCacheLogger->getMissCount()); - $this->assertTrue($this->cache->containsEntity(Country::class, $this->countries[0]->getId())); - $this->assertTrue($this->cache->containsEntity(Country::class, $this->countries[1]->getId())); + self::assertTrue($this->cache->containsEntity(Country::class, $this->countries[0]->getId())); + self::assertTrue($this->cache->containsEntity(Country::class, $this->countries[1]->getId())); - $this->assertInstanceOf(Country::class, $c1); - $this->assertInstanceOf(Country::class, $c2); + self::assertInstanceOf(Country::class, $c1); + self::assertInstanceOf(Country::class, $c2); - $this->assertEquals($this->countries[0]->getId(), $c1->getId()); - $this->assertEquals($this->countries[0]->getName(), $c1->getName()); + self::assertEquals($this->countries[0]->getId(), $c1->getId()); + self::assertEquals($this->countries[0]->getName(), $c1->getName()); - $this->assertEquals($this->countries[1]->getId(), $c2->getId()); - $this->assertEquals($this->countries[1]->getName(), $c2->getName()); + self::assertEquals($this->countries[1]->getId(), $c2->getId()); + self::assertEquals($this->countries[1]->getName(), $c2->getName()); $this->_em->remove($c1); $this->_em->remove($c2); $this->_em->flush(); $this->_em->clear(); - $this->assertFalse($this->cache->containsEntity(Country::class, $this->countries[0]->getId())); - $this->assertFalse($this->cache->containsEntity(Country::class, $this->countries[1]->getId())); + self::assertFalse($this->cache->containsEntity(Country::class, $this->countries[0]->getId())); + self::assertFalse($this->cache->containsEntity(Country::class, $this->countries[1]->getId())); - $this->assertNull($this->_em->find(Country::class, $this->countries[0]->getId())); - $this->assertNull($this->_em->find(Country::class, $this->countries[1]->getId())); + self::assertNull($this->_em->find(Country::class, $this->countries[0]->getId())); + self::assertNull($this->_em->find(Country::class, $this->countries[1]->getId())); - $this->assertEquals(2, $this->secondLevelCacheLogger->getPutCount()); - $this->assertEquals(2, $this->secondLevelCacheLogger->getMissCount()); + self::assertEquals(2, $this->secondLevelCacheLogger->getPutCount()); + self::assertEquals(2, $this->secondLevelCacheLogger->getMissCount()); } public function testUpdateEntities(): void @@ -133,34 +133,34 @@ public function testUpdateEntities(): void $this->loadFixturesStates(); $this->_em->clear(); - $this->assertEquals(6, $this->secondLevelCacheLogger->getPutCount()); - $this->assertEquals(2, $this->secondLevelCacheLogger->getRegionPutCount($this->getEntityRegion(Country::class))); - $this->assertEquals(4, $this->secondLevelCacheLogger->getRegionPutCount($this->getEntityRegion(State::class))); + self::assertEquals(6, $this->secondLevelCacheLogger->getPutCount()); + self::assertEquals(2, $this->secondLevelCacheLogger->getRegionPutCount($this->getEntityRegion(Country::class))); + self::assertEquals(4, $this->secondLevelCacheLogger->getRegionPutCount($this->getEntityRegion(State::class))); $this->cache->evictEntityRegion(State::class); $this->secondLevelCacheLogger->clearRegionStats($this->getEntityRegion(State::class)); - $this->assertFalse($this->cache->containsEntity(State::class, $this->states[0]->getId())); - $this->assertFalse($this->cache->containsEntity(State::class, $this->states[1]->getId())); + self::assertFalse($this->cache->containsEntity(State::class, $this->states[0]->getId())); + self::assertFalse($this->cache->containsEntity(State::class, $this->states[1]->getId())); $s1 = $this->_em->find(State::class, $this->states[0]->getId()); $s2 = $this->_em->find(State::class, $this->states[1]->getId()); - $this->assertEquals(4, $this->secondLevelCacheLogger->getPutCount()); - $this->assertEquals(2, $this->secondLevelCacheLogger->getRegionPutCount($this->getEntityRegion(Country::class))); - $this->assertEquals(2, $this->secondLevelCacheLogger->getRegionPutCount($this->getEntityRegion(State::class))); + self::assertEquals(4, $this->secondLevelCacheLogger->getPutCount()); + self::assertEquals(2, $this->secondLevelCacheLogger->getRegionPutCount($this->getEntityRegion(Country::class))); + self::assertEquals(2, $this->secondLevelCacheLogger->getRegionPutCount($this->getEntityRegion(State::class))); - $this->assertTrue($this->cache->containsEntity(State::class, $this->states[0]->getId())); - $this->assertTrue($this->cache->containsEntity(State::class, $this->states[1]->getId())); + self::assertTrue($this->cache->containsEntity(State::class, $this->states[0]->getId())); + self::assertTrue($this->cache->containsEntity(State::class, $this->states[1]->getId())); - $this->assertInstanceOf(State::class, $s1); - $this->assertInstanceOf(State::class, $s2); + self::assertInstanceOf(State::class, $s1); + self::assertInstanceOf(State::class, $s2); - $this->assertEquals($this->states[0]->getId(), $s1->getId()); - $this->assertEquals($this->states[0]->getName(), $s1->getName()); + self::assertEquals($this->states[0]->getId(), $s1->getId()); + self::assertEquals($this->states[0]->getName(), $s1->getName()); - $this->assertEquals($this->states[1]->getId(), $s2->getId()); - $this->assertEquals($this->states[1]->getName(), $s2->getName()); + self::assertEquals($this->states[1]->getId(), $s2->getId()); + self::assertEquals($this->states[1]->getName(), $s2->getName()); $s1->setName('NEW NAME 1'); $s2->setName('NEW NAME 2'); @@ -170,37 +170,37 @@ public function testUpdateEntities(): void $this->_em->flush(); $this->_em->clear(); - $this->assertTrue($this->cache->containsEntity(State::class, $this->states[0]->getId())); - $this->assertTrue($this->cache->containsEntity(State::class, $this->states[1]->getId())); + self::assertTrue($this->cache->containsEntity(State::class, $this->states[0]->getId())); + self::assertTrue($this->cache->containsEntity(State::class, $this->states[1]->getId())); - $this->assertEquals(6, $this->secondLevelCacheLogger->getPutCount()); - $this->assertEquals(2, $this->secondLevelCacheLogger->getRegionPutCount($this->getEntityRegion(Country::class))); - $this->assertEquals(4, $this->secondLevelCacheLogger->getRegionPutCount($this->getEntityRegion(State::class))); + self::assertEquals(6, $this->secondLevelCacheLogger->getPutCount()); + self::assertEquals(2, $this->secondLevelCacheLogger->getRegionPutCount($this->getEntityRegion(Country::class))); + self::assertEquals(4, $this->secondLevelCacheLogger->getRegionPutCount($this->getEntityRegion(State::class))); $queryCount = $this->getCurrentQueryCount(); $c3 = $this->_em->find(State::class, $this->states[0]->getId()); $c4 = $this->_em->find(State::class, $this->states[1]->getId()); - $this->assertEquals(2, $this->secondLevelCacheLogger->getHitCount()); - $this->assertEquals(2, $this->secondLevelCacheLogger->getRegionHitCount($this->getEntityRegion(State::class))); + self::assertEquals(2, $this->secondLevelCacheLogger->getHitCount()); + self::assertEquals(2, $this->secondLevelCacheLogger->getRegionHitCount($this->getEntityRegion(State::class))); - $this->assertEquals($queryCount, $this->getCurrentQueryCount()); + self::assertEquals($queryCount, $this->getCurrentQueryCount()); - $this->assertTrue($this->cache->containsEntity(State::class, $this->states[0]->getId())); - $this->assertTrue($this->cache->containsEntity(State::class, $this->states[1]->getId())); + self::assertTrue($this->cache->containsEntity(State::class, $this->states[0]->getId())); + self::assertTrue($this->cache->containsEntity(State::class, $this->states[1]->getId())); - $this->assertInstanceOf(State::class, $c3); - $this->assertInstanceOf(State::class, $c4); + self::assertInstanceOf(State::class, $c3); + self::assertInstanceOf(State::class, $c4); - $this->assertEquals($s1->getId(), $c3->getId()); - $this->assertEquals('NEW NAME 1', $c3->getName()); + self::assertEquals($s1->getId(), $c3->getId()); + self::assertEquals('NEW NAME 1', $c3->getName()); - $this->assertEquals($s2->getId(), $c4->getId()); - $this->assertEquals('NEW NAME 2', $c4->getName()); + self::assertEquals($s2->getId(), $c4->getId()); + self::assertEquals('NEW NAME 2', $c4->getName()); - $this->assertEquals(2, $this->secondLevelCacheLogger->getHitCount()); - $this->assertEquals(2, $this->secondLevelCacheLogger->getRegionHitCount($this->getEntityRegion(State::class))); + self::assertEquals(2, $this->secondLevelCacheLogger->getHitCount()); + self::assertEquals(2, $this->secondLevelCacheLogger->getRegionHitCount($this->getEntityRegion(State::class))); } public function testPostFlushFailure(): void @@ -223,11 +223,11 @@ public function testPostFlushFailure(): void try { $this->_em->persist($country); $this->_em->flush(); - $this->fail('Should throw exception'); + self::fail('Should throw exception'); } catch (RuntimeException $exc) { - $this->assertNotNull($country->getId()); - $this->assertEquals('post flush failure', $exc->getMessage()); - $this->assertTrue($this->cache->containsEntity(Country::class, $country->getId())); + self::assertNotNull($country->getId()); + self::assertEquals('post flush failure', $exc->getMessage()); + self::assertTrue($this->cache->containsEntity(Country::class, $country->getId())); } } @@ -254,9 +254,9 @@ public function testPostUpdateFailure(): void $stateName = $this->states[0]->getName(); $state = $this->_em->find(State::class, $stateId); - $this->assertTrue($this->cache->containsEntity(State::class, $stateId)); - $this->assertInstanceOf(State::class, $state); - $this->assertEquals($stateName, $state->getName()); + self::assertTrue($this->cache->containsEntity(State::class, $stateId)); + self::assertInstanceOf(State::class, $state); + self::assertEquals($stateName, $state->getName()); $state->setName($stateName . uniqid()); @@ -264,19 +264,19 @@ public function testPostUpdateFailure(): void try { $this->_em->flush(); - $this->fail('Should throw exception'); + self::fail('Should throw exception'); } catch (Exception $exc) { - $this->assertEquals('post update failure', $exc->getMessage()); + self::assertEquals('post update failure', $exc->getMessage()); } $this->_em->clear(); - $this->assertTrue($this->cache->containsEntity(State::class, $stateId)); + self::assertTrue($this->cache->containsEntity(State::class, $stateId)); $state = $this->_em->find(State::class, $stateId); - $this->assertInstanceOf(State::class, $state); - $this->assertEquals($stateName, $state->getName()); + self::assertInstanceOf(State::class, $state); + self::assertEquals($stateName, $state->getName()); } public function testPostRemoveFailure(): void @@ -300,26 +300,26 @@ public function testPostRemoveFailure(): void $countryId = $this->countries[0]->getId(); $country = $this->_em->find(Country::class, $countryId); - $this->assertTrue($this->cache->containsEntity(Country::class, $countryId)); - $this->assertInstanceOf(Country::class, $country); + self::assertTrue($this->cache->containsEntity(Country::class, $countryId)); + self::assertInstanceOf(Country::class, $country); $this->_em->remove($country); try { $this->_em->flush(); - $this->fail('Should throw exception'); + self::fail('Should throw exception'); } catch (Exception $exc) { - $this->assertEquals('post remove failure', $exc->getMessage()); + self::assertEquals('post remove failure', $exc->getMessage()); } $this->_em->clear(); - $this->assertFalse( + self::assertFalse( $this->cache->containsEntity(Country::class, $countryId), 'Removal attempts should clear the cache entry corresponding to the entity' ); - $this->assertInstanceOf(Country::class, $this->_em->find(Country::class, $countryId)); + self::assertInstanceOf(Country::class, $this->_em->find(Country::class, $countryId)); } public function testCachedNewEntityExists(): void @@ -329,11 +329,11 @@ public function testCachedNewEntityExists(): void $persister = $this->_em->getUnitOfWork()->getEntityPersister(Country::class); $queryCount = $this->getCurrentQueryCount(); - $this->assertTrue($persister->exists($this->countries[0])); + self::assertTrue($persister->exists($this->countries[0])); - $this->assertEquals($queryCount, $this->getCurrentQueryCount()); + self::assertEquals($queryCount, $this->getCurrentQueryCount()); - $this->assertFalse($persister->exists(new Country('Foo'))); + self::assertFalse($persister->exists(new Country('Foo'))); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/SequenceEmulatedIdentityStrategyTest.php b/tests/Doctrine/Tests/ORM/Functional/SequenceEmulatedIdentityStrategyTest.php index b9e1e1f917a..4817a60e8e9 100644 --- a/tests/Doctrine/Tests/ORM/Functional/SequenceEmulatedIdentityStrategyTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/SequenceEmulatedIdentityStrategyTest.php @@ -22,7 +22,7 @@ protected function setUp(): void parent::setUp(); if (! $this->_em->getConnection()->getDatabasePlatform()->usesSequenceEmulatedIdentityColumns()) { - $this->markTestSkipped( + self::markTestSkipped( 'This test is special to platforms emulating IDENTITY key generation strategy through sequences.' ); } else { @@ -57,9 +57,9 @@ public function testPreSavePostSaveCallbacksAreInvoked(): void $entity->setValue('hello'); $this->_em->persist($entity); $this->_em->flush(); - $this->assertTrue(is_numeric($entity->getId())); - $this->assertTrue($entity->getId() > 0); - $this->assertTrue($this->_em->contains($entity)); + self::assertTrue(is_numeric($entity->getId())); + self::assertTrue($entity->getId() > 0); + self::assertTrue($this->_em->contains($entity)); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/SequenceGeneratorTest.php b/tests/Doctrine/Tests/ORM/Functional/SequenceGeneratorTest.php index c2b95f94a43..287b18775af 100644 --- a/tests/Doctrine/Tests/ORM/Functional/SequenceGeneratorTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/SequenceGeneratorTest.php @@ -21,7 +21,7 @@ protected function setUp(): void parent::setUp(); if (! $this->_em->getConnection()->getDatabasePlatform()->supportsSequences()) { - $this->markTestSkipped('Only working for Databases that support sequences.'); + self::markTestSkipped('Only working for Databases that support sequences.'); } try { diff --git a/tests/Doctrine/Tests/ORM/Functional/SingleTableCompositeKeyTest.php b/tests/Doctrine/Tests/ORM/Functional/SingleTableCompositeKeyTest.php index 821b7f1d8e1..1c7a4d95611 100644 --- a/tests/Doctrine/Tests/ORM/Functional/SingleTableCompositeKeyTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/SingleTableCompositeKeyTest.php @@ -25,7 +25,7 @@ public function testInsertWithCompositeKey(): void $this->_em->clear(); $entity = $this->findEntity(); - $this->assertEquals($childEntity, $entity); + self::assertEquals($childEntity, $entity); } /** @@ -47,7 +47,7 @@ public function testUpdateWithCompositeKey(): void $this->_em->clear(); $persistedEntity = $this->findEntity(); - $this->assertEquals($entity, $persistedEntity); + self::assertEquals($entity, $persistedEntity); } private function findEntity(): SingleChildClass diff --git a/tests/Doctrine/Tests/ORM/Functional/SingleTableInheritanceTest.php b/tests/Doctrine/Tests/ORM/Functional/SingleTableInheritanceTest.php index ac003f7f250..4365bb830cd 100644 --- a/tests/Doctrine/Tests/ORM/Functional/SingleTableInheritanceTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/SingleTableInheritanceTest.php @@ -131,9 +131,9 @@ public function testPersistChildOfBaseClass(): void $contract = $this->_em->find(CompanyFixContract::class, $fixContract->getId()); - $this->assertInstanceOf(CompanyFixContract::class, $contract); - $this->assertEquals(1000, $contract->getFixPrice()); - $this->assertEquals($this->salesPerson->getId(), $contract->getSalesPerson()->getId()); + self::assertInstanceOf(CompanyFixContract::class, $contract); + self::assertEquals(1000, $contract->getFixPrice()); + self::assertEquals($this->salesPerson->getId(), $contract->getSalesPerson()->getId()); } public function testPersistDeepChildOfBaseClass(): void @@ -152,10 +152,10 @@ public function testPersistDeepChildOfBaseClass(): void $contract = $this->_em->find(CompanyFlexUltraContract::class, $ultraContract->getId()); - $this->assertInstanceOf(CompanyFlexUltraContract::class, $contract); - $this->assertEquals(7000, $contract->getMaxPrice()); - $this->assertEquals(100, $contract->getHoursWorked()); - $this->assertEquals(50, $contract->getPricePerHour()); + self::assertInstanceOf(CompanyFlexUltraContract::class, $contract); + self::assertEquals(7000, $contract->getMaxPrice()); + self::assertEquals(100, $contract->getHoursWorked()); + self::assertEquals(50, $contract->getPricePerHour()); } public function testChildClassLifecycleUpdate(): void @@ -169,7 +169,7 @@ public function testChildClassLifecycleUpdate(): void $this->_em->clear(); $newFix = $this->_em->find(CompanyContract::class, $this->fix->getId()); - $this->assertEquals(2500, $newFix->getFixPrice()); + self::assertEquals(2500, $newFix->getFixPrice()); } public function testChildClassLifecycleRemove(): void @@ -180,7 +180,7 @@ public function testChildClassLifecycleRemove(): void $this->_em->remove($fix); $this->_em->flush(); - $this->assertNull($this->_em->find(CompanyContract::class, $this->fix->getId())); + self::assertNull($this->_em->find(CompanyContract::class, $this->fix->getId())); } public function testFindAllForAbstractBaseClass(): void @@ -188,17 +188,17 @@ public function testFindAllForAbstractBaseClass(): void $this->loadFullFixture(); $contracts = $this->_em->getRepository(CompanyContract::class)->findAll(); - $this->assertEquals(3, count($contracts)); - $this->assertContainsOnly(CompanyContract::class, $contracts); + self::assertEquals(3, count($contracts)); + self::assertContainsOnly(CompanyContract::class, $contracts); } public function testFindAllForChildClass(): void { $this->loadFullFixture(); - $this->assertEquals(1, count($this->_em->getRepository(CompanyFixContract::class)->findAll())); - $this->assertEquals(2, count($this->_em->getRepository(CompanyFlexContract::class)->findAll())); - $this->assertEquals(1, count($this->_em->getRepository(CompanyFlexUltraContract::class)->findAll())); + self::assertEquals(1, count($this->_em->getRepository(CompanyFixContract::class)->findAll())); + self::assertEquals(2, count($this->_em->getRepository(CompanyFlexContract::class)->findAll())); + self::assertEquals(1, count($this->_em->getRepository(CompanyFlexUltraContract::class)->findAll())); } public function testFindForAbstractBaseClass(): void @@ -207,8 +207,8 @@ public function testFindForAbstractBaseClass(): void $contract = $this->_em->find(CompanyContract::class, $this->fix->getId()); - $this->assertInstanceOf(CompanyFixContract::class, $contract); - $this->assertEquals(1000, $contract->getFixPrice()); + self::assertInstanceOf(CompanyFixContract::class, $contract); + self::assertEquals(1000, $contract->getFixPrice()); } public function testQueryForAbstractBaseClass(): void @@ -217,17 +217,17 @@ public function testQueryForAbstractBaseClass(): void $contracts = $this->_em->createQuery('SELECT c FROM Doctrine\Tests\Models\Company\CompanyContract c')->getResult(); - $this->assertEquals(3, count($contracts)); - $this->assertContainsOnly(CompanyContract::class, $contracts); + self::assertEquals(3, count($contracts)); + self::assertContainsOnly(CompanyContract::class, $contracts); } public function testQueryForChildClass(): void { $this->loadFullFixture(); - $this->assertEquals(1, count($this->_em->createQuery('SELECT c FROM Doctrine\Tests\Models\Company\CompanyFixContract c')->getResult())); - $this->assertEquals(2, count($this->_em->createQuery('SELECT c FROM Doctrine\Tests\Models\Company\CompanyFlexContract c')->getResult())); - $this->assertEquals(1, count($this->_em->createQuery('SELECT c FROM Doctrine\Tests\Models\Company\CompanyFlexUltraContract c')->getResult())); + self::assertEquals(1, count($this->_em->createQuery('SELECT c FROM Doctrine\Tests\Models\Company\CompanyFixContract c')->getResult())); + self::assertEquals(2, count($this->_em->createQuery('SELECT c FROM Doctrine\Tests\Models\Company\CompanyFlexContract c')->getResult())); + self::assertEquals(1, count($this->_em->createQuery('SELECT c FROM Doctrine\Tests\Models\Company\CompanyFlexUltraContract c')->getResult())); } public function testQueryBaseClassWithJoin(): void @@ -235,8 +235,8 @@ public function testQueryBaseClassWithJoin(): void $this->loadFullFixture(); $contracts = $this->_em->createQuery('SELECT c, p FROM Doctrine\Tests\Models\Company\CompanyContract c JOIN c.salesPerson p')->getResult(); - $this->assertEquals(3, count($contracts)); - $this->assertContainsOnly(CompanyContract::class, $contracts); + self::assertEquals(3, count($contracts)); + self::assertContainsOnly(CompanyContract::class, $contracts); } public function testQueryScalarWithDiscriminatorValue(): void @@ -251,7 +251,7 @@ public function testQueryScalarWithDiscriminatorValue(): void sort($discrValues); - $this->assertEquals(['fix', 'flexible', 'flexultra'], $discrValues); + self::assertEquals(['fix', 'flexible', 'flexultra'], $discrValues); } public function testQueryChildClassWithCondition(): void @@ -261,8 +261,8 @@ public function testQueryChildClassWithCondition(): void $dql = 'SELECT c FROM Doctrine\Tests\Models\Company\CompanyFixContract c WHERE c.fixPrice = ?1'; $contract = $this->_em->createQuery($dql)->setParameter(1, 1000)->getSingleResult(); - $this->assertInstanceOf(CompanyFixContract::class, $contract); - $this->assertEquals(1000, $contract->getFixPrice()); + self::assertInstanceOf(CompanyFixContract::class, $contract); + self::assertEquals(1000, $contract->getFixPrice()); } /** @@ -275,13 +275,13 @@ public function testUpdateChildClassWithCondition(): void $dql = 'UPDATE Doctrine\Tests\Models\Company\CompanyFlexContract c SET c.hoursWorked = c.hoursWorked * 2 WHERE c.hoursWorked = 150'; $affected = $this->_em->createQuery($dql)->execute(); - $this->assertEquals(1, $affected); + self::assertEquals(1, $affected); $flexContract = $this->_em->find(CompanyContract::class, $this->flex->getId()); $ultraContract = $this->_em->find(CompanyContract::class, $this->ultra->getId()); - $this->assertEquals(300, $ultraContract->getHoursWorked()); - $this->assertEquals(100, $flexContract->getHoursWorked()); + self::assertEquals(300, $ultraContract->getHoursWorked()); + self::assertEquals(100, $flexContract->getHoursWorked()); } public function testUpdateBaseClassWithCondition(): void @@ -291,12 +291,12 @@ public function testUpdateBaseClassWithCondition(): void $dql = 'UPDATE Doctrine\Tests\Models\Company\CompanyContract c SET c.completed = true WHERE c.completed = false'; $affected = $this->_em->createQuery($dql)->execute(); - $this->assertEquals(1, $affected); + self::assertEquals(1, $affected); $dql = 'UPDATE Doctrine\Tests\Models\Company\CompanyContract c SET c.completed = false'; $affected = $this->_em->createQuery($dql)->execute(); - $this->assertEquals(3, $affected); + self::assertEquals(3, $affected); } public function testDeleteByChildClassCondition(): void @@ -306,7 +306,7 @@ public function testDeleteByChildClassCondition(): void $dql = 'DELETE Doctrine\Tests\Models\Company\CompanyFlexContract c'; $affected = $this->_em->createQuery($dql)->execute(); - $this->assertEquals(2, $affected); + self::assertEquals(2, $affected); } public function testDeleteByBaseClassCondition(): void @@ -316,12 +316,12 @@ public function testDeleteByBaseClassCondition(): void $dql = 'DELETE Doctrine\Tests\Models\Company\CompanyContract c WHERE c.completed = true'; $affected = $this->_em->createQuery($dql)->execute(); - $this->assertEquals(2, $affected); + self::assertEquals(2, $affected); $contracts = $this->_em->createQuery('SELECT c FROM Doctrine\Tests\Models\Company\CompanyContract c')->getResult(); - $this->assertEquals(1, count($contracts)); + self::assertEquals(1, count($contracts)); - $this->assertFalse($contracts[0]->isCompleted(), 'Only non completed contracts should be left.'); + self::assertFalse($contracts[0]->isCompleted(), 'Only non completed contracts should be left.'); } /** @@ -335,7 +335,7 @@ public function testDeleteJoinTableRecords(): void $this->_em->remove($this->_em->find(get_class($this->fix), $this->fix->getId())); $this->_em->flush(); - $this->assertNull($this->_em->find(get_class($this->fix), $this->fix->getId()), 'Contract should not be present in the database anymore.'); + self::assertNull($this->_em->find(get_class($this->fix), $this->fix->getId()), 'Contract should not be present in the database anymore.'); } /** @@ -347,19 +347,19 @@ public function testFindByAssociation(): void $repos = $this->_em->getRepository(CompanyContract::class); $contracts = $repos->findBy(['salesPerson' => $this->salesPerson->getId()]); - $this->assertEquals(3, count($contracts), 'There should be 3 entities related to ' . $this->salesPerson->getId() . " for 'Doctrine\Tests\Models\Company\CompanyContract'"); + self::assertEquals(3, count($contracts), 'There should be 3 entities related to ' . $this->salesPerson->getId() . " for 'Doctrine\Tests\Models\Company\CompanyContract'"); $repos = $this->_em->getRepository(CompanyFixContract::class); $contracts = $repos->findBy(['salesPerson' => $this->salesPerson->getId()]); - $this->assertEquals(1, count($contracts), 'There should be 1 entities related to ' . $this->salesPerson->getId() . " for 'Doctrine\Tests\Models\Company\CompanyFixContract'"); + self::assertEquals(1, count($contracts), 'There should be 1 entities related to ' . $this->salesPerson->getId() . " for 'Doctrine\Tests\Models\Company\CompanyFixContract'"); $repos = $this->_em->getRepository(CompanyFlexContract::class); $contracts = $repos->findBy(['salesPerson' => $this->salesPerson->getId()]); - $this->assertEquals(2, count($contracts), 'There should be 2 entities related to ' . $this->salesPerson->getId() . " for 'Doctrine\Tests\Models\Company\CompanyFlexContract'"); + self::assertEquals(2, count($contracts), 'There should be 2 entities related to ' . $this->salesPerson->getId() . " for 'Doctrine\Tests\Models\Company\CompanyFlexContract'"); $repos = $this->_em->getRepository(CompanyFlexUltraContract::class); $contracts = $repos->findBy(['salesPerson' => $this->salesPerson->getId()]); - $this->assertEquals(1, count($contracts), 'There should be 1 entities related to ' . $this->salesPerson->getId() . " for 'Doctrine\Tests\Models\Company\CompanyFlexUltraContract'"); + self::assertEquals(1, count($contracts), 'There should be 1 entities related to ' . $this->salesPerson->getId() . " for 'Doctrine\Tests\Models\Company\CompanyFlexUltraContract'"); } /** @@ -373,13 +373,13 @@ public function testInheritanceMatching(): void $contracts = $repository->matching(new Criteria( Criteria::expr()->eq('salesPerson', $this->salesPerson) )); - $this->assertEquals(3, count($contracts)); + self::assertEquals(3, count($contracts)); $repository = $this->_em->getRepository(CompanyFixContract::class); $contracts = $repository->matching(new Criteria( Criteria::expr()->eq('salesPerson', $this->salesPerson) )); - $this->assertEquals(1, count($contracts)); + self::assertEquals(1, count($contracts)); } /** @@ -410,13 +410,13 @@ public function testGetReferenceEntityWithSubclasses(): void $this->loadFullFixture(); $ref = $this->_em->getReference(CompanyContract::class, $this->fix->getId()); - $this->assertNotInstanceOf(Proxy::class, $ref, 'Cannot Request a proxy from a class that has subclasses.'); - $this->assertInstanceOf(CompanyContract::class, $ref); - $this->assertInstanceOf(CompanyFixContract::class, $ref, 'Direct fetch of the reference has to load the child class Employee directly.'); + self::assertNotInstanceOf(Proxy::class, $ref, 'Cannot Request a proxy from a class that has subclasses.'); + self::assertInstanceOf(CompanyContract::class, $ref); + self::assertInstanceOf(CompanyFixContract::class, $ref, 'Direct fetch of the reference has to load the child class Employee directly.'); $this->_em->clear(); $ref = $this->_em->getReference(CompanyFixContract::class, $this->fix->getId()); - $this->assertInstanceOf(Proxy::class, $ref, 'A proxy can be generated only if no subclasses exists for the requested reference.'); + self::assertInstanceOf(Proxy::class, $ref, 'A proxy can be generated only if no subclasses exists for the requested reference.'); } /** @@ -432,6 +432,6 @@ public function testEagerLoadInheritanceHierarchy(): void ->setParameter(1, $this->fix->getId()) ->getSingleResult(); - $this->assertNotInstanceOf(Proxy::class, $contract->getSalesPerson()); + self::assertNotInstanceOf(Proxy::class, $contract->getSalesPerson()); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/StandardEntityPersisterTest.php b/tests/Doctrine/Tests/ORM/Functional/StandardEntityPersisterTest.php index 401e06fa078..04fc0439e40 100644 --- a/tests/Doctrine/Tests/ORM/Functional/StandardEntityPersisterTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/StandardEntityPersisterTest.php @@ -43,7 +43,7 @@ public function testAcceptsForeignKeysAsCriteria(): void $newCart = new ECommerceCart(); $this->_em->getUnitOfWork()->registerManaged($newCart, ['id' => $cardId], []); $persister->load(['customer_id' => $customer->getId()], $newCart, $class->associationMappings['customer']); - $this->assertEquals('Credit card', $newCart->getPayment()); + self::assertEquals('Credit card', $newCart->getPayment()); } /** @@ -64,8 +64,8 @@ public function testAddPersistRetrieve(): void $this->_em->flush(); - $this->assertEquals(2, count($p->getFeatures())); - $this->assertInstanceOf(PersistentCollection::class, $p->getFeatures()); + self::assertEquals(2, count($p->getFeatures())); + self::assertInstanceOf(PersistentCollection::class, $p->getFeatures()); $q = $this->_em->createQuery( 'SELECT p, f @@ -75,15 +75,15 @@ public function testAddPersistRetrieve(): void $res = $q->getResult(); - $this->assertEquals(2, count($p->getFeatures())); - $this->assertInstanceOf(PersistentCollection::class, $p->getFeatures()); + self::assertEquals(2, count($p->getFeatures())); + self::assertInstanceOf(PersistentCollection::class, $p->getFeatures()); // Check that the features are the same instances still foreach ($p->getFeatures() as $feature) { if ($feature->getDescription() === 'AC-3') { - $this->assertTrue($feature === $f1); + self::assertTrue($feature === $f1); } else { - $this->assertTrue($feature === $f2); + self::assertTrue($feature === $f2); } } @@ -106,6 +106,6 @@ public function testAddPersistRetrieve(): void $res = $q->getResult(); // Persisted Product now must have 3 Feature items - $this->assertEquals(3, count($res[0]->getFeatures())); + self::assertEquals(3, count($res[0]->getFeatures())); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1040Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1040Test.php index 84e6010e3ec..6230702185f 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1040Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1040Test.php @@ -51,7 +51,7 @@ public function testReuseNamedEntityParameter(): void ->setParameter('topic', 'This is John Galt speaking!') ->getSingleResult(); - $this->assertSame($article, $farticle); + self::assertSame($article, $farticle); } public function testUseMultiplePositionalParameters(): void @@ -77,6 +77,6 @@ public function testUseMultiplePositionalParameters(): void ->setParameter(3, $user) ->getSingleResult(); - $this->assertSame($article, $farticle); + self::assertSame($article, $farticle); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1041Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1041Test.php index 14642a657c9..7769a883882 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1041Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1041Test.php @@ -28,8 +28,8 @@ public function testGrabWrongSubtypeReturnsNull(): void $id = $fix->getId(); - $this->assertNull($this->_em->find(Models\Company\CompanyFlexContract::class, $id)); - $this->assertNull($this->_em->getReference(Models\Company\CompanyFlexContract::class, $id)); - $this->assertNull($this->_em->getPartialReference(Models\Company\CompanyFlexContract::class, $id)); + self::assertNull($this->_em->find(Models\Company\CompanyFlexContract::class, $id)); + self::assertNull($this->_em->getReference(Models\Company\CompanyFlexContract::class, $id)); + self::assertNull($this->_em->getPartialReference(Models\Company\CompanyFlexContract::class, $id)); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1043Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1043Test.php index 815e243caf4..54f6e75bdfc 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1043Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1043Test.php @@ -33,6 +33,6 @@ public function testChangeSetPlusWeirdPHPCastingIntCastingRule(): void $this->_em->clear(); $user = $this->_em->find(CmsUser::class, $user->id); - $this->assertSame('44', $user->status); + self::assertSame('44', $user->status); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1080Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1080Test.php index 17e8abb7d4c..f3b55b00a58 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1080Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1080Test.php @@ -77,7 +77,7 @@ public function testHydration(): void $foo = $this->_em->find(DDC1080Foo::class, $foo1->getFooID()); $fooBars = $foo->getFooBars(); - $this->assertEquals(3, count($fooBars), 'Should return three foobars.'); + self::assertEquals(3, count($fooBars), 'Should return three foobars.'); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1129Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1129Test.php index 4086715537e..a38509a9a89 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1129Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1129Test.php @@ -29,22 +29,22 @@ public function testVersionFieldIgnoredInChangesetComputation(): void $this->_em->persist($article); $this->_em->flush(); - $this->assertEquals(1, $article->version); + self::assertEquals(1, $article->version); $class = $this->_em->getClassMetadata(CmsArticle::class); $uow = $this->_em->getUnitOfWork(); $uow->computeChangeSet($class, $article); $changeSet = $uow->getEntityChangeSet($article); - $this->assertEquals(0, count($changeSet), 'No changesets should be computed.'); + self::assertEquals(0, count($changeSet), 'No changesets should be computed.'); $article->text = 'This is John Galt speaking.'; $this->_em->flush(); - $this->assertEquals(2, $article->version); + self::assertEquals(2, $article->version); $uow->computeChangeSet($class, $article); $changeSet = $uow->getEntityChangeSet($article); - $this->assertEquals(0, count($changeSet), 'No changesets should be computed.'); + self::assertEquals(0, count($changeSet), 'No changesets should be computed.'); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1151Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1151Test.php index 67707a4c0cb..ac4f015ea12 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1151Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1151Test.php @@ -21,7 +21,7 @@ class DDC1151Test extends OrmFunctionalTestCase public function testQuoteForeignKey(): void { if ($this->_em->getConnection()->getDatabasePlatform()->getName() !== 'postgresql') { - $this->markTestSkipped('This test is useful for all databases, but designed only for postgresql.'); + self::markTestSkipped('This test is useful for all databases, but designed only for postgresql.'); } $sql = $this->_schemaTool->getCreateSchemaSql( @@ -31,15 +31,15 @@ public function testQuoteForeignKey(): void ] ); - $this->assertEquals('CREATE TABLE "User" (id INT NOT NULL, PRIMARY KEY(id))', $sql[0]); - $this->assertEquals('CREATE TABLE ddc1151user_ddc1151group (ddc1151user_id INT NOT NULL, ddc1151group_id INT NOT NULL, PRIMARY KEY(ddc1151user_id, ddc1151group_id))', $sql[1]); - $this->assertEquals('CREATE INDEX IDX_88A3259AC5AD08A ON ddc1151user_ddc1151group (ddc1151user_id)', $sql[2]); - $this->assertEquals('CREATE INDEX IDX_88A32597357E0B1 ON ddc1151user_ddc1151group (ddc1151group_id)', $sql[3]); - $this->assertEquals('CREATE TABLE "Group" (id INT NOT NULL, PRIMARY KEY(id))', $sql[4]); - $this->assertEquals('CREATE SEQUENCE "User_id_seq" INCREMENT BY 1 MINVALUE 1 START 1', $sql[5]); - $this->assertEquals('CREATE SEQUENCE "Group_id_seq" INCREMENT BY 1 MINVALUE 1 START 1', $sql[6]); - $this->assertEquals('ALTER TABLE ddc1151user_ddc1151group ADD CONSTRAINT FK_88A3259AC5AD08A FOREIGN KEY (ddc1151user_id) REFERENCES "User" (id) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE', $sql[7]); - $this->assertEquals('ALTER TABLE ddc1151user_ddc1151group ADD CONSTRAINT FK_88A32597357E0B1 FOREIGN KEY (ddc1151group_id) REFERENCES "Group" (id) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE', $sql[8]); + self::assertEquals('CREATE TABLE "User" (id INT NOT NULL, PRIMARY KEY(id))', $sql[0]); + self::assertEquals('CREATE TABLE ddc1151user_ddc1151group (ddc1151user_id INT NOT NULL, ddc1151group_id INT NOT NULL, PRIMARY KEY(ddc1151user_id, ddc1151group_id))', $sql[1]); + self::assertEquals('CREATE INDEX IDX_88A3259AC5AD08A ON ddc1151user_ddc1151group (ddc1151user_id)', $sql[2]); + self::assertEquals('CREATE INDEX IDX_88A32597357E0B1 ON ddc1151user_ddc1151group (ddc1151group_id)', $sql[3]); + self::assertEquals('CREATE TABLE "Group" (id INT NOT NULL, PRIMARY KEY(id))', $sql[4]); + self::assertEquals('CREATE SEQUENCE "User_id_seq" INCREMENT BY 1 MINVALUE 1 START 1', $sql[5]); + self::assertEquals('CREATE SEQUENCE "Group_id_seq" INCREMENT BY 1 MINVALUE 1 START 1', $sql[6]); + self::assertEquals('ALTER TABLE ddc1151user_ddc1151group ADD CONSTRAINT FK_88A3259AC5AD08A FOREIGN KEY (ddc1151user_id) REFERENCES "User" (id) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE', $sql[7]); + self::assertEquals('ALTER TABLE ddc1151user_ddc1151group ADD CONSTRAINT FK_88A32597357E0B1 FOREIGN KEY (ddc1151group_id) REFERENCES "Group" (id) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE', $sql[8]); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1163Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1163Test.php index 71daa538b8c..bb8c6ca17ca 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1163Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1163Test.php @@ -81,7 +81,7 @@ private function createProxyForSpecialProduct(): void $proxyHolder = $this->_em->find(DDC1163ProxyHolder::class, $this->proxyHolderId); assert($proxyHolder instanceof DDC1163ProxyHolder); - $this->assertInstanceOf(DDC1163SpecialProduct::class, $proxyHolder->getSpecialProduct()); + self::assertInstanceOf(DDC1163SpecialProduct::class, $proxyHolder->getSpecialProduct()); } private function setPropertyAndAssignTagToSpecialProduct(): void @@ -89,13 +89,13 @@ private function setPropertyAndAssignTagToSpecialProduct(): void $specialProduct = $this->_em->find(DDC1163SpecialProduct::class, $this->productId); assert($specialProduct instanceof DDC1163SpecialProduct); - $this->assertInstanceOf(DDC1163SpecialProduct::class, $specialProduct); - $this->assertInstanceOf(Proxy::class, $specialProduct); + self::assertInstanceOf(DDC1163SpecialProduct::class, $specialProduct); + self::assertInstanceOf(Proxy::class, $specialProduct); $specialProduct->setSubclassProperty('foobar'); // this screams violation of law of demeter ;) - $this->assertEquals( + self::assertEquals( DDC1163SpecialProduct::class, $this->_em->getUnitOfWork()->getEntityPersister(get_class($specialProduct))->getClassMetadata()->name ); diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC117Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC117Test.php index 7f28fc54a61..2791a9fc877 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC117Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC117Test.php @@ -78,30 +78,30 @@ public function testAssociationOnlyCompositeKey(): void $idCriteria = ['source' => $this->article1->id(), 'target' => $this->article2->id()]; $mapRef = $this->_em->find(DDC117Reference::class, $idCriteria); - $this->assertInstanceOf(DDC117Reference::class, $mapRef); - $this->assertInstanceOf(DDC117Article::class, $mapRef->target()); - $this->assertInstanceOf(DDC117Article::class, $mapRef->source()); - $this->assertSame($mapRef, $this->_em->find(DDC117Reference::class, $idCriteria)); + self::assertInstanceOf(DDC117Reference::class, $mapRef); + self::assertInstanceOf(DDC117Article::class, $mapRef->target()); + self::assertInstanceOf(DDC117Article::class, $mapRef->source()); + self::assertSame($mapRef, $this->_em->find(DDC117Reference::class, $idCriteria)); $this->_em->clear(); $dql = 'SELECT r, s FROM ' . DDC117Reference::class . ' r JOIN r.source s WHERE r.source = ?1'; $dqlRef = $this->_em->createQuery($dql)->setParameter(1, 1)->getSingleResult(); - $this->assertInstanceOf(DDC117Reference::class, $mapRef); - $this->assertInstanceOf(DDC117Article::class, $mapRef->target()); - $this->assertInstanceOf(DDC117Article::class, $mapRef->source()); - $this->assertSame($dqlRef, $this->_em->find(DDC117Reference::class, $idCriteria)); + self::assertInstanceOf(DDC117Reference::class, $mapRef); + self::assertInstanceOf(DDC117Article::class, $mapRef->target()); + self::assertInstanceOf(DDC117Article::class, $mapRef->source()); + self::assertSame($dqlRef, $this->_em->find(DDC117Reference::class, $idCriteria)); $this->_em->clear(); $dql = 'SELECT r, s FROM ' . DDC117Reference::class . ' r JOIN r.source s WHERE s.title = ?1'; $dqlRef = $this->_em->createQuery($dql)->setParameter(1, 'Foo')->getSingleResult(); - $this->assertInstanceOf(DDC117Reference::class, $dqlRef); - $this->assertInstanceOf(DDC117Article::class, $dqlRef->target()); - $this->assertInstanceOf(DDC117Article::class, $dqlRef->source()); - $this->assertSame($dqlRef, $this->_em->find(DDC117Reference::class, $idCriteria)); + self::assertInstanceOf(DDC117Reference::class, $dqlRef); + self::assertInstanceOf(DDC117Article::class, $dqlRef->target()); + self::assertInstanceOf(DDC117Article::class, $dqlRef->source()); + self::assertSame($dqlRef, $this->_em->find(DDC117Reference::class, $idCriteria)); $dql = 'SELECT r, s FROM ' . DDC117Reference::class . ' r JOIN r.source s WHERE s.title = ?1'; $dqlRef = $this->_em->createQuery($dql)->setParameter(1, 'Foo')->getSingleResult(); @@ -117,14 +117,14 @@ public function testUpdateAssociationEntity(): void $idCriteria = ['source' => $this->article1->id(), 'target' => $this->article2->id()]; $mapRef = $this->_em->find(DDC117Reference::class, $idCriteria); - $this->assertNotNull($mapRef); + self::assertNotNull($mapRef); $mapRef->setDescription('New Description!!'); $this->_em->flush(); $this->_em->clear(); $mapRef = $this->_em->find(DDC117Reference::class, $idCriteria); - $this->assertEquals('New Description!!', $mapRef->getDescription()); + self::assertEquals('New Description!!', $mapRef->getDescription()); } /** @@ -135,11 +135,11 @@ public function testFetchDql(): void $dql = 'SELECT r, s FROM Doctrine\Tests\Models\DDC117\DDC117Reference r JOIN r.source s WHERE s.title = ?1'; $refs = $this->_em->createQuery($dql)->setParameter(1, 'Foo')->getResult(); - $this->assertTrue(count($refs) > 0, 'Has to contain at least one Reference.'); + self::assertTrue(count($refs) > 0, 'Has to contain at least one Reference.'); foreach ($refs as $ref) { - $this->assertInstanceOf(DDC117Reference::class, $ref, 'Contains only Reference instances.'); - $this->assertTrue($this->_em->contains($ref), 'Contains Reference in the IdentityMap.'); + self::assertInstanceOf(DDC117Reference::class, $ref, 'Contains only Reference instances.'); + self::assertTrue($this->_em->contains($ref), 'Contains Reference in the IdentityMap.'); } } @@ -156,7 +156,7 @@ public function testRemoveCompositeElement(): void $this->_em->flush(); $this->_em->clear(); - $this->assertNull($this->_em->find(DDC117Reference::class, $idCriteria)); + self::assertNull($this->_em->find(DDC117Reference::class, $idCriteria)); } /** @@ -173,7 +173,7 @@ public function testDqlRemoveCompositeElement(): void ->setParameter(2, $this->article2->id()) ->execute(); - $this->assertNull($this->_em->find(DDC117Reference::class, $idCriteria)); + self::assertNull($this->_em->find(DDC117Reference::class, $idCriteria)); } /** @@ -183,11 +183,11 @@ public function testInverseSideAccess(): void { $this->article1 = $this->_em->find(DDC117Article::class, $this->article1->id()); - $this->assertEquals(1, count($this->article1->references())); + self::assertEquals(1, count($this->article1->references())); foreach ($this->article1->references() as $this->reference) { - $this->assertInstanceOf(DDC117Reference::class, $this->reference); - $this->assertSame($this->article1, $this->reference->source()); + self::assertInstanceOf(DDC117Reference::class, $this->reference); + self::assertSame($this->article1, $this->reference->source()); } $this->_em->clear(); @@ -197,11 +197,11 @@ public function testInverseSideAccess(): void ->setParameter(1, $this->article1->id()) ->getSingleResult(); - $this->assertEquals(1, count($this->article1->references())); + self::assertEquals(1, count($this->article1->references())); foreach ($this->article1->references() as $this->reference) { - $this->assertInstanceOf(DDC117Reference::class, $this->reference); - $this->assertSame($this->article1, $this->reference->source()); + self::assertInstanceOf(DDC117Reference::class, $this->reference); + self::assertSame($this->article1, $this->reference->source()); } } @@ -213,9 +213,9 @@ public function testMixedCompositeKey(): void $idCriteria = ['article' => $this->article1->id(), 'language' => 'en']; $this->translation = $this->_em->find(DDC117Translation::class, $idCriteria); - $this->assertInstanceOf(DDC117Translation::class, $this->translation); + self::assertInstanceOf(DDC117Translation::class, $this->translation); - $this->assertSame($this->translation, $this->_em->find(DDC117Translation::class, $idCriteria)); + self::assertSame($this->translation, $this->_em->find(DDC117Translation::class, $idCriteria)); $this->_em->clear(); @@ -225,7 +225,7 @@ public function testMixedCompositeKey(): void ->setParameter(2, 'en') ->getSingleResult(); - $this->assertInstanceOf(DDC117Translation::class, $this->translation); + self::assertInstanceOf(DDC117Translation::class, $this->translation); } /** @@ -245,7 +245,7 @@ public function testMixedCompositeKeyViolateUniqueness(): void $exceptionThrown = true; } - $this->assertTrue($exceptionThrown, 'The underlying database driver throws an exception.'); + self::assertTrue($exceptionThrown, 'The underlying database driver throws an exception.'); } /** @@ -267,7 +267,7 @@ public function testOneToOneForeignObjectId(): void $article = $this->_em->find(get_class($this->article1), $this->article1->id()); assert($article instanceof DDC117Article); - $this->assertEquals('not so very long text!', $article->getText()); + self::assertEquals('not so very long text!', $article->getText()); } /** @@ -279,7 +279,7 @@ public function testOneToOneCascadeRemove(): void $this->_em->remove($article); $this->_em->flush(); - $this->assertFalse($this->_em->contains($article->getDetails())); + self::assertFalse($this->_em->contains($article->getDetails())); } /** @@ -288,7 +288,7 @@ public function testOneToOneCascadeRemove(): void public function testOneToOneCascadePersist(): void { if (! $this->_em->getConnection()->getDatabasePlatform()->prefersSequences()) { - $this->markTestSkipped('Test only works with databases that prefer sequences as ID strategy.'); + self::markTestSkipped('Test only works with databases that prefer sequences as ID strategy.'); } $this->article1 = new DDC117Article('Foo'); @@ -318,9 +318,9 @@ public function testReferencesToForeignKeyEntities(): void $approveChanges = $this->_em->find(DDC117ApproveChanges::class, $approveChanges->getId()); - $this->assertInstanceOf(DDC117ArticleDetails::class, $approveChanges->getArticleDetails()); - $this->assertInstanceOf(DDC117Reference::class, $approveChanges->getReference()); - $this->assertInstanceOf(DDC117Translation::class, $approveChanges->getTranslation()); + self::assertInstanceOf(DDC117ArticleDetails::class, $approveChanges->getArticleDetails()); + self::assertInstanceOf(DDC117Reference::class, $approveChanges->getReference()); + self::assertInstanceOf(DDC117Translation::class, $approveChanges->getTranslation()); } /** @@ -332,9 +332,9 @@ public function testLoadOneToManyCollectionOfForeignKeyEntities(): void assert($article instanceof DDC117Article); $translations = $article->getTranslations(); - $this->assertFalse($translations->isInitialized()); - $this->assertContainsOnly(DDC117Translation::class, $translations); - $this->assertTrue($translations->isInitialized()); + self::assertFalse($translations->isInitialized()); + self::assertContainsOnly(DDC117Translation::class, $translations); + self::assertTrue($translations->isInitialized()); } /** @@ -344,16 +344,16 @@ public function testLoadManyToManyCollectionOfForeignKeyEntities(): void { $editor = $this->loadEditorFixture(); - $this->assertFalse($editor->reviewingTranslations->isInitialized()); - $this->assertContainsOnly(DDC117Translation::class, $editor->reviewingTranslations); - $this->assertTrue($editor->reviewingTranslations->isInitialized()); + self::assertFalse($editor->reviewingTranslations->isInitialized()); + self::assertContainsOnly(DDC117Translation::class, $editor->reviewingTranslations); + self::assertTrue($editor->reviewingTranslations->isInitialized()); $this->_em->clear(); $dql = 'SELECT e, t FROM Doctrine\Tests\Models\DDC117\DDC117Editor e JOIN e.reviewingTranslations t WHERE e.id = ?1'; $editor = $this->_em->createQuery($dql)->setParameter(1, $editor->id)->getSingleResult(); - $this->assertTrue($editor->reviewingTranslations->isInitialized()); - $this->assertContainsOnly(DDC117Translation::class, $editor->reviewingTranslations); + self::assertTrue($editor->reviewingTranslations->isInitialized()); + self::assertContainsOnly(DDC117Translation::class, $editor->reviewingTranslations); } /** @@ -362,14 +362,14 @@ public function testLoadManyToManyCollectionOfForeignKeyEntities(): void public function testClearManyToManyCollectionOfForeignKeyEntities(): void { $editor = $this->loadEditorFixture(); - $this->assertEquals(3, count($editor->reviewingTranslations)); + self::assertEquals(3, count($editor->reviewingTranslations)); $editor->reviewingTranslations->clear(); $this->_em->flush(); $this->_em->clear(); $editor = $this->_em->find(get_class($editor), $editor->id); - $this->assertEquals(0, count($editor->reviewingTranslations)); + self::assertEquals(0, count($editor->reviewingTranslations)); } /** @@ -379,11 +379,11 @@ public function testLoadInverseManyToManyCollection(): void { $editor = $this->loadEditorFixture(); - $this->assertInstanceOf(DDC117Translation::class, $editor->reviewingTranslations[0]); + self::assertInstanceOf(DDC117Translation::class, $editor->reviewingTranslations[0]); $reviewedBy = $editor->reviewingTranslations[0]->getReviewedByEditors(); - $this->assertEquals(1, count($reviewedBy)); - $this->assertSame($editor, $reviewedBy[0]); + self::assertEquals(1, count($reviewedBy)); + self::assertSame($editor, $reviewedBy[0]); $this->_em->clear(); @@ -394,9 +394,9 @@ public function testLoadInverseManyToManyCollection(): void ->setParameter(2, $this->translation->getLanguage()) ->getSingleResult(); - $this->assertInstanceOf(DDC117Translation::class, $trans); - $this->assertContainsOnly(DDC117Editor::class, $trans->reviewedByEditors); - $this->assertEquals(1, count($trans->reviewedByEditors)); + self::assertInstanceOf(DDC117Translation::class, $trans); + self::assertContainsOnly(DDC117Editor::class, $trans->reviewedByEditors); + self::assertEquals(1, count($trans->reviewedByEditors)); } /** @@ -414,7 +414,7 @@ public function testLoadOneToManyOfSourceEntityWithAssociationIdentifier(): void $lastTranslatedBy = $editor->reviewingTranslations[0]->getLastTranslatedBy(); $lastTranslatedBy->count(); - $this->assertEquals(1, count($lastTranslatedBy)); + self::assertEquals(1, count($lastTranslatedBy)); } private function loadEditorFixture(): DDC117Editor @@ -456,8 +456,8 @@ public function testMergeForeignKeyIdentifierEntity(): void $this->_em->clear(DDC117Reference::class); $refRep = $this->_em->merge($refRep); - $this->assertEquals($this->article1->id(), $refRep->source()->id()); - $this->assertEquals($this->article2->id(), $refRep->target()->id()); + self::assertEquals($this->article1->id(), $refRep->source()->id()); + self::assertEquals($this->article2->id(), $refRep->target()->id()); } /** @@ -485,7 +485,7 @@ public function testArrayHydrationWithCompositeKey(): void $dql = 'SELECT r,s,t FROM Doctrine\Tests\Models\DDC117\DDC117Reference r INNER JOIN r.source s INNER JOIN r.target t'; $data = $this->_em->createQuery($dql)->getArrayResult(); - $this->assertEquals($before + 3, count($data)); + self::assertEquals($before + 3, count($data)); } /** @@ -494,7 +494,7 @@ public function testArrayHydrationWithCompositeKey(): void public function testGetEntityState(): void { if ($this->isSecondLevelCacheEnabled) { - $this->markTestIncomplete('Second level cache - not supported yet'); + self::markTestIncomplete('Second level cache - not supported yet'); } $this->article1 = $this->_em->find(DDC117Article::class, $this->article1->id()); @@ -502,12 +502,12 @@ public function testGetEntityState(): void $this->reference = new DDC117Reference($this->article2, $this->article1, 'Test-Description'); - $this->assertEquals(UnitOfWork::STATE_NEW, $this->_em->getUnitOfWork()->getEntityState($this->reference)); + self::assertEquals(UnitOfWork::STATE_NEW, $this->_em->getUnitOfWork()->getEntityState($this->reference)); $idCriteria = ['source' => $this->article1->id(), 'target' => $this->article2->id()]; $reference = $this->_em->find(DDC117Reference::class, $idCriteria); - $this->assertEquals(UnitOfWork::STATE_MANAGED, $this->_em->getUnitOfWork()->getEntityState($reference)); + self::assertEquals(UnitOfWork::STATE_MANAGED, $this->_em->getUnitOfWork()->getEntityState($reference)); } /** @@ -517,8 +517,8 @@ public function testIndexByOnCompositeKeyField(): void { $article = $this->_em->find(DDC117Article::class, $this->article1->id()); - $this->assertInstanceOf(DDC117Article::class, $article); - $this->assertEquals(1, count($article->getLinks())); - $this->assertTrue($article->getLinks()->offsetExists($this->article2->id())); + self::assertInstanceOf(DDC117Article::class, $article); + self::assertEquals(1, count($article->getLinks())); + self::assertTrue($article->getLinks()->offsetExists($this->article2->id())); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1193Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1193Test.php index 9620dc0a491..785db21088b 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1193Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1193Test.php @@ -53,14 +53,14 @@ public function testIssue(): void $company = $this->_em->find(get_class($company), $companyId); - $this->assertTrue($this->_em->getUnitOfWork()->isInIdentityMap($company), 'Company is in identity map.'); - $this->assertFalse($company->member->__isInitialized__, 'Pre-Condition'); - $this->assertTrue($this->_em->getUnitOfWork()->isInIdentityMap($company->member), 'Member is in identity map.'); + self::assertTrue($this->_em->getUnitOfWork()->isInIdentityMap($company), 'Company is in identity map.'); + self::assertFalse($company->member->__isInitialized__, 'Pre-Condition'); + self::assertTrue($this->_em->getUnitOfWork()->isInIdentityMap($company->member), 'Member is in identity map.'); $this->_em->remove($company); $this->_em->flush(); - $this->assertEquals(count($this->_em->getRepository(get_class($account))->findAll()), 0); + self::assertEquals(count($this->_em->getRepository(get_class($account))->findAll()), 0); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1225Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1225Test.php index c9790db09eb..8ef5af902e4 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1225Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1225Test.php @@ -40,7 +40,7 @@ public function testIssue(): void ->where('te1.testEntity2 = ?1') ->setParameter(1, 0); - $this->assertEquals( + self::assertEquals( strtolower('SELECT t0_.test_entity2_id AS test_entity2_id_0 FROM te1 t0_ WHERE t0_.test_entity2_id = ?'), strtolower($qb->getQuery()->getSQL()) ); diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1228Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1228Test.php index c4fec217d30..010e3ba4e23 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1228Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1228Test.php @@ -46,18 +46,18 @@ public function testOneToOnePersist(): void $user = $this->_em->find(DDC1228User::class, $user->id); - $this->assertFalse($user->getProfile()->__isInitialized__, 'Proxy is not initialized'); + self::assertFalse($user->getProfile()->__isInitialized__, 'Proxy is not initialized'); $user->getProfile()->setName('Bar'); - $this->assertTrue($user->getProfile()->__isInitialized__, 'Proxy is not initialized'); + self::assertTrue($user->getProfile()->__isInitialized__, 'Proxy is not initialized'); - $this->assertEquals('Bar', $user->getProfile()->getName()); - $this->assertEquals(['id' => 1, 'name' => 'Foo'], $this->_em->getUnitOfWork()->getOriginalEntityData($user->getProfile())); + self::assertEquals('Bar', $user->getProfile()->getName()); + self::assertEquals(['id' => 1, 'name' => 'Foo'], $this->_em->getUnitOfWork()->getOriginalEntityData($user->getProfile())); $this->_em->flush(); $this->_em->clear(); $user = $this->_em->find(DDC1228User::class, $user->id); - $this->assertEquals('Bar', $user->getProfile()->getName()); + self::assertEquals('Bar', $user->getProfile()->getName()); } public function testRefresh(): void @@ -80,7 +80,7 @@ public function testRefresh(): void $this->_em->clear(); $user = $this->_em->find(DDC1228User::class, $user->id); - $this->assertEquals('Baz', $user->name); + self::assertEquals('Baz', $user->name); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1238Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1238Test.php index 6c434b2fc5f..81f3d9c1009 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1238Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1238Test.php @@ -45,7 +45,7 @@ public function testIssue(): void $this->_em->clear(); $userId2 = $user->getId(); - $this->assertEquals($userId, $userId2, 'This proxy can still be initialized.'); + self::assertEquals($userId, $userId2, 'This proxy can still be initialized.'); } public function testIssueProxyClear(): void @@ -69,7 +69,7 @@ public function testIssueProxyClear(): void // force proxy load, getId() doesn't work anymore $user->getName(); - $this->assertNull($user->getId(), 'Now this is null, we already have a user instance of that type'); + self::assertNull($user->getId(), 'Now this is null, we already have a user instance of that type'); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1250Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1250Test.php index 561e8b2e838..cf31db6c7d5 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1250Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1250Test.php @@ -43,7 +43,7 @@ public function testIssue(): void $history = $this->_em->createQuery('SELECT h FROM ' . __NAMESPACE__ . '\\DDC1250ClientHistory h WHERE h.id = ?1') ->setParameter(1, $c2->id)->getSingleResult(); - $this->assertInstanceOf(DDC1250ClientHistory::class, $history); + self::assertInstanceOf(DDC1250ClientHistory::class, $history); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1276Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1276Test.php index cfe5dcd9c14..600b49ca5f3 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1276Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1276Test.php @@ -42,11 +42,11 @@ public function testIssue(): void $user = $this->_em->find(CmsUser::class, $user->id); $cloned = clone $user; - $this->assertSame($user->groups, $cloned->groups); - $this->assertEquals(2, count($user->groups)); + self::assertSame($user->groups, $cloned->groups); + self::assertEquals(2, count($user->groups)); $this->_em->merge($cloned); - $this->assertEquals(2, count($user->groups)); + self::assertEquals(2, count($user->groups)); $this->_em->flush(); } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1300Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1300Test.php index 2c71a1a01ac..6dec4ac6a96 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1300Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1300Test.php @@ -51,7 +51,7 @@ public function testIssue(): void $query = $this->_em->createQuery('SELECT f, fl FROM Doctrine\Tests\ORM\Functional\Ticket\DDC1300Foo f JOIN f.fooLocaleRefFoo fl'); $result = $query->getResult(); - $this->assertEquals(1, count($result)); + self::assertEquals(1, count($result)); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1301Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1301Test.php index b58f71f4502..75720169f18 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1301Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1301Test.php @@ -47,14 +47,14 @@ public function testCountNotInitializesLegacyCollection(): void $user = $this->_em->find(Models\Legacy\LegacyUser::class, $this->userId); $queryCount = $this->getCurrentQueryCount(); - $this->assertFalse($user->articles->isInitialized()); - $this->assertEquals(2, count($user->articles)); - $this->assertFalse($user->articles->isInitialized()); + self::assertFalse($user->articles->isInitialized()); + self::assertEquals(2, count($user->articles)); + self::assertFalse($user->articles->isInitialized()); foreach ($user->articles as $article) { } - $this->assertEquals($queryCount + 2, $this->getCurrentQueryCount(), 'Expecting two queries to be fired for count, then iteration.'); + self::assertEquals($queryCount + 2, $this->getCurrentQueryCount(), 'Expecting two queries to be fired for count, then iteration.'); } public function testCountNotInitializesLegacyCollectionWithForeignIdentifier(): void @@ -62,14 +62,14 @@ public function testCountNotInitializesLegacyCollectionWithForeignIdentifier(): $user = $this->_em->find(Models\Legacy\LegacyUser::class, $this->userId); $queryCount = $this->getCurrentQueryCount(); - $this->assertFalse($user->references->isInitialized()); - $this->assertEquals(2, count($user->references)); - $this->assertFalse($user->references->isInitialized()); + self::assertFalse($user->references->isInitialized()); + self::assertEquals(2, count($user->references)); + self::assertFalse($user->references->isInitialized()); foreach ($user->references as $reference) { } - $this->assertEquals($queryCount + 2, $this->getCurrentQueryCount(), 'Expecting two queries to be fired for count, then iteration.'); + self::assertEquals($queryCount + 2, $this->getCurrentQueryCount(), 'Expecting two queries to be fired for count, then iteration.'); } public function testCountNotInitializesLegacyManyToManyCollection(): void @@ -77,14 +77,14 @@ public function testCountNotInitializesLegacyManyToManyCollection(): void $user = $this->_em->find(Models\Legacy\LegacyUser::class, $this->userId); $queryCount = $this->getCurrentQueryCount(); - $this->assertFalse($user->cars->isInitialized()); - $this->assertEquals(3, count($user->cars)); - $this->assertFalse($user->cars->isInitialized()); + self::assertFalse($user->cars->isInitialized()); + self::assertEquals(3, count($user->cars)); + self::assertFalse($user->cars->isInitialized()); foreach ($user->cars as $reference) { } - $this->assertEquals($queryCount + 2, $this->getCurrentQueryCount(), 'Expecting two queries to be fired for count, then iteration.'); + self::assertEquals($queryCount + 2, $this->getCurrentQueryCount(), 'Expecting two queries to be fired for count, then iteration.'); } public function loadFixture(): void diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1335Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1335Test.php index fae2f7f2e87..62ce120c827 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1335Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1335Test.php @@ -44,39 +44,39 @@ public function testDql(): void $query = $this->_em->createQuery($dql); $result = $query->getResult(); - $this->assertEquals(count($result), 3); - $this->assertArrayHasKey(1, $result); - $this->assertArrayHasKey(2, $result); - $this->assertArrayHasKey(3, $result); + self::assertEquals(count($result), 3); + self::assertArrayHasKey(1, $result); + self::assertArrayHasKey(2, $result); + self::assertArrayHasKey(3, $result); $dql = 'SELECT u, p FROM ' . __NAMESPACE__ . '\DDC1335User u INDEX BY u.email INNER JOIN u.phones p INDEX BY p.id'; $query = $this->_em->createQuery($dql); $result = $query->getResult(); - $this->assertEquals(count($result), 3); - $this->assertArrayHasKey('foo@foo.com', $result); - $this->assertArrayHasKey('bar@bar.com', $result); - $this->assertArrayHasKey('foobar@foobar.com', $result); + self::assertEquals(count($result), 3); + self::assertArrayHasKey('foo@foo.com', $result); + self::assertArrayHasKey('bar@bar.com', $result); + self::assertArrayHasKey('foobar@foobar.com', $result); - $this->assertEquals(count($result['foo@foo.com']->phones), 3); - $this->assertEquals(count($result['bar@bar.com']->phones), 3); - $this->assertEquals(count($result['foobar@foobar.com']->phones), 3); + self::assertEquals(count($result['foo@foo.com']->phones), 3); + self::assertEquals(count($result['bar@bar.com']->phones), 3); + self::assertEquals(count($result['foobar@foobar.com']->phones), 3); $foo = $result['foo@foo.com']->phones->toArray(); $bar = $result['bar@bar.com']->phones->toArray(); $foobar = $result['foobar@foobar.com']->phones->toArray(); - $this->assertArrayHasKey(1, $foo); - $this->assertArrayHasKey(2, $foo); - $this->assertArrayHasKey(3, $foo); + self::assertArrayHasKey(1, $foo); + self::assertArrayHasKey(2, $foo); + self::assertArrayHasKey(3, $foo); - $this->assertArrayHasKey(4, $bar); - $this->assertArrayHasKey(5, $bar); - $this->assertArrayHasKey(6, $bar); + self::assertArrayHasKey(4, $bar); + self::assertArrayHasKey(5, $bar); + self::assertArrayHasKey(6, $bar); - $this->assertArrayHasKey(7, $foobar); - $this->assertArrayHasKey(8, $foobar); - $this->assertArrayHasKey(9, $foobar); + self::assertArrayHasKey(7, $foobar); + self::assertArrayHasKey(8, $foobar); + self::assertArrayHasKey(9, $foobar); } public function testTicket(): void @@ -87,11 +87,11 @@ public function testTicket(): void $dql = $builder->getQuery()->getDQL(); $result = $builder->getQuery()->getResult(); - $this->assertEquals(count($result), 3); - $this->assertArrayHasKey(1, $result); - $this->assertArrayHasKey(2, $result); - $this->assertArrayHasKey(3, $result); - $this->assertEquals('SELECT u FROM ' . __NAMESPACE__ . '\DDC1335User u INDEX BY u.id', $dql); + self::assertEquals(count($result), 3); + self::assertArrayHasKey(1, $result); + self::assertArrayHasKey(2, $result); + self::assertArrayHasKey(3, $result); + self::assertEquals('SELECT u FROM ' . __NAMESPACE__ . '\DDC1335User u INDEX BY u.id', $dql); } public function testIndexByUnique(): void @@ -102,11 +102,11 @@ public function testIndexByUnique(): void $dql = $builder->getQuery()->getDQL(); $result = $builder->getQuery()->getResult(); - $this->assertEquals(count($result), 3); - $this->assertArrayHasKey('foo@foo.com', $result); - $this->assertArrayHasKey('bar@bar.com', $result); - $this->assertArrayHasKey('foobar@foobar.com', $result); - $this->assertEquals('SELECT u FROM ' . __NAMESPACE__ . '\DDC1335User u INDEX BY u.email', $dql); + self::assertEquals(count($result), 3); + self::assertArrayHasKey('foo@foo.com', $result); + self::assertArrayHasKey('bar@bar.com', $result); + self::assertArrayHasKey('foobar@foobar.com', $result); + self::assertEquals('SELECT u FROM ' . __NAMESPACE__ . '\DDC1335User u INDEX BY u.email', $dql); } public function testIndexWithJoin(): void @@ -119,28 +119,28 @@ public function testIndexWithJoin(): void $dql = $builder->getQuery()->getDQL(); $result = $builder->getQuery()->getResult(); - $this->assertEquals(count($result), 3); - $this->assertArrayHasKey('foo@foo.com', $result); - $this->assertArrayHasKey('bar@bar.com', $result); - $this->assertArrayHasKey('foobar@foobar.com', $result); + self::assertEquals(count($result), 3); + self::assertArrayHasKey('foo@foo.com', $result); + self::assertArrayHasKey('bar@bar.com', $result); + self::assertArrayHasKey('foobar@foobar.com', $result); - $this->assertEquals(count($result['foo@foo.com']->phones), 3); - $this->assertEquals(count($result['bar@bar.com']->phones), 3); - $this->assertEquals(count($result['foobar@foobar.com']->phones), 3); + self::assertEquals(count($result['foo@foo.com']->phones), 3); + self::assertEquals(count($result['bar@bar.com']->phones), 3); + self::assertEquals(count($result['foobar@foobar.com']->phones), 3); - $this->assertArrayHasKey(1, $result['foo@foo.com']->phones->toArray()); - $this->assertArrayHasKey(2, $result['foo@foo.com']->phones->toArray()); - $this->assertArrayHasKey(3, $result['foo@foo.com']->phones->toArray()); + self::assertArrayHasKey(1, $result['foo@foo.com']->phones->toArray()); + self::assertArrayHasKey(2, $result['foo@foo.com']->phones->toArray()); + self::assertArrayHasKey(3, $result['foo@foo.com']->phones->toArray()); - $this->assertArrayHasKey(4, $result['bar@bar.com']->phones->toArray()); - $this->assertArrayHasKey(5, $result['bar@bar.com']->phones->toArray()); - $this->assertArrayHasKey(6, $result['bar@bar.com']->phones->toArray()); + self::assertArrayHasKey(4, $result['bar@bar.com']->phones->toArray()); + self::assertArrayHasKey(5, $result['bar@bar.com']->phones->toArray()); + self::assertArrayHasKey(6, $result['bar@bar.com']->phones->toArray()); - $this->assertArrayHasKey(7, $result['foobar@foobar.com']->phones->toArray()); - $this->assertArrayHasKey(8, $result['foobar@foobar.com']->phones->toArray()); - $this->assertArrayHasKey(9, $result['foobar@foobar.com']->phones->toArray()); + self::assertArrayHasKey(7, $result['foobar@foobar.com']->phones->toArray()); + self::assertArrayHasKey(8, $result['foobar@foobar.com']->phones->toArray()); + self::assertArrayHasKey(9, $result['foobar@foobar.com']->phones->toArray()); - $this->assertEquals('SELECT u, p FROM ' . __NAMESPACE__ . '\DDC1335User u INDEX BY u.email INNER JOIN u.phones p INDEX BY p.id', $dql); + self::assertEquals('SELECT u, p FROM ' . __NAMESPACE__ . '\DDC1335User u INDEX BY u.email INNER JOIN u.phones p INDEX BY p.id', $dql); } private function loadFixture(): void diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1360Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1360Test.php index 63828451a80..29db8ae1026 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1360Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1360Test.php @@ -19,7 +19,7 @@ class DDC1360Test extends OrmFunctionalTestCase public function testSchemaDoubleQuotedCreate(): void { if ($this->_em->getConnection()->getDatabasePlatform()->getName() !== 'postgresql') { - $this->markTestSkipped('PostgreSQL only test.'); + self::markTestSkipped('PostgreSQL only test.'); } $sql = $this->_schemaTool->getCreateSchemaSql( @@ -28,7 +28,7 @@ public function testSchemaDoubleQuotedCreate(): void ] ); - $this->assertEquals( + self::assertEquals( [ 'CREATE SCHEMA user', 'CREATE TABLE "user"."user" (id INT NOT NULL, PRIMARY KEY(id))', diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1392Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1392Test.php index eefedfc5707..05744bc93ac 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1392Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1392Test.php @@ -49,10 +49,10 @@ public function testFailingCase(): void $fileId = $file->getFileId(); $pictureId = $picture->getPictureId(); - $this->assertTrue($fileId > 0); + self::assertTrue($fileId > 0); $picture = $em->find(DDC1392Picture::class, $pictureId); - $this->assertEquals(UnitOfWork::STATE_MANAGED, $em->getUnitOfWork()->getEntityState($picture->getFile()), 'Lazy Proxy should be marked MANAGED.'); + self::assertEquals(UnitOfWork::STATE_MANAGED, $em->getUnitOfWork()->getEntityState($picture->getFile()), 'Lazy Proxy should be marked MANAGED.'); $file = $picture->getFile(); diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1404Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1404Test.php index 37ca6796527..3a18b029913 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1404Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1404Test.php @@ -49,13 +49,13 @@ public function testTicket(): void $queryFirst = $repository->createNamedQuery('first'); $querySecond = $repository->createNamedQuery('second'); - $this->assertEquals('SELECT p FROM Doctrine\Tests\ORM\Functional\Ticket\DDC1404ChildEntity p', $queryAll->getDQL()); - $this->assertEquals('SELECT p FROM Doctrine\Tests\ORM\Functional\Ticket\DDC1404ChildEntity p WHERE p.id = 1', $queryFirst->getDQL()); - $this->assertEquals('SELECT p FROM Doctrine\Tests\ORM\Functional\Ticket\DDC1404ChildEntity p WHERE p.id = 2', $querySecond->getDQL()); + self::assertEquals('SELECT p FROM Doctrine\Tests\ORM\Functional\Ticket\DDC1404ChildEntity p', $queryAll->getDQL()); + self::assertEquals('SELECT p FROM Doctrine\Tests\ORM\Functional\Ticket\DDC1404ChildEntity p WHERE p.id = 1', $queryFirst->getDQL()); + self::assertEquals('SELECT p FROM Doctrine\Tests\ORM\Functional\Ticket\DDC1404ChildEntity p WHERE p.id = 2', $querySecond->getDQL()); - $this->assertEquals(count($queryAll->getResult()), 2); - $this->assertEquals(count($queryFirst->getResult()), 1); - $this->assertEquals(count($querySecond->getResult()), 1); + self::assertEquals(count($queryAll->getResult()), 2); + self::assertEquals(count($queryFirst->getResult()), 1); + self::assertEquals(count($querySecond->getResult()), 1); } public function loadFixtures(): void diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC142Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC142Test.php index 0bd6ea7bf64..16806987ace 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC142Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC142Test.php @@ -41,16 +41,16 @@ public function testCreateRetrieveUpdateDelete(): void $this->_em->clear(); $id = $user->id; - $this->assertNotNull($id); + self::assertNotNull($id); $user = $this->_em->find(User::class, $id); $address = $user->getAddress(); - $this->assertInstanceOf(User::class, $user); - $this->assertInstanceOf(Address::class, $user->getAddress()); + self::assertInstanceOf(User::class, $user); + self::assertInstanceOf(Address::class, $user->getAddress()); - $this->assertEquals('FabioBatSilva', $user->name); - $this->assertEquals('12345', $address->zip); + self::assertEquals('FabioBatSilva', $user->name); + self::assertEquals('12345', $address->zip); $user->name = 'FabioBatSilva1'; $user->address = null; @@ -61,15 +61,15 @@ public function testCreateRetrieveUpdateDelete(): void $this->_em->clear(); $user = $this->_em->find(User::class, $id); - $this->assertInstanceOf(User::class, $user); - $this->assertNull($user->getAddress()); + self::assertInstanceOf(User::class, $user); + self::assertNull($user->getAddress()); - $this->assertEquals('FabioBatSilva1', $user->name); + self::assertEquals('FabioBatSilva1', $user->name); $this->_em->remove($user); $this->_em->flush(); $this->_em->clear(); - $this->assertNull($this->_em->find(User::class, $id)); + self::assertNull($this->_em->find(User::class, $id)); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1430Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1430Test.php index 1cc4e941cda..ee6b7e82697 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1430Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1430Test.php @@ -54,19 +54,19 @@ public function testOrderByFields(): void $result = $query->getResult(); - $this->assertEquals(2, count($result)); + self::assertEquals(2, count($result)); - $this->assertArrayHasKey('id', $result[0]); - $this->assertArrayHasKey('id', $result[1]); + self::assertArrayHasKey('id', $result[0]); + self::assertArrayHasKey('id', $result[1]); - $this->assertArrayHasKey('p_count', $result[0]); - $this->assertArrayHasKey('p_count', $result[1]); + self::assertArrayHasKey('p_count', $result[0]); + self::assertArrayHasKey('p_count', $result[1]); - $this->assertEquals(1, $result[0]['id']); - $this->assertEquals(2, $result[1]['id']); + self::assertEquals(1, $result[0]['id']); + self::assertEquals(2, $result[1]['id']); - $this->assertEquals(2, $result[0]['p_count']); - $this->assertEquals(3, $result[1]['p_count']); + self::assertEquals(2, $result[0]['p_count']); + self::assertEquals(3, $result[1]['p_count']); } public function testOrderByAllObjectFields(): void @@ -84,16 +84,16 @@ public function testOrderByAllObjectFields(): void $result = $query->getResult(); - $this->assertEquals(2, count($result)); + self::assertEquals(2, count($result)); - $this->assertTrue($result[0][0] instanceof DDC1430Order); - $this->assertTrue($result[1][0] instanceof DDC1430Order); + self::assertTrue($result[0][0] instanceof DDC1430Order); + self::assertTrue($result[1][0] instanceof DDC1430Order); - $this->assertEquals($result[0][0]->getId(), 1); - $this->assertEquals($result[1][0]->getId(), 2); + self::assertEquals($result[0][0]->getId(), 1); + self::assertEquals($result[1][0]->getId(), 2); - $this->assertEquals($result[0]['p_count'], 2); - $this->assertEquals($result[1]['p_count'], 3); + self::assertEquals($result[0]['p_count'], 2); + self::assertEquals($result[1]['p_count'], 3); } public function testTicket(): void @@ -111,16 +111,16 @@ public function testTicket(): void $result = $query->getResult(); - $this->assertEquals(2, count($result)); + self::assertEquals(2, count($result)); - $this->assertTrue($result[0][0] instanceof DDC1430Order); - $this->assertTrue($result[1][0] instanceof DDC1430Order); + self::assertTrue($result[0][0] instanceof DDC1430Order); + self::assertTrue($result[1][0] instanceof DDC1430Order); - $this->assertEquals($result[0][0]->getId(), 1); - $this->assertEquals($result[1][0]->getId(), 2); + self::assertEquals($result[0][0]->getId(), 1); + self::assertEquals($result[1][0]->getId(), 2); - $this->assertEquals($result[0]['p_count'], 2); - $this->assertEquals($result[1]['p_count'], 3); + self::assertEquals($result[0]['p_count'], 2); + self::assertEquals($result[1]['p_count'], 3); } public function loadFixtures(): void diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1436Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1436Test.php index acbfdcb6610..8b62c7a4a7a 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1436Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1436Test.php @@ -54,13 +54,13 @@ public function testIdentityMap(): void ->setParameter('id', $id) ->getOneOrNullResult(); - $this->assertInstanceOf(DDC1436Page::class, $page); + self::assertInstanceOf(DDC1436Page::class, $page); // step 2 $page = $this->_em->find(DDC1436Page::class, $id); - $this->assertInstanceOf(DDC1436Page::class, $page); - $this->assertInstanceOf(DDC1436Page::class, $page->getParent()); - $this->assertInstanceOf(DDC1436Page::class, $page->getParent()->getParent()); + self::assertInstanceOf(DDC1436Page::class, $page); + self::assertInstanceOf(DDC1436Page::class, $page->getParent()); + self::assertInstanceOf(DDC1436Page::class, $page->getParent()->getParent()); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1452Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1452Test.php index 24e206d92ae..29ee1f119bf 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1452Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1452Test.php @@ -60,9 +60,9 @@ public function testIssue(): void $dql = 'SELECT a, b, ba FROM ' . __NAMESPACE__ . '\DDC1452EntityA AS a LEFT JOIN a.entitiesB AS b LEFT JOIN b.entityATo AS ba'; $results = $this->_em->createQuery($dql)->setMaxResults(1)->getResult(); - $this->assertSame($results[0], $results[0]->entitiesB[0]->entityAFrom); - $this->assertNotInstanceOf(Proxy::class, $results[0]->entitiesB[0]->entityATo); - $this->assertInstanceOf(Collection::class, $results[0]->entitiesB[0]->entityATo->getEntitiesB()); + self::assertSame($results[0], $results[0]->entitiesB[0]->entityAFrom); + self::assertNotInstanceOf(Proxy::class, $results[0]->entitiesB[0]->entityATo); + self::assertInstanceOf(Collection::class, $results[0]->entitiesB[0]->entityATo->getEntitiesB()); } public function testFetchJoinOneToOneFromInverse(): void @@ -89,12 +89,12 @@ public function testFetchJoinOneToOneFromInverse(): void $data = $this->_em->createQuery($dql)->getResult(); $this->_em->clear(); - $this->assertNotInstanceOf(Proxy::class, $data[0]->user); + self::assertNotInstanceOf(Proxy::class, $data[0]->user); $dql = 'SELECT u, a FROM Doctrine\Tests\Models\CMS\CmsUser u INNER JOIN u.address a'; $data = $this->_em->createQuery($dql)->getResult(); - $this->assertNotInstanceOf(Proxy::class, $data[0]->address); + self::assertNotInstanceOf(Proxy::class, $data[0]->address); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1458Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1458Test.php index eeafbb06b1c..3b9596ad71b 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1458Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1458Test.php @@ -34,7 +34,7 @@ public function testIssue(): void $this->_em->clear(); // So here the value is 3 - $this->assertEquals(3, $testEntity->getValue()); + self::assertEquals(3, $testEntity->getValue()); $test = $this->_em->getRepository(TestEntity::class)->find(1); @@ -42,19 +42,19 @@ public function testIssue(): void $test->setValue(5); // So here the value is 5 - $this->assertEquals(5, $test->getValue()); + self::assertEquals(5, $test->getValue()); // Get the additional entity $additional = $test->getAdditional(); // Still 5.. - $this->assertEquals(5, $test->getValue()); + self::assertEquals(5, $test->getValue()); // Force the proxy to load $additional->getBool(); // The value should still be 5 - $this->assertEquals(5, $test->getValue()); + self::assertEquals(5, $test->getValue()); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1461Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1461Test.php index a13a4b4eae2..7e668d942bf 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1461Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1461Test.php @@ -42,8 +42,8 @@ public function testChangeDetectionDeferredExplicit(): void $this->_em->persist($user); $this->_em->flush(); - $this->assertEquals(UnitOfWork::STATE_MANAGED, $this->_em->getUnitOfWork()->getEntityState($user, UnitOfWork::STATE_NEW), 'Entity should be managed.'); - $this->assertEquals(UnitOfWork::STATE_MANAGED, $this->_em->getUnitOfWork()->getEntityState($user), 'Entity should be managed.'); + self::assertEquals(UnitOfWork::STATE_MANAGED, $this->_em->getUnitOfWork()->getEntityState($user, UnitOfWork::STATE_NEW), 'Entity should be managed.'); + self::assertEquals(UnitOfWork::STATE_MANAGED, $this->_em->getUnitOfWork()->getEntityState($user), 'Entity should be managed.'); $acc = new DDC1461TwitterAccount(); $user->twitterAccount = $acc; @@ -52,7 +52,7 @@ public function testChangeDetectionDeferredExplicit(): void $this->_em->flush(); $user = $this->_em->find(get_class($user), $user->id); - $this->assertNotNull($user->twitterAccount); + self::assertNotNull($user->twitterAccount); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1509Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1509Test.php index 5667c8799af..10ba0c85bae 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1509Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1509Test.php @@ -59,8 +59,8 @@ public function testFailingCase(): void $pic = $em->merge($picture); assert($pic instanceof DDC1509Picture); - $this->assertNotNull($pic->getThumbnail()); - $this->assertNotNull($pic->getFile()); + self::assertNotNull($pic->getThumbnail()); + self::assertNotNull($pic->getFile()); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1514Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1514Test.php index c266d32ad71..41cf8418aa1 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1514Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1514Test.php @@ -67,11 +67,11 @@ public function testIssue(): void $dql = 'SELECT a, b, ba, c FROM ' . __NAMESPACE__ . '\DDC1514EntityA AS a LEFT JOIN a.entitiesB AS b LEFT JOIN b.entityATo AS ba LEFT JOIN a.entityC AS c ORDER BY a.title'; $results = $this->_em->createQuery($dql)->getResult(); - $this->assertEquals($a1->id, $results[0]->id); - $this->assertNull($results[0]->entityC); + self::assertEquals($a1->id, $results[0]->id); + self::assertNull($results[0]->entityC); - $this->assertEquals($a2->id, $results[1]->id); - $this->assertEquals($c->title, $results[1]->entityC->title); + self::assertEquals($a2->id, $results[1]->id); + self::assertEquals($c->title, $results[1]->entityC->title); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1515Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1515Test.php index 9d75494ae2b..ddee8ea3d9d 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1515Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1515Test.php @@ -40,7 +40,7 @@ public function testIssue(): void $this->_em->clear(); $bar = $this->_em->find(DDC1515Bar::class, $bar->id); - $this->assertInstanceOf(DDC1515Foo::class, $bar->foo); + self::assertInstanceOf(DDC1515Foo::class, $bar->foo); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1526Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1526Test.php index 69f5caffb27..9c0cdfea0ce 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1526Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1526Test.php @@ -52,7 +52,7 @@ public function testIssue(): void // All Children collection now have to be initialized foreach ($menus as $menu) { - $this->assertTrue($menu->children->isInitialized()); + self::assertTrue($menu->children->isInitialized()); } } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1545Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1545Test.php index 72ab55c9f94..43039d69d25 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1545Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1545Test.php @@ -78,8 +78,8 @@ public function testLinkObjects(): void ->setParameter('id', $this->articleId) ->getOneOrNullResult(); - $this->assertNotNull($article->user); - $this->assertEquals($user->id, $article->user->id); + self::assertNotNull($article->user); + self::assertEquals($user->id, $article->user->id); } public function testLinkObjectsWithAssociationLoaded(): void @@ -104,8 +104,8 @@ public function testLinkObjectsWithAssociationLoaded(): void ->setParameter('id', $this->articleId) ->getOneOrNullResult(); - $this->assertNotNull($article->user); - $this->assertEquals($user->id, $article->user->id); + self::assertNotNull($article->user); + self::assertEquals($user->id, $article->user->id); } public function testUnlinkObjects(): void @@ -125,7 +125,7 @@ public function testUnlinkObjects(): void ->setParameter('id', $this->articleId) ->getOneOrNullResult(); - $this->assertNull($article->user); + self::assertNull($article->user); } public function testUnlinkObjectsWithAssociationLoaded(): void @@ -148,7 +148,7 @@ public function testUnlinkObjectsWithAssociationLoaded(): void ->setParameter('id', $this->articleId) ->getOneOrNullResult(); - $this->assertNull($article->user); + self::assertNull($article->user); } public function testChangeLink(): void @@ -170,8 +170,8 @@ public function testChangeLink(): void ->setParameter('id', $this->articleId) ->getOneOrNullResult(); - $this->assertNotNull($article->user); - $this->assertEquals($user2->id, $article->user->id); + self::assertNotNull($article->user); + self::assertEquals($user2->id, $article->user->id); } public function testChangeLinkWithAssociationLoaded(): void @@ -196,7 +196,7 @@ public function testChangeLinkWithAssociationLoaded(): void ->setParameter('id', $this->articleId) ->getOneOrNullResult(); - $this->assertNotNull($article->user); - $this->assertEquals($user2->id, $article->user->id); + self::assertNotNull($article->user); + self::assertEquals($user2->id, $article->user->id); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1548Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1548Test.php index 54e924f6ac0..79aa61f7f4e 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1548Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1548Test.php @@ -42,7 +42,7 @@ public function testIssue(): void $obt = $this->_em->find(DDC1548Rel::class, $rel->id); - $this->assertNull($obt->e2); + self::assertNull($obt->e2); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1594Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1594Test.php index e1e4da1e1bc..d8e6fed7f0b 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1594Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1594Test.php @@ -39,8 +39,8 @@ public function testIssue(): void $mergedUser = $this->_em->merge($detachedUser); - $this->assertNotSame($mergedUser, $detachedUser); - $this->assertEquals('bar', $detachedUser->getName()); - $this->assertEquals('bar', $mergedUser->getName()); + self::assertNotSame($mergedUser, $detachedUser); + self::assertEquals('bar', $detachedUser->getName()); + self::assertEquals('bar', $mergedUser->getName()); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1595Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1595Test.php index 34e15054b45..12b28ded7a3 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1595Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1595Test.php @@ -64,7 +64,7 @@ public function testIssue(): void $entities = $entity1->getEntities()->getValues(); - $this->assertEquals( + self::assertEquals( "SELECT t0.id AS id_1, t0.type FROM base t0 INNER JOIN entity1_entity2 ON t0.id = entity1_entity2.item WHERE entity1_entity2.parent = ? AND t0.type IN ('Entity2')", $sqlLogger->queries[count($sqlLogger->queries)]['sql'] ); diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC163Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC163Test.php index 5f6560dec34..c758eb04093 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC163Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC163Test.php @@ -59,8 +59,8 @@ public function testQueryWithOrConditionUsingTwoRelationOnSameEntity(): void $q->setParameter('name2', 'p4'); $result = $q->getScalarResult(); - $this->assertEquals('p3', $result[0]['spouse_name']); - $this->assertEquals('p1', $result[0]['person_name']); - $this->assertEquals('p2', $result[0]['friend_name']); + self::assertEquals('p3', $result[0]['spouse_name']); + self::assertEquals('p1', $result[0]['person_name']); + self::assertEquals('p2', $result[0]['friend_name']); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1643Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1643Test.php index f335e3838df..424917753c9 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1643Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1643Test.php @@ -64,7 +64,7 @@ public function testClonePersistentCollectionAndReuse(): void $user1 = $this->_em->find(get_class($user1), $user1->id); - $this->assertEquals(2, count($user1->groups)); + self::assertEquals(2, count($user1->groups)); } public function testClonePersistentCollectionAndShare(): void @@ -80,8 +80,8 @@ public function testClonePersistentCollectionAndShare(): void $user1 = $this->_em->find(get_class($user1), $user1->id); $user2 = $this->_em->find(get_class($user1), $user2->id); - $this->assertEquals(2, count($user1->groups)); - $this->assertEquals(2, count($user2->groups)); + self::assertEquals(2, count($user1->groups)); + self::assertEquals(2, count($user2->groups)); } public function testCloneThenDirtyPersistentCollection(): void @@ -101,8 +101,8 @@ public function testCloneThenDirtyPersistentCollection(): void $user1 = $this->_em->find(get_class($user1), $user1->id); $user2 = $this->_em->find(get_class($user1), $user2->id); - $this->assertEquals(3, count($user2->groups)); - $this->assertEquals(2, count($user1->groups)); + self::assertEquals(3, count($user2->groups)); + self::assertEquals(2, count($user1->groups)); } public function testNotCloneAndPassAroundFlush(): void @@ -115,7 +115,7 @@ public function testNotCloneAndPassAroundFlush(): void $user2->groups = $user1->groups; $user2->groups->add($group3); - $this->assertCount(1, $user1->groups->getInsertDiff()); + self::assertCount(1, $user1->groups->getInsertDiff()); $this->_em->persist($group3); $this->_em->flush(); @@ -124,7 +124,7 @@ public function testNotCloneAndPassAroundFlush(): void $user1 = $this->_em->find(get_class($user1), $user1->id); $user2 = $this->_em->find(get_class($user1), $user2->id); - $this->assertEquals(3, count($user2->groups)); - $this->assertEquals(3, count($user1->groups)); + self::assertEquals(3, count($user2->groups)); + self::assertEquals(3, count($user1->groups)); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1654Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1654Test.php index eed59143409..b0760740389 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1654Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1654Test.php @@ -54,7 +54,7 @@ public function testManyToManyRemoveFromCollectionOrphanRemoval(): void $this->_em->clear(); $comments = $this->_em->getRepository(DDC1654Comment::class)->findAll(); - $this->assertEquals(0, count($comments)); + self::assertEquals(0, count($comments)); } public function testManyToManyRemoveElementFromCollectionOrphanRemoval(): void @@ -73,7 +73,7 @@ public function testManyToManyRemoveElementFromCollectionOrphanRemoval(): void $this->_em->clear(); $comments = $this->_em->getRepository(DDC1654Comment::class)->findAll(); - $this->assertEquals(0, count($comments)); + self::assertEquals(0, count($comments)); } /** @@ -96,7 +96,7 @@ public function testManyToManyRemoveElementFromReAddToCollectionOrphanRemoval(): $this->_em->clear(); $comments = $this->_em->getRepository(DDC1654Comment::class)->findAll(); - $this->assertEquals(2, count($comments)); + self::assertEquals(2, count($comments)); } public function testManyToManyClearCollectionOrphanRemoval(): void @@ -114,7 +114,7 @@ public function testManyToManyClearCollectionOrphanRemoval(): void $this->_em->clear(); $comments = $this->_em->getRepository(DDC1654Comment::class)->findAll(); - $this->assertEquals(0, count($comments)); + self::assertEquals(0, count($comments)); } /** @@ -137,7 +137,7 @@ public function testManyToManyClearCollectionReAddOrphanRemoval(): void $this->_em->clear(); $comments = $this->_em->getRepository(DDC1654Comment::class)->findAll(); - $this->assertEquals(1, count($comments)); + self::assertEquals(1, count($comments)); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1655Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1655Test.php index 93e287fd9c9..599c28ab0fc 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1655Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1655Test.php @@ -46,10 +46,10 @@ protected function setUp(): void public function testPostLoadOneToManyInheritance(): void { $cm = $this->_em->getClassMetadata(DDC1655Foo::class); - $this->assertEquals(['postLoad' => ['postLoad']], $cm->lifecycleCallbacks); + self::assertEquals(['postLoad' => ['postLoad']], $cm->lifecycleCallbacks); $cm = $this->_em->getClassMetadata(DDC1655Bar::class); - $this->assertEquals(['postLoad' => ['postLoad', 'postSubLoaded']], $cm->lifecycleCallbacks); + self::assertEquals(['postLoad' => ['postLoad', 'postSubLoaded']], $cm->lifecycleCallbacks); $baz = new DDC1655Baz(); $foo = new DDC1655Foo(); @@ -65,7 +65,7 @@ public function testPostLoadOneToManyInheritance(): void $baz = $this->_em->find(get_class($baz), $baz->id); foreach ($baz->foos as $foo) { - $this->assertEquals(1, $foo->loaded, 'should have loaded callback counter incremented for ' . get_class($foo)); + self::assertEquals(1, $foo->loaded, 'should have loaded callback counter incremented for ' . get_class($foo)); } } @@ -82,23 +82,23 @@ public function testPostLoadInheritanceChild(): void $this->_em->clear(); $bar = $this->_em->find(get_class($bar), $bar->id); - $this->assertEquals(1, $bar->loaded); - $this->assertEquals(1, $bar->subLoaded); + self::assertEquals(1, $bar->loaded); + self::assertEquals(1, $bar->subLoaded); $bar = $this->_em->find(get_class($bar), $bar->id); - $this->assertEquals(1, $bar->loaded); - $this->assertEquals(1, $bar->subLoaded); + self::assertEquals(1, $bar->loaded); + self::assertEquals(1, $bar->subLoaded); $dql = 'SELECT b FROM ' . __NAMESPACE__ . '\DDC1655Bar b WHERE b.id = ?1'; $bar = $this->_em->createQuery($dql)->setParameter(1, $bar->id)->getSingleResult(); - $this->assertEquals(1, $bar->loaded); - $this->assertEquals(1, $bar->subLoaded); + self::assertEquals(1, $bar->loaded); + self::assertEquals(1, $bar->subLoaded); $this->_em->refresh($bar); - $this->assertEquals(2, $bar->loaded); - $this->assertEquals(2, $bar->subLoaded); + self::assertEquals(2, $bar->loaded); + self::assertEquals(2, $bar->subLoaded); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1666Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1666Test.php index aba16f27ca4..9fd6311bd01 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1666Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1666Test.php @@ -31,13 +31,13 @@ public function testGivenOrphanRemovalOneToOneWhenReplacingThenNoUniqueConstrain $this->_em->persist($user); $this->_em->flush(); - $this->assertTrue($this->_em->contains($email)); + self::assertTrue($this->_em->contains($email)); $user->setEmail($newEmail = new CmsEmail()); $newEmail->setEmail('benjamin.eberlei@googlemail.com'); $this->_em->flush(); - $this->assertFalse($this->_em->contains($email)); + self::assertFalse($this->_em->contains($email)); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1685Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1685Test.php index e9d956b910f..17a200b5712 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1685Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1685Test.php @@ -44,20 +44,20 @@ protected function setUp(): void public function testPaginateCount(): void { - $this->assertEquals(1, count($this->paginator)); + self::assertEquals(1, count($this->paginator)); } public function testPaginateIterate(): void { foreach ($this->paginator as $ad) { - $this->assertInstanceOf(DDC117ArticleDetails::class, $ad); + self::assertInstanceOf(DDC117ArticleDetails::class, $ad); } } public function testPaginateCountNoOutputWalkers(): void { $this->paginator->setUseOutputWalkers(false); - $this->assertEquals(1, count($this->paginator)); + self::assertEquals(1, count($this->paginator)); } public function testPaginateIterateNoOutputWalkers(): void @@ -68,7 +68,7 @@ public function testPaginateIterateNoOutputWalkers(): void $this->expectExceptionMessage('Paginating an entity with foreign key as identifier only works when using the Output Walkers. Call Paginator#setUseOutputWalkers(true) before iterating the paginator.'); foreach ($this->paginator as $ad) { - $this->assertInstanceOf(DDC117ArticleDetails::class, $ad); + self::assertInstanceOf(DDC117ArticleDetails::class, $ad); } } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC168Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC168Test.php index 4640fadcd7a..a8a279cf52a 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC168Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC168Test.php @@ -61,10 +61,10 @@ public function testJoinedSubclassPersisterRequiresSpecificOrderOfMetadataReflFi $q->setParameter(1, 'Foo'); $theEmployee = $q->getSingleResult(); - $this->assertEquals('bar', $theEmployee->getDepartment()); - $this->assertEquals('Foo', $theEmployee->getName()); - $this->assertEquals(1000, $theEmployee->getSalary()); - $this->assertInstanceOf(CompanyEmployee::class, $theEmployee); - $this->assertInstanceOf(CompanyEmployee::class, $theEmployee->getSpouse()); + self::assertEquals('bar', $theEmployee->getDepartment()); + self::assertEquals('Foo', $theEmployee->getName()); + self::assertEquals(1000, $theEmployee->getSalary()); + self::assertInstanceOf(CompanyEmployee::class, $theEmployee); + self::assertInstanceOf(CompanyEmployee::class, $theEmployee->getSpouse()); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1690Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1690Test.php index a186057c072..f3eaddf8de3 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1690Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1690Test.php @@ -49,14 +49,14 @@ public function testChangeTracking(): void $this->_em->persist($parent); $this->_em->persist($child); - $this->assertEquals(1, count($parent->listeners)); - $this->assertEquals(1, count($child->listeners)); + self::assertEquals(1, count($parent->listeners)); + self::assertEquals(1, count($child->listeners)); $this->_em->flush(); $this->_em->clear(); - $this->assertEquals(1, count($parent->listeners)); - $this->assertEquals(1, count($child->listeners)); + self::assertEquals(1, count($parent->listeners)); + self::assertEquals(1, count($child->listeners)); $parentId = $parent->getId(); $childId = $child->getId(); @@ -65,25 +65,25 @@ public function testChangeTracking(): void $parent = $this->_em->find(DDC1690Parent::class, $parentId); $child = $this->_em->find(DDC1690Child::class, $childId); - $this->assertEquals(1, count($parent->listeners)); - $this->assertInstanceOf(Proxy::class, $child, 'Verifying that $child is a proxy before using proxy API'); - $this->assertCount(0, $child->listeners); + self::assertEquals(1, count($parent->listeners)); + self::assertInstanceOf(Proxy::class, $child, 'Verifying that $child is a proxy before using proxy API'); + self::assertCount(0, $child->listeners); $child->__load(); - $this->assertCount(1, $child->listeners); + self::assertCount(1, $child->listeners); unset($parent, $child); $parent = $this->_em->find(DDC1690Parent::class, $parentId); $child = $parent->getChild(); - $this->assertEquals(1, count($parent->listeners)); - $this->assertEquals(1, count($child->listeners)); + self::assertEquals(1, count($parent->listeners)); + self::assertEquals(1, count($child->listeners)); unset($parent, $child); $child = $this->_em->find(DDC1690Child::class, $childId); $parent = $child->getParent(); - $this->assertEquals(1, count($parent->listeners)); - $this->assertEquals(1, count($child->listeners)); + self::assertEquals(1, count($parent->listeners)); + self::assertEquals(1, count($child->listeners)); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1695Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1695Test.php index e2e74754911..91b157d3499 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1695Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1695Test.php @@ -19,13 +19,13 @@ class DDC1695Test extends OrmFunctionalTestCase public function testIssue(): void { if ($this->_em->getConnection()->getDatabasePlatform()->getName() !== 'sqlite') { - $this->markTestSkipped('Only with sqlite'); + self::markTestSkipped('Only with sqlite'); } $dql = 'SELECT n.smallText, n.publishDate FROM ' . __NAMESPACE__ . '\\DDC1695News n'; $sql = $this->_em->createQuery($dql)->getSQL(); - $this->assertEquals( + self::assertEquals( 'SELECT d0_."SmallText" AS SmallText_0, d0_."PublishDate" AS PublishDate_1 FROM "DDC1695News" d0_', $sql ); diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1707Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1707Test.php index 94006c888bf..3db0472597b 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1707Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1707Test.php @@ -43,7 +43,7 @@ public function testPostLoadOnChild(): void $class->invokeLifecycleCallbacks(Events::postLoad, $entity); - $this->assertTrue($entity->postLoad); + self::assertTrue($entity->postLoad); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1719Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1719Test.php index 188cb87a1d2..da036428d89 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1719Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1719Test.php @@ -56,14 +56,14 @@ public function testCreateRetrieveUpdateDelete(): void $e1 = $this->_em->find(DDC1719SimpleEntity::class, $e1Id); $e2 = $this->_em->find(DDC1719SimpleEntity::class, $e2Id); - $this->assertInstanceOf(DDC1719SimpleEntity::class, $e1); - $this->assertInstanceOf(DDC1719SimpleEntity::class, $e2); + self::assertInstanceOf(DDC1719SimpleEntity::class, $e1); + self::assertInstanceOf(DDC1719SimpleEntity::class, $e2); - $this->assertEquals($e1Id, $e1->id); - $this->assertEquals($e2Id, $e2->id); + self::assertEquals($e1Id, $e1->id); + self::assertEquals($e2Id, $e2->id); - $this->assertEquals('Bar 1', $e1->value); - $this->assertEquals('Foo 1', $e2->value); + self::assertEquals('Bar 1', $e1->value); + self::assertEquals('Foo 1', $e2->value); $e1->value = 'Bar 2'; $e2->value = 'Foo 2'; @@ -73,17 +73,17 @@ public function testCreateRetrieveUpdateDelete(): void $this->_em->persist($e2); $this->_em->flush(); - $this->assertEquals('Bar 2', $e1->value); - $this->assertEquals('Foo 2', $e2->value); + self::assertEquals('Bar 2', $e1->value); + self::assertEquals('Foo 2', $e2->value); - $this->assertInstanceOf(DDC1719SimpleEntity::class, $e1); - $this->assertInstanceOf(DDC1719SimpleEntity::class, $e2); + self::assertInstanceOf(DDC1719SimpleEntity::class, $e1); + self::assertInstanceOf(DDC1719SimpleEntity::class, $e2); - $this->assertEquals($e1Id, $e1->id); - $this->assertEquals($e2Id, $e2->id); + self::assertEquals($e1Id, $e1->id); + self::assertEquals($e2Id, $e2->id); - $this->assertEquals('Bar 2', $e1->value); - $this->assertEquals('Foo 2', $e2->value); + self::assertEquals('Bar 2', $e1->value); + self::assertEquals('Foo 2', $e2->value); // Delete $this->_em->remove($e1); @@ -93,8 +93,8 @@ public function testCreateRetrieveUpdateDelete(): void $e1 = $this->_em->find(DDC1719SimpleEntity::class, $e1Id); $e2 = $this->_em->find(DDC1719SimpleEntity::class, $e2Id); - $this->assertNull($e1); - $this->assertNull($e2); + self::assertNull($e1); + self::assertNull($e2); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1734Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1734Test.php index fa262d8e21a..3757fa3c941 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1734Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1734Test.php @@ -36,15 +36,15 @@ public function testMergeWorksOnNonSerializedProxies(): void $proxy = $this->getProxy($group); - $this->assertInstanceOf(Proxy::class, $proxy); - $this->assertFalse($proxy->__isInitialized()); + self::assertInstanceOf(Proxy::class, $proxy); + self::assertFalse($proxy->__isInitialized()); $this->_em->detach($proxy); $this->_em->clear(); $proxy = $this->_em->merge($proxy); - $this->assertEquals('Foo', $proxy->getName(), 'The entity is broken'); + self::assertEquals('Foo', $proxy->getName(), 'The entity is broken'); } /** @@ -66,15 +66,15 @@ public function testMergeWorksOnSerializedProxies(): void $proxy = $this->getProxy($group); - $this->assertInstanceOf(Proxy::class, $proxy); - $this->assertFalse($proxy->__isInitialized()); + self::assertInstanceOf(Proxy::class, $proxy); + self::assertFalse($proxy->__isInitialized()); $this->_em->detach($proxy); $serializedProxy = serialize($proxy); $this->_em->clear(); $unserializedProxy = $this->_em->merge(unserialize($serializedProxy)); - $this->assertEquals('Foo', $unserializedProxy->getName(), 'The entity is broken'); + self::assertEquals('Foo', $unserializedProxy->getName(), 'The entity is broken'); } /** diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1778Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1778Test.php index b87aec97f3b..23e4eeb3777 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1778Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1778Test.php @@ -51,7 +51,7 @@ public function testClear(): void $this->user = $this->_em->find(CmsUser::class, $this->user->getId()); - $this->assertCount(1, $this->user->getPhonenumbers()); + self::assertCount(1, $this->user->getPhonenumbers()); } public function testRemove(): void @@ -63,7 +63,7 @@ public function testRemove(): void $this->user = $this->_em->find(CmsUser::class, $this->user->getId()); - $this->assertCount(1, $this->user->getPhonenumbers()); + self::assertCount(1, $this->user->getPhonenumbers()); } public function testRemoveElement(): void @@ -75,6 +75,6 @@ public function testRemoveElement(): void $this->user = $this->_em->find(CmsUser::class, $this->user->getId()); - $this->assertCount(1, $this->user->getPhonenumbers()); + self::assertCount(1, $this->user->getPhonenumbers()); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1787Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1787Test.php index 55afff72ab6..877aeb3f7cc 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1787Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1787Test.php @@ -38,7 +38,7 @@ public function testIssue(): void $this->_em->persist($bar2); $this->_em->flush(); - $this->assertSame(1, $bar->getVersion()); + self::assertSame(1, $bar->getVersion()); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1843Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1843Test.php index 571c818902e..cd037335bf2 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1843Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1843Test.php @@ -49,20 +49,20 @@ public function testCreateRetrieveUpdateDelete(): void $e3 = $this->_em->find(Group::class, $e3Id); $e4 = $this->_em->find(Group::class, $e4Id); - $this->assertInstanceOf(Group::class, $e1); - $this->assertInstanceOf(Group::class, $e2); - $this->assertInstanceOf(Group::class, $e3); - $this->assertInstanceOf(Group::class, $e4); + self::assertInstanceOf(Group::class, $e1); + self::assertInstanceOf(Group::class, $e2); + self::assertInstanceOf(Group::class, $e3); + self::assertInstanceOf(Group::class, $e4); - $this->assertEquals($e1Id, $e1->id); - $this->assertEquals($e2Id, $e2->id); - $this->assertEquals($e3Id, $e3->id); - $this->assertEquals($e4Id, $e4->id); + self::assertEquals($e1Id, $e1->id); + self::assertEquals($e2Id, $e2->id); + self::assertEquals($e3Id, $e3->id); + self::assertEquals($e4Id, $e4->id); - $this->assertEquals('Parent Bar 1', $e1->name); - $this->assertEquals('Parent Foo 2', $e2->name); - $this->assertEquals('Bar 3', $e3->name); - $this->assertEquals('Foo 4', $e4->name); + self::assertEquals('Parent Bar 1', $e1->name); + self::assertEquals('Parent Foo 2', $e2->name); + self::assertEquals('Bar 3', $e3->name); + self::assertEquals('Foo 4', $e4->name); $e1->name = 'Parent Bar 11'; $e2->name = 'Parent Foo 22'; @@ -76,25 +76,25 @@ public function testCreateRetrieveUpdateDelete(): void $this->_em->persist($e4); $this->_em->flush(); - $this->assertEquals('Parent Bar 11', $e1->name); - $this->assertEquals('Parent Foo 22', $e2->name); - $this->assertEquals('Bar 33', $e3->name); - $this->assertEquals('Foo 44', $e4->name); + self::assertEquals('Parent Bar 11', $e1->name); + self::assertEquals('Parent Foo 22', $e2->name); + self::assertEquals('Bar 33', $e3->name); + self::assertEquals('Foo 44', $e4->name); - $this->assertInstanceOf(Group::class, $e1); - $this->assertInstanceOf(Group::class, $e2); - $this->assertInstanceOf(Group::class, $e3); - $this->assertInstanceOf(Group::class, $e4); + self::assertInstanceOf(Group::class, $e1); + self::assertInstanceOf(Group::class, $e2); + self::assertInstanceOf(Group::class, $e3); + self::assertInstanceOf(Group::class, $e4); - $this->assertEquals($e1Id, $e1->id); - $this->assertEquals($e2Id, $e2->id); - $this->assertEquals($e3Id, $e3->id); - $this->assertEquals($e4Id, $e4->id); + self::assertEquals($e1Id, $e1->id); + self::assertEquals($e2Id, $e2->id); + self::assertEquals($e3Id, $e3->id); + self::assertEquals($e4Id, $e4->id); - $this->assertEquals('Parent Bar 11', $e1->name); - $this->assertEquals('Parent Foo 22', $e2->name); - $this->assertEquals('Bar 33', $e3->name); - $this->assertEquals('Foo 44', $e4->name); + self::assertEquals('Parent Bar 11', $e1->name); + self::assertEquals('Parent Foo 22', $e2->name); + self::assertEquals('Bar 33', $e3->name); + self::assertEquals('Foo 44', $e4->name); // Delete $this->_em->remove($e4); @@ -105,10 +105,10 @@ public function testCreateRetrieveUpdateDelete(): void $this->_em->flush(); $this->_em->clear(); - $this->assertInstanceOf(Group::class, $e1); - $this->assertInstanceOf(Group::class, $e2); - $this->assertInstanceOf(Group::class, $e3); - $this->assertInstanceOf(Group::class, $e4); + self::assertInstanceOf(Group::class, $e1); + self::assertInstanceOf(Group::class, $e2); + self::assertInstanceOf(Group::class, $e3); + self::assertInstanceOf(Group::class, $e4); // Retrieve $e1 = $this->_em->find(Group::class, $e1Id); @@ -116,9 +116,9 @@ public function testCreateRetrieveUpdateDelete(): void $e3 = $this->_em->find(Group::class, $e3Id); $e4 = $this->_em->find(Group::class, $e4Id); - $this->assertNull($e1); - $this->assertNull($e2); - $this->assertNull($e3); - $this->assertNull($e4); + self::assertNull($e1); + self::assertNull($e2); + self::assertNull($e3); + self::assertNull($e4); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1884Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1884Test.php index 0b8d1b63b1c..c31acf44e5e 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1884Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1884Test.php @@ -121,9 +121,9 @@ public function testSelectFromInverseSideWithCompositePkAndSolelyIdentifierColum ->getQuery() ->getArrayResult(); - $this->assertCount(1, $result); - $this->assertArrayHasKey('freeDriverRides', $result[0]); - $this->assertCount(3, $result[0]['freeDriverRides']); + self::assertCount(1, $result); + self::assertArrayHasKey('freeDriverRides', $result[0]); + self::assertCount(3, $result[0]['freeDriverRides']); } /** @@ -142,9 +142,9 @@ public function testSelectFromInverseSideWithCompositePkUsingFetchJoins(): void ->setParameter(1, 'John Doe') ->getQuery()->getArrayResult(); - $this->assertCount(1, $result); - $this->assertArrayHasKey('driverRides', $result[0]); - $this->assertCount(3, $result[0]['driverRides']); + self::assertCount(1, $result); + self::assertArrayHasKey('driverRides', $result[0]); + self::assertCount(3, $result[0]['driverRides']); } /** @@ -162,8 +162,8 @@ public function testSelectFromOwningSideUsingFetchJoins(): void ->setParameter(1, 'John Doe') ->getQuery()->getArrayResult(); - $this->assertCount(3, $result); - $this->assertArrayHasKey('driver', $result[0]); - $this->assertArrayHasKey('car', $result[0]); + self::assertCount(3, $result); + self::assertArrayHasKey('driver', $result[0]); + self::assertArrayHasKey('car', $result[0]); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1885Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1885Test.php index 54ae8f538f3..8ee1d7b7110 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1885Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1885Test.php @@ -49,17 +49,17 @@ public function testCreateRetrieveUpdateDelete(): void // Retrieve $user = $this->_em->find(User::class, $u1Id); - $this->assertInstanceOf(User::class, $user); - $this->assertEquals('FabioBatSilva', $user->name); - $this->assertEquals($u1Id, $user->id); + self::assertInstanceOf(User::class, $user); + self::assertEquals('FabioBatSilva', $user->name); + self::assertEquals($u1Id, $user->id); - $this->assertCount(2, $user->groups); + self::assertCount(2, $user->groups); $g1 = $user->getGroups()->get(0); $g2 = $user->getGroups()->get(1); - $this->assertInstanceOf(Group::class, $g1); - $this->assertInstanceOf(Group::class, $g2); + self::assertInstanceOf(Group::class, $g1); + self::assertInstanceOf(Group::class, $g2); $g1->name = 'Bar 11'; $g2->name = 'Foo 22'; @@ -71,9 +71,9 @@ public function testCreateRetrieveUpdateDelete(): void $user = $this->_em->find(User::class, $u1Id); - $this->assertInstanceOf(User::class, $user); - $this->assertEquals('FabioBatSilva', $user->name); - $this->assertEquals($u1Id, $user->id); + self::assertInstanceOf(User::class, $user); + self::assertEquals('FabioBatSilva', $user->name); + self::assertEquals($u1Id, $user->id); // Delete $this->_em->remove($user); @@ -81,9 +81,9 @@ public function testCreateRetrieveUpdateDelete(): void $this->_em->flush(); $this->_em->clear(); - $this->assertNull($this->_em->find(User::class, $u1Id)); - $this->assertNull($this->_em->find(Group::class, $g1Id)); - $this->assertNull($this->_em->find(Group::class, $g2Id)); + self::assertNull($this->_em->find(User::class, $u1Id)); + self::assertNull($this->_em->find(Group::class, $g1Id)); + self::assertNull($this->_em->find(Group::class, $g2Id)); } public function testRemoveItem(): void @@ -92,13 +92,13 @@ public function testRemoveItem(): void $u1Id = $user->id; $user = $this->_em->find(User::class, $u1Id); - $this->assertInstanceOf(User::class, $user); - $this->assertEquals('FabioBatSilva', $user->name); - $this->assertEquals($u1Id, $user->id); + self::assertInstanceOf(User::class, $user); + self::assertEquals('FabioBatSilva', $user->name); + self::assertEquals($u1Id, $user->id); - $this->assertCount(2, $user->groups); - $this->assertInstanceOf(Group::class, $user->getGroups()->get(0)); - $this->assertInstanceOf(Group::class, $user->getGroups()->get(1)); + self::assertCount(2, $user->groups); + self::assertInstanceOf(Group::class, $user->getGroups()->get(0)); + self::assertInstanceOf(Group::class, $user->getGroups()->get(1)); $user->getGroups()->remove(0); @@ -109,11 +109,11 @@ public function testRemoveItem(): void $user = $this->_em->find(User::class, $u1Id); - $this->assertInstanceOf(User::class, $user); - $this->assertEquals('FabioBatSilva', $user->name); - $this->assertEquals($u1Id, $user->id); + self::assertInstanceOf(User::class, $user); + self::assertEquals('FabioBatSilva', $user->name); + self::assertEquals($u1Id, $user->id); - $this->assertCount(1, $user->getGroups()); + self::assertCount(1, $user->getGroups()); } public function testClearAll(): void @@ -122,13 +122,13 @@ public function testClearAll(): void $u1Id = $user->id; $user = $this->_em->find(User::class, $u1Id); - $this->assertInstanceOf(User::class, $user); - $this->assertEquals('FabioBatSilva', $user->name); - $this->assertEquals($u1Id, $user->id); + self::assertInstanceOf(User::class, $user); + self::assertEquals('FabioBatSilva', $user->name); + self::assertEquals($u1Id, $user->id); - $this->assertCount(2, $user->groups); - $this->assertInstanceOf(Group::class, $user->getGroups()->get(0)); - $this->assertInstanceOf(Group::class, $user->getGroups()->get(1)); + self::assertCount(2, $user->groups); + self::assertInstanceOf(Group::class, $user->getGroups()->get(0)); + self::assertInstanceOf(Group::class, $user->getGroups()->get(1)); $user->getGroups()->clear(); @@ -139,11 +139,11 @@ public function testClearAll(): void $user = $this->_em->find(User::class, $u1Id); - $this->assertInstanceOf(User::class, $user); - $this->assertEquals('FabioBatSilva', $user->name); - $this->assertEquals($u1Id, $user->id); + self::assertInstanceOf(User::class, $user); + self::assertEquals('FabioBatSilva', $user->name); + self::assertEquals($u1Id, $user->id); - $this->assertCount(0, $user->getGroups()); + self::assertCount(0, $user->getGroups()); } public function testCountExtraLazy(): void @@ -152,12 +152,12 @@ public function testCountExtraLazy(): void $u1Id = $user->id; $user = $this->_em->find(User::class, $u1Id); - $this->assertInstanceOf(User::class, $user); - $this->assertEquals('FabioBatSilva', $user->name); - $this->assertEquals($u1Id, $user->id); + self::assertInstanceOf(User::class, $user); + self::assertEquals('FabioBatSilva', $user->name); + self::assertEquals($u1Id, $user->id); - $this->assertCount(2, $user->groups); - $this->assertInstanceOf(Group::class, $user->getGroups()->get(0)); - $this->assertInstanceOf(Group::class, $user->getGroups()->get(1)); + self::assertCount(2, $user->groups); + self::assertInstanceOf(Group::class, $user->getGroups()->get(0)); + self::assertInstanceOf(Group::class, $user->getGroups()->get(1)); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1918Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1918Test.php index 15a1d0c9996..95cd33a4fa4 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1918Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1918Test.php @@ -51,18 +51,18 @@ public function testLastPageCorrect(): void $query->setMaxResults(3); $paginator = new Paginator($query, true); - $this->assertEquals(3, count(iterator_to_array($paginator))); + self::assertEquals(3, count(iterator_to_array($paginator))); $query->setFirstResult(8); $query->setMaxResults(3); $paginator = new Paginator($query, true); - $this->assertEquals(2, count(iterator_to_array($paginator))); + self::assertEquals(2, count(iterator_to_array($paginator))); $query->setFirstResult(10); $query->setMaxResults(3); $paginator = new Paginator($query, true); - $this->assertEquals(0, count(iterator_to_array($paginator))); + self::assertEquals(0, count(iterator_to_array($paginator))); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1995Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1995Test.php index 84a5ff94c67..2e2cb0a5350 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1995Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1995Test.php @@ -41,8 +41,8 @@ public function testIssue(): void ->setParameter(1, $class) ->getResult(); - $this->assertCount(1, $result); - $this->assertInstanceOf(CompanyEmployee::class, $result[0]); + self::assertCount(1, $result); + self::assertInstanceOf(CompanyEmployee::class, $result[0]); } public function testQueryCache(): void @@ -74,10 +74,10 @@ public function testQueryCache(): void ->useQueryCache(true) ->getResult(); - $this->assertCount(1, $result1); - $this->assertCount(2, $result2); + self::assertCount(1, $result1); + self::assertCount(2, $result2); - $this->assertInstanceOf(CompanyEmployee::class, $result1[0]); - $this->assertContainsOnlyInstancesOf(CompanyPerson::class, $result2); + self::assertInstanceOf(CompanyEmployee::class, $result1[0]); + self::assertContainsOnlyInstancesOf(CompanyPerson::class, $result2); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1998Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1998Test.php index c8485185d87..3ea25b78858 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1998Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1998Test.php @@ -44,12 +44,12 @@ public function testSqlConversionAsIdentifier(): void $this->_em->clear(); $found = $this->_em->find(DDC1998Entity::class, $entity->id); - $this->assertNull($found); + self::assertNull($found); $found = $this->_em->find(DDC1998Entity::class, 'foo'); - $this->assertNull($found); + self::assertNull($found); - $this->assertEquals(0, count($this->_em->getRepository(DDC1998Entity::class)->findAll())); + self::assertEquals(0, count($this->_em->getRepository(DDC1998Entity::class)->findAll())); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC199Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC199Test.php index 74008a78952..59ac8d50e3b 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC199Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC199Test.php @@ -57,12 +57,12 @@ public function testPolymorphicLoading(): void $query = $this->_em->createQuery('select e,r from Doctrine\Tests\ORM\Functional\Ticket\DDC199ParentClass e join e.relatedEntities r'); $result = $query->getResult(); - $this->assertEquals(1, count($result)); - $this->assertInstanceOf(DDC199ParentClass::class, $result[0]); - $this->assertTrue($result[0]->relatedEntities->isInitialized()); - $this->assertEquals(2, $result[0]->relatedEntities->count()); - $this->assertInstanceOf(DDC199RelatedClass::class, $result[0]->relatedEntities[0]); - $this->assertInstanceOf(DDC199RelatedClass::class, $result[0]->relatedEntities[1]); + self::assertEquals(1, count($result)); + self::assertInstanceOf(DDC199ParentClass::class, $result[0]); + self::assertTrue($result[0]->relatedEntities->isInitialized()); + self::assertEquals(2, $result[0]->relatedEntities->count()); + self::assertInstanceOf(DDC199RelatedClass::class, $result[0]->relatedEntities[0]); + self::assertInstanceOf(DDC199RelatedClass::class, $result[0]->relatedEntities[1]); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2012Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2012Test.php index e1c86841e14..860792f645d 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2012Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2012Test.php @@ -55,16 +55,16 @@ public function testIssue(): void $item = $this->_em->find(get_class($item), $item->id); - $this->assertArrayHasKey('convertToDatabaseValueSQL', DDC2012TsVectorType::$calls); - $this->assertArrayHasKey('convertToDatabaseValue', DDC2012TsVectorType::$calls); - $this->assertArrayHasKey('convertToPHPValue', DDC2012TsVectorType::$calls); + self::assertArrayHasKey('convertToDatabaseValueSQL', DDC2012TsVectorType::$calls); + self::assertArrayHasKey('convertToDatabaseValue', DDC2012TsVectorType::$calls); + self::assertArrayHasKey('convertToPHPValue', DDC2012TsVectorType::$calls); - $this->assertCount(1, DDC2012TsVectorType::$calls['convertToDatabaseValueSQL']); - $this->assertCount(1, DDC2012TsVectorType::$calls['convertToDatabaseValue']); - $this->assertCount(1, DDC2012TsVectorType::$calls['convertToPHPValue']); + self::assertCount(1, DDC2012TsVectorType::$calls['convertToDatabaseValueSQL']); + self::assertCount(1, DDC2012TsVectorType::$calls['convertToDatabaseValue']); + self::assertCount(1, DDC2012TsVectorType::$calls['convertToPHPValue']); - $this->assertInstanceOf(DDC2012Item::class, $item); - $this->assertEquals(['word1', 'word2', 'word3'], $item->tsv); + self::assertInstanceOf(DDC2012Item::class, $item); + self::assertEquals(['word1', 'word2', 'word3'], $item->tsv); $item->tsv = ['word1', 'word2']; @@ -74,12 +74,12 @@ public function testIssue(): void $item = $this->_em->find(get_class($item), $item->id); - $this->assertCount(2, DDC2012TsVectorType::$calls['convertToDatabaseValueSQL']); - $this->assertCount(2, DDC2012TsVectorType::$calls['convertToDatabaseValue']); - $this->assertCount(2, DDC2012TsVectorType::$calls['convertToPHPValue']); + self::assertCount(2, DDC2012TsVectorType::$calls['convertToDatabaseValueSQL']); + self::assertCount(2, DDC2012TsVectorType::$calls['convertToDatabaseValue']); + self::assertCount(2, DDC2012TsVectorType::$calls['convertToPHPValue']); - $this->assertInstanceOf(DDC2012Item::class, $item); - $this->assertEquals(['word1', 'word2'], $item->tsv); + self::assertInstanceOf(DDC2012Item::class, $item); + self::assertEquals(['word1', 'word2'], $item->tsv); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2074Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2074Test.php index 19c45c3a963..cbb8f1c8d32 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2074Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2074Test.php @@ -35,7 +35,7 @@ public function testShouldNotScheduleDeletionOnClonedInstances(): void $clonedCollection = clone $collection; $clonedCollection->clear(); - $this->assertEquals(0, count($uow->getScheduledCollectionDeletions())); + self::assertEquals(0, count($uow->getScheduledCollectionDeletions())); } public function testSavingClonedPersistentCollection(): void @@ -58,9 +58,9 @@ public function testSavingClonedPersistentCollection(): void $product1 = $this->_em->find(ECommerceProduct::class, $product->getId()); $product2 = $this->_em->find(ECommerceProduct::class, $newProduct->getId()); - $this->assertCount(1, $product1->getCategories()); - $this->assertCount(1, $product2->getCategories()); + self::assertCount(1, $product1->getCategories()); + self::assertCount(1, $product2->getCategories()); - $this->assertSame($product1->getCategories()->get(0), $product2->getCategories()->get(0)); + self::assertSame($product1->getCategories()->get(0), $product2->getCategories()->get(0)); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2084Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2084Test.php index 435f141752a..18e70e21a21 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2084Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2084Test.php @@ -56,9 +56,9 @@ public function testIssue(): void $e2 = $e1->getMyEntity2(); $e = $this->_em->find(__NAMESPACE__ . '\DDC2084\MyEntity1', $e2); - $this->assertInstanceOf(__NAMESPACE__ . '\DDC2084\MyEntity1', $e); - $this->assertInstanceOf(__NAMESPACE__ . '\DDC2084\MyEntity2', $e->getMyEntity2()); - $this->assertEquals('Foo', $e->getMyEntity2()->getValue()); + self::assertInstanceOf(__NAMESPACE__ . '\DDC2084\MyEntity1', $e); + self::assertInstanceOf(__NAMESPACE__ . '\DDC2084\MyEntity2', $e->getMyEntity2()); + self::assertEquals('Foo', $e->getMyEntity2()->getValue()); } public function testinvalidIdentifierBindingEntityException(): void diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2090Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2090Test.php index 124f66965a8..9cce7861ded 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2090Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2090Test.php @@ -79,10 +79,10 @@ public function testIssue(): void $e1 = $this->_em->find(CompanyEmployee::class, $employee1->getId()); $e2 = $this->_em->find(CompanyEmployee::class, $employee2->getId()); - $this->assertEquals(101, $e1->getSalary()); - $this->assertEquals(102, $e2->getSalary()); - $this->assertEquals($date1, $e1->getStartDate()); - $this->assertEquals($date2, $e2->getStartDate()); + self::assertEquals(101, $e1->getSalary()); + self::assertEquals(102, $e2->getSalary()); + self::assertEquals($date1, $e1->getStartDate()); + self::assertEquals($date2, $e2->getStartDate()); $this->_em->createQueryBuilder() ->update(CompanyEmployee::class, 'e') @@ -109,9 +109,9 @@ public function testIssue(): void $e1 = $this->_em->find(CompanyEmployee::class, $employee1->getId()); $e2 = $this->_em->find(CompanyEmployee::class, $employee2->getId()); - $this->assertEquals(101, $e1->getSalary()); - $this->assertEquals(102, $e2->getSalary()); - $this->assertEquals($date1, $e1->getStartDate()); - $this->assertEquals($date2, $e2->getStartDate()); + self::assertEquals(101, $e1->getSalary()); + self::assertEquals(102, $e2->getSalary()); + self::assertEquals($date1, $e1->getStartDate()); + self::assertEquals($date2, $e2->getStartDate()); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC211Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC211Test.php index c9fc4b434a8..771812d6271 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC211Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC211Test.php @@ -53,7 +53,7 @@ public function testIssue(): void } } - $this->assertEquals(4, $user->getGroups()->count()); + self::assertEquals(4, $user->getGroups()->count()); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2138Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2138Test.php index 90ae4769293..098b9c78a3f 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2138Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2138Test.php @@ -43,22 +43,22 @@ public function testForeignKeyOnSTIWithMultipleMapping(): void ]; $schema = $schemaTool->getSchemaFromMetadata($classes); - $this->assertTrue($schema->hasTable('users_followed_objects'), 'Table users_followed_objects should exist.'); + self::assertTrue($schema->hasTable('users_followed_objects'), 'Table users_followed_objects should exist.'); $table = $schema->getTable('users_followed_objects'); assert($table instanceof DbalTable); - $this->assertTrue($table->columnsAreIndexed(['object_id'])); - $this->assertTrue($table->columnsAreIndexed(['user_id'])); + self::assertTrue($table->columnsAreIndexed(['object_id'])); + self::assertTrue($table->columnsAreIndexed(['user_id'])); $foreignKeys = $table->getForeignKeys(); - $this->assertCount(1, $foreignKeys, 'user_id column has to have FK, but not object_id'); + self::assertCount(1, $foreignKeys, 'user_id column has to have FK, but not object_id'); $fk = reset($foreignKeys); assert($fk instanceof ForeignKeyConstraint); - $this->assertEquals('users', $fk->getForeignTableName()); + self::assertEquals('users', $fk->getForeignTableName()); $localColumns = $fk->getLocalColumns(); - $this->assertContains('user_id', $localColumns); - $this->assertCount(1, $localColumns); + self::assertContains('user_id', $localColumns); + self::assertCount(1, $localColumns); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2175Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2175Test.php index 711fa39ff16..b6240a60ead 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2175Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2175Test.php @@ -35,17 +35,17 @@ public function testIssue(): void $this->_em->persist($entity); $this->_em->flush(); - $this->assertEquals(1, $entity->version); + self::assertEquals(1, $entity->version); $entity->field = 'bar'; $this->_em->flush(); - $this->assertEquals(2, $entity->version); + self::assertEquals(2, $entity->version); $entity->field = 'baz'; $this->_em->flush(); - $this->assertEquals(3, $entity->version); + self::assertEquals(3, $entity->version); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2182Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2182Test.php index 79f9d54d8b5..c3b471f1361 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2182Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2182Test.php @@ -20,7 +20,7 @@ class DDC2182Test extends OrmFunctionalTestCase public function testPassColumnOptionsToJoinColumns(): void { if ($this->_em->getConnection()->getDatabasePlatform()->getName() !== 'mysql') { - $this->markTestSkipped('This test is useful for all databases, but designed only for mysql.'); + self::markTestSkipped('This test is useful for all databases, but designed only for mysql.'); } $sql = $this->_schemaTool->getCreateSchemaSql( @@ -31,9 +31,9 @@ public function testPassColumnOptionsToJoinColumns(): void ); $collation = $this->getColumnCollationDeclarationSQL('utf8_unicode_ci'); - $this->assertEquals('CREATE TABLE DDC2182OptionParent (id INT UNSIGNED NOT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 ' . $collation . ' ENGINE = InnoDB', $sql[0]); - $this->assertEquals('CREATE TABLE DDC2182OptionChild (id VARCHAR(255) NOT NULL, parent_id INT UNSIGNED DEFAULT NULL, INDEX IDX_B314D4AD727ACA70 (parent_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 ' . $collation . ' ENGINE = InnoDB', $sql[1]); - $this->assertEquals('ALTER TABLE DDC2182OptionChild ADD CONSTRAINT FK_B314D4AD727ACA70 FOREIGN KEY (parent_id) REFERENCES DDC2182OptionParent (id)', $sql[2]); + self::assertEquals('CREATE TABLE DDC2182OptionParent (id INT UNSIGNED NOT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 ' . $collation . ' ENGINE = InnoDB', $sql[0]); + self::assertEquals('CREATE TABLE DDC2182OptionChild (id VARCHAR(255) NOT NULL, parent_id INT UNSIGNED DEFAULT NULL, INDEX IDX_B314D4AD727ACA70 (parent_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 ' . $collation . ' ENGINE = InnoDB', $sql[1]); + self::assertEquals('ALTER TABLE DDC2182OptionChild ADD CONSTRAINT FK_B314D4AD727ACA70 FOREIGN KEY (parent_id) REFERENCES DDC2182OptionParent (id)', $sql[2]); } private function getColumnCollationDeclarationSQL(string $collation): string diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2214Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2214Test.php index 5cd0dcb60cc..24f2d427f9b 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2214Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2214Test.php @@ -62,7 +62,7 @@ public function testIssue(): void $query = end($logger->queries); - $this->assertEquals(Connection::PARAM_INT_ARRAY, $query['types'][0]); + self::assertEquals(Connection::PARAM_INT_ARRAY, $query['types'][0]); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2224Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2224Test.php index ee1dbcfb4f9..77e311d4c37 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2224Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2224Test.php @@ -34,7 +34,7 @@ public function testIssue(): Query $query->setQueryCacheDriver(DoctrineProvider::wrap(new ArrayAdapter())); $query->setParameter('field', 'test', 'DDC2224Type'); - $this->assertStringEndsWith('.field = FUNCTION(?)', $query->getSQL()); + self::assertStringEndsWith('.field = FUNCTION(?)', $query->getSQL()); return $query; } @@ -45,7 +45,7 @@ public function testIssue(): Query public function testCacheMissWhenTypeChanges(Query $query): void { $query->setParameter('field', 'test', 'string'); - $this->assertStringEndsWith('.field = ?', $query->getSQL()); + self::assertStringEndsWith('.field = ?', $query->getSQL()); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2230Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2230Test.php index 17025923fd8..c8025dc6dc6 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2230Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2230Test.php @@ -57,8 +57,8 @@ public function testNotifyTrackingNotCalledOnUninitializedProxies(): void $address = $mergedUser->address; assert($address instanceof Proxy); - $this->assertInstanceOf(Proxy::class, $address); - $this->assertFalse($address->__isInitialized()); + self::assertInstanceOf(Proxy::class, $address); + self::assertFalse($address->__isInitialized()); } public function testNotifyTrackingCalledOnProxyInitialization(): void @@ -72,12 +72,12 @@ public function testNotifyTrackingCalledOnProxyInitialization(): void $addressProxy = $this->_em->getReference(DDC2230Address::class, $insertedAddress->id); assert($addressProxy instanceof Proxy || $addressProxy instanceof DDC2230Address); - $this->assertFalse($addressProxy->__isInitialized()); - $this->assertNull($addressProxy->listener); + self::assertFalse($addressProxy->__isInitialized()); + self::assertNull($addressProxy->listener); $addressProxy->__load(); - $this->assertSame($this->_em->getUnitOfWork(), $addressProxy->listener); + self::assertSame($this->_em->getUnitOfWork(), $addressProxy->listener); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2231Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2231Test.php index 6cf8b76504e..d1037adee2b 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2231Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2231Test.php @@ -43,13 +43,13 @@ public function testInjectObjectManagerInProxyIfInitializedInUow(): void $y1ref = $this->_em->getReference(get_class($y1), $y1->id); - $this->assertInstanceOf(Proxy::class, $y1ref); - $this->assertFalse($y1ref->__isInitialized__); + self::assertInstanceOf(Proxy::class, $y1ref); + self::assertFalse($y1ref->__isInitialized__); $id = $y1ref->doSomething(); - $this->assertTrue($y1ref->__isInitialized__); - $this->assertEquals($this->_em, $y1ref->om); + self::assertTrue($y1ref->__isInitialized__); + self::assertEquals($this->_em, $y1ref->om); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2252Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2252Test.php index 56b7d3e80b7..3fa9b6488ef 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2252Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2252Test.php @@ -87,8 +87,8 @@ public function testIssue(): void $membership = $this->_em->find(DDC2252Membership::class, $identifier); - $this->assertInstanceOf(DDC2252Membership::class, $membership); - $this->assertCount(3, $membership->getPrivileges()); + self::assertInstanceOf(DDC2252Membership::class, $membership); + self::assertCount(3, $membership->getPrivileges()); $membership->getPrivileges()->remove(2); $this->_em->persist($membership); @@ -97,8 +97,8 @@ public function testIssue(): void $membership = $this->_em->find(DDC2252Membership::class, $identifier); - $this->assertInstanceOf(DDC2252Membership::class, $membership); - $this->assertCount(2, $membership->getPrivileges()); + self::assertInstanceOf(DDC2252Membership::class, $membership); + self::assertCount(2, $membership->getPrivileges()); $membership->getPrivileges()->clear(); $this->_em->persist($membership); @@ -107,8 +107,8 @@ public function testIssue(): void $membership = $this->_em->find(DDC2252Membership::class, $identifier); - $this->assertInstanceOf(DDC2252Membership::class, $membership); - $this->assertCount(0, $membership->getPrivileges()); + self::assertInstanceOf(DDC2252Membership::class, $membership); + self::assertCount(0, $membership->getPrivileges()); $membership->addPrivilege($privilege3 = new DDC2252Privilege()); $this->_em->persist($privilege3); @@ -118,8 +118,8 @@ public function testIssue(): void $membership = $this->_em->find(DDC2252Membership::class, $identifier); - $this->assertInstanceOf(DDC2252Membership::class, $membership); - $this->assertCount(1, $membership->getPrivileges()); + self::assertInstanceOf(DDC2252Membership::class, $membership); + self::assertCount(1, $membership->getPrivileges()); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2306Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2306Test.php index 43c81aa5803..53b51bebde6 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2306Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2306Test.php @@ -69,16 +69,16 @@ public function testIssue(): void $user = $address->users->first()->user; assert($user instanceof DDC2306User || $user instanceof Proxy); - $this->assertInstanceOf(Proxy::class, $user); - $this->assertInstanceOf(DDC2306User::class, $user); + self::assertInstanceOf(Proxy::class, $user); + self::assertInstanceOf(DDC2306User::class, $user); $userId = $user->id; - $this->assertNotNull($userId); + self::assertNotNull($userId); $user->__load(); - $this->assertEquals( + self::assertEquals( $userId, $user->id, 'As of DDC-1734, the identifier is NULL for un-managed proxies. The identifier should be an integer here' diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2346Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2346Test.php index 43e1d41ef1c..9b3402c0b1d 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2346Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2346Test.php @@ -70,8 +70,8 @@ public function testIssue(): void $fetchedBazs = $this->_em->getRepository(DDC2346Baz::class)->findAll(); - $this->assertCount(2, $fetchedBazs); - $this->assertCount(2, $this->logger->queries, 'The total number of executed queries is 2, and not n+1'); + self::assertCount(2, $fetchedBazs); + self::assertCount(2, $this->logger->queries, 'The total number of executed queries is 2, and not n+1'); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2350Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2350Test.php index e4e337700b9..44e32d5553b 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2350Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2350Test.php @@ -51,11 +51,11 @@ public function testEagerCollectionsAreOnlyRetrievedOnce(): void $cnt = $this->getCurrentQueryCount(); $user = $this->_em->find(DDC2350User::class, $user->id); - $this->assertEquals($cnt + 1, $this->getCurrentQueryCount()); + self::assertEquals($cnt + 1, $this->getCurrentQueryCount()); - $this->assertEquals(2, count($user->reportedBugs)); + self::assertEquals(2, count($user->reportedBugs)); - $this->assertEquals($cnt + 1, $this->getCurrentQueryCount()); + self::assertEquals($cnt + 1, $this->getCurrentQueryCount()); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2359Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2359Test.php index 8ec7fd05391..db23318b16e 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2359Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2359Test.php @@ -47,23 +47,23 @@ public function testIssue(): void $connection = $this->createMock(Connection::class); $configuration - ->expects($this->any()) + ->expects(self::any()) ->method('getMetadataDriverImpl') - ->will($this->returnValue($mockDriver)); + ->will(self::returnValue($mockDriver)); - $entityManager->expects($this->any())->method('getConfiguration')->will($this->returnValue($configuration)); - $entityManager->expects($this->any())->method('getConnection')->will($this->returnValue($connection)); + $entityManager->expects(self::any())->method('getConfiguration')->will(self::returnValue($configuration)); + $entityManager->expects(self::any())->method('getConnection')->will(self::returnValue($connection)); $entityManager - ->expects($this->any()) + ->expects(self::any()) ->method('getEventManager') - ->will($this->returnValue($this->createMock(EventManager::class))); + ->will(self::returnValue($this->createMock(EventManager::class))); - $metadataFactory->expects($this->any())->method('newClassMetadataInstance')->will($this->returnValue($mockMetadata)); - $metadataFactory->expects($this->once())->method('wakeupReflection'); + $metadataFactory->expects(self::any())->method('newClassMetadataInstance')->will(self::returnValue($mockMetadata)); + $metadataFactory->expects(self::once())->method('wakeupReflection'); $metadataFactory->setEntityManager($entityManager); - $this->assertSame($mockMetadata, $metadataFactory->getMetadataFor(DDC2359Foo::class)); + self::assertSame($mockMetadata, $metadataFactory->getMetadataFor(DDC2359Foo::class)); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC237Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC237Test.php index 5a5799241a8..d11ed2d0b42 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC237Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC237Test.php @@ -51,26 +51,26 @@ public function testUninitializedProxyIsInitializedOnFetchJoin(): void $this->_em->clear(); $x2 = $this->_em->find(get_class($x), $x->id); // proxy injected for Y - $this->assertInstanceOf(Proxy::class, $x2->y); - $this->assertFalse($x2->y->__isInitialized__); + self::assertInstanceOf(Proxy::class, $x2->y); + self::assertFalse($x2->y->__isInitialized__); // proxy for Y is in identity map $z2 = $this->_em->createQuery('select z,y from ' . get_class($z) . ' z join z.y y where z.id = ?1') ->setParameter(1, $z->id) ->getSingleResult(); - $this->assertInstanceOf(Proxy::class, $z2->y); - $this->assertTrue($z2->y->__isInitialized__); - $this->assertEquals('Y', $z2->y->data); - $this->assertEquals($y->id, $z2->y->id); + self::assertInstanceOf(Proxy::class, $z2->y); + self::assertTrue($z2->y->__isInitialized__); + self::assertEquals('Y', $z2->y->data); + self::assertEquals($y->id, $z2->y->id); // since the Y is the same, the instance from the identity map is // used, even if it is a proxy. - $this->assertNotSame($x, $x2); - $this->assertNotSame($z, $z2); - $this->assertSame($z2->y, $x2->y); - $this->assertInstanceOf(Proxy::class, $z2->y); + self::assertNotSame($x, $x2); + self::assertNotSame($z, $z2); + self::assertSame($z2->y, $x2->y); + self::assertInstanceOf(Proxy::class, $z2->y); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2387Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2387Test.php index 719ed49e14a..8ac3c3c4f31 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2387Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2387Test.php @@ -27,7 +27,7 @@ public function testCompositeAssociationKeyDetection(): void $metadata = $this->convertToClassMetadata([$product, $attributes], []); - $this->assertEquals(ClassMetadataInfo::GENERATOR_TYPE_NONE, $metadata['Ddc2387Attributes']->generatorType); - $this->assertEquals(ClassMetadataInfo::GENERATOR_TYPE_AUTO, $metadata['Ddc2387Product']->generatorType); + self::assertEquals(ClassMetadataInfo::GENERATOR_TYPE_NONE, $metadata['Ddc2387Attributes']->generatorType); + self::assertEquals(ClassMetadataInfo::GENERATOR_TYPE_AUTO, $metadata['Ddc2387Product']->generatorType); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2409Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2409Test.php index f8443b7c189..ee9b654fcd1 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2409Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2409Test.php @@ -51,10 +51,10 @@ public function testIssue(): void $article->setAuthor($user); - $this->assertEquals(UnitOfWork::STATE_DETACHED, $uow->getEntityState($originalArticle)); - $this->assertEquals(UnitOfWork::STATE_DETACHED, $uow->getEntityState($originalUser)); - $this->assertEquals(UnitOfWork::STATE_MANAGED, $uow->getEntityState($article)); - $this->assertEquals(UnitOfWork::STATE_NEW, $uow->getEntityState($user)); + self::assertEquals(UnitOfWork::STATE_DETACHED, $uow->getEntityState($originalArticle)); + self::assertEquals(UnitOfWork::STATE_DETACHED, $uow->getEntityState($originalUser)); + self::assertEquals(UnitOfWork::STATE_MANAGED, $uow->getEntityState($article)); + self::assertEquals(UnitOfWork::STATE_NEW, $uow->getEntityState($user)); $em->clear(CmsUser::class); $em->clear(CmsArticle::class); @@ -62,14 +62,14 @@ public function testIssue(): void $userMerged = $em->merge($user); $articleMerged = $em->merge($article); - $this->assertEquals(UnitOfWork::STATE_NEW, $uow->getEntityState($user)); - $this->assertEquals(UnitOfWork::STATE_DETACHED, $uow->getEntityState($article)); - $this->assertEquals(UnitOfWork::STATE_MANAGED, $uow->getEntityState($userMerged)); - $this->assertEquals(UnitOfWork::STATE_MANAGED, $uow->getEntityState($articleMerged)); + self::assertEquals(UnitOfWork::STATE_NEW, $uow->getEntityState($user)); + self::assertEquals(UnitOfWork::STATE_DETACHED, $uow->getEntityState($article)); + self::assertEquals(UnitOfWork::STATE_MANAGED, $uow->getEntityState($userMerged)); + self::assertEquals(UnitOfWork::STATE_MANAGED, $uow->getEntityState($articleMerged)); - $this->assertNotSame($user, $userMerged); - $this->assertNotSame($article, $articleMerged); - $this->assertNotSame($userMerged, $articleMerged->user); - $this->assertSame($user, $articleMerged->user); + self::assertNotSame($user, $userMerged); + self::assertNotSame($article, $articleMerged); + self::assertNotSame($userMerged, $articleMerged->user); + self::assertSame($user, $articleMerged->user); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2415Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2415Test.php index 6773ed4c3b5..0c74c1fe92c 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2415Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2415Test.php @@ -36,9 +36,9 @@ public function testTicket(): void $parentMetadata = $this->_em->getClassMetadata(DDC2415ParentEntity::class); $childMetadata = $this->_em->getClassMetadata(DDC2415ChildEntity::class); - $this->assertEquals($parentMetadata->generatorType, $childMetadata->generatorType); - $this->assertEquals($parentMetadata->customGeneratorDefinition, $childMetadata->customGeneratorDefinition); - $this->assertEquals(DDC2415Generator::class, $parentMetadata->customGeneratorDefinition['class']); + self::assertEquals($parentMetadata->generatorType, $childMetadata->generatorType); + self::assertEquals($parentMetadata->customGeneratorDefinition, $childMetadata->customGeneratorDefinition); + self::assertEquals(DDC2415Generator::class, $parentMetadata->customGeneratorDefinition['class']); $e1 = new DDC2415ChildEntity('ChildEntity 1'); $e2 = new DDC2415ChildEntity('ChildEntity 2'); @@ -48,8 +48,8 @@ public function testTicket(): void $this->_em->flush(); $this->_em->clear(); - $this->assertEquals(md5($e1->getName()), $e1->getId()); - $this->assertEquals(md5($e2->getName()), $e2->getId()); + self::assertEquals(md5($e1->getName()), $e1->getId()); + self::assertEquals(md5($e2->getName()), $e2->getId()); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2494Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2494Test.php index b0e1f244139..ecf0c9b4408 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2494Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2494Test.php @@ -52,33 +52,33 @@ public function testIssue(): void $this->_em->flush(); $this->_em->close(); - $this->assertArrayHasKey('convertToDatabaseValue', DDC2494TinyIntType::$calls); - $this->assertCount(3, DDC2494TinyIntType::$calls['convertToDatabaseValue']); + self::assertArrayHasKey('convertToDatabaseValue', DDC2494TinyIntType::$calls); + self::assertCount(3, DDC2494TinyIntType::$calls['convertToDatabaseValue']); $item = $this->_em->find(DDC2494Campaign::class, $campaign->getId()); - $this->assertInstanceOf(DDC2494Campaign::class, $item); - $this->assertInstanceOf(DDC2494Currency::class, $item->getCurrency()); + self::assertInstanceOf(DDC2494Campaign::class, $item); + self::assertInstanceOf(DDC2494Currency::class, $item->getCurrency()); $queryCount = $this->getCurrentQueryCount(); - $this->assertInstanceOf('\Doctrine\Common\Proxy\Proxy', $item->getCurrency()); - $this->assertFalse($item->getCurrency()->__isInitialized()); + self::assertInstanceOf('\Doctrine\Common\Proxy\Proxy', $item->getCurrency()); + self::assertFalse($item->getCurrency()->__isInitialized()); - $this->assertArrayHasKey('convertToPHPValue', DDC2494TinyIntType::$calls); - $this->assertCount(1, DDC2494TinyIntType::$calls['convertToPHPValue']); + self::assertArrayHasKey('convertToPHPValue', DDC2494TinyIntType::$calls); + self::assertCount(1, DDC2494TinyIntType::$calls['convertToPHPValue']); - $this->assertIsInt($item->getCurrency()->getId()); - $this->assertCount(1, DDC2494TinyIntType::$calls['convertToPHPValue']); - $this->assertFalse($item->getCurrency()->__isInitialized()); + self::assertIsInt($item->getCurrency()->getId()); + self::assertCount(1, DDC2494TinyIntType::$calls['convertToPHPValue']); + self::assertFalse($item->getCurrency()->__isInitialized()); - $this->assertEquals($queryCount, $this->getCurrentQueryCount()); + self::assertEquals($queryCount, $this->getCurrentQueryCount()); - $this->assertIsInt($item->getCurrency()->getTemp()); - $this->assertCount(3, DDC2494TinyIntType::$calls['convertToPHPValue']); - $this->assertTrue($item->getCurrency()->__isInitialized()); + self::assertIsInt($item->getCurrency()->getTemp()); + self::assertCount(3, DDC2494TinyIntType::$calls['convertToPHPValue']); + self::assertTrue($item->getCurrency()->__isInitialized()); - $this->assertEquals($queryCount + 1, $this->getCurrentQueryCount()); + self::assertEquals($queryCount + 1, $this->getCurrentQueryCount()); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2519Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2519Test.php index 1fddd12bb9b..0af5d161883 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2519Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2519Test.php @@ -30,29 +30,29 @@ public function testIssue(): void $dql = 'SELECT PARTIAL l.{_source, _target} FROM Doctrine\Tests\Models\Legacy\LegacyUserReference l'; $result = $this->_em->createQuery($dql)->getResult(); - $this->assertCount(2, $result); - $this->assertInstanceOf(LegacyUserReference::class, $result[0]); - $this->assertInstanceOf(LegacyUserReference::class, $result[1]); - - $this->assertInstanceOf(LegacyUser::class, $result[0]->source()); - $this->assertInstanceOf(LegacyUser::class, $result[0]->target()); - $this->assertInstanceOf(LegacyUser::class, $result[1]->source()); - $this->assertInstanceOf(LegacyUser::class, $result[1]->target()); - - $this->assertInstanceOf(Proxy::class, $result[0]->source()); - $this->assertInstanceOf(Proxy::class, $result[0]->target()); - $this->assertInstanceOf(Proxy::class, $result[1]->source()); - $this->assertInstanceOf(Proxy::class, $result[1]->target()); - - $this->assertFalse($result[0]->target()->__isInitialized()); - $this->assertFalse($result[0]->source()->__isInitialized()); - $this->assertFalse($result[1]->target()->__isInitialized()); - $this->assertFalse($result[1]->source()->__isInitialized()); - - $this->assertNotNull($result[0]->source()->getId()); - $this->assertNotNull($result[0]->target()->getId()); - $this->assertNotNull($result[1]->source()->getId()); - $this->assertNotNull($result[1]->target()->getId()); + self::assertCount(2, $result); + self::assertInstanceOf(LegacyUserReference::class, $result[0]); + self::assertInstanceOf(LegacyUserReference::class, $result[1]); + + self::assertInstanceOf(LegacyUser::class, $result[0]->source()); + self::assertInstanceOf(LegacyUser::class, $result[0]->target()); + self::assertInstanceOf(LegacyUser::class, $result[1]->source()); + self::assertInstanceOf(LegacyUser::class, $result[1]->target()); + + self::assertInstanceOf(Proxy::class, $result[0]->source()); + self::assertInstanceOf(Proxy::class, $result[0]->target()); + self::assertInstanceOf(Proxy::class, $result[1]->source()); + self::assertInstanceOf(Proxy::class, $result[1]->target()); + + self::assertFalse($result[0]->target()->__isInitialized()); + self::assertFalse($result[0]->source()->__isInitialized()); + self::assertFalse($result[1]->target()->__isInitialized()); + self::assertFalse($result[1]->source()->__isInitialized()); + + self::assertNotNull($result[0]->source()->getId()); + self::assertNotNull($result[0]->target()->getId()); + self::assertNotNull($result[1]->source()->getId()); + self::assertNotNull($result[1]->target()->getId()); } public function loadFixture(): void diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2575Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2575Test.php index b6b46c05d6b..762704d232b 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2575Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2575Test.php @@ -79,23 +79,23 @@ public function testHydrationIssue(): void $query = $qb->getQuery(); $result = $query->getResult(); - $this->assertCount(2, $result); + self::assertCount(2, $result); $row = $result[0]; - $this->assertNotNull($row->aRelation); - $this->assertEquals(1, $row->id); - $this->assertNotNull($row->aRelation->rootRelation); - $this->assertSame($row, $row->aRelation->rootRelation); - $this->assertNotNull($row->aRelation->bRelation); - $this->assertEquals(2, $row->aRelation->bRelation->id); + self::assertNotNull($row->aRelation); + self::assertEquals(1, $row->id); + self::assertNotNull($row->aRelation->rootRelation); + self::assertSame($row, $row->aRelation->rootRelation); + self::assertNotNull($row->aRelation->bRelation); + self::assertEquals(2, $row->aRelation->bRelation->id); $row = $result[1]; - $this->assertNotNull($row->aRelation); - $this->assertEquals(3, $row->id); - $this->assertNotNull($row->aRelation->rootRelation); - $this->assertSame($row, $row->aRelation->rootRelation); - $this->assertNotNull($row->aRelation->bRelation); - $this->assertEquals(4, $row->aRelation->bRelation->id); + self::assertNotNull($row->aRelation); + self::assertEquals(3, $row->id); + self::assertNotNull($row->aRelation->rootRelation); + self::assertSame($row, $row->aRelation->rootRelation); + self::assertNotNull($row->aRelation->bRelation); + self::assertEquals(4, $row->aRelation->bRelation->id); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2579Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2579Test.php index 209c87bda11..053680fbe86 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2579Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2579Test.php @@ -58,15 +58,15 @@ public function testIssue(): void $criteria = ['assoc' => $assoc, 'id' => $id]; $entity = $repository->findOneBy($criteria); - $this->assertInstanceOf(DDC2579Entity::class, $entity); - $this->assertEquals($value, $entity->value); + self::assertInstanceOf(DDC2579Entity::class, $entity); + self::assertEquals($value, $entity->value); $this->_em->remove($entity); $this->_em->flush(); $this->_em->clear(); - $this->assertNull($repository->findOneBy($criteria)); - $this->assertCount(0, $repository->findAll()); + self::assertNull($repository->findOneBy($criteria)); + self::assertCount(0, $repository->findAll()); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC258Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC258Test.php index 753f090fabf..2159d6aeeb8 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC258Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC258Test.php @@ -57,27 +57,27 @@ public function testIssue(): void $e2 = $this->_em->find(DDC258Super::class, $c2->id); - $this->assertInstanceOf(DDC258Class2::class, $e2); - $this->assertEquals('Bar', $e2->title); - $this->assertEquals('Bar', $e2->description); - $this->assertEquals('Bar', $e2->text); + self::assertInstanceOf(DDC258Class2::class, $e2); + self::assertEquals('Bar', $e2->title); + self::assertEquals('Bar', $e2->description); + self::assertEquals('Bar', $e2->text); $all = $this->_em->getRepository(DDC258Super::class)->findAll(); foreach ($all as $obj) { if ($obj instanceof DDC258Class1) { - $this->assertEquals('Foo', $obj->title); - $this->assertEquals('Foo', $obj->description); + self::assertEquals('Foo', $obj->title); + self::assertEquals('Foo', $obj->description); } elseif ($obj instanceof DDC258Class2) { - $this->assertTrue($e2 === $obj); - $this->assertEquals('Bar', $obj->title); - $this->assertEquals('Bar', $obj->description); - $this->assertEquals('Bar', $obj->text); + self::assertTrue($e2 === $obj); + self::assertEquals('Bar', $obj->title); + self::assertEquals('Bar', $obj->description); + self::assertEquals('Bar', $obj->text); } elseif ($obj instanceof DDC258Class3) { - $this->assertEquals('Baz', $obj->apples); - $this->assertEquals('Baz', $obj->bananas); + self::assertEquals('Baz', $obj->apples); + self::assertEquals('Baz', $obj->bananas); } else { - $this->fail('Instance of DDC258Class1, DDC258Class2 or DDC258Class3 expected.'); + self::fail('Instance of DDC258Class1, DDC258Class2 or DDC258Class3 expected.'); } } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2645Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2645Test.php index 992d8c648f4..4e12ee95fe5 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2645Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2645Test.php @@ -29,8 +29,8 @@ public function testIssue(): void $foo3 = $this->_em->merge($foo2); - $this->assertSame($foo, $foo3); - $this->assertEquals('Bar', $foo->name); + self::assertSame($foo, $foo3); + self::assertEquals('Bar', $foo->name); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2655Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2655Test.php index 382aec669f0..05d0e8e7c42 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2655Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2655Test.php @@ -21,6 +21,6 @@ protected function setUp(): void public function testSingleScalarOneOrNullResult(): void { $query = $this->_em->createQuery("SELECT u.name FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.username = 'happy_doctrine_user'"); - $this->assertNull($query->getOneOrNullResult(Query::HYDRATE_SINGLE_SCALAR)); + self::assertNull($query->getOneOrNullResult(Query::HYDRATE_SINGLE_SCALAR)); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2660Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2660Test.php index af632081b46..fd7a162fd01 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2660Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2660Test.php @@ -61,11 +61,11 @@ public function testIssueWithExtraColumn(): void $query = $this->_em->createNativeQuery($sql, $rsm); $result = $query->getResult(); - $this->assertCount(5, $result); + self::assertCount(5, $result); foreach ($result as $order) { - $this->assertNotNull($order); - $this->assertInstanceOf(DDC2660CustomerOrder::class, $order); + self::assertNotNull($order); + self::assertInstanceOf(DDC2660CustomerOrder::class, $order); } } @@ -79,11 +79,11 @@ public function testIssueWithoutExtraColumn(): void $query = $this->_em->createNativeQuery($sql, $rsm); $result = $query->getResult(); - $this->assertCount(5, $result); + self::assertCount(5, $result); foreach ($result as $order) { - $this->assertNotNull($order); - $this->assertInstanceOf(DDC2660CustomerOrder::class, $order); + self::assertNotNull($order); + self::assertInstanceOf(DDC2660CustomerOrder::class, $order); } } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2692Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2692Test.php index 2dcc7ff2254..75a2a8526a0 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2692Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2692Test.php @@ -43,7 +43,7 @@ public function testIsListenerCalledOnlyOnceOnPreFlush(): void ->setMethods(['preFlush']) ->getMock(); - $listener->expects($this->once())->method('preFlush'); + $listener->expects(self::once())->method('preFlush'); $this->_em->getEventManager()->addEventSubscriber($listener); diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2759Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2759Test.php index 23437afa791..9582cd6c10f 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2759Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2759Test.php @@ -72,7 +72,7 @@ public function testCorrectNumberOfAssociationsIsReturned(): void $result = $builder->getQuery() ->getArrayResult(); - $this->assertCount(2, $result[0]['metadata']['metadataCategories']); + self::assertCount(2, $result[0]['metadata']['metadataCategories']); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2780Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2780Test.php index 3ff6eda8911..0c8a2166489 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2780Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2780Test.php @@ -53,7 +53,7 @@ public function testIssue(): void ->getQuery() ->getOneOrNullResult(); - $this->assertInstanceOf(DDC2780User::class, $result); + self::assertInstanceOf(DDC2780User::class, $result); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2790Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2790Test.php index e6a358429f7..abf958b1e99 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2790Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2790Test.php @@ -55,7 +55,7 @@ public function testIssue(): void $qb->from(get_class($entity), 'c'); $qb->select('count(c)'); $count = intval($qb->getQuery()->getSingleScalarResult()); - $this->assertEquals($initial, $count); + self::assertEquals($initial, $count); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC279Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC279Test.php index 50713d453a4..298b076edee 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC279Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC279Test.php @@ -65,10 +65,10 @@ public function testDDC279(): void $expected1 = 'Y'; $expected2 = 'Z'; - $this->assertEquals(1, count($result)); + self::assertEquals(1, count($result)); - $this->assertEquals($expected1, $result[0]->y->data); - $this->assertEquals($expected2, $result[0]->y->z->data); + self::assertEquals($expected1, $result[0]->y->data); + self::assertEquals($expected2, $result[0]->y->z->data); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2825Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2825Test.php index c1679020df0..e1b1f079630 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2825Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2825Test.php @@ -31,7 +31,7 @@ protected function setUp(): void $platform = $this->_em->getConnection()->getDatabasePlatform(); if (! $platform->supportsSchemas() && ! $platform->canEmulateSchemas()) { - $this->markTestSkipped('This test is only useful for databases that support schemas or can emulate them.'); + self::markTestSkipped('This test is only useful for databases that support schemas or can emulate them.'); } } @@ -45,8 +45,8 @@ public function testClassSchemaMappingsValidity(string $className, string $expec $quotedTableName = $this->_em->getConfiguration()->getQuoteStrategy()->getTableName($classMetadata, $platform); // Check if table name and schema properties are defined in the class metadata - $this->assertEquals($expectedTableName, $classMetadata->table['name']); - $this->assertEquals($expectedSchemaName, $classMetadata->table['schema']); + self::assertEquals($expectedTableName, $classMetadata->table['name']); + self::assertEquals($expectedSchemaName, $classMetadata->table['schema']); if ($this->_em->getConnection()->getDatabasePlatform()->supportsSchemas()) { $fullTableName = sprintf('%s.%s', $expectedSchemaName, $expectedTableName); @@ -54,10 +54,10 @@ public function testClassSchemaMappingsValidity(string $className, string $expec $fullTableName = sprintf('%s__%s', $expectedSchemaName, $expectedTableName); } - $this->assertEquals($fullTableName, $quotedTableName); + self::assertEquals($fullTableName, $quotedTableName); // Checks sequence name validity - $this->assertEquals( + self::assertEquals( $fullTableName . '_' . $classMetadata->getSingleIdentifierColumnName() . '_seq', $classMetadata->getSequenceName($platform) ); @@ -78,7 +78,7 @@ public function testPersistenceOfEntityWithSchemaMapping(string $className): voi $this->_em->flush(); $this->_em->clear(); - $this->assertCount(1, $this->_em->getRepository($className)->findAll()); + self::assertCount(1, $this->_em->getRepository($className)->findAll()); } /** diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2862Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2862Test.php index 9d48289b3c1..12ad31c2966 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2862Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2862Test.php @@ -46,32 +46,32 @@ public function testIssue(): void $this->_em->flush(); $this->_em->clear(); - $this->assertTrue($this->_em->getCache()->containsEntity(DDC2862User::class, ['id' => $user1->getId()])); - $this->assertTrue($this->_em->getCache()->containsEntity(DDC2862Driver::class, ['id' => $driver1->getId()])); + self::assertTrue($this->_em->getCache()->containsEntity(DDC2862User::class, ['id' => $user1->getId()])); + self::assertTrue($this->_em->getCache()->containsEntity(DDC2862Driver::class, ['id' => $driver1->getId()])); $queryCount = $this->getCurrentQueryCount(); $driver2 = $this->_em->find(DDC2862Driver::class, $driver1->getId()); - $this->assertEquals($queryCount, $this->getCurrentQueryCount()); - $this->assertInstanceOf(DDC2862Driver::class, $driver2); - $this->assertInstanceOf(DDC2862User::class, $driver2->getUserProfile()); + self::assertEquals($queryCount, $this->getCurrentQueryCount()); + self::assertInstanceOf(DDC2862Driver::class, $driver2); + self::assertInstanceOf(DDC2862User::class, $driver2->getUserProfile()); $driver2->setName('Franta'); $this->_em->flush(); $this->_em->clear(); - $this->assertTrue($this->_em->getCache()->containsEntity(DDC2862User::class, ['id' => $user1->getId()])); - $this->assertTrue($this->_em->getCache()->containsEntity(DDC2862Driver::class, ['id' => $driver1->getId()])); + self::assertTrue($this->_em->getCache()->containsEntity(DDC2862User::class, ['id' => $user1->getId()])); + self::assertTrue($this->_em->getCache()->containsEntity(DDC2862Driver::class, ['id' => $driver1->getId()])); $queryCount = $this->getCurrentQueryCount(); $driver3 = $this->_em->find(DDC2862Driver::class, $driver1->getId()); - $this->assertEquals($queryCount, $this->getCurrentQueryCount()); - $this->assertInstanceOf(DDC2862Driver::class, $driver3); - $this->assertInstanceOf(DDC2862User::class, $driver3->getUserProfile()); - $this->assertEquals('Franta', $driver3->getName()); - $this->assertEquals('Foo', $driver3->getUserProfile()->getName()); + self::assertEquals($queryCount, $this->getCurrentQueryCount()); + self::assertInstanceOf(DDC2862Driver::class, $driver3); + self::assertInstanceOf(DDC2862User::class, $driver3->getUserProfile()); + self::assertEquals('Franta', $driver3->getName()); + self::assertEquals('Foo', $driver3->getUserProfile()->getName()); } public function testIssueReopened(): void @@ -87,38 +87,38 @@ public function testIssueReopened(): void $this->_em->getCache()->evictEntityRegion(DDC2862User::class); $this->_em->getCache()->evictEntityRegion(DDC2862Driver::class); - $this->assertFalse($this->_em->getCache()->containsEntity(DDC2862User::class, ['id' => $user1->getId()])); - $this->assertFalse($this->_em->getCache()->containsEntity(DDC2862Driver::class, ['id' => $driver1->getId()])); + self::assertFalse($this->_em->getCache()->containsEntity(DDC2862User::class, ['id' => $user1->getId()])); + self::assertFalse($this->_em->getCache()->containsEntity(DDC2862Driver::class, ['id' => $driver1->getId()])); $queryCount = $this->getCurrentQueryCount(); $driver2 = $this->_em->find(DDC2862Driver::class, $driver1->getId()); - $this->assertInstanceOf(DDC2862Driver::class, $driver2); - $this->assertInstanceOf(DDC2862User::class, $driver2->getUserProfile()); - $this->assertEquals($queryCount + 1, $this->getCurrentQueryCount()); + self::assertInstanceOf(DDC2862Driver::class, $driver2); + self::assertInstanceOf(DDC2862User::class, $driver2->getUserProfile()); + self::assertEquals($queryCount + 1, $this->getCurrentQueryCount()); $this->_em->clear(); - $this->assertFalse($this->_em->getCache()->containsEntity(DDC2862User::class, ['id' => $user1->getId()])); - $this->assertTrue($this->_em->getCache()->containsEntity(DDC2862Driver::class, ['id' => $driver1->getId()])); + self::assertFalse($this->_em->getCache()->containsEntity(DDC2862User::class, ['id' => $user1->getId()])); + self::assertTrue($this->_em->getCache()->containsEntity(DDC2862Driver::class, ['id' => $driver1->getId()])); $queryCount = $this->getCurrentQueryCount(); $driver3 = $this->_em->find(DDC2862Driver::class, $driver1->getId()); - $this->assertInstanceOf(DDC2862Driver::class, $driver3); - $this->assertInstanceOf(DDC2862User::class, $driver3->getUserProfile()); - $this->assertEquals($queryCount, $this->getCurrentQueryCount()); - $this->assertEquals('Foo', $driver3->getUserProfile()->getName()); - $this->assertEquals($queryCount + 1, $this->getCurrentQueryCount()); + self::assertInstanceOf(DDC2862Driver::class, $driver3); + self::assertInstanceOf(DDC2862User::class, $driver3->getUserProfile()); + self::assertEquals($queryCount, $this->getCurrentQueryCount()); + self::assertEquals('Foo', $driver3->getUserProfile()->getName()); + self::assertEquals($queryCount + 1, $this->getCurrentQueryCount()); $queryCount = $this->getCurrentQueryCount(); $driver4 = $this->_em->find(DDC2862Driver::class, $driver1->getId()); - $this->assertInstanceOf(DDC2862Driver::class, $driver4); - $this->assertInstanceOf(DDC2862User::class, $driver4->getUserProfile()); - $this->assertEquals($queryCount, $this->getCurrentQueryCount()); - $this->assertEquals('Foo', $driver4->getUserProfile()->getName()); - $this->assertEquals($queryCount, $this->getCurrentQueryCount()); + self::assertInstanceOf(DDC2862Driver::class, $driver4); + self::assertInstanceOf(DDC2862User::class, $driver4->getUserProfile()); + self::assertEquals($queryCount, $this->getCurrentQueryCount()); + self::assertEquals('Foo', $driver4->getUserProfile()->getName()); + self::assertEquals($queryCount, $this->getCurrentQueryCount()); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2895Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2895Test.php index 6095750f6c9..e6c3d0a296e 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2895Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2895Test.php @@ -38,7 +38,7 @@ public function testPostLoadOneToManyInheritance(): void { $cm = $this->_em->getClassMetadata(DDC2895::class); - $this->assertEquals( + self::assertEquals( [ 'prePersist' => ['setLastModifiedPreUpdate'], 'preUpdate' => ['setLastModifiedPreUpdate'], @@ -55,7 +55,7 @@ public function testPostLoadOneToManyInheritance(): void $ddc2895 = $this->_em->find(get_class($ddc2895), $ddc2895->id); assert($ddc2895 instanceof DDC2895); - $this->assertNotNull($ddc2895->getLastModified()); + self::assertNotNull($ddc2895->getLastModified()); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2931Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2931Test.php index fd51d97fb45..9d198a42aac 100755 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2931Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2931Test.php @@ -51,7 +51,7 @@ public function testIssue(): void $second = $this->_em->find(DDC2931User::class, $second->id); - $this->assertSame(2, $second->getRank()); + self::assertSame(2, $second->getRank()); } public function testFetchJoinedEntitiesCanBeRefreshed(): void @@ -87,10 +87,10 @@ public function testFetchJoinedEntitiesCanBeRefreshed(): void ->setHint(Query::HINT_REFRESH, true) ->getResult(); - $this->assertCount(1, $refreshedSecond); - $this->assertSame(1, $first->value); - $this->assertSame(2, $second->value); - $this->assertSame(3, $third->value); + self::assertCount(1, $refreshedSecond); + self::assertSame(1, $first->value); + self::assertSame(2, $second->value); + self::assertSame(3, $third->value); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2943Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2943Test.php index 65c87ea68c1..0d37fd55d2d 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2943Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2943Test.php @@ -71,23 +71,23 @@ public function testIssueNonFetchJoin(): void public function assertPaginatorQueryPut(Paginator $paginator, $regionName, $count, $pageSize): void { - $this->assertCount($count, $paginator); - $this->assertCount($pageSize, $paginator->getIterator()); + self::assertCount($count, $paginator); + self::assertCount($pageSize, $paginator->getIterator()); - $this->assertEquals(0, $this->secondLevelCacheLogger->getRegionHitCount(Cache::DEFAULT_QUERY_REGION_NAME)); - $this->assertEquals(1, $this->secondLevelCacheLogger->getRegionPutCount(Cache::DEFAULT_QUERY_REGION_NAME)); - $this->assertEquals(0, $this->secondLevelCacheLogger->getRegionHitCount($regionName)); - $this->assertEquals($count, $this->secondLevelCacheLogger->getRegionPutCount($regionName)); + self::assertEquals(0, $this->secondLevelCacheLogger->getRegionHitCount(Cache::DEFAULT_QUERY_REGION_NAME)); + self::assertEquals(1, $this->secondLevelCacheLogger->getRegionPutCount(Cache::DEFAULT_QUERY_REGION_NAME)); + self::assertEquals(0, $this->secondLevelCacheLogger->getRegionHitCount($regionName)); + self::assertEquals($count, $this->secondLevelCacheLogger->getRegionPutCount($regionName)); } public function assertPaginatorQueryHit(Paginator $paginator, $regionName, $count, $pageSize): void { - $this->assertCount($count, $paginator); - $this->assertCount($pageSize, $paginator->getIterator()); + self::assertCount($count, $paginator); + self::assertCount($pageSize, $paginator->getIterator()); - $this->assertEquals(1, $this->secondLevelCacheLogger->getRegionHitCount(Cache::DEFAULT_QUERY_REGION_NAME)); - $this->assertEquals(0, $this->secondLevelCacheLogger->getRegionPutCount(Cache::DEFAULT_QUERY_REGION_NAME)); - $this->assertEquals($pageSize, $this->secondLevelCacheLogger->getRegionHitCount($regionName)); - $this->assertEquals(0, $this->secondLevelCacheLogger->getRegionPutCount($regionName)); + self::assertEquals(1, $this->secondLevelCacheLogger->getRegionHitCount(Cache::DEFAULT_QUERY_REGION_NAME)); + self::assertEquals(0, $this->secondLevelCacheLogger->getRegionPutCount(Cache::DEFAULT_QUERY_REGION_NAME)); + self::assertEquals($pageSize, $this->secondLevelCacheLogger->getRegionHitCount($regionName)); + self::assertEquals(0, $this->secondLevelCacheLogger->getRegionPutCount($regionName)); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2984Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2984Test.php index 49c2262f06b..517dabfc565 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2984Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2984Test.php @@ -58,15 +58,15 @@ public function testIssue(): void $sameUser = $repository->find(new DDC2984DomainUserId('unique_id_within_a_vo')); //Until know, everything works as expected - $this->assertTrue($user->sameIdentityAs($sameUser)); + self::assertTrue($user->sameIdentityAs($sameUser)); $this->_em->clear(); //After clearing the identity map, the UnitOfWork produces the warning described in DDC-2984 $equalUser = $repository->find(new DDC2984DomainUserId('unique_id_within_a_vo')); - $this->assertNotSame($user, $equalUser); - $this->assertTrue($user->sameIdentityAs($equalUser)); + self::assertNotSame($user, $equalUser); + self::assertTrue($user->sameIdentityAs($equalUser)); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2996Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2996Test.php index 1f6ddf90d59..2b4029b8cec 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2996Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2996Test.php @@ -40,12 +40,12 @@ public function testIssue(): void $pref->value = 'bar'; $this->_em->flush(); - $this->assertEquals(1, $pref->user->counter); + self::assertEquals(1, $pref->user->counter); $this->_em->clear(); $pref = $this->_em->find(DDC2996UserPreference::class, $pref->id); - $this->assertEquals(1, $pref->user->counter); + self::assertEquals(1, $pref->user->counter); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3033Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3033Test.php index a9f50263f53..be272389fe2 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3033Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3033Test.php @@ -65,7 +65,7 @@ public function testIssue(): void ], ]; - $this->assertEquals($expect, $product->changeSet); + self::assertEquals($expect, $product->changeSet); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3042Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3042Test.php index e835a30a67a..99597727105 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3042Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3042Test.php @@ -29,7 +29,7 @@ protected function setUp(): void public function testSQLGenerationDoesNotProvokeAliasCollisions(): void { - $this->assertStringNotMatchesFormat( + self::assertStringNotMatchesFormat( '%sfield11%sfield11%s', $this ->_em diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3068Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3068Test.php index 3587100d186..cfa5570f626 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3068Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3068Test.php @@ -49,14 +49,14 @@ public function testFindUsingAnArrayOfObjectAsPrimaryKey(): void 'car' => $this->merc->getBrand(), ]); - $this->assertInstanceOf(Ride::class, $ride1); + self::assertInstanceOf(Ride::class, $ride1); $ride2 = $this->_em->find(Ride::class, [ 'driver' => $this->foo, 'car' => $this->merc, ]); - $this->assertInstanceOf(Ride::class, $ride2); - $this->assertSame($ride1, $ride2); + self::assertInstanceOf(Ride::class, $ride2); + self::assertSame($ride1, $ride2); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC309Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC309Test.php index 7292d2b31fa..5d5b0ef0c4c 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC309Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC309Test.php @@ -40,18 +40,18 @@ public function testTwoIterateHydrations(): void $q = $this->_em->createQuery('SELECT c FROM Doctrine\Tests\ORM\Functional\Ticket\DDC309Country c')->iterate(); $c = $q->next(); - $this->assertEquals(1, $c[0]->id); + self::assertEquals(1, $c[0]->id); $r = $this->_em->createQuery('SELECT u FROM Doctrine\Tests\ORM\Functional\Ticket\DDC309User u')->iterate(); $u = $r->next(); // This line breaks - $this->assertEquals(1, $u[0]->id); + self::assertEquals(1, $u[0]->id); $c = $q->next(); $u = $r->next(); - $this->assertEquals(2, $c[0]->id); - $this->assertEquals(2, $u[0]->id); + self::assertEquals(2, $c[0]->id); + self::assertEquals(2, $u[0]->id); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3103Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3103Test.php index 02e80565259..4906cdb44ba 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3103Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3103Test.php @@ -26,12 +26,12 @@ public function testIssue(): void $this->createAnnotationDriver()->loadMetadataForClass(DDC3103ArticleId::class, $classMetadata); - $this->assertTrue( + self::assertTrue( $classMetadata->isEmbeddedClass, 'The isEmbeddedClass property should be true from the mapping data.' ); - $this->assertTrue( + self::assertTrue( unserialize(serialize($classMetadata))->isEmbeddedClass, 'The isEmbeddedClass property should still be true after serialization and unserialization.' ); diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3123Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3123Test.php index fc9c1f8d929..d9eb0ec223b 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3123Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3123Test.php @@ -37,9 +37,9 @@ public function testIssue(): void ->getMock(); $listener - ->expects($this->once()) + ->expects(self::once()) ->method(Events::postFlush) - ->will($this->returnCallback(function () use ($uow): void { + ->will(self::returnCallback(function () use ($uow): void { $reflection = new ReflectionObject($uow); $property = $reflection->getProperty('extraUpdates'); diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3160Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3160Test.php index 2283a634e77..91a57bedd90 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3160Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3160Test.php @@ -40,9 +40,9 @@ public function testNoUpdateOnInsert(): void $this->_em->refresh($user); - $this->assertEquals('romanc', $user->username); - $this->assertEquals(1, $listener->inserts); - $this->assertEquals(0, $listener->updates); + self::assertEquals('romanc', $user->username); + self::assertEquals(1, $listener->inserts); + self::assertEquals(0, $listener->updates); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3192Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3192Test.php index 88271adb796..d8f8a30efd8 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3192Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3192Test.php @@ -30,7 +30,7 @@ protected function setUp(): void parent::setUp(); if (Type::hasType('ddc3192_currency_code')) { - $this->fail( + self::fail( 'Type ddc3192_currency_code exists for testing DDC-3192 only, ' . 'but it has already been registered for some reason' ); @@ -63,7 +63,7 @@ public function testIssue(): void $resultByPersister = $this->_em->find(DDC3192Transaction::class, $transaction->id); // This works: DDC2494 makes persister set type mapping info to ResultSetMapping - $this->assertEquals('BYR', $resultByPersister->currency->code); + self::assertEquals('BYR', $resultByPersister->currency->code); $this->_em->close(); @@ -75,7 +75,7 @@ public function testIssue(): void // This is fixed here: before the fix it used to return 974. // because unlike the BasicEntityPersister, SQLWalker doesn't set type info - $this->assertEquals('BYR', $resultByQuery->currency->code); + self::assertEquals('BYR', $resultByQuery->currency->code); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3223Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3223Test.php index 147392390f3..4445f53547e 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3223Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3223Test.php @@ -50,7 +50,7 @@ public function testIssueGetId(): void $profileStatus = clone $participant->profileStatus; - $this->assertSame(1, $profileStatus->getId(), 'The identifier on the cloned instance is an integer'); + self::assertSame(1, $profileStatus->getId(), 'The identifier on the cloned instance is an integer'); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3300Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3300Test.php index 23b97f93947..8cc3a11b4c6 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3300Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3300Test.php @@ -52,8 +52,8 @@ public function testResolveTargetEntitiesChangesDiscriminatorMapValues(): void $this->_em->flush(); $this->_em->clear(); - $this->assertEquals($boss, $this->_em->find(DDC3300Boss::class, $boss->id)); - $this->assertEquals($employee, $this->_em->find(DDC3300Employee::class, $employee->id)); + self::assertEquals($boss, $this->_em->find(DDC3300Boss::class, $boss->id)); + self::assertEquals($employee, $this->_em->find(DDC3300Employee::class, $employee->id)); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC331Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC331Test.php index 4e81129a714..128245576b0 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC331Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC331Test.php @@ -25,7 +25,7 @@ protected function setUp(): void public function testSelectFieldOnRootEntity(): void { $q = $this->_em->createQuery('SELECT e.name FROM Doctrine\Tests\Models\Company\CompanyEmployee e'); - $this->assertEquals( + self::assertEquals( strtolower('SELECT c0_.name AS name_0 FROM company_employees c1_ INNER JOIN company_persons c0_ ON c1_.id = c0_.id LEFT JOIN company_managers c2_ ON c1_.id = c2_.id'), strtolower($q->getSQL()) ); diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3330Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3330Test.php index d65d4e55656..6ae31c53c68 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3330Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3330Test.php @@ -53,7 +53,7 @@ public function testIssueCollectionOrderWithPaginator(): void $paginator = new Paginator($query, true); - $this->assertEquals(3, count(iterator_to_array($paginator)), 'Count is not correct for pagination'); + self::assertEquals(3, count(iterator_to_array($paginator)), 'Count is not correct for pagination'); } /** diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3346Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3346Test.php index c3575abfc65..a3ddde88e88 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3346Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3346Test.php @@ -31,7 +31,7 @@ public function testFindOneWithEagerFetchWillNotHydrateLimitedCollection(): void ); assert($author instanceof DDC3346Author); - $this->assertCount(2, $author->articles); + self::assertCount(2, $author->articles); } public function testFindLimitedWithEagerFetchWillNotHydrateLimitedCollection(): void @@ -43,8 +43,8 @@ public function testFindLimitedWithEagerFetchWillNotHydrateLimitedCollection(): 1 ); - $this->assertCount(1, $authors); - $this->assertCount(2, $authors[0]->articles); + self::assertCount(1, $authors); + self::assertCount(2, $authors[0]->articles); } public function testFindWithEagerFetchAndOffsetWillNotHydrateLimitedCollection(): void @@ -57,8 +57,8 @@ public function testFindWithEagerFetchAndOffsetWillNotHydrateLimitedCollection() 0 // using an explicitly defined offset ); - $this->assertCount(1, $authors); - $this->assertCount(2, $authors[0]->articles); + self::assertCount(1, $authors); + self::assertCount(2, $authors[0]->articles); } private function loadAuthorFixture(): void diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC345Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC345Test.php index d39fc5d23e0..2a37cbfd401 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC345Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC345Test.php @@ -65,9 +65,9 @@ public function testTwoIterateHydrations(): void $this->_em->flush(); - $this->assertEquals(1, $membership->prePersistCallCount); - $this->assertEquals(0, $membership->preUpdateCallCount); - $this->assertInstanceOf('DateTime', $membership->updated); + self::assertEquals(1, $membership->prePersistCallCount); + self::assertEquals(0, $membership->preUpdateCallCount); + self::assertInstanceOf('DateTime', $membership->updated); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC353Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC353Test.php index f4295a89e55..589561d9d29 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC353Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC353Test.php @@ -44,13 +44,13 @@ public function testWorkingCase(): void $em->clear(); $fileId = $file->getFileId(); - $this->assertTrue($fileId > 0); + self::assertTrue($fileId > 0); $file = $em->getReference(DDC353File::class, $fileId); - $this->assertEquals(UnitOfWork::STATE_MANAGED, $em->getUnitOfWork()->getEntityState($file), 'Reference Proxy should be marked MANAGED.'); + self::assertEquals(UnitOfWork::STATE_MANAGED, $em->getUnitOfWork()->getEntityState($file), 'Reference Proxy should be marked MANAGED.'); $picture = $em->find(DDC353Picture::class, $picture->getPictureId()); - $this->assertEquals(UnitOfWork::STATE_MANAGED, $em->getUnitOfWork()->getEntityState($picture->getFile()), 'Lazy Proxy should be marked MANAGED.'); + self::assertEquals(UnitOfWork::STATE_MANAGED, $em->getUnitOfWork()->getEntityState($picture->getFile()), 'Lazy Proxy should be marked MANAGED.'); $em->remove($picture); $em->flush(); @@ -71,10 +71,10 @@ public function testFailingCase(): void $fileId = $file->getFileId(); $pictureId = $picture->getPictureId(); - $this->assertTrue($fileId > 0); + self::assertTrue($fileId > 0); $picture = $em->find(DDC353Picture::class, $pictureId); - $this->assertEquals(UnitOfWork::STATE_MANAGED, $em->getUnitOfWork()->getEntityState($picture->getFile()), 'Lazy Proxy should be marked MANAGED.'); + self::assertEquals(UnitOfWork::STATE_MANAGED, $em->getUnitOfWork()->getEntityState($picture->getFile()), 'Lazy Proxy should be marked MANAGED.'); $em->remove($picture); $em->flush(); diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3582Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3582Test.php index cece720af60..a301b2fbf26 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3582Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3582Test.php @@ -25,9 +25,9 @@ public function testNestedEmbeddablesAreHydratedWithProperClass(): void $entity = $this->_em->find(DDC3582Entity::class, 'foo'); assert($entity instanceof DDC3582Entity); - $this->assertInstanceOf(DDC3582Embeddable1::class, $entity->embeddable1); - $this->assertInstanceOf(DDC3582Embeddable2::class, $entity->embeddable1->embeddable2); - $this->assertInstanceOf(DDC3582Embeddable3::class, $entity->embeddable1->embeddable2->embeddable3); + self::assertInstanceOf(DDC3582Embeddable1::class, $entity->embeddable1); + self::assertInstanceOf(DDC3582Embeddable2::class, $entity->embeddable1->embeddable2); + self::assertInstanceOf(DDC3582Embeddable3::class, $entity->embeddable1->embeddable2->embeddable3); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3597Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3597Test.php index 41334f3f573..d7f200166c0 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3597Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3597Test.php @@ -44,7 +44,7 @@ public function testSaveImageEntity(): void //request entity $imageEntity = $this->_em->find(DDC3597Image::class, $imageEntity->getId()); - $this->assertInstanceOf(DDC3597Image::class, $imageEntity); + self::assertInstanceOf(DDC3597Image::class, $imageEntity); //cleanup $this->_em->remove($imageEntity); @@ -53,6 +53,6 @@ public function testSaveImageEntity(): void //check delete $imageEntity = $this->_em->find(DDC3597Image::class, $imageEntity->getId()); - $this->assertNull($imageEntity); + self::assertNull($imageEntity); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3634Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3634Test.php index aca44cdf4e4..63e8804d7de 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3634Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3634Test.php @@ -34,7 +34,7 @@ protected function setUp(): void $metadata = $this->_em->getClassMetadata(DDC3634Entity::class); if (! $metadata->idGenerator->isPostInsertGenerator()) { - $this->markTestSkipped('Need a post-insert ID generator in order to make this test work correctly'); + self::markTestSkipped('Need a post-insert ID generator in order to make this test work correctly'); } try { @@ -62,7 +62,7 @@ public function testSavesVeryLargeIntegerAutoGeneratedValue(): void $entityManager->persist($entity); $entityManager->flush(); - $this->assertSame($veryLargeId, $entity->id); + self::assertSame($veryLargeId, $entity->id); } public function testSavesIntegerAutoGeneratedValueAsString(): void @@ -72,7 +72,7 @@ public function testSavesIntegerAutoGeneratedValueAsString(): void $this->_em->persist($entity); $this->_em->flush(); - $this->assertIsString($entity->id); + self::assertIsString($entity->id); } public function testSavesIntegerAutoGeneratedValueAsStringWithJoinedInheritance(): void @@ -82,7 +82,7 @@ public function testSavesIntegerAutoGeneratedValueAsStringWithJoinedInheritance( $this->_em->persist($entity); $this->_em->flush(); - $this->assertIsString($entity->id); + self::assertIsString($entity->id); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3644Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3644Test.php index 0174d86755d..d1217ec7010 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3644Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3644Test.php @@ -80,13 +80,13 @@ public function testIssueWithRegularEntity(): void // We should only have 1 item in the collection list now $user = $this->_em->find(DDC3644User::class, $userId); - $this->assertCount(1, $user->addresses); + self::assertCount(1, $user->addresses); // We should only have 1 item in the addresses table too $repository = $this->_em->getRepository(DDC3644Address::class); $addresses = $repository->findAll(); - $this->assertCount(1, $addresses); + self::assertCount(1, $addresses); } /** @@ -130,13 +130,13 @@ public function testIssueWithJoinedEntity(): void // We should only have 1 item in the collection list now $user = $this->_em->find(DDC3644User::class, $userId); - $this->assertCount(1, $user->pets); + self::assertCount(1, $user->pets); // We should only have 1 item in the pets table too $repository = $this->_em->getRepository(DDC3644Pet::class); $pets = $repository->findAll(); - $this->assertCount(1, $pets); + self::assertCount(1, $pets); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3699Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3699Test.php index 424ee126ed8..5d002ef01a9 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3699Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3699Test.php @@ -61,8 +61,8 @@ public function testMergingParentClassFieldsDoesNotStopMergingScalarFieldsForToO $mergedChild = $this->_em->merge($unManagedChild); assert($mergedChild instanceof DDC3699Child); - $this->assertSame($mergedChild->childField, 'modifiedChildValue'); - $this->assertSame($mergedChild->parentField, 'modifiedParentValue'); + self::assertSame($mergedChild->childField, 'modifiedChildValue'); + self::assertSame($mergedChild->parentField, 'modifiedParentValue'); } /** @@ -102,7 +102,7 @@ public function testMergingParentClassFieldsDoesNotStopMergingScalarFieldsForToM $mergedChild = $this->_em->merge($unmanagedChild); assert($mergedChild instanceof DDC3699Child); - $this->assertSame($mergedChild->childField, 'modifiedChildValue'); - $this->assertSame($mergedChild->parentField, 'modifiedParentValue'); + self::assertSame($mergedChild->childField, 'modifiedChildValue'); + self::assertSame($mergedChild->parentField, 'modifiedParentValue'); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3711Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3711Test.php index 1202464ec3d..599e2162c71 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3711Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3711Test.php @@ -23,7 +23,7 @@ public function testCompositeKeyForJoinTableInManyToManyCreation(): void $entityA = new ClassMetadata(DDC3711EntityA::class); $entityA = $factory->getMetadataFor(DDC3711EntityA::class); - $this->assertEquals(['link_a_id1' => 'id1', 'link_a_id2' => 'id2'], $entityA->associationMappings['entityB']['relationToSourceKeyColumns']); - $this->assertEquals(['link_b_id1' => 'id1', 'link_b_id2' => 'id2'], $entityA->associationMappings['entityB']['relationToTargetKeyColumns']); + self::assertEquals(['link_a_id1' => 'id1', 'link_a_id2' => 'id2'], $entityA->associationMappings['entityB']['relationToSourceKeyColumns']); + self::assertEquals(['link_b_id1' => 'id1', 'link_b_id2' => 'id2'], $entityA->associationMappings['entityB']['relationToTargetKeyColumns']); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3719Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3719Test.php index dbaf68e42af..d6a3c48c3e5 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3719Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3719Test.php @@ -42,12 +42,12 @@ public function testCriteriaOnNotOwningSide(): void $this->_em->refresh($manager); $contracts = $manager->managedContracts; - static::assertCount(2, $contracts); + self::assertCount(2, $contracts); $criteria = Criteria::create(); $criteria->where(Criteria::expr()->eq('completed', true)); $completedContracts = $contracts->matching($criteria); - static::assertCount(1, $completedContracts); + self::assertCount(1, $completedContracts); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC371Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC371Test.php index 2030c9e5da8..cd9c998aa4a 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC371Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC371Test.php @@ -59,10 +59,10 @@ public function testIssue(): void ->setHint(Query::HINT_REFRESH, true) ->getResult(); - $this->assertEquals(1, count($children)); - $this->assertNotInstanceOf(Proxy::class, $children[0]->parent); - $this->assertFalse($children[0]->parent->children->isInitialized()); - $this->assertEquals(0, $children[0]->parent->children->unwrap()->count()); + self::assertEquals(1, count($children)); + self::assertNotInstanceOf(Proxy::class, $children[0]->parent); + self::assertFalse($children[0]->parent->children->isInitialized()); + self::assertEquals(0, $children[0]->parent->children->unwrap()->count()); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC381Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC381Test.php index e9030836d04..439b8388a03 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC381Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC381Test.php @@ -47,7 +47,7 @@ public function testCallUnserializedProxyMethods(): void $data = serialize($entity); $entity = unserialize($data); - $this->assertEquals($persistedId, $entity->getId()); + self::assertEquals($persistedId, $entity->getId()); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3967Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3967Test.php index c66b4b8e61e..1a0597bd5d3 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3967Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3967Test.php @@ -34,6 +34,6 @@ public function testIdentifierCachedWithProperType(): void assert($country instanceof Country); // Identifier type should be integer - $this->assertSame($country->getId(), $id); + self::assertSame($country->getId(), $id); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC4003Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC4003Test.php index 3adc65619d4..7e6cfe5883b 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC4003Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC4003Test.php @@ -59,6 +59,6 @@ public function testReadsThroughRepositorySameDataThatItWroteInCache(): void $cached = $repository->findOneBy(['id' => $id]); assert($cached instanceof Bar); - $this->assertEquals($newName, $cached->getName()); + self::assertEquals($newName, $cached->getName()); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC422Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC422Test.php index 391d49667e6..905271161b6 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC422Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC422Test.php @@ -48,15 +48,15 @@ public function testIssue(): void $customer = $this->_em->find(get_class($customer), $customer->id); - $this->assertInstanceOf(PersistentCollection::class, $customer->contacts); - $this->assertFalse($customer->contacts->isInitialized()); + self::assertInstanceOf(PersistentCollection::class, $customer->contacts); + self::assertFalse($customer->contacts->isInitialized()); $contact = new DDC422Contact(); $customer->contacts->add($contact); - $this->assertTrue($customer->contacts->isDirty()); - $this->assertFalse($customer->contacts->isInitialized()); + self::assertTrue($customer->contacts->isDirty()); + self::assertFalse($customer->contacts->isInitialized()); $this->_em->flush(); - $this->assertEquals(1, $this->_em->getConnection()->fetchColumn('select count(*) from ddc422_customers_contacts')); + self::assertEquals(1, $this->_em->getConnection()->fetchColumn('select count(*) from ddc422_customers_contacts')); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC425Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC425Test.php index 0c6f4f72569..5c4605935d8 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC425Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC425Test.php @@ -34,7 +34,7 @@ public function testIssue(): void $num = $this->_em->createQuery('DELETE ' . __NAMESPACE__ . '\DDC425Entity e WHERE e.someDatetimeField > ?1') ->setParameter(1, new DateTime(), Type::DATETIME) ->getResult(); - $this->assertEquals(0, $num); + self::assertEquals(0, $num); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC440Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC440Test.php index a3534c3a4af..91a3955e0d0 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC440Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC440Test.php @@ -81,14 +81,14 @@ public function testOriginalEntityDataEmptyWhenProxyLoadedFromTwoAssociations(): // Test the first phone. The assertion actually failed because original entity data is not set properly. // This was because it is also set as MainPhone and that one is created as a proxy, not the // original object when the find on Client is called. However loading proxies did not work correctly. - $this->assertInstanceOf(DDC440Phone::class, $p1); + self::assertInstanceOf(DDC440Phone::class, $p1); $originalData = $uw->getOriginalEntityData($p1); - $this->assertEquals($phone->getNumber(), $originalData['number']); + self::assertEquals($phone->getNumber(), $originalData['number']); //If you comment out previous test, this one should pass - $this->assertInstanceOf(DDC440Phone::class, $p2); + self::assertInstanceOf(DDC440Phone::class, $p2); $originalData = $uw->getOriginalEntityData($p2); - $this->assertEquals($phone2->getNumber(), $originalData['number']); + self::assertEquals($phone2->getNumber(), $originalData['number']); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC444Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC444Test.php index a4b6fa158cf..b53c9ada9c3 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC444Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC444Test.php @@ -40,7 +40,7 @@ public function testExplicitPolicy(): void $q = $this->_em->createQuery(sprintf('SELECT u FROM %s u', $classname)); $u = $q->getSingleResult(); - $this->assertEquals('Initial value', $u->name); + self::assertEquals('Initial value', $u->name); $u->name = 'Modified value'; @@ -51,7 +51,7 @@ public function testExplicitPolicy(): void $u = $this->_em->createQuery(sprintf('SELECT u FROM %s u', $classname)); $u = $q->getSingleResult(); - $this->assertEquals('Initial value', $u->name); + self::assertEquals('Initial value', $u->name); $u->name = 'Modified value'; $this->_em->persist($u); @@ -61,7 +61,7 @@ public function testExplicitPolicy(): void $q = $this->_em->createQuery(sprintf('SELECT u FROM %s u', $classname)); $u = $q->getSingleResult(); - $this->assertEquals('Modified value', $u->name); + self::assertEquals('Modified value', $u->name); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC448Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC448Test.php index d5c2694a6b0..8b30908b87b 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC448Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC448Test.php @@ -36,7 +36,7 @@ protected function setUp(): void public function testIssue(): void { $q = $this->_em->createQuery('select b from ' . __NAMESPACE__ . '\\DDC448SubTable b where b.connectedClassId = ?1'); - $this->assertEquals( + self::assertEquals( strtolower('SELECT d0_.id AS id_0, d0_.discr AS discr_1, d0_.connectedClassId AS connectedClassId_2 FROM SubTable s1_ INNER JOIN DDC448MainTable d0_ ON s1_.id = d0_.id WHERE d0_.connectedClassId = ?'), strtolower($q->getSQL()) ); diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC493Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC493Test.php index a09d6bd90a2..fd99cc6d5c8 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC493Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC493Test.php @@ -34,7 +34,7 @@ protected function setUp(): void public function testIssue(): void { $q = $this->_em->createQuery('select u, c.data from ' . __NAMESPACE__ . '\\DDC493Distributor u JOIN u.contact c'); - $this->assertEquals( + self::assertEquals( strtolower('SELECT d0_.id AS id_0, d1_.data AS data_1, d0_.discr AS discr_2, d0_.contact AS contact_3 FROM DDC493Distributor d2_ INNER JOIN DDC493Customer d0_ ON d2_.id = d0_.id INNER JOIN DDC493Contact d1_ ON d0_.contact = d1_.id'), strtolower($q->getSQL()) ); diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC501Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC501Test.php index 952c8656f89..7abdfcaafbc 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC501Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC501Test.php @@ -27,55 +27,55 @@ public function testMergeUnitializedManyToManyAndOneToManyCollections(): void $user = $this->createAndPersistUser(); $this->_em->flush(); - $this->assertTrue($this->_em->contains($user)); + self::assertTrue($this->_em->contains($user)); $this->_em->clear(); - $this->assertFalse($this->_em->contains($user)); + self::assertFalse($this->_em->contains($user)); unset($user); // Reload User from DB *without* any associations (i.e. an uninitialized PersistantCollection) $userReloaded = $this->loadUserFromEntityManager(); - $this->assertTrue($this->_em->contains($userReloaded)); + self::assertTrue($this->_em->contains($userReloaded)); $this->_em->clear(); - $this->assertFalse($this->_em->contains($userReloaded)); + self::assertFalse($this->_em->contains($userReloaded)); // freeze and unfreeze $userClone = unserialize(serialize($userReloaded)); - $this->assertInstanceOf(CmsUser::class, $userClone); + self::assertInstanceOf(CmsUser::class, $userClone); // detached user can't know about his phonenumbers - $this->assertEquals(0, count($userClone->getPhonenumbers())); - $this->assertFalse($userClone->getPhonenumbers()->isInitialized(), 'User::phonenumbers should not be marked initialized.'); + self::assertEquals(0, count($userClone->getPhonenumbers())); + self::assertFalse($userClone->getPhonenumbers()->isInitialized(), 'User::phonenumbers should not be marked initialized.'); // detached user can't know about his groups either - $this->assertEquals(0, count($userClone->getGroups())); - $this->assertFalse($userClone->getGroups()->isInitialized(), 'User::groups should not be marked initialized.'); + self::assertEquals(0, count($userClone->getGroups())); + self::assertFalse($userClone->getGroups()->isInitialized(), 'User::groups should not be marked initialized.'); // Merge back and flush $userClone = $this->_em->merge($userClone); // Back in managed world I would expect to have my phonenumbers back but they aren't! // Remember I didn't touch (and probably didn't need) them at all while in detached mode. - $this->assertEquals(4, count($userClone->getPhonenumbers()), 'Phonenumbers are not available anymore'); + self::assertEquals(4, count($userClone->getPhonenumbers()), 'Phonenumbers are not available anymore'); // This works fine as long as cmUser::groups doesn't cascade "merge" - $this->assertEquals(2, count($userClone->getGroups())); + self::assertEquals(2, count($userClone->getGroups())); $this->_em->flush(); $this->_em->clear(); - $this->assertFalse($this->_em->contains($userClone)); + self::assertFalse($this->_em->contains($userClone)); // Reload user from DB $userFromEntityManager = $this->loadUserFromEntityManager(); //Strange: Now the phonenumbers are back again - $this->assertEquals(4, count($userFromEntityManager->getPhonenumbers())); + self::assertEquals(4, count($userFromEntityManager->getPhonenumbers())); // This works fine as long as cmUser::groups doesn't cascade "merge" // Otherwise group memberships are physically deleted now! - $this->assertEquals(2, count($userClone->getGroups())); + self::assertEquals(2, count($userClone->getGroups())); } protected function createAndPersistUser(): CmsUser diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC512Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC512Test.php index c456e62f978..4aa787293b2 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC512Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC512Test.php @@ -47,16 +47,16 @@ public function testIssue(): void $q = $this->_em->createQuery('select u,i from ' . __NAMESPACE__ . '\\DDC512Customer u left join u.item i'); $result = $q->getResult(); - $this->assertEquals(2, count($result)); - $this->assertInstanceOf(DDC512Customer::class, $result[0]); - $this->assertInstanceOf(DDC512Customer::class, $result[1]); + self::assertEquals(2, count($result)); + self::assertInstanceOf(DDC512Customer::class, $result[0]); + self::assertInstanceOf(DDC512Customer::class, $result[1]); if ($result[0]->id === $customer1->id) { - $this->assertInstanceOf(DDC512OfferItem::class, $result[0]->item); - $this->assertEquals($item->id, $result[0]->item->id); - $this->assertNull($result[1]->item); + self::assertInstanceOf(DDC512OfferItem::class, $result[0]->item); + self::assertEquals($item->id, $result[0]->item->id); + self::assertNull($result[1]->item); } else { - $this->assertInstanceOf(DDC512OfferItem::class, $result[1]->item); - $this->assertNull($result[0]->item); + self::assertInstanceOf(DDC512OfferItem::class, $result[1]->item); + self::assertNull($result[0]->item); } } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC513Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC513Test.php index d55f55fb7b4..ef0856f5078 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC513Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC513Test.php @@ -34,7 +34,7 @@ protected function setUp(): void public function testIssue(): void { $q = $this->_em->createQuery('select u from ' . __NAMESPACE__ . '\\DDC513OfferItem u left join u.price p'); - $this->assertEquals( + self::assertEquals( strtolower('SELECT d0_.id AS id_0, d0_.discr AS discr_1, d0_.price AS price_2 FROM DDC513OfferItem d1_ INNER JOIN DDC513Item d0_ ON d1_.id = d0_.id LEFT JOIN DDC513Price d2_ ON d0_.price = d2_.id'), strtolower($q->getSQL()) ); diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC518Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC518Test.php index d0b12a42e3f..f1ef8b0e6f8 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC518Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC518Test.php @@ -36,6 +36,6 @@ public function testMergeWithRelatedNew(): void $this->_em->persist($user); $managedArticle = $this->_em->merge($article); - $this->assertSame($article->user, $managedArticle->user); + self::assertSame($article->user, $managedArticle->user); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC522Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC522Test.php index b5d39887ad8..be563e2fbfd 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC522Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC522Test.php @@ -58,10 +58,10 @@ public function testJoinColumnWithSameNameAsAssociationField(): void $r = $this->_em->createQuery('select ca,c from ' . DDC522Cart::class . ' ca join ca.customer c') ->getResult(); - $this->assertInstanceOf(DDC522Cart::class, $r[0]); - $this->assertInstanceOf(DDC522Customer::class, $r[0]->customer); - $this->assertNotInstanceOf(Proxy::class, $r[0]->customer); - $this->assertEquals('name', $r[0]->customer->name); + self::assertInstanceOf(DDC522Cart::class, $r[0]); + self::assertInstanceOf(DDC522Customer::class, $r[0]->customer); + self::assertNotInstanceOf(Proxy::class, $r[0]->customer); + self::assertEquals('name', $r[0]->customer->name); $fkt = new DDC522ForeignKeyTest(); $fkt->cartId = $r[0]->id; // ignored for persistence @@ -71,9 +71,9 @@ public function testJoinColumnWithSameNameAsAssociationField(): void $this->_em->clear(); $fkt2 = $this->_em->find(get_class($fkt), $fkt->id); - $this->assertEquals($fkt->cart->id, $fkt2->cartId); - $this->assertInstanceOf(Proxy::class, $fkt2->cart); - $this->assertFalse($fkt2->cart->__isInitialized__); + self::assertEquals($fkt->cart->id, $fkt2->cartId); + self::assertInstanceOf(Proxy::class, $fkt2->cart); + self::assertFalse($fkt2->cart->__isInitialized__); } /** diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC531Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC531Test.php index 91bdba5c50a..d6d0ada4276 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC531Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC531Test.php @@ -46,12 +46,12 @@ public function testIssue(): void $item3 = $this->_em->find(DDC531Item::class, $item2->id); // Load child item first (id 2) // parent will already be loaded, cannot be lazy because it has mapped subclasses and we would not // know which proxy type to put in. - $this->assertInstanceOf(DDC531Item::class, $item3->parent); - $this->assertNotInstanceOf(Proxy::class, $item3->parent); + self::assertInstanceOf(DDC531Item::class, $item3->parent); + self::assertNotInstanceOf(Proxy::class, $item3->parent); $item4 = $this->_em->find(DDC531Item::class, $item1->id); // Load parent item (id 1) - $this->assertNull($item4->parent); - $this->assertNotNull($item4->getChildren()); - $this->assertTrue($item4->getChildren()->contains($item3)); // lazy-loads children + self::assertNull($item4->parent); + self::assertNotNull($item4->getChildren()); + self::assertTrue($item4->getChildren()->contains($item3)); // lazy-loads children } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC5684Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC5684Test.php index 964b8a5f5e0..08493f32f2f 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC5684Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC5684Test.php @@ -48,7 +48,7 @@ public function testAutoIncrementIdWithCustomType(): void $this->_em->persist($object); $this->_em->flush(); - $this->assertInstanceOf(DDC5684ObjectId::class, $object->id); + self::assertInstanceOf(DDC5684ObjectId::class, $object->id); } public function testFetchObjectWithAutoIncrementedCustomType(): void @@ -61,8 +61,8 @@ public function testFetchObjectWithAutoIncrementedCustomType(): void $rawId = $object->id->value; $object = $this->_em->find(DDC5684Object::class, new DDC5684ObjectId($rawId)); - $this->assertInstanceOf(DDC5684ObjectId::class, $object->id); - $this->assertEquals($rawId, $object->id->value); + self::assertInstanceOf(DDC5684ObjectId::class, $object->id); + self::assertEquals($rawId, $object->id->value); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC599Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC599Test.php index 54e1c34485f..ab586df9f7e 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC599Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC599Test.php @@ -54,9 +54,9 @@ public function testCascadeRemoveOnInheritanceHierarchy(): void $this->_em->remove($item); $this->_em->flush(); // Should not fail - $this->assertFalse($this->_em->contains($item)); + self::assertFalse($this->_em->contains($item)); $children = $item->getChildren(); - $this->assertFalse($this->_em->contains($children[0])); + self::assertFalse($this->_em->contains($children[0])); $this->_em->clear(); @@ -74,17 +74,17 @@ public function testCascadeRemoveOnInheritanceHierarchy(): void $this->_em->remove($item2); $this->_em->flush(); // should not fail - $this->assertFalse($this->_em->contains($item)); + self::assertFalse($this->_em->contains($item)); $children = $item->getChildren(); - $this->assertFalse($this->_em->contains($children[0])); + self::assertFalse($this->_em->contains($children[0])); } public function testCascadeRemoveOnChildren(): void { $class = $this->_em->getClassMetadata(DDC599Subitem::class); - $this->assertArrayHasKey('children', $class->associationMappings); - $this->assertTrue($class->associationMappings['children']['isCascadeRemove']); + self::assertArrayHasKey('children', $class->associationMappings); + self::assertTrue($class->associationMappings['children']['isCascadeRemove']); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC618Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC618Test.php index b8933917908..ff17ab2d6ae 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC618Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC618Test.php @@ -64,8 +64,8 @@ public function testIndexByHydrateObject(): void $joe = $this->_em->find(DDC618Author::class, 10); $alice = $this->_em->find(DDC618Author::class, 11); - $this->assertArrayHasKey('Joe', $result, "INDEX BY A.name should return an index by the name of 'Joe'."); - $this->assertArrayHasKey('Alice', $result, "INDEX BY A.name should return an index by the name of 'Alice'."); + self::assertArrayHasKey('Joe', $result, "INDEX BY A.name should return an index by the name of 'Joe'."); + self::assertArrayHasKey('Alice', $result, "INDEX BY A.name should return an index by the name of 'Alice'."); } public function testIndexByHydrateArray(): void @@ -76,8 +76,8 @@ public function testIndexByHydrateArray(): void $joe = $this->_em->find(DDC618Author::class, 10); $alice = $this->_em->find(DDC618Author::class, 11); - $this->assertArrayHasKey('Joe', $result, "INDEX BY A.name should return an index by the name of 'Joe'."); - $this->assertArrayHasKey('Alice', $result, "INDEX BY A.name should return an index by the name of 'Alice'."); + self::assertArrayHasKey('Joe', $result, "INDEX BY A.name should return an index by the name of 'Joe'."); + self::assertArrayHasKey('Alice', $result, "INDEX BY A.name should return an index by the name of 'Alice'."); } /** @@ -89,19 +89,19 @@ public function testIndexByJoin(): void 'INNER JOIN A.books B INDEX BY B.title ORDER BY A.name ASC'; $result = $this->_em->createQuery($dql)->getResult(Query::HYDRATE_OBJECT); - $this->assertEquals(3, count($result[0]->books)); // Alice, Joe doesn't appear because he has no books. - $this->assertEquals('Alice', $result[0]->name); - $this->assertTrue(isset($result[0]->books['In Wonderland']), 'Indexing by title should have books by title.'); - $this->assertTrue(isset($result[0]->books['Reloaded']), 'Indexing by title should have books by title.'); - $this->assertTrue(isset($result[0]->books['Test']), 'Indexing by title should have books by title.'); + self::assertEquals(3, count($result[0]->books)); // Alice, Joe doesn't appear because he has no books. + self::assertEquals('Alice', $result[0]->name); + self::assertTrue(isset($result[0]->books['In Wonderland']), 'Indexing by title should have books by title.'); + self::assertTrue(isset($result[0]->books['Reloaded']), 'Indexing by title should have books by title.'); + self::assertTrue(isset($result[0]->books['Test']), 'Indexing by title should have books by title.'); $result = $this->_em->createQuery($dql)->getResult(Query::HYDRATE_ARRAY); - $this->assertEquals(3, count($result[0]['books'])); // Alice, Joe doesn't appear because he has no books. - $this->assertEquals('Alice', $result[0]['name']); - $this->assertTrue(isset($result[0]['books']['In Wonderland']), 'Indexing by title should have books by title.'); - $this->assertTrue(isset($result[0]['books']['Reloaded']), 'Indexing by title should have books by title.'); - $this->assertTrue(isset($result[0]['books']['Test']), 'Indexing by title should have books by title.'); + self::assertEquals(3, count($result[0]['books'])); // Alice, Joe doesn't appear because he has no books. + self::assertEquals('Alice', $result[0]['name']); + self::assertTrue(isset($result[0]['books']['In Wonderland']), 'Indexing by title should have books by title.'); + self::assertTrue(isset($result[0]['books']['Reloaded']), 'Indexing by title should have books by title.'); + self::assertTrue(isset($result[0]['books']['Test']), 'Indexing by title should have books by title.'); } /** @@ -113,14 +113,14 @@ public function testIndexByToOneJoinSilentlyIgnored(): void 'INNER JOIN B.author A INDEX BY A.name ORDER BY A.name ASC'; $result = $this->_em->createQuery($dql)->getResult(Query::HYDRATE_OBJECT); - $this->assertInstanceOf(DDC618Book::class, $result[0]); - $this->assertInstanceOf(DDC618Author::class, $result[0]->author); + self::assertInstanceOf(DDC618Book::class, $result[0]); + self::assertInstanceOf(DDC618Author::class, $result[0]->author); $dql = 'SELECT B, A FROM Doctrine\Tests\ORM\Functional\Ticket\DDC618Book B ' . 'INNER JOIN B.author A INDEX BY A.name ORDER BY A.name ASC'; $result = $this->_em->createQuery($dql)->getResult(Query::HYDRATE_ARRAY); - $this->assertEquals('Alice', $result[0]['author']['name']); + self::assertEquals('Alice', $result[0]['author']['name']); } /** @@ -132,13 +132,13 @@ public function testCombineIndexBy(): void 'INNER JOIN A.books B INDEX BY B.title ORDER BY A.name ASC'; $result = $this->_em->createQuery($dql)->getResult(Query::HYDRATE_OBJECT); - $this->assertArrayHasKey(11, $result); // Alice + self::assertArrayHasKey(11, $result); // Alice - $this->assertEquals(3, count($result[11]->books)); // Alice, Joe doesn't appear because he has no books. - $this->assertEquals('Alice', $result[11]->name); - $this->assertTrue(isset($result[11]->books['In Wonderland']), 'Indexing by title should have books by title.'); - $this->assertTrue(isset($result[11]->books['Reloaded']), 'Indexing by title should have books by title.'); - $this->assertTrue(isset($result[11]->books['Test']), 'Indexing by title should have books by title.'); + self::assertEquals(3, count($result[11]->books)); // Alice, Joe doesn't appear because he has no books. + self::assertEquals('Alice', $result[11]->name); + self::assertTrue(isset($result[11]->books['In Wonderland']), 'Indexing by title should have books by title.'); + self::assertTrue(isset($result[11]->books['Reloaded']), 'Indexing by title should have books by title.'); + self::assertTrue(isset($result[11]->books['Test']), 'Indexing by title should have books by title.'); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC633Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC633Test.php index 1fe2e6514e8..78750bcd71d 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC633Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC633Test.php @@ -49,8 +49,8 @@ public function testOneToOneEager(): void $eagerAppointment = $this->_em->find(DDC633Appointment::class, $app->id); // Eager loading of one to one leads to fetch-join - $this->assertNotInstanceOf(Proxy::class, $eagerAppointment->patient); - $this->assertTrue($this->_em->contains($eagerAppointment->patient)); + self::assertNotInstanceOf(Proxy::class, $eagerAppointment->patient); + self::assertTrue($this->_em->contains($eagerAppointment->patient)); } /** @@ -75,8 +75,8 @@ public function testDQLDeferredEagerLoad(): void $appointments = $this->_em->createQuery('SELECT a FROM ' . __NAMESPACE__ . '\DDC633Appointment a')->getResult(); foreach ($appointments as $eagerAppointment) { - $this->assertInstanceOf(Proxy::class, $eagerAppointment->patient); - $this->assertTrue($eagerAppointment->patient->__isInitialized__, 'Proxy should already be initialized due to eager loading!'); + self::assertInstanceOf(Proxy::class, $eagerAppointment->patient); + self::assertTrue($eagerAppointment->patient->__isInitialized__, 'Proxy should already be initialized due to eager loading!'); } } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC6460Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC6460Test.php index 06a20f089a3..90a9a55d5d2 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC6460Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC6460Test.php @@ -41,7 +41,7 @@ public function testInlineEmbeddable(): void ->getClassMetadata(DDC6460Entity::class) ->hasField('embedded'); - $this->assertTrue($isFieldMapped); + self::assertTrue($isFieldMapped); } /** @@ -65,11 +65,11 @@ public function testInlineEmbeddableProxyInitialization(): void $secondEntityWithLazyParameter = $this->_em->getRepository(DDC6460ParentEntity::class)->findOneById(1); - $this->assertInstanceOf(Proxy::class, $secondEntityWithLazyParameter->lazyLoaded); - $this->assertInstanceOf(DDC6460Entity::class, $secondEntityWithLazyParameter->lazyLoaded); - $this->assertFalse($secondEntityWithLazyParameter->lazyLoaded->__isInitialized()); - $this->assertEquals($secondEntityWithLazyParameter->lazyLoaded->embedded, $entity->embedded); - $this->assertTrue($secondEntityWithLazyParameter->lazyLoaded->__isInitialized()); + self::assertInstanceOf(Proxy::class, $secondEntityWithLazyParameter->lazyLoaded); + self::assertInstanceOf(DDC6460Entity::class, $secondEntityWithLazyParameter->lazyLoaded); + self::assertFalse($secondEntityWithLazyParameter->lazyLoaded->__isInitialized()); + self::assertEquals($secondEntityWithLazyParameter->lazyLoaded->embedded, $entity->embedded); + self::assertTrue($secondEntityWithLazyParameter->lazyLoaded->__isInitialized()); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC656Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC656Test.php index e2121d8b93a..30e5920a60e 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC656Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC656Test.php @@ -42,14 +42,14 @@ public function testRecomputeSingleEntityChangeSetPreservesFieldOrder(): void $this->_em->getUnitOfWork()->recomputeSingleEntityChangeSet($this->_em->getClassMetadata(get_class($entity)), $entity); $data2 = $this->_em->getUnitOfWork()->getEntityChangeSet($entity); - $this->assertEquals(array_keys($data1), array_keys($data2)); + self::assertEquals(array_keys($data1), array_keys($data2)); $this->_em->flush(); $this->_em->clear(); $persistedEntity = $this->_em->find(get_class($entity), $entity->specificationId); - $this->assertEquals('type2', $persistedEntity->getType()); - $this->assertEquals('test1', $persistedEntity->getName()); + self::assertEquals('type2', $persistedEntity->getType()); + self::assertEquals('test1', $persistedEntity->getName()); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC657Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC657Test.php index 788ff9e0915..91d8a3f0b01 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC657Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC657Test.php @@ -29,11 +29,11 @@ public function testEntitySingleResult(): void $query = $this->_em->createQuery('SELECT d FROM ' . DateTimeModel::class . ' d'); $datetime = $query->setMaxResults(1)->getSingleResult(); - $this->assertInstanceOf(DateTimeModel::class, $datetime); + self::assertInstanceOf(DateTimeModel::class, $datetime); - $this->assertInstanceOf('DateTime', $datetime->datetime); - $this->assertInstanceOf('DateTime', $datetime->time); - $this->assertInstanceOf('DateTime', $datetime->date); + self::assertInstanceOf('DateTime', $datetime->datetime); + self::assertInstanceOf('DateTime', $datetime->time); + self::assertInstanceOf('DateTime', $datetime->date); } public function testScalarResult(): void @@ -41,15 +41,15 @@ public function testScalarResult(): void $query = $this->_em->createQuery('SELECT d.id, d.time, d.date, d.datetime FROM ' . DateTimeModel::class . ' d ORDER BY d.date ASC'); $result = $query->getScalarResult(); - $this->assertCount(2, $result); + self::assertCount(2, $result); - $this->assertStringContainsString('11:11:11', $result[0]['time']); - $this->assertStringContainsString('2010-01-01', $result[0]['date']); - $this->assertStringContainsString('2010-01-01 11:11:11', $result[0]['datetime']); + self::assertStringContainsString('11:11:11', $result[0]['time']); + self::assertStringContainsString('2010-01-01', $result[0]['date']); + self::assertStringContainsString('2010-01-01 11:11:11', $result[0]['datetime']); - $this->assertStringContainsString('12:12:12', $result[1]['time']); - $this->assertStringContainsString('2010-02-02', $result[1]['date']); - $this->assertStringContainsString('2010-02-02 12:12:12', $result[1]['datetime']); + self::assertStringContainsString('12:12:12', $result[1]['time']); + self::assertStringContainsString('2010-02-02', $result[1]['date']); + self::assertStringContainsString('2010-02-02 12:12:12', $result[1]['datetime']); } public function testaTicketEntityArrayResult(): void @@ -57,15 +57,15 @@ public function testaTicketEntityArrayResult(): void $query = $this->_em->createQuery('SELECT d FROM ' . DateTimeModel::class . ' d ORDER BY d.date ASC'); $result = $query->getArrayResult(); - $this->assertCount(2, $result); + self::assertCount(2, $result); - $this->assertInstanceOf('DateTime', $result[0]['datetime']); - $this->assertInstanceOf('DateTime', $result[0]['time']); - $this->assertInstanceOf('DateTime', $result[0]['date']); + self::assertInstanceOf('DateTime', $result[0]['datetime']); + self::assertInstanceOf('DateTime', $result[0]['time']); + self::assertInstanceOf('DateTime', $result[0]['date']); - $this->assertInstanceOf('DateTime', $result[1]['datetime']); - $this->assertInstanceOf('DateTime', $result[1]['time']); - $this->assertInstanceOf('DateTime', $result[1]['date']); + self::assertInstanceOf('DateTime', $result[1]['datetime']); + self::assertInstanceOf('DateTime', $result[1]['time']); + self::assertInstanceOf('DateTime', $result[1]['date']); } public function testTicketSingleResult(): void @@ -73,11 +73,11 @@ public function testTicketSingleResult(): void $query = $this->_em->createQuery('SELECT d.id, d.time, d.date, d.datetime FROM ' . DateTimeModel::class . ' d ORDER BY d.date ASC'); $datetime = $query->setMaxResults(1)->getSingleResult(); - $this->assertTrue(is_array($datetime)); + self::assertTrue(is_array($datetime)); - $this->assertInstanceOf('DateTime', $datetime['datetime']); - $this->assertInstanceOf('DateTime', $datetime['time']); - $this->assertInstanceOf('DateTime', $datetime['date']); + self::assertInstanceOf('DateTime', $datetime['datetime']); + self::assertInstanceOf('DateTime', $datetime['time']); + self::assertInstanceOf('DateTime', $datetime['date']); } public function testTicketResult(): void @@ -85,19 +85,19 @@ public function testTicketResult(): void $query = $this->_em->createQuery('SELECT d.id, d.time, d.date, d.datetime FROM ' . DateTimeModel::class . ' d ORDER BY d.date ASC'); $result = $query->getResult(); - $this->assertCount(2, $result); + self::assertCount(2, $result); - $this->assertInstanceOf('DateTime', $result[0]['time']); - $this->assertInstanceOf('DateTime', $result[0]['date']); - $this->assertInstanceOf('DateTime', $result[0]['datetime']); + self::assertInstanceOf('DateTime', $result[0]['time']); + self::assertInstanceOf('DateTime', $result[0]['date']); + self::assertInstanceOf('DateTime', $result[0]['datetime']); - $this->assertEquals('2010-01-01 11:11:11', $result[0]['datetime']->format('Y-m-d G:i:s')); + self::assertEquals('2010-01-01 11:11:11', $result[0]['datetime']->format('Y-m-d G:i:s')); - $this->assertInstanceOf('DateTime', $result[1]['time']); - $this->assertInstanceOf('DateTime', $result[1]['date']); - $this->assertInstanceOf('DateTime', $result[1]['datetime']); + self::assertInstanceOf('DateTime', $result[1]['time']); + self::assertInstanceOf('DateTime', $result[1]['date']); + self::assertInstanceOf('DateTime', $result[1]['datetime']); - $this->assertEquals('2010-02-02 12:12:12', $result[1]['datetime']->format('Y-m-d G:i:s')); + self::assertEquals('2010-02-02 12:12:12', $result[1]['datetime']->format('Y-m-d G:i:s')); } public function loadFixtures(): void diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC698Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC698Test.php index a9d3329562c..f03ef002355 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC698Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC698Test.php @@ -43,7 +43,7 @@ public function testTicket(): void $sql = $qb->getQuery()->getSQL(); - $this->assertEquals( + self::assertEquals( strtolower('SELECT p0_.privilegeID AS privilegeID_0, p0_.name AS name_1, r1_.roleID AS roleID_2, r1_.name AS name_3, r1_.shortName AS shortName_4 FROM Privileges p0_ LEFT JOIN RolePrivileges r2_ ON p0_.privilegeID = r2_.privilegeID LEFT JOIN Roles r1_ ON r1_.roleID = r2_.roleID'), strtolower($sql) ); diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC69Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC69Test.php index dd8dd4a1433..ebaf105bfac 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC69Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC69Test.php @@ -102,13 +102,13 @@ public function testIssue(): void $res = $query->getResult(); $lemma = $res[0]; - $this->assertEquals('foo', $lemma->getLemma()); - $this->assertInstanceOf(Lemma::class, $lemma); + self::assertEquals('foo', $lemma->getLemma()); + self::assertInstanceOf(Lemma::class, $lemma); $relations = $lemma->getRelations(); foreach ($relations as $relation) { - $this->assertInstanceOf(Relation::class, $relation); - $this->assertTrue($relation->getType()->getType() !== ''); + self::assertInstanceOf(Relation::class, $relation); + self::assertTrue($relation->getType()->getType() !== ''); } $this->_em->clear(); diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC719Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC719Test.php index 42f9502aed6..559ff9c99c2 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC719Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC719Test.php @@ -37,7 +37,7 @@ public function testIsEmptySqlGeneration(): void $referenceSQL = 'SELECT g0_.name AS name_0, g0_.description AS description_1, g0_.id AS id_2, g1_.name AS name_3, g1_.description AS description_4, g1_.id AS id_5 FROM groups g0_ LEFT JOIN groups_groups g2_ ON g0_.id = g2_.parent_id LEFT JOIN groups g1_ ON g1_.id = g2_.child_id WHERE (SELECT COUNT(*) FROM groups_groups g3_ WHERE g3_.child_id = g0_.id) = 0'; - $this->assertEquals( + self::assertEquals( strtolower($referenceSQL), strtolower($q->getSQL()) ); diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC729Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC729Test.php index f0a86f8426c..3754508b175 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC729Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC729Test.php @@ -51,20 +51,20 @@ public function testMergeManyToMany(): void $a = new DDC729A(); $a->id = $aId; - $this->assertInstanceOf(ArrayCollection::class, $a->related); + self::assertInstanceOf(ArrayCollection::class, $a->related); $a = $this->_em->merge($a); - $this->assertInstanceOf(PersistentCollection::class, $a->related); + self::assertInstanceOf(PersistentCollection::class, $a->related); - $this->assertFalse($a->related->isInitialized(), 'Collection should not be marked initialized.'); - $this->assertFalse($a->related->isDirty(), 'Collection should not be marked as dirty.'); + self::assertFalse($a->related->isInitialized(), 'Collection should not be marked initialized.'); + self::assertFalse($a->related->isDirty(), 'Collection should not be marked as dirty.'); $this->_em->flush(); $this->_em->clear(); $a = $this->_em->find(DDC729A::class, $aId); - $this->assertEquals(1, count($a->related)); + self::assertEquals(1, count($a->related)); } public function testUnidirectionalMergeManyToMany(): void @@ -94,7 +94,7 @@ public function testUnidirectionalMergeManyToMany(): void $this->_em->clear(); $a = $this->_em->find(DDC729A::class, $aId); - $this->assertEquals(2, count($a->related)); + self::assertEquals(2, count($a->related)); } public function testBidirectionalMergeManyToMany(): void @@ -126,7 +126,7 @@ public function testBidirectionalMergeManyToMany(): void $this->_em->clear(); $a = $this->_em->find(DDC729A::class, $aId); - $this->assertEquals(2, count($a->related)); + self::assertEquals(2, count($a->related)); } public function testBidirectionalMultiMergeManyToMany(): void @@ -158,7 +158,7 @@ public function testBidirectionalMultiMergeManyToMany(): void $this->_em->clear(); $a = $this->_em->find(DDC729A::class, $aId); - $this->assertEquals(2, count($a->related)); + self::assertEquals(2, count($a->related)); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC735Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC735Test.php index ae0b0e77057..68b62145243 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC735Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC735Test.php @@ -44,7 +44,7 @@ public function testRemoveElementAppliesOrphanRemoval(): void $this->_em->flush(); // Now you see it - $this->assertEquals(1, count($product->getReviews())); + self::assertEquals(1, count($product->getReviews())); // Remove the review $reviewId = $review->getId(); @@ -52,16 +52,16 @@ public function testRemoveElementAppliesOrphanRemoval(): void $this->_em->flush(); // Now you don't - $this->assertEquals(0, count($product->getReviews()), 'count($reviews) should be 0 after removing its only Review'); + self::assertEquals(0, count($product->getReviews()), 'count($reviews) should be 0 after removing its only Review'); // Refresh $this->_em->refresh($product); // It should still be 0 - $this->assertEquals(0, count($product->getReviews()), 'count($reviews) should still be 0 after the refresh'); + self::assertEquals(0, count($product->getReviews()), 'count($reviews) should still be 0 after the refresh'); // Review should also not be available anymore - $this->assertNull($this->_em->find(DDC735Review::class, $reviewId)); + self::assertNull($this->_em->find(DDC735Review::class, $reviewId)); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC736Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC736Test.php index aff73ffde13..a025cce1198 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC736Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC736Test.php @@ -47,10 +47,10 @@ public function testReorderEntityFetchJoinForHydration(): void $cart2 = $result[0]; unset($result[0]); - $this->assertInstanceOf(ECommerceCart::class, $cart2); - $this->assertNotInstanceOf(Proxy::class, $cart2->getCustomer()); - $this->assertInstanceOf(ECommerceCustomer::class, $cart2->getCustomer()); - $this->assertEquals(['name' => 'roman', 'payment' => 'cash'], $result); + self::assertInstanceOf(ECommerceCart::class, $cart2); + self::assertNotInstanceOf(Proxy::class, $cart2->getCustomer()); + self::assertInstanceOf(ECommerceCustomer::class, $cart2->getCustomer()); + self::assertEquals(['name' => 'roman', 'payment' => 'cash'], $result); } /** @@ -79,7 +79,7 @@ public function testDqlTreeWalkerReordering(): void $cart2 = $result[0][0]; assert($cart2 instanceof ECommerceCart); - $this->assertInstanceOf(Proxy::class, $cart2->getCustomer()); + self::assertInstanceOf(Proxy::class, $cart2->getCustomer()); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC742Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC742Test.php index a447897fd96..68188621cd9 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC742Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC742Test.php @@ -31,7 +31,7 @@ class DDC742Test extends OrmFunctionalTestCase protected function setUp(): void { if (! class_exists(FilesystemCache::class)) { - $this->markTestSkipped('Test only applies with doctrine/cache 1.x'); + self::markTestSkipped('Test only applies with doctrine/cache 1.x'); } parent::setUp(); diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC748Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC748Test.php index ede9a604a00..e24b9f3d3cf 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC748Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC748Test.php @@ -34,10 +34,10 @@ public function testRefreshWithManyToOne(): void $this->_em->persist($article); $this->_em->flush(); - $this->assertInstanceOf(Collection::class, $user->articles); + self::assertInstanceOf(Collection::class, $user->articles); $this->_em->refresh($article); - $this->assertTrue($article !== $user->articles, 'The article should not be replaced on the inverse side of the relation.'); - $this->assertInstanceOf(Collection::class, $user->articles); + self::assertTrue($article !== $user->articles, 'The article should not be replaced on the inverse side of the relation.'); + self::assertInstanceOf(Collection::class, $user->articles); } public function testRefreshOneToOne(): void @@ -59,7 +59,7 @@ public function testRefreshOneToOne(): void $this->_em->flush(); $this->_em->refresh($address); - $this->assertSame($user, $address->user); - $this->assertSame($user->address, $address); + self::assertSame($user, $address->user); + self::assertSame($user->address, $address); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC758Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC758Test.php index 8c4cc9315dd..461cf116d90 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC758Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC758Test.php @@ -15,7 +15,7 @@ class DDC758Test extends OrmFunctionalTestCase { protected function setUp(): void { - $this->markTestSkipped('Destroys testsuite'); + self::markTestSkipped('Destroys testsuite'); $this->useModelSet('cms'); parent::setUp(); @@ -99,18 +99,18 @@ public function testManyToManyMergeAssociationAdds(): void $cmsGroups = $this->_em->getRepository(CmsGroup::class)->findAll(); // Check the entities are in the database - $this->assertEquals(1, count($cmsUsers)); - $this->assertEquals(2, count($cmsGroups)); + self::assertEquals(1, count($cmsUsers)); + self::assertEquals(2, count($cmsGroups)); // Check the associations between the entities are now in the database - $this->assertEquals(2, count($cmsUsers[0]->groups)); - $this->assertEquals(1, count($cmsGroups[0]->users)); - $this->assertEquals(1, count($cmsGroups[1]->users)); - - $this->assertSame($cmsUsers[0]->groups[0], $cmsGroups[0]); - $this->assertSame($cmsUsers[0]->groups[1], $cmsGroups[1]); - $this->assertSame($cmsGroups[0]->users[0], $cmsUsers[0]); - $this->assertSame($cmsGroups[1]->users[0], $cmsUsers[0]); + self::assertEquals(2, count($cmsUsers[0]->groups)); + self::assertEquals(1, count($cmsGroups[0]->users)); + self::assertEquals(1, count($cmsGroups[1]->users)); + + self::assertSame($cmsUsers[0]->groups[0], $cmsGroups[0]); + self::assertSame($cmsUsers[0]->groups[1], $cmsGroups[1]); + self::assertSame($cmsGroups[0]->users[0], $cmsUsers[0]); + self::assertSame($cmsGroups[1]->users[0], $cmsUsers[0]); } /** @@ -175,12 +175,12 @@ public function testManyToManyMergeAssociationRemoves(): void $cmsGroups = $this->_em->getRepository(CmsGroup::class)->findAll(); // Check the entities are in the database - $this->assertEquals(1, count($cmsUsers)); - $this->assertEquals(2, count($cmsGroups)); + self::assertEquals(1, count($cmsUsers)); + self::assertEquals(2, count($cmsGroups)); // Check the associations between the entities are now in the database - $this->assertEquals(0, count($cmsUsers[0]->groups)); - $this->assertEquals(0, count($cmsGroups[0]->users)); - $this->assertEquals(0, count($cmsGroups[1]->users)); + self::assertEquals(0, count($cmsUsers[0]->groups)); + self::assertEquals(0, count($cmsGroups[0]->users)); + self::assertEquals(0, count($cmsGroups[1]->users)); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC767Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC767Test.php index f90deb45914..0767866ab89 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC767Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC767Test.php @@ -53,7 +53,7 @@ public function testCollectionChangesInsideTransaction(): void $pUser = $this->_em->find(get_class($user), $user->id); assert($pUser instanceof CmsUser); - $this->assertNotNull($pUser, 'User not retrieved from database.'); + self::assertNotNull($pUser, 'User not retrieved from database.'); $groups = [$group2->id, $group3->id]; diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC7969Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC7969Test.php index ecfce0d7482..507b0a979ab 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC7969Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC7969Test.php @@ -32,20 +32,20 @@ public function testChildEntityRetrievedFromCache(): void $repository = $this->_em->getRepository(Bar::class); - $this->assertFalse($this->cache->containsEntity(Bar::class, $bar->getId())); - $this->assertFalse($this->cache->containsEntity(Attraction::class, $bar->getId())); + self::assertFalse($this->cache->containsEntity(Bar::class, $bar->getId())); + self::assertFalse($this->cache->containsEntity(Attraction::class, $bar->getId())); $repository->findOneBy([ 'name' => $bar->getName(), ]); - $this->assertTrue($this->cache->containsEntity(Bar::class, $bar->getId())); + self::assertTrue($this->cache->containsEntity(Bar::class, $bar->getId())); $repository->findOneBy([ 'name' => $bar->getName(), ]); // One hit for entity cache, one hit for query cache - $this->assertEquals(2, $this->secondLevelCacheLogger->getHitCount()); + self::assertEquals(2, $this->secondLevelCacheLogger->getHitCount()); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC809Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC809Test.php index 6acde91b616..f132d8f0d20 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC809Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC809Test.php @@ -62,8 +62,8 @@ public function testIssue(): void ->getQuery() ->getResult(); - $this->assertEquals(4, count($result[0]->getSpecificationValues()), 'Works in test-setup.'); - $this->assertEquals(4, count($result[1]->getSpecificationValues()), 'Only returns 2 in the case of the hydration bug.'); + self::assertEquals(4, count($result[0]->getSpecificationValues()), 'Works in test-setup.'); + self::assertEquals(4, count($result[1]->getSpecificationValues()), 'Only returns 2 in the case of the hydration bug.'); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC812Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC812Test.php index d34e043edc3..c3fee0942af 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC812Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC812Test.php @@ -46,7 +46,7 @@ public function testFetchJoinInitializesPreviouslyUninitializedCollectionOfManag ->setParameter(1, $article->id) ->getSingleResult(); - $this->assertTrue($article2Again === $article2); - $this->assertTrue($article2Again->comments->isInitialized()); + self::assertTrue($article2Again === $article2); + self::assertTrue($article2Again->comments->isInitialized()); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC832Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC832Test.php index 30dbb659d6f..a938ce82879 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC832Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC832Test.php @@ -25,7 +25,7 @@ protected function setUp(): void $platform = $this->_em->getConnection()->getDatabasePlatform(); if ($platform->getName() === 'oracle') { - $this->markTestSkipped('Doesnt run on Oracle.'); + self::markTestSkipped('Doesnt run on Oracle.'); } $this->_em->getConfiguration()->setSQLLogger(new EchoSQLLogger()); diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC837Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC837Test.php index 27f0646dd69..0cde48e344c 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC837Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC837Test.php @@ -66,38 +66,38 @@ public function testIssue(): void // Test Class1 $e1 = $this->_em->find(DDC837Super::class, $c1->id); - $this->assertInstanceOf(DDC837Class1::class, $e1); - $this->assertEquals('Foo', $e1->title); - $this->assertEquals('Foo', $e1->description); - $this->assertInstanceOf(DDC837Aggregate::class, $e1->aggregate); - $this->assertEquals('test1', $e1->aggregate->getSysname()); + self::assertInstanceOf(DDC837Class1::class, $e1); + self::assertEquals('Foo', $e1->title); + self::assertEquals('Foo', $e1->description); + self::assertInstanceOf(DDC837Aggregate::class, $e1->aggregate); + self::assertEquals('test1', $e1->aggregate->getSysname()); // Test Class 2 $e2 = $this->_em->find(DDC837Super::class, $c2->id); - $this->assertInstanceOf(DDC837Class2::class, $e2); - $this->assertEquals('Bar', $e2->title); - $this->assertEquals('Bar', $e2->description); - $this->assertEquals('Bar', $e2->text); - $this->assertInstanceOf(DDC837Aggregate::class, $e2->aggregate); - $this->assertEquals('test2', $e2->aggregate->getSysname()); + self::assertInstanceOf(DDC837Class2::class, $e2); + self::assertEquals('Bar', $e2->title); + self::assertEquals('Bar', $e2->description); + self::assertEquals('Bar', $e2->text); + self::assertInstanceOf(DDC837Aggregate::class, $e2->aggregate); + self::assertEquals('test2', $e2->aggregate->getSysname()); $all = $this->_em->getRepository(DDC837Super::class)->findAll(); foreach ($all as $obj) { if ($obj instanceof DDC837Class1) { - $this->assertEquals('Foo', $obj->title); - $this->assertEquals('Foo', $obj->description); + self::assertEquals('Foo', $obj->title); + self::assertEquals('Foo', $obj->description); } elseif ($obj instanceof DDC837Class2) { - $this->assertTrue($e2 === $obj); - $this->assertEquals('Bar', $obj->title); - $this->assertEquals('Bar', $obj->description); - $this->assertEquals('Bar', $obj->text); + self::assertTrue($e2 === $obj); + self::assertEquals('Bar', $obj->title); + self::assertEquals('Bar', $obj->description); + self::assertEquals('Bar', $obj->text); } elseif ($obj instanceof DDC837Class3) { - $this->assertEquals('Baz', $obj->apples); - $this->assertEquals('Baz', $obj->bananas); + self::assertEquals('Baz', $obj->apples); + self::assertEquals('Baz', $obj->bananas); } else { - $this->fail('Instance of DDC837Class1, DDC837Class2 or DDC837Class3 expected.'); + self::fail('Instance of DDC837Class1, DDC837Class2 or DDC837Class3 expected.'); } } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC849Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC849Test.php index 3fbbcd3c9a5..a8cfadd7b32 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC849Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC849Test.php @@ -54,25 +54,25 @@ public function testRemoveContains(): void $group1 = $this->user->groups[0]; $group2 = $this->user->groups[1]; - $this->assertTrue($this->user->groups->contains($group1)); - $this->assertTrue($this->user->groups->contains($group2)); + self::assertTrue($this->user->groups->contains($group1)); + self::assertTrue($this->user->groups->contains($group2)); $this->user->groups->removeElement($group1); $this->user->groups->remove(1); - $this->assertFalse($this->user->groups->contains($group1)); - $this->assertFalse($this->user->groups->contains($group2)); + self::assertFalse($this->user->groups->contains($group1)); + self::assertFalse($this->user->groups->contains($group2)); } public function testClearCount(): void { $this->user->addGroup(new CmsGroup()); - $this->assertEquals(3, count($this->user->groups)); + self::assertEquals(3, count($this->user->groups)); $this->user->groups->clear(); - $this->assertEquals(0, $this->user->groups->count()); - $this->assertEquals(0, count($this->user->groups)); + self::assertEquals(0, $this->user->groups->count()); + self::assertEquals(0, count($this->user->groups)); } public function testClearContains(): void @@ -80,12 +80,12 @@ public function testClearContains(): void $group1 = $this->user->groups[0]; $group2 = $this->user->groups[1]; - $this->assertTrue($this->user->groups->contains($group1)); - $this->assertTrue($this->user->groups->contains($group2)); + self::assertTrue($this->user->groups->contains($group1)); + self::assertTrue($this->user->groups->contains($group2)); $this->user->groups->clear(); - $this->assertFalse($this->user->groups->contains($group1)); - $this->assertFalse($this->user->groups->contains($group2)); + self::assertFalse($this->user->groups->contains($group1)); + self::assertFalse($this->user->groups->contains($group2)); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC881Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC881Test.php index e650907f3d5..a52537ff4de 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC881Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC881Test.php @@ -97,16 +97,16 @@ public function testIssue(): void $dql = 'SELECT c, p FROM ' . DDC881PhoneCall::class . ' c JOIN c.phonenumber p'; $calls = $this->_em->createQuery($dql)->getResult(); - $this->assertEquals(2, count($calls)); - $this->assertNotInstanceOf(Proxy::class, $calls[0]->getPhoneNumber()); - $this->assertNotInstanceOf(Proxy::class, $calls[1]->getPhoneNumber()); + self::assertEquals(2, count($calls)); + self::assertNotInstanceOf(Proxy::class, $calls[0]->getPhoneNumber()); + self::assertNotInstanceOf(Proxy::class, $calls[1]->getPhoneNumber()); $dql = 'SELECT p, c FROM ' . DDC881PhoneNumber::class . ' p JOIN p.calls c'; $numbers = $this->_em->createQuery($dql)->getResult(); - $this->assertEquals(2, count($numbers)); - $this->assertInstanceOf(PersistentCollection::class, $numbers[0]->getCalls()); - $this->assertTrue($numbers[0]->getCalls()->isInitialized()); + self::assertEquals(2, count($numbers)); + self::assertInstanceOf(PersistentCollection::class, $numbers[0]->getCalls()); + self::assertTrue($numbers[0]->getCalls()->isInitialized()); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC949Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC949Test.php index ab5ff8965db..d7101851405 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC949Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC949Test.php @@ -34,10 +34,10 @@ public function testBooleanThroughRepository(): void $true = $this->_em->getRepository(BooleanModel::class)->findOneBy(['booleanField' => true]); $false = $this->_em->getRepository(BooleanModel::class)->findOneBy(['booleanField' => false]); - $this->assertInstanceOf(BooleanModel::class, $true, 'True model not found'); - $this->assertTrue($true->booleanField, 'True Boolean Model should be true.'); + self::assertInstanceOf(BooleanModel::class, $true, 'True model not found'); + self::assertTrue($true->booleanField, 'True Boolean Model should be true.'); - $this->assertInstanceOf(BooleanModel::class, $false, 'False model not found'); - $this->assertFalse($false->booleanField, 'False Boolean Model should be false.'); + self::assertInstanceOf(BooleanModel::class, $false, 'False model not found'); + self::assertFalse($false->booleanField, 'False Boolean Model should be false.'); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC960Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC960Test.php index 54df850abcf..eea7a7fb994 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC960Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC960Test.php @@ -42,7 +42,7 @@ public function testUpdateRootVersion(): void $this->_em->flush(); - $this->assertEquals(2, $child->getVersion()); + self::assertEquals(2, $child->getVersion()); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC992Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC992Test.php index ffec514f49a..38002f1d8ff 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC992Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC992Test.php @@ -60,9 +60,9 @@ public function testIssue(): void $child = $this->_em->getRepository(get_class($role))->find($child->roleID); $parents = count($child->extends); - $this->assertEquals(1, $parents); + self::assertEquals(1, $parents); foreach ($child->extends as $parent) { - $this->assertEquals($role->getRoleID(), $parent->getRoleID()); + self::assertEquals($role->getRoleID(), $parent->getRoleID()); } } @@ -82,21 +82,21 @@ public function testOneToManyChild(): void $childRepository = $this->_em->getRepository(get_class($child)); $parent = $parentRepository->find($parent->id); - $this->assertEquals(1, count($parent->childs)); - $this->assertEquals(0, count($parent->childs[0]->childs())); + self::assertEquals(1, count($parent->childs)); + self::assertEquals(0, count($parent->childs[0]->childs())); $child = $parentRepository->findOneBy(['id' => $child->id]); - $this->assertSame($parent->childs[0], $child); + self::assertSame($parent->childs[0], $child); $this->_em->clear(); $child = $parentRepository->find($child->id); - $this->assertEquals(0, count($child->childs)); + self::assertEquals(0, count($child->childs)); $this->_em->clear(); $child = $childRepository->find($child->id); - $this->assertEquals(0, count($child->childs)); + self::assertEquals(0, count($child->childs)); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH5887Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH5887Test.php index c8ded4f1ed5..845f35ef0bb 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH5887Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH5887Test.php @@ -62,7 +62,7 @@ public function testLazyLoadsForeignEntitiesInOneToOneRelationWhileHavingCustomI ->getOneOrNullResult(); assert($customer instanceof GH5887Customer); - $this->assertInstanceOf(GH5887Cart::class, $customer->getCart()); + self::assertInstanceOf(GH5887Cart::class, $customer->getCart()); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH6362Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH6362Test.php index 869c275ec18..5116d6b268a 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH6362Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH6362Test.php @@ -83,8 +83,8 @@ public function testInheritanceJoinAlias(): void $hydrator = new ObjectHydrator($this->_em); $result = $hydrator->hydrateAll($stmt, $rsm, [Query::HINT_FORCE_PARTIAL_LOAD => true]); - $this->assertInstanceOf(GH6362Start::class, $result[0]['base']); - $this->assertInstanceOf(GH6362Child::class, $result[1][0]); + self::assertInstanceOf(GH6362Start::class, $result[0]['base']); + self::assertInstanceOf(GH6362Child::class, $result[1][0]); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH6464Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH6464Test.php index 3e401b9e11b..062d932c344 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH6464Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH6464Test.php @@ -43,14 +43,14 @@ public function testIssue(): void ->innerJoin(GH6464Author::class, 'a', 'WITH', 'p.authorId = a.id') ->getQuery(); - $this->assertDoesNotMatchRegularExpression( + self::assertDoesNotMatchRegularExpression( '/INNER JOIN \w+ \w+ INNER JOIN/', $query->getSQL(), 'As of GH-6464, every INNER JOIN should have an ON clause, which is missing here' ); // Query shouldn't yield a result, yet it shouldn't crash (anymore) - $this->assertEquals([], $query->getResult()); + self::assertEquals([], $query->getResult()); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7496WithToIterableTest.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7496WithToIterableTest.php index ee6801f85ae..92937baef95 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7496WithToIterableTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7496WithToIterableTest.php @@ -47,19 +47,19 @@ public function testNonUniqueObjectHydrationDuringIteration(): void $q->toIterable([], AbstractQuery::HYDRATE_OBJECT) ); - $this->assertCount(2, $bs); - $this->assertInstanceOf(GH7496EntityB::class, $bs[0]); - $this->assertInstanceOf(GH7496EntityB::class, $bs[1]); - $this->assertEquals(1, $bs[0]->id); - $this->assertEquals(1, $bs[1]->id); + self::assertCount(2, $bs); + self::assertInstanceOf(GH7496EntityB::class, $bs[0]); + self::assertInstanceOf(GH7496EntityB::class, $bs[1]); + self::assertEquals(1, $bs[0]->id); + self::assertEquals(1, $bs[1]->id); $bs = IterableTester::iterableToArray( $q->toIterable([], AbstractQuery::HYDRATE_ARRAY) ); - $this->assertCount(2, $bs); - $this->assertEquals(1, $bs[0]['id']); - $this->assertEquals(1, $bs[1]['id']); + self::assertCount(2, $bs); + self::assertEquals(1, $bs[0]['id']); + self::assertEquals(1, $bs[1]['id']); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7684Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7684Test.php index 70eeac9f7e1..b5bda3261f4 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7684Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7684Test.php @@ -17,7 +17,7 @@ class GH7684 extends DatabaseDriverTestCase public function testIssue(): void { if (! $this->_em->getConnection()->getDatabasePlatform()->supportsForeignKeyConstraints()) { - $this->markTestSkipped('Platform does not support foreign keys.'); + self::markTestSkipped('Platform does not support foreign keys.'); } $table1 = new Table('GH7684_identity_test_table'); @@ -33,6 +33,6 @@ public function testIssue(): void $metadatas = $this->convertToClassMetadata([$table1, $table2]); $metadata = $metadatas['Gh7684IdentityTestAssocTable']; - $this->assertArrayHasKey('gh7684IdentityTest', $metadata->associationMappings); + self::assertArrayHasKey('gh7684IdentityTest', $metadata->associationMappings); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7829Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7829Test.php index c3f9d7bec90..c7a5862fa63 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7829Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7829Test.php @@ -45,7 +45,7 @@ public function testPaginatorWithLimitSubquery(): void $paginator->count(); $paginator->getIterator(); - $this->assertCount(3, $this->logger->queries); + self::assertCount(3, $this->logger->queries); } public function testPaginatorWithLimitSubquerySkipped(): void @@ -58,6 +58,6 @@ public function testPaginatorWithLimitSubquerySkipped(): void $paginator->count(); $paginator->getIterator(); - $this->assertCount(2, $this->logger->queries); + self::assertCount(2, $this->logger->queries); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7864Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7864Test.php index 26e359842d0..b0d130c44a4 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7864Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7864Test.php @@ -61,7 +61,7 @@ public function testExtraLazyRemoveElement(): void return $tweet->content; }); - $this->assertEquals(['Goodbye, and thanks for all the fish'], array_values($tweets->toArray())); + self::assertEquals(['Goodbye, and thanks for all the fish'], array_values($tweets->toArray())); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7869Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7869Test.php index c098d5d4b51..5ff4820a266 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7869Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7869Test.php @@ -31,7 +31,7 @@ public function testDQLDeferredEagerLoad(): void ->setMethods(['getClassMetadata']) ->getMock(); - $em->expects($this->exactly(2)) + $em->expects(self::exactly(2)) ->method('getClassMetadata') ->willReturnCallback([$decoratedEm, 'getClassMetadata']); diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/Issue5989Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/Issue5989Test.php index b00cd680f75..0c2b6b06d2a 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/Issue5989Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/Issue5989Test.php @@ -48,7 +48,7 @@ public function testSimpleArrayTypeHydratedCorrectlyInJoinedInheritance(): void $manager = $repository->find($managerId); $employee = $repository->find($employeeId); - static::assertEquals($managerTags, $manager->tags); - static::assertEquals($employeeTags, $employee->tags); + self::assertEquals($managerTags, $manager->tags); + self::assertEquals($employeeTags, $employee->tags); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/Ticket2481Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/Ticket2481Test.php index df82949713d..2a5c66e19ba 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/Ticket2481Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/Ticket2481Test.php @@ -37,7 +37,7 @@ public function testEmptyInsert(): void $this->_em->persist($test); $this->_em->flush(); - $this->assertTrue($test->id > 0); + self::assertTrue($test->id > 0); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/TypeTest.php b/tests/Doctrine/Tests/ORM/Functional/TypeTest.php index b06675e013e..3c7c6207a2e 100644 --- a/tests/Doctrine/Tests/ORM/Functional/TypeTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/TypeTest.php @@ -36,8 +36,8 @@ public function testDecimal(): void $dql = 'SELECT d FROM ' . DecimalModel::class . ' d'; $decimal = $this->_em->createQuery($dql)->getSingleResult(); - $this->assertSame('0.15', $decimal->decimal); - $this->assertSame('0.1515', $decimal->highScale); + self::assertSame('0.15', $decimal->decimal); + self::assertSame('0.1515', $decimal->highScale); } /** @@ -55,7 +55,7 @@ public function testBoolean(): void $dql = 'SELECT b FROM ' . BooleanModel::class . ' b WHERE b.booleanField = true'; $bool = $this->_em->createQuery($dql)->getSingleResult(); - $this->assertTrue($bool->booleanField); + self::assertTrue($bool->booleanField); $bool->booleanField = false; @@ -65,7 +65,7 @@ public function testBoolean(): void $dql = 'SELECT b FROM ' . BooleanModel::class . ' b WHERE b.booleanField = false'; $bool = $this->_em->createQuery($dql)->getSingleResult(); - $this->assertFalse($bool->booleanField); + self::assertFalse($bool->booleanField); } public function testArray(): void @@ -81,7 +81,7 @@ public function testArray(): void $dql = 'SELECT s FROM ' . SerializationModel::class . ' s'; $serialize = $this->_em->createQuery($dql)->getSingleResult(); - $this->assertSame(['foo' => 'bar', 'bar' => 'baz'], $serialize->array); + self::assertSame(['foo' => 'bar', 'bar' => 'baz'], $serialize->array); } public function testObject(): void @@ -96,7 +96,7 @@ public function testObject(): void $dql = 'SELECT s FROM ' . SerializationModel::class . ' s'; $serialize = $this->_em->createQuery($dql)->getSingleResult(); - $this->assertInstanceOf('stdClass', $serialize->object); + self::assertInstanceOf('stdClass', $serialize->object); } public function testDate(): void @@ -110,8 +110,8 @@ public function testDate(): void $dateTimeDb = $this->_em->find(DateTimeModel::class, $dateTime->id); - $this->assertInstanceOf(DateTime::class, $dateTimeDb->date); - $this->assertSame('2009-10-01', $dateTimeDb->date->format('Y-m-d')); + self::assertInstanceOf(DateTime::class, $dateTimeDb->date); + self::assertSame('2009-10-01', $dateTimeDb->date->format('Y-m-d')); } public function testDateTime(): void @@ -125,13 +125,13 @@ public function testDateTime(): void $dateTimeDb = $this->_em->find(DateTimeModel::class, $dateTime->id); - $this->assertInstanceOf(DateTime::class, $dateTimeDb->datetime); - $this->assertSame('2009-10-02 20:10:52', $dateTimeDb->datetime->format('Y-m-d H:i:s')); + self::assertInstanceOf(DateTime::class, $dateTimeDb->datetime); + self::assertSame('2009-10-02 20:10:52', $dateTimeDb->datetime->format('Y-m-d H:i:s')); $articles = $this->_em->getRepository(DateTimeModel::class) ->findBy(['datetime' => new DateTime()]); - $this->assertEmpty($articles); + self::assertEmpty($articles); } public function testDqlQueryBindDateTimeInstance(): void @@ -149,8 +149,8 @@ public function testDqlQueryBindDateTimeInstance(): void ->setParameter(1, $date, DBALType::DATETIME) ->getSingleResult(); - $this->assertInstanceOf(DateTime::class, $dateTimeDb->datetime); - $this->assertSame('2009-10-02 20:10:52', $dateTimeDb->datetime->format('Y-m-d H:i:s')); + self::assertInstanceOf(DateTime::class, $dateTimeDb->datetime); + self::assertSame('2009-10-02 20:10:52', $dateTimeDb->datetime->format('Y-m-d H:i:s')); } public function testDqlQueryBuilderBindDateTimeInstance(): void @@ -171,8 +171,8 @@ public function testDqlQueryBuilderBindDateTimeInstance(): void ->setParameter(1, $date, DBALType::DATETIME) ->getQuery()->getSingleResult(); - $this->assertInstanceOf(DateTime::class, $dateTimeDb->datetime); - $this->assertSame('2009-10-02 20:10:52', $dateTimeDb->datetime->format('Y-m-d H:i:s')); + self::assertInstanceOf(DateTime::class, $dateTimeDb->datetime); + self::assertSame('2009-10-02 20:10:52', $dateTimeDb->datetime->format('Y-m-d H:i:s')); } public function testTime(): void @@ -186,7 +186,7 @@ public function testTime(): void $dateTimeDb = $this->_em->find(DateTimeModel::class, $dateTime->id); - $this->assertInstanceOf(DateTime::class, $dateTimeDb->time); - $this->assertSame('19:27:20', $dateTimeDb->time->format('H:i:s')); + self::assertInstanceOf(DateTime::class, $dateTimeDb->time); + self::assertSame('19:27:20', $dateTimeDb->time->format('H:i:s')); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/TypeValueSqlTest.php b/tests/Doctrine/Tests/ORM/Functional/TypeValueSqlTest.php index 086cbe79ab2..2bcfb552a8a 100644 --- a/tests/Doctrine/Tests/ORM/Functional/TypeValueSqlTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/TypeValueSqlTest.php @@ -48,8 +48,8 @@ public function testUpperCaseStringType(): void $entity = $this->_em->find('\Doctrine\Tests\Models\CustomType\CustomTypeUpperCase', $id); - $this->assertEquals('foo', $entity->lowerCaseString, 'Entity holds lowercase string'); - $this->assertEquals('FOO', $this->_em->getConnection()->fetchColumn('select lowerCaseString from customtype_uppercases where id=' . $entity->id . ''), 'Database holds uppercase string'); + self::assertEquals('foo', $entity->lowerCaseString, 'Entity holds lowercase string'); + self::assertEquals('FOO', $this->_em->getConnection()->fetchColumn('select lowerCaseString from customtype_uppercases where id=' . $entity->id . ''), 'Database holds uppercase string'); } /** @@ -69,8 +69,8 @@ public function testUpperCaseStringTypeWhenColumnNameIsDefined(): void $this->_em->clear(); $entity = $this->_em->find('\Doctrine\Tests\Models\CustomType\CustomTypeUpperCase', $id); - $this->assertEquals('foo', $entity->namedLowerCaseString, 'Entity holds lowercase string'); - $this->assertEquals('FOO', $this->_em->getConnection()->fetchColumn('select named_lower_case_string from customtype_uppercases where id=' . $entity->id . ''), 'Database holds uppercase string'); + self::assertEquals('foo', $entity->namedLowerCaseString, 'Entity holds lowercase string'); + self::assertEquals('FOO', $this->_em->getConnection()->fetchColumn('select named_lower_case_string from customtype_uppercases where id=' . $entity->id . ''), 'Database holds uppercase string'); $entity->namedLowerCaseString = 'bar'; @@ -82,8 +82,8 @@ public function testUpperCaseStringTypeWhenColumnNameIsDefined(): void $this->_em->clear(); $entity = $this->_em->find('\Doctrine\Tests\Models\CustomType\CustomTypeUpperCase', $id); - $this->assertEquals('bar', $entity->namedLowerCaseString, 'Entity holds lowercase string'); - $this->assertEquals('BAR', $this->_em->getConnection()->fetchColumn('select named_lower_case_string from customtype_uppercases where id=' . $entity->id . ''), 'Database holds uppercase string'); + self::assertEquals('bar', $entity->namedLowerCaseString, 'Entity holds lowercase string'); + self::assertEquals('BAR', $this->_em->getConnection()->fetchColumn('select named_lower_case_string from customtype_uppercases where id=' . $entity->id . ''), 'Database holds uppercase string'); } public function testTypeValueSqlWithAssociations(): void @@ -109,11 +109,11 @@ public function testTypeValueSqlWithAssociations(): void $entity = $this->_em->find(CustomTypeParent::class, $parentId); - $this->assertTrue($entity->customInteger < 0, 'Fetched customInteger negative'); - $this->assertEquals(1, $this->_em->getConnection()->fetchColumn('select customInteger from customtype_parents where id=' . $entity->id . ''), 'Database has stored customInteger positive'); + self::assertTrue($entity->customInteger < 0, 'Fetched customInteger negative'); + self::assertEquals(1, $this->_em->getConnection()->fetchColumn('select customInteger from customtype_parents where id=' . $entity->id . ''), 'Database has stored customInteger positive'); - $this->assertNotNull($parent->child, 'Child attached'); - $this->assertCount(2, $entity->getMyFriends(), '2 friends attached'); + self::assertNotNull($parent->child, 'Child attached'); + self::assertCount(2, $entity->getMyFriends(), '2 friends attached'); } public function testSelectDQL(): void @@ -133,12 +133,12 @@ public function testSelectDQL(): void $result = $query->getResult(); - $this->assertEquals(1, count($result)); - $this->assertInstanceOf(CustomTypeParent::class, $result[0][0]); - $this->assertEquals(-1, $result[0][0]->customInteger); + self::assertEquals(1, count($result)); + self::assertInstanceOf(CustomTypeParent::class, $result[0][0]); + self::assertEquals(-1, $result[0][0]->customInteger); - $this->assertEquals(-1, $result[0]['customInteger']); + self::assertEquals(-1, $result[0]['customInteger']); - $this->assertEquals('foo', $result[0][0]->child->lowerCaseString); + self::assertEquals('foo', $result[0][0]->child->lowerCaseString); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/UUIDGeneratorTest.php b/tests/Doctrine/Tests/ORM/Functional/UUIDGeneratorTest.php index 5a4a009a59f..e7bfbcffdf8 100644 --- a/tests/Doctrine/Tests/ORM/Functional/UUIDGeneratorTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/UUIDGeneratorTest.php @@ -29,7 +29,7 @@ public function testItIsDeprecated(): void public function testGenerateUUID(): void { if ($this->_em->getConnection()->getDatabasePlatform()->getName() !== 'mysql') { - $this->markTestSkipped('Currently restricted to MySQL platform.'); + self::markTestSkipped('Currently restricted to MySQL platform.'); } $this->_schemaTool->createSchema([ @@ -38,8 +38,8 @@ public function testGenerateUUID(): void $entity = new UUIDEntity(); $this->_em->persist($entity); - $this->assertNotNull($entity->getId()); - $this->assertTrue(strlen($entity->getId()) > 0); + self::assertNotNull($entity->getId()); + self::assertTrue(strlen($entity->getId()) > 0); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/ValueConversionType/ManyToManyCompositeIdForeignKeyTest.php b/tests/Doctrine/Tests/ORM/Functional/ValueConversionType/ManyToManyCompositeIdForeignKeyTest.php index 0acf8a9be58..024303cab26 100644 --- a/tests/Doctrine/Tests/ORM/Functional/ValueConversionType/ManyToManyCompositeIdForeignKeyTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/ValueConversionType/ManyToManyCompositeIdForeignKeyTest.php @@ -60,16 +60,16 @@ public function testThatTheValueOfIdentifiersAreConvertedInTheDatabase(): void { $conn = $this->_em->getConnection(); - $this->assertEquals('nop', $conn->fetchColumn('SELECT id4 FROM vct_auxiliary LIMIT 1')); + self::assertEquals('nop', $conn->fetchColumn('SELECT id4 FROM vct_auxiliary LIMIT 1')); - $this->assertEquals('qrs', $conn->fetchColumn('SELECT id1 FROM vct_inversed_manytomany_compositeid_foreignkey LIMIT 1')); - $this->assertEquals('nop', $conn->fetchColumn('SELECT foreign_id FROM vct_inversed_manytomany_compositeid_foreignkey LIMIT 1')); + self::assertEquals('qrs', $conn->fetchColumn('SELECT id1 FROM vct_inversed_manytomany_compositeid_foreignkey LIMIT 1')); + self::assertEquals('nop', $conn->fetchColumn('SELECT foreign_id FROM vct_inversed_manytomany_compositeid_foreignkey LIMIT 1')); - $this->assertEquals('tuv', $conn->fetchColumn('SELECT id2 FROM vct_owning_manytomany_compositeid_foreignkey LIMIT 1')); + self::assertEquals('tuv', $conn->fetchColumn('SELECT id2 FROM vct_owning_manytomany_compositeid_foreignkey LIMIT 1')); - $this->assertEquals('qrs', $conn->fetchColumn('SELECT associated_id FROM vct_xref_manytomany_compositeid_foreignkey LIMIT 1')); - $this->assertEquals('nop', $conn->fetchColumn('SELECT associated_foreign_id FROM vct_xref_manytomany_compositeid_foreignkey LIMIT 1')); - $this->assertEquals('tuv', $conn->fetchColumn('SELECT owning_id FROM vct_xref_manytomany_compositeid_foreignkey LIMIT 1')); + self::assertEquals('qrs', $conn->fetchColumn('SELECT associated_id FROM vct_xref_manytomany_compositeid_foreignkey LIMIT 1')); + self::assertEquals('nop', $conn->fetchColumn('SELECT associated_foreign_id FROM vct_xref_manytomany_compositeid_foreignkey LIMIT 1')); + self::assertEquals('tuv', $conn->fetchColumn('SELECT owning_id FROM vct_xref_manytomany_compositeid_foreignkey LIMIT 1')); } /** @@ -92,9 +92,9 @@ public function testThatEntitiesAreFetchedFromTheDatabase(): void 'ghi' ); - $this->assertInstanceOf(Models\ValueConversionType\AuxiliaryEntity::class, $auxiliary); - $this->assertInstanceOf(Models\ValueConversionType\InversedManyToManyCompositeIdForeignKeyEntity::class, $inversed); - $this->assertInstanceOf(Models\ValueConversionType\OwningManyToManyCompositeIdForeignKeyEntity::class, $owning); + self::assertInstanceOf(Models\ValueConversionType\AuxiliaryEntity::class, $auxiliary); + self::assertInstanceOf(Models\ValueConversionType\InversedManyToManyCompositeIdForeignKeyEntity::class, $inversed); + self::assertInstanceOf(Models\ValueConversionType\OwningManyToManyCompositeIdForeignKeyEntity::class, $owning); } /** @@ -117,10 +117,10 @@ public function testThatTheValueOfIdentifiersAreConvertedBackAfterBeingFetchedFr 'ghi' ); - $this->assertEquals('abc', $auxiliary->id4); - $this->assertEquals('def', $inversed->id1); - $this->assertEquals('abc', $inversed->foreignEntity->id4); - $this->assertEquals('ghi', $owning->id2); + self::assertEquals('abc', $auxiliary->id4); + self::assertEquals('def', $inversed->id1); + self::assertEquals('abc', $inversed->foreignEntity->id4); + self::assertEquals('ghi', $owning->id2); } /** @@ -138,7 +138,7 @@ public function testThatInversedEntityIsFetchedFromTheDatabaseUsingAuxiliaryEnti ['id1' => 'def', 'foreignEntity' => $auxiliary] ); - $this->assertInstanceOf(Models\ValueConversionType\InversedManyToManyCompositeIdForeignKeyEntity::class, $inversed); + self::assertInstanceOf(Models\ValueConversionType\InversedManyToManyCompositeIdForeignKeyEntity::class, $inversed); } /** @@ -151,7 +151,7 @@ public function testThatTheCollectionFromOwningToInversedIsLoaded(): void 'ghi' ); - $this->assertCount(1, $owning->associatedEntities); + self::assertCount(1, $owning->associatedEntities); } /** @@ -164,7 +164,7 @@ public function testThatTheCollectionFromInversedToOwningIsLoaded(): void ['id1' => 'def', 'foreignEntity' => 'abc'] ); - $this->assertCount(1, $inversed->associatedEntities); + self::assertCount(1, $inversed->associatedEntities); } /** @@ -192,6 +192,6 @@ public function testThatTheJoinTableRowsAreRemovedWhenRemovingTheAssociation(): // test association is removed - $this->assertEquals(0, $conn->fetchColumn('SELECT COUNT(*) FROM vct_xref_manytomany_compositeid_foreignkey')); + self::assertEquals(0, $conn->fetchColumn('SELECT COUNT(*) FROM vct_xref_manytomany_compositeid_foreignkey')); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/ValueConversionType/ManyToManyCompositeIdTest.php b/tests/Doctrine/Tests/ORM/Functional/ValueConversionType/ManyToManyCompositeIdTest.php index 9d7460b38f8..2715909af42 100644 --- a/tests/Doctrine/Tests/ORM/Functional/ValueConversionType/ManyToManyCompositeIdTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/ValueConversionType/ManyToManyCompositeIdTest.php @@ -54,14 +54,14 @@ public function testThatTheValueOfIdentifiersAreConvertedInTheDatabase(): void { $conn = $this->_em->getConnection(); - $this->assertEquals('nop', $conn->fetchColumn('SELECT id1 FROM vct_inversed_manytomany_compositeid LIMIT 1')); - $this->assertEquals('qrs', $conn->fetchColumn('SELECT id2 FROM vct_inversed_manytomany_compositeid LIMIT 1')); + self::assertEquals('nop', $conn->fetchColumn('SELECT id1 FROM vct_inversed_manytomany_compositeid LIMIT 1')); + self::assertEquals('qrs', $conn->fetchColumn('SELECT id2 FROM vct_inversed_manytomany_compositeid LIMIT 1')); - $this->assertEquals('tuv', $conn->fetchColumn('SELECT id3 FROM vct_owning_manytomany_compositeid LIMIT 1')); + self::assertEquals('tuv', $conn->fetchColumn('SELECT id3 FROM vct_owning_manytomany_compositeid LIMIT 1')); - $this->assertEquals('nop', $conn->fetchColumn('SELECT inversed_id1 FROM vct_xref_manytomany_compositeid LIMIT 1')); - $this->assertEquals('qrs', $conn->fetchColumn('SELECT inversed_id2 FROM vct_xref_manytomany_compositeid LIMIT 1')); - $this->assertEquals('tuv', $conn->fetchColumn('SELECT owning_id FROM vct_xref_manytomany_compositeid LIMIT 1')); + self::assertEquals('nop', $conn->fetchColumn('SELECT inversed_id1 FROM vct_xref_manytomany_compositeid LIMIT 1')); + self::assertEquals('qrs', $conn->fetchColumn('SELECT inversed_id2 FROM vct_xref_manytomany_compositeid LIMIT 1')); + self::assertEquals('tuv', $conn->fetchColumn('SELECT owning_id FROM vct_xref_manytomany_compositeid LIMIT 1')); } /** @@ -79,8 +79,8 @@ public function testThatEntitiesAreFetchedFromTheDatabase(): void 'ghi' ); - $this->assertInstanceOf(Models\ValueConversionType\InversedManyToManyCompositeIdEntity::class, $inversed); - $this->assertInstanceOf(Models\ValueConversionType\OwningManyToManyCompositeIdEntity::class, $owning); + self::assertInstanceOf(Models\ValueConversionType\InversedManyToManyCompositeIdEntity::class, $inversed); + self::assertInstanceOf(Models\ValueConversionType\OwningManyToManyCompositeIdEntity::class, $owning); } /** @@ -98,9 +98,9 @@ public function testThatTheValueOfIdentifiersAreConvertedBackAfterBeingFetchedFr 'ghi' ); - $this->assertEquals('abc', $inversed->id1); - $this->assertEquals('def', $inversed->id2); - $this->assertEquals('ghi', $owning->id3); + self::assertEquals('abc', $inversed->id1); + self::assertEquals('def', $inversed->id2); + self::assertEquals('ghi', $owning->id3); } /** @@ -113,7 +113,7 @@ public function testThatTheCollectionFromOwningToInversedIsLoaded(): void 'ghi' ); - $this->assertCount(1, $owning->associatedEntities); + self::assertCount(1, $owning->associatedEntities); } /** @@ -126,7 +126,7 @@ public function testThatTheCollectionFromInversedToOwningIsLoaded(): void ['id1' => 'abc', 'id2' => 'def'] ); - $this->assertCount(1, $inversed->associatedEntities); + self::assertCount(1, $inversed->associatedEntities); } /** @@ -154,6 +154,6 @@ public function testThatTheJoinTableRowsAreRemovedWhenRemovingTheAssociation(): // test association is removed - $this->assertEquals(0, $conn->fetchColumn('SELECT COUNT(*) FROM vct_xref_manytomany_compositeid')); + self::assertEquals(0, $conn->fetchColumn('SELECT COUNT(*) FROM vct_xref_manytomany_compositeid')); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/ValueConversionType/ManyToManyExtraLazyTest.php b/tests/Doctrine/Tests/ORM/Functional/ValueConversionType/ManyToManyExtraLazyTest.php index 6096b48a997..79f6beebc23 100644 --- a/tests/Doctrine/Tests/ORM/Functional/ValueConversionType/ManyToManyExtraLazyTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/ValueConversionType/ManyToManyExtraLazyTest.php @@ -71,7 +71,7 @@ public function testThatTheExtraLazyCollectionFromOwningToInversedIsCounted(): v 'ghi' ); - $this->assertEquals(2, $owning->associatedEntities->count()); + self::assertEquals(2, $owning->associatedEntities->count()); } public function testThatTheExtraLazyCollectionFromInversedToOwningIsCounted(): void @@ -81,7 +81,7 @@ public function testThatTheExtraLazyCollectionFromInversedToOwningIsCounted(): v 'abc' ); - $this->assertEquals(2, $inversed->associatedEntities->count()); + self::assertEquals(2, $inversed->associatedEntities->count()); } public function testThatTheExtraLazyCollectionFromOwningToInversedContainsAnEntity(): void @@ -96,7 +96,7 @@ public function testThatTheExtraLazyCollectionFromOwningToInversedContainsAnEnti 'abc' ); - $this->assertTrue($owning->associatedEntities->contains($inversed)); + self::assertTrue($owning->associatedEntities->contains($inversed)); } public function testThatTheExtraLazyCollectionFromInversedToOwningContainsAnEntity(): void @@ -111,7 +111,7 @@ public function testThatTheExtraLazyCollectionFromInversedToOwningContainsAnEnti 'ghi' ); - $this->assertTrue($inversed->associatedEntities->contains($owning)); + self::assertTrue($inversed->associatedEntities->contains($owning)); } public function testThatTheExtraLazyCollectionFromOwningToInversedContainsAnIndexByKey(): void @@ -121,7 +121,7 @@ public function testThatTheExtraLazyCollectionFromOwningToInversedContainsAnInde 'ghi' ); - $this->assertTrue($owning->associatedEntities->containsKey('abc')); + self::assertTrue($owning->associatedEntities->containsKey('abc')); } public function testThatTheExtraLazyCollectionFromInversedToOwningContainsAnIndexByKey(): void @@ -131,7 +131,7 @@ public function testThatTheExtraLazyCollectionFromInversedToOwningContainsAnInde 'abc' ); - $this->assertTrue($inversed->associatedEntities->containsKey('ghi')); + self::assertTrue($inversed->associatedEntities->containsKey('ghi')); } public function testThatASliceOfTheExtraLazyCollectionFromOwningToInversedIsLoaded(): void @@ -141,7 +141,7 @@ public function testThatASliceOfTheExtraLazyCollectionFromOwningToInversedIsLoad 'ghi' ); - $this->assertCount(1, $owning->associatedEntities->slice(0, 1)); + self::assertCount(1, $owning->associatedEntities->slice(0, 1)); } public function testThatASliceOfTheExtraLazyCollectionFromInversedToOwningIsLoaded(): void @@ -151,6 +151,6 @@ public function testThatASliceOfTheExtraLazyCollectionFromInversedToOwningIsLoad 'abc' ); - $this->assertCount(1, $inversed->associatedEntities->slice(1, 1)); + self::assertCount(1, $inversed->associatedEntities->slice(1, 1)); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/ValueConversionType/ManyToManyTest.php b/tests/Doctrine/Tests/ORM/Functional/ValueConversionType/ManyToManyTest.php index 67cb2107e00..f4dc1be9c9d 100644 --- a/tests/Doctrine/Tests/ORM/Functional/ValueConversionType/ManyToManyTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/ValueConversionType/ManyToManyTest.php @@ -53,12 +53,12 @@ public function testThatTheValueOfIdentifiersAreConvertedInTheDatabase(): void { $conn = $this->_em->getConnection(); - $this->assertEquals('nop', $conn->fetchColumn('SELECT id1 FROM vct_inversed_manytomany LIMIT 1')); + self::assertEquals('nop', $conn->fetchColumn('SELECT id1 FROM vct_inversed_manytomany LIMIT 1')); - $this->assertEquals('qrs', $conn->fetchColumn('SELECT id2 FROM vct_owning_manytomany LIMIT 1')); + self::assertEquals('qrs', $conn->fetchColumn('SELECT id2 FROM vct_owning_manytomany LIMIT 1')); - $this->assertEquals('nop', $conn->fetchColumn('SELECT inversed_id FROM vct_xref_manytomany LIMIT 1')); - $this->assertEquals('qrs', $conn->fetchColumn('SELECT owning_id FROM vct_xref_manytomany LIMIT 1')); + self::assertEquals('nop', $conn->fetchColumn('SELECT inversed_id FROM vct_xref_manytomany LIMIT 1')); + self::assertEquals('qrs', $conn->fetchColumn('SELECT owning_id FROM vct_xref_manytomany LIMIT 1')); } /** @@ -76,8 +76,8 @@ public function testThatEntitiesAreFetchedFromTheDatabase(): void 'def' ); - $this->assertInstanceOf(Models\ValueConversionType\InversedManyToManyEntity::class, $inversed); - $this->assertInstanceOf(Models\ValueConversionType\OwningManyToManyEntity::class, $owning); + self::assertInstanceOf(Models\ValueConversionType\InversedManyToManyEntity::class, $inversed); + self::assertInstanceOf(Models\ValueConversionType\OwningManyToManyEntity::class, $owning); } /** @@ -95,8 +95,8 @@ public function testThatTheValueOfIdentifiersAreConvertedBackAfterBeingFetchedFr 'def' ); - $this->assertEquals('abc', $inversed->id1); - $this->assertEquals('def', $owning->id2); + self::assertEquals('abc', $inversed->id1); + self::assertEquals('def', $owning->id2); } /** @@ -109,7 +109,7 @@ public function testThatTheCollectionFromOwningToInversedIsLoaded(): void 'def' ); - $this->assertCount(1, $owning->associatedEntities); + self::assertCount(1, $owning->associatedEntities); } /** @@ -122,7 +122,7 @@ public function testThatTheCollectionFromInversedToOwningIsLoaded(): void 'abc' ); - $this->assertCount(1, $inversed->associatedEntities); + self::assertCount(1, $inversed->associatedEntities); } /** @@ -150,6 +150,6 @@ public function testThatTheJoinTableRowsAreRemovedWhenRemovingTheAssociation(): // test association is removed - $this->assertEquals(0, $conn->fetchColumn('SELECT COUNT(*) FROM vct_xref_manytomany')); + self::assertEquals(0, $conn->fetchColumn('SELECT COUNT(*) FROM vct_xref_manytomany')); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/ValueConversionType/OneToManyCompositeIdForeignKeyTest.php b/tests/Doctrine/Tests/ORM/Functional/ValueConversionType/OneToManyCompositeIdForeignKeyTest.php index fb9d11c6a8d..422f1b960fc 100644 --- a/tests/Doctrine/Tests/ORM/Functional/ValueConversionType/OneToManyCompositeIdForeignKeyTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/ValueConversionType/OneToManyCompositeIdForeignKeyTest.php @@ -60,14 +60,14 @@ public function testThatTheValueOfIdentifiersAreConvertedInTheDatabase(): void { $conn = $this->_em->getConnection(); - $this->assertEquals('nop', $conn->fetchColumn('SELECT id4 FROM vct_auxiliary LIMIT 1')); + self::assertEquals('nop', $conn->fetchColumn('SELECT id4 FROM vct_auxiliary LIMIT 1')); - $this->assertEquals('qrs', $conn->fetchColumn('SELECT id1 FROM vct_inversed_onetomany_compositeid_foreignkey LIMIT 1')); - $this->assertEquals('nop', $conn->fetchColumn('SELECT foreign_id FROM vct_inversed_onetomany_compositeid_foreignkey LIMIT 1')); + self::assertEquals('qrs', $conn->fetchColumn('SELECT id1 FROM vct_inversed_onetomany_compositeid_foreignkey LIMIT 1')); + self::assertEquals('nop', $conn->fetchColumn('SELECT foreign_id FROM vct_inversed_onetomany_compositeid_foreignkey LIMIT 1')); - $this->assertEquals('tuv', $conn->fetchColumn('SELECT id2 FROM vct_owning_manytoone_compositeid_foreignkey LIMIT 1')); - $this->assertEquals('qrs', $conn->fetchColumn('SELECT associated_id FROM vct_owning_manytoone_compositeid_foreignkey LIMIT 1')); - $this->assertEquals('nop', $conn->fetchColumn('SELECT associated_foreign_id FROM vct_owning_manytoone_compositeid_foreignkey LIMIT 1')); + self::assertEquals('tuv', $conn->fetchColumn('SELECT id2 FROM vct_owning_manytoone_compositeid_foreignkey LIMIT 1')); + self::assertEquals('qrs', $conn->fetchColumn('SELECT associated_id FROM vct_owning_manytoone_compositeid_foreignkey LIMIT 1')); + self::assertEquals('nop', $conn->fetchColumn('SELECT associated_foreign_id FROM vct_owning_manytoone_compositeid_foreignkey LIMIT 1')); } /** @@ -90,9 +90,9 @@ public function testThatEntitiesAreFetchedFromTheDatabase(): void 'ghi' ); - $this->assertInstanceOf(Models\ValueConversionType\AuxiliaryEntity::class, $auxiliary); - $this->assertInstanceOf(Models\ValueConversionType\InversedOneToManyCompositeIdForeignKeyEntity::class, $inversed); - $this->assertInstanceOf(Models\ValueConversionType\OwningManyToOneCompositeIdForeignKeyEntity::class, $owning); + self::assertInstanceOf(Models\ValueConversionType\AuxiliaryEntity::class, $auxiliary); + self::assertInstanceOf(Models\ValueConversionType\InversedOneToManyCompositeIdForeignKeyEntity::class, $inversed); + self::assertInstanceOf(Models\ValueConversionType\OwningManyToOneCompositeIdForeignKeyEntity::class, $owning); } /** @@ -115,10 +115,10 @@ public function testThatTheValueOfIdentifiersAreConvertedBackAfterBeingFetchedFr 'ghi' ); - $this->assertEquals('abc', $auxiliary->id4); - $this->assertEquals('def', $inversed->id1); - $this->assertEquals('abc', $inversed->foreignEntity->id4); - $this->assertEquals('ghi', $owning->id2); + self::assertEquals('abc', $auxiliary->id4); + self::assertEquals('def', $inversed->id1); + self::assertEquals('abc', $inversed->foreignEntity->id4); + self::assertEquals('ghi', $owning->id2); } /** @@ -136,7 +136,7 @@ public function testThatInversedEntityIsFetchedFromTheDatabaseUsingAuxiliaryEnti ['id1' => 'def', 'foreignEntity' => $auxiliary] ); - $this->assertInstanceOf(Models\ValueConversionType\InversedOneToManyCompositeIdForeignKeyEntity::class, $inversed); + self::assertInstanceOf(Models\ValueConversionType\InversedOneToManyCompositeIdForeignKeyEntity::class, $inversed); } /** @@ -151,9 +151,9 @@ public function testThatTheProxyFromOwningToInversedIsLoaded(): void $inversedProxy = $owning->associatedEntity; - $this->assertSame('def', $inversedProxy->id1, 'Proxy identifier is converted'); + self::assertSame('def', $inversedProxy->id1, 'Proxy identifier is converted'); - $this->assertEquals('some value to be loaded', $inversedProxy->someProperty); + self::assertEquals('some value to be loaded', $inversedProxy->someProperty); } /** @@ -166,6 +166,6 @@ public function testThatTheCollectionFromInversedToOwningIsLoaded(): void ['id1' => 'def', 'foreignEntity' => 'abc'] ); - $this->assertCount(1, $inversed->associatedEntities); + self::assertCount(1, $inversed->associatedEntities); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/ValueConversionType/OneToManyCompositeIdTest.php b/tests/Doctrine/Tests/ORM/Functional/ValueConversionType/OneToManyCompositeIdTest.php index e0a323b6b5d..0ec1e7aa54b 100644 --- a/tests/Doctrine/Tests/ORM/Functional/ValueConversionType/OneToManyCompositeIdTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/ValueConversionType/OneToManyCompositeIdTest.php @@ -54,12 +54,12 @@ public function testThatTheValueOfIdentifiersAreConvertedInTheDatabase(): void { $conn = $this->_em->getConnection(); - $this->assertEquals('nop', $conn->fetchColumn('SELECT id1 FROM vct_inversed_onetomany_compositeid LIMIT 1')); - $this->assertEquals('qrs', $conn->fetchColumn('SELECT id2 FROM vct_inversed_onetomany_compositeid LIMIT 1')); + self::assertEquals('nop', $conn->fetchColumn('SELECT id1 FROM vct_inversed_onetomany_compositeid LIMIT 1')); + self::assertEquals('qrs', $conn->fetchColumn('SELECT id2 FROM vct_inversed_onetomany_compositeid LIMIT 1')); - $this->assertEquals('tuv', $conn->fetchColumn('SELECT id3 FROM vct_owning_manytoone_compositeid LIMIT 1')); - $this->assertEquals('nop', $conn->fetchColumn('SELECT associated_id1 FROM vct_owning_manytoone_compositeid LIMIT 1')); - $this->assertEquals('qrs', $conn->fetchColumn('SELECT associated_id2 FROM vct_owning_manytoone_compositeid LIMIT 1')); + self::assertEquals('tuv', $conn->fetchColumn('SELECT id3 FROM vct_owning_manytoone_compositeid LIMIT 1')); + self::assertEquals('nop', $conn->fetchColumn('SELECT associated_id1 FROM vct_owning_manytoone_compositeid LIMIT 1')); + self::assertEquals('qrs', $conn->fetchColumn('SELECT associated_id2 FROM vct_owning_manytoone_compositeid LIMIT 1')); } /** @@ -77,8 +77,8 @@ public function testThatEntitiesAreFetchedFromTheDatabase(): void 'ghi' ); - $this->assertInstanceOf(Models\ValueConversionType\InversedOneToManyCompositeIdEntity::class, $inversed); - $this->assertInstanceOf(Models\ValueConversionType\OwningManyToOneCompositeIdEntity::class, $owning); + self::assertInstanceOf(Models\ValueConversionType\InversedOneToManyCompositeIdEntity::class, $inversed); + self::assertInstanceOf(Models\ValueConversionType\OwningManyToOneCompositeIdEntity::class, $owning); } /** @@ -96,9 +96,9 @@ public function testThatTheValueOfIdentifiersAreConvertedBackAfterBeingFetchedFr 'ghi' ); - $this->assertEquals('abc', $inversed->id1); - $this->assertEquals('def', $inversed->id2); - $this->assertEquals('ghi', $owning->id3); + self::assertEquals('abc', $inversed->id1); + self::assertEquals('def', $inversed->id2); + self::assertEquals('ghi', $owning->id3); } /** @@ -113,7 +113,7 @@ public function testThatTheProxyFromOwningToInversedIsLoaded(): void $inversedProxy = $owning->associatedEntity; - $this->assertEquals('some value to be loaded', $inversedProxy->someProperty); + self::assertEquals('some value to be loaded', $inversedProxy->someProperty); } /** @@ -126,6 +126,6 @@ public function testThatTheCollectionFromInversedToOwningIsLoaded(): void ['id1' => 'abc', 'id2' => 'def'] ); - $this->assertCount(1, $inversed->associatedEntities); + self::assertCount(1, $inversed->associatedEntities); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/ValueConversionType/OneToManyExtraLazyTest.php b/tests/Doctrine/Tests/ORM/Functional/ValueConversionType/OneToManyExtraLazyTest.php index 512cbdfa11b..b8a417fb901 100644 --- a/tests/Doctrine/Tests/ORM/Functional/ValueConversionType/OneToManyExtraLazyTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/ValueConversionType/OneToManyExtraLazyTest.php @@ -68,7 +68,7 @@ public function testThatExtraLazyCollectionIsCounted(): void 'abc' ); - $this->assertEquals(3, $inversed->associatedEntities->count()); + self::assertEquals(3, $inversed->associatedEntities->count()); } public function testThatExtraLazyCollectionContainsAnEntity(): void @@ -83,7 +83,7 @@ public function testThatExtraLazyCollectionContainsAnEntity(): void 'def' ); - $this->assertTrue($inversed->associatedEntities->contains($owning)); + self::assertTrue($inversed->associatedEntities->contains($owning)); } public function testThatExtraLazyCollectionContainsAnIndexbyKey(): void @@ -93,7 +93,7 @@ public function testThatExtraLazyCollectionContainsAnIndexbyKey(): void 'abc' ); - $this->assertTrue($inversed->associatedEntities->containsKey('def')); + self::assertTrue($inversed->associatedEntities->containsKey('def')); } public function testThatASliceOfTheExtraLazyCollectionIsLoaded(): void @@ -103,6 +103,6 @@ public function testThatASliceOfTheExtraLazyCollectionIsLoaded(): void 'abc' ); - $this->assertCount(2, $inversed->associatedEntities->slice(0, 2)); + self::assertCount(2, $inversed->associatedEntities->slice(0, 2)); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/ValueConversionType/OneToManyTest.php b/tests/Doctrine/Tests/ORM/Functional/ValueConversionType/OneToManyTest.php index 9e65c899467..c69ca285bfd 100644 --- a/tests/Doctrine/Tests/ORM/Functional/ValueConversionType/OneToManyTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/ValueConversionType/OneToManyTest.php @@ -53,10 +53,10 @@ public function testThatTheValueOfIdentifiersAreConvertedInTheDatabase(): void { $conn = $this->_em->getConnection(); - $this->assertEquals('nop', $conn->fetchColumn('SELECT id1 FROM vct_inversed_onetomany LIMIT 1')); + self::assertEquals('nop', $conn->fetchColumn('SELECT id1 FROM vct_inversed_onetomany LIMIT 1')); - $this->assertEquals('qrs', $conn->fetchColumn('SELECT id2 FROM vct_owning_manytoone LIMIT 1')); - $this->assertEquals('nop', $conn->fetchColumn('SELECT associated_id FROM vct_owning_manytoone LIMIT 1')); + self::assertEquals('qrs', $conn->fetchColumn('SELECT id2 FROM vct_owning_manytoone LIMIT 1')); + self::assertEquals('nop', $conn->fetchColumn('SELECT associated_id FROM vct_owning_manytoone LIMIT 1')); } /** @@ -74,8 +74,8 @@ public function testThatEntitiesAreFetchedFromTheDatabase(): void 'def' ); - $this->assertInstanceOf(Models\ValueConversionType\InversedOneToManyEntity::class, $inversed); - $this->assertInstanceOf(Models\ValueConversionType\OwningManyToOneEntity::class, $owning); + self::assertInstanceOf(Models\ValueConversionType\InversedOneToManyEntity::class, $inversed); + self::assertInstanceOf(Models\ValueConversionType\OwningManyToOneEntity::class, $owning); } /** @@ -93,8 +93,8 @@ public function testThatTheValueOfIdentifiersAreConvertedBackAfterBeingFetchedFr 'def' ); - $this->assertEquals('abc', $inversed->id1); - $this->assertEquals('def', $owning->id2); + self::assertEquals('abc', $inversed->id1); + self::assertEquals('def', $owning->id2); } /** @@ -109,7 +109,7 @@ public function testThatTheProxyFromOwningToInversedIsLoaded(): void $inversedProxy = $owning->associatedEntity; - $this->assertEquals('some value to be loaded', $inversedProxy->someProperty); + self::assertEquals('some value to be loaded', $inversedProxy->someProperty); } /** @@ -122,6 +122,6 @@ public function testThatTheCollectionFromInversedToOwningIsLoaded(): void 'abc' ); - $this->assertCount(1, $inversed->associatedEntities); + self::assertCount(1, $inversed->associatedEntities); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/ValueConversionType/OneToOneCompositeIdForeignKeyTest.php b/tests/Doctrine/Tests/ORM/Functional/ValueConversionType/OneToOneCompositeIdForeignKeyTest.php index a5467be8b14..6155b09ef9b 100644 --- a/tests/Doctrine/Tests/ORM/Functional/ValueConversionType/OneToOneCompositeIdForeignKeyTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/ValueConversionType/OneToOneCompositeIdForeignKeyTest.php @@ -59,14 +59,14 @@ public function testThatTheValueOfIdentifiersAreConvertedInTheDatabase(): void { $conn = $this->_em->getConnection(); - $this->assertEquals('nop', $conn->fetchColumn('SELECT id4 FROM vct_auxiliary LIMIT 1')); + self::assertEquals('nop', $conn->fetchColumn('SELECT id4 FROM vct_auxiliary LIMIT 1')); - $this->assertEquals('qrs', $conn->fetchColumn('SELECT id1 FROM vct_inversed_onetoone_compositeid_foreignkey LIMIT 1')); - $this->assertEquals('nop', $conn->fetchColumn('SELECT foreign_id FROM vct_inversed_onetoone_compositeid_foreignkey LIMIT 1')); + self::assertEquals('qrs', $conn->fetchColumn('SELECT id1 FROM vct_inversed_onetoone_compositeid_foreignkey LIMIT 1')); + self::assertEquals('nop', $conn->fetchColumn('SELECT foreign_id FROM vct_inversed_onetoone_compositeid_foreignkey LIMIT 1')); - $this->assertEquals('tuv', $conn->fetchColumn('SELECT id2 FROM vct_owning_onetoone_compositeid_foreignkey LIMIT 1')); - $this->assertEquals('qrs', $conn->fetchColumn('SELECT associated_id FROM vct_owning_onetoone_compositeid_foreignkey LIMIT 1')); - $this->assertEquals('nop', $conn->fetchColumn('SELECT associated_foreign_id FROM vct_owning_onetoone_compositeid_foreignkey LIMIT 1')); + self::assertEquals('tuv', $conn->fetchColumn('SELECT id2 FROM vct_owning_onetoone_compositeid_foreignkey LIMIT 1')); + self::assertEquals('qrs', $conn->fetchColumn('SELECT associated_id FROM vct_owning_onetoone_compositeid_foreignkey LIMIT 1')); + self::assertEquals('nop', $conn->fetchColumn('SELECT associated_foreign_id FROM vct_owning_onetoone_compositeid_foreignkey LIMIT 1')); } /** @@ -89,9 +89,9 @@ public function testThatEntitiesAreFetchedFromTheDatabase(): void 'ghi' ); - $this->assertInstanceOf(Models\ValueConversionType\AuxiliaryEntity::class, $auxiliary); - $this->assertInstanceOf(Models\ValueConversionType\InversedOneToOneCompositeIdForeignKeyEntity::class, $inversed); - $this->assertInstanceOf(Models\ValueConversionType\OwningOneToOneCompositeIdForeignKeyEntity::class, $owning); + self::assertInstanceOf(Models\ValueConversionType\AuxiliaryEntity::class, $auxiliary); + self::assertInstanceOf(Models\ValueConversionType\InversedOneToOneCompositeIdForeignKeyEntity::class, $inversed); + self::assertInstanceOf(Models\ValueConversionType\OwningOneToOneCompositeIdForeignKeyEntity::class, $owning); } /** @@ -114,10 +114,10 @@ public function testThatTheValueOfIdentifiersAreConvertedBackAfterBeingFetchedFr 'ghi' ); - $this->assertEquals('abc', $auxiliary->id4); - $this->assertEquals('def', $inversed->id1); - $this->assertEquals('abc', $inversed->foreignEntity->id4); - $this->assertEquals('ghi', $owning->id2); + self::assertEquals('abc', $auxiliary->id4); + self::assertEquals('def', $inversed->id1); + self::assertEquals('abc', $inversed->foreignEntity->id4); + self::assertEquals('ghi', $owning->id2); } /** @@ -135,7 +135,7 @@ public function testThatInversedEntityIsFetchedFromTheDatabaseUsingAuxiliaryEnti ['id1' => 'def', 'foreignEntity' => $auxiliary] ); - $this->assertInstanceOf(Models\ValueConversionType\InversedOneToOneCompositeIdForeignKeyEntity::class, $inversed); + self::assertInstanceOf(Models\ValueConversionType\InversedOneToOneCompositeIdForeignKeyEntity::class, $inversed); } /** @@ -150,7 +150,7 @@ public function testThatTheProxyFromOwningToInversedIsLoaded(): void $inversedProxy = $owning->associatedEntity; - $this->assertEquals('some value to be loaded', $inversedProxy->someProperty); + self::assertEquals('some value to be loaded', $inversedProxy->someProperty); } /** @@ -163,6 +163,6 @@ public function testThatTheEntityFromInversedToOwningIsEagerLoaded(): void ['id1' => 'def', 'foreignEntity' => 'abc'] ); - $this->assertInstanceOf(Models\ValueConversionType\OwningOneToOneCompositeIdForeignKeyEntity::class, $inversed->associatedEntity); + self::assertInstanceOf(Models\ValueConversionType\OwningOneToOneCompositeIdForeignKeyEntity::class, $inversed->associatedEntity); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/ValueConversionType/OneToOneCompositeIdTest.php b/tests/Doctrine/Tests/ORM/Functional/ValueConversionType/OneToOneCompositeIdTest.php index f4fdb05b8d1..5011f58f36f 100644 --- a/tests/Doctrine/Tests/ORM/Functional/ValueConversionType/OneToOneCompositeIdTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/ValueConversionType/OneToOneCompositeIdTest.php @@ -53,12 +53,12 @@ public function testThatTheValueOfIdentifiersAreConvertedInTheDatabase(): void { $conn = $this->_em->getConnection(); - $this->assertEquals('nop', $conn->fetchColumn('SELECT id1 FROM vct_inversed_onetoone_compositeid LIMIT 1')); - $this->assertEquals('qrs', $conn->fetchColumn('SELECT id2 FROM vct_inversed_onetoone_compositeid LIMIT 1')); + self::assertEquals('nop', $conn->fetchColumn('SELECT id1 FROM vct_inversed_onetoone_compositeid LIMIT 1')); + self::assertEquals('qrs', $conn->fetchColumn('SELECT id2 FROM vct_inversed_onetoone_compositeid LIMIT 1')); - $this->assertEquals('tuv', $conn->fetchColumn('SELECT id3 FROM vct_owning_onetoone_compositeid LIMIT 1')); - $this->assertEquals('nop', $conn->fetchColumn('SELECT associated_id1 FROM vct_owning_onetoone_compositeid LIMIT 1')); - $this->assertEquals('qrs', $conn->fetchColumn('SELECT associated_id2 FROM vct_owning_onetoone_compositeid LIMIT 1')); + self::assertEquals('tuv', $conn->fetchColumn('SELECT id3 FROM vct_owning_onetoone_compositeid LIMIT 1')); + self::assertEquals('nop', $conn->fetchColumn('SELECT associated_id1 FROM vct_owning_onetoone_compositeid LIMIT 1')); + self::assertEquals('qrs', $conn->fetchColumn('SELECT associated_id2 FROM vct_owning_onetoone_compositeid LIMIT 1')); } /** @@ -76,8 +76,8 @@ public function testThatEntitiesAreFetchedFromTheDatabase(): void 'ghi' ); - $this->assertInstanceOf(Models\ValueConversionType\InversedOneToOneCompositeIdEntity::class, $inversed); - $this->assertInstanceOf(Models\ValueConversionType\OwningOneToOneCompositeIdEntity::class, $owning); + self::assertInstanceOf(Models\ValueConversionType\InversedOneToOneCompositeIdEntity::class, $inversed); + self::assertInstanceOf(Models\ValueConversionType\OwningOneToOneCompositeIdEntity::class, $owning); } /** @@ -95,9 +95,9 @@ public function testThatTheValueOfIdentifiersAreConvertedBackAfterBeingFetchedFr 'ghi' ); - $this->assertEquals('abc', $inversed->id1); - $this->assertEquals('def', $inversed->id2); - $this->assertEquals('ghi', $owning->id3); + self::assertEquals('abc', $inversed->id1); + self::assertEquals('def', $inversed->id2); + self::assertEquals('ghi', $owning->id3); } /** @@ -112,7 +112,7 @@ public function testThatTheProxyFromOwningToInversedIsLoaded(): void $inversedProxy = $owning->associatedEntity; - $this->assertEquals('some value to be loaded', $inversedProxy->someProperty); + self::assertEquals('some value to be loaded', $inversedProxy->someProperty); } /** @@ -125,6 +125,6 @@ public function testThatTheEntityFromInversedToOwningIsEagerLoaded(): void ['id1' => 'abc', 'id2' => 'def'] ); - $this->assertInstanceOf(Models\ValueConversionType\OwningOneToOneCompositeIdEntity::class, $inversed->associatedEntity); + self::assertInstanceOf(Models\ValueConversionType\OwningOneToOneCompositeIdEntity::class, $inversed->associatedEntity); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/ValueConversionType/OneToOneTest.php b/tests/Doctrine/Tests/ORM/Functional/ValueConversionType/OneToOneTest.php index 8143a478fb9..55b359fc1c0 100644 --- a/tests/Doctrine/Tests/ORM/Functional/ValueConversionType/OneToOneTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/ValueConversionType/OneToOneTest.php @@ -53,10 +53,10 @@ public function testThatTheValueOfIdentifiersAreConvertedInTheDatabase(): void { $conn = $this->_em->getConnection(); - $this->assertEquals('nop', $conn->fetchColumn('SELECT id1 FROM vct_inversed_onetoone LIMIT 1')); + self::assertEquals('nop', $conn->fetchColumn('SELECT id1 FROM vct_inversed_onetoone LIMIT 1')); - $this->assertEquals('qrs', $conn->fetchColumn('SELECT id2 FROM vct_owning_onetoone LIMIT 1')); - $this->assertEquals('nop', $conn->fetchColumn('SELECT associated_id FROM vct_owning_onetoone LIMIT 1')); + self::assertEquals('qrs', $conn->fetchColumn('SELECT id2 FROM vct_owning_onetoone LIMIT 1')); + self::assertEquals('nop', $conn->fetchColumn('SELECT associated_id FROM vct_owning_onetoone LIMIT 1')); } /** @@ -74,8 +74,8 @@ public function testThatEntitiesAreFetchedFromTheDatabase(): void 'def' ); - $this->assertInstanceOf(Models\ValueConversionType\InversedOneToOneEntity::class, $inversed); - $this->assertInstanceOf(Models\ValueConversionType\OwningOneToOneEntity::class, $owning); + self::assertInstanceOf(Models\ValueConversionType\InversedOneToOneEntity::class, $inversed); + self::assertInstanceOf(Models\ValueConversionType\OwningOneToOneEntity::class, $owning); } /** @@ -93,8 +93,8 @@ public function testThatTheValueOfIdentifiersAreConvertedBackAfterBeingFetchedFr 'def' ); - $this->assertEquals('abc', $inversed->id1); - $this->assertEquals('def', $owning->id2); + self::assertEquals('abc', $inversed->id1); + self::assertEquals('def', $owning->id2); } /** @@ -109,7 +109,7 @@ public function testThatTheProxyFromOwningToInversedIsLoaded(): void $inversedProxy = $owning->associatedEntity; - $this->assertEquals('some value to be loaded', $inversedProxy->someProperty); + self::assertEquals('some value to be loaded', $inversedProxy->someProperty); } /** @@ -122,6 +122,6 @@ public function testThatTheEntityFromInversedToOwningIsEagerLoaded(): void 'abc' ); - $this->assertInstanceOf(Models\ValueConversionType\OwningOneToOneEntity::class, $inversed->associatedEntity); + self::assertInstanceOf(Models\ValueConversionType\OwningOneToOneEntity::class, $inversed->associatedEntity); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/ValueObjectsTest.php b/tests/Doctrine/Tests/ORM/Functional/ValueObjectsTest.php index 6fc42a0f20a..78845c1f9db 100644 --- a/tests/Doctrine/Tests/ORM/Functional/ValueObjectsTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/ValueObjectsTest.php @@ -55,18 +55,18 @@ public function testMetadataHasReflectionEmbeddablesAccessible(): void $classMetadata = $this->_em->getClassMetadata(DDC93Person::class); if (class_exists(CommonRuntimePublicReflectionProperty::class)) { - $this->assertInstanceOf( + self::assertInstanceOf( CommonRuntimePublicReflectionProperty::class, $classMetadata->getReflectionProperty('address') ); } else { - $this->assertInstanceOf( + self::assertInstanceOf( RuntimePublicReflectionProperty::class, $classMetadata->getReflectionProperty('address') ); } - $this->assertInstanceOf(ReflectionEmbeddedProperty::class, $classMetadata->getReflectionProperty('address.street')); + self::assertInstanceOf(ReflectionEmbeddedProperty::class, $classMetadata->getReflectionProperty('address.street')); } public function testCRUD(): void @@ -88,12 +88,12 @@ public function testCRUD(): void // 2. check loading value objects works $person = $this->_em->find(DDC93Person::class, $person->id); - $this->assertInstanceOf(DDC93Address::class, $person->address); - $this->assertEquals('United States of Tara Street', $person->address->street); - $this->assertEquals('12345', $person->address->zip); - $this->assertEquals('funkytown', $person->address->city); - $this->assertInstanceOf(DDC93Country::class, $person->address->country); - $this->assertEquals('Germany', $person->address->country->name); + self::assertInstanceOf(DDC93Address::class, $person->address); + self::assertEquals('United States of Tara Street', $person->address->street); + self::assertEquals('12345', $person->address->zip); + self::assertEquals('funkytown', $person->address->city); + self::assertInstanceOf(DDC93Country::class, $person->address->country); + self::assertEquals('Germany', $person->address->country->name); // 3. check changing value objects works $person->address->street = 'Street'; @@ -106,10 +106,10 @@ public function testCRUD(): void $person = $this->_em->find(DDC93Person::class, $person->id); - $this->assertEquals('Street', $person->address->street); - $this->assertEquals('54321', $person->address->zip); - $this->assertEquals('another town', $person->address->city); - $this->assertEquals('United States of America', $person->address->country->name); + self::assertEquals('Street', $person->address->street); + self::assertEquals('54321', $person->address->zip); + self::assertEquals('another town', $person->address->city); + self::assertEquals('United States of America', $person->address->country->name); // 4. check deleting works $personId = $person->id; @@ -117,7 +117,7 @@ public function testCRUD(): void $this->_em->remove($person); $this->_em->flush(); - $this->assertNull($this->_em->find(DDC93Person::class, $personId)); + self::assertNull($this->_em->find(DDC93Person::class, $personId)); } public function testLoadDql(): void @@ -140,24 +140,24 @@ public function testLoadDql(): void $dql = 'SELECT p FROM ' . __NAMESPACE__ . '\DDC93Person p'; $persons = $this->_em->createQuery($dql)->getResult(); - $this->assertCount(3, $persons); + self::assertCount(3, $persons); foreach ($persons as $person) { - $this->assertInstanceOf(DDC93Address::class, $person->address); - $this->assertEquals('Tree', $person->address->street); - $this->assertEquals('12345', $person->address->zip); - $this->assertEquals('funkytown', $person->address->city); - $this->assertInstanceOf(DDC93Country::class, $person->address->country); - $this->assertEquals('United States of America', $person->address->country->name); + self::assertInstanceOf(DDC93Address::class, $person->address); + self::assertEquals('Tree', $person->address->street); + self::assertEquals('12345', $person->address->zip); + self::assertEquals('funkytown', $person->address->city); + self::assertInstanceOf(DDC93Country::class, $person->address->country); + self::assertEquals('United States of America', $person->address->country->name); } $dql = 'SELECT p FROM ' . __NAMESPACE__ . '\DDC93Person p'; $persons = $this->_em->createQuery($dql)->getArrayResult(); foreach ($persons as $person) { - $this->assertEquals('Tree', $person['address.street']); - $this->assertEquals('12345', $person['address.zip']); - $this->assertEquals('funkytown', $person['address.city']); - $this->assertEquals('United States of America', $person['address.country.name']); + self::assertEquals('Tree', $person['address.street']); + self::assertEquals('12345', $person['address.zip']); + self::assertEquals('funkytown', $person['address.city']); + self::assertEquals('United States of America', $person['address.country.name']); } } @@ -167,7 +167,7 @@ public function testLoadDql(): void public function testDqlOnEmbeddedObjectsField(): void { if ($this->isSecondLevelCacheEnabled) { - $this->markTestSkipped('SLC does not work with UPDATE/DELETE queries through EM.'); + self::markTestSkipped('SLC does not work with UPDATE/DELETE queries through EM.'); } $person = new DDC93Person('Johannes', new DDC93Address('Moo', '12345', 'Karlsruhe', new DDC93Country('Germany'))); @@ -180,9 +180,9 @@ public function testDqlOnEmbeddedObjectsField(): void ->setParameter('city', 'Karlsruhe') ->setParameter('country', 'Germany') ->getSingleResult(); - $this->assertEquals($person, $loadedPerson); + self::assertEquals($person, $loadedPerson); - $this->assertNull( + self::assertNull( $this->_em->createQuery($selectDql) ->setParameter('city', 'asdf') ->setParameter('country', 'Germany') @@ -198,8 +198,8 @@ public function testDqlOnEmbeddedObjectsField(): void ->execute(); $this->_em->refresh($person); - $this->assertEquals('Boo', $person->address->street); - $this->assertEquals('DE', $person->address->country->name); + self::assertEquals('Boo', $person->address->street); + self::assertEquals('DE', $person->address->country->name); // DELETE $this->_em->createQuery('DELETE ' . __NAMESPACE__ . '\\DDC93Person p WHERE p.address.city = :city AND p.address.country.name = :country') @@ -208,7 +208,7 @@ public function testDqlOnEmbeddedObjectsField(): void ->execute(); $this->_em->clear(); - $this->assertNull($this->_em->find(DDC93Person::class, $person->id)); + self::assertNull($this->_em->find(DDC93Person::class, $person->id)); } public function testPartialDqlOnEmbeddedObjectsField(): void @@ -225,10 +225,10 @@ public function testPartialDqlOnEmbeddedObjectsField(): void ->setParameter('name', 'Karl') ->getSingleResult(); - $this->assertEquals('Gosport', $person->address->city); - $this->assertEquals('Foo', $person->address->street); - $this->assertEquals('12345', $person->address->zip); - $this->assertEquals('England', $person->address->country->name); + self::assertEquals('Gosport', $person->address->city); + self::assertEquals('Foo', $person->address->street); + self::assertEquals('12345', $person->address->zip); + self::assertEquals('England', $person->address->country->name); // Clear the EM and prove that the embeddable can be the subject of a partial query. $this->_em->clear(); @@ -240,11 +240,11 @@ public function testPartialDqlOnEmbeddedObjectsField(): void ->getSingleResult(); // Selected field must be equal, all other fields must be null. - $this->assertEquals('Gosport', $person->address->city); - $this->assertNull($person->address->street); - $this->assertNull($person->address->zip); - $this->assertNull($person->address->country); - $this->assertNull($person->name); + self::assertEquals('Gosport', $person->address->city); + self::assertNull($person->address->street); + self::assertNull($person->address->zip); + self::assertNull($person->address->country); + self::assertNull($person->name); // Clear the EM and prove that the embeddable can be the subject of a partial query regardless of attributes positions. $this->_em->clear(); @@ -256,11 +256,11 @@ public function testPartialDqlOnEmbeddedObjectsField(): void ->getSingleResult(); // Selected field must be equal, all other fields must be null. - $this->assertEquals('Gosport', $person->address->city); - $this->assertNull($person->address->street); - $this->assertNull($person->address->zip); - $this->assertNull($person->address->country); - $this->assertNull($person->name); + self::assertEquals('Gosport', $person->address->city); + self::assertNull($person->address->street); + self::assertNull($person->address->zip); + self::assertNull($person->address->country); + self::assertNull($person->name); } public function testDqlWithNonExistentEmbeddableField(): void @@ -288,27 +288,27 @@ public function testEmbeddableWithInheritance(): void $this->_em->flush(); $reloadedCar = $this->_em->find(DDC93Car::class, $car->id); - $this->assertEquals($car, $reloadedCar); + self::assertEquals($car, $reloadedCar); } public function testInlineEmbeddableWithPrefix(): void { $metadata = $this->_em->getClassMetadata(DDC3028PersonWithPrefix::class); - $this->assertEquals('foobar_id', $metadata->getColumnName('id.id')); - $this->assertEquals('bloo_foo_id', $metadata->getColumnName('nested.nestedWithPrefix.id')); - $this->assertEquals('bloo_nestedWithEmptyPrefix_id', $metadata->getColumnName('nested.nestedWithEmptyPrefix.id')); - $this->assertEquals('bloo_id', $metadata->getColumnName('nested.nestedWithPrefixFalse.id')); + self::assertEquals('foobar_id', $metadata->getColumnName('id.id')); + self::assertEquals('bloo_foo_id', $metadata->getColumnName('nested.nestedWithPrefix.id')); + self::assertEquals('bloo_nestedWithEmptyPrefix_id', $metadata->getColumnName('nested.nestedWithEmptyPrefix.id')); + self::assertEquals('bloo_id', $metadata->getColumnName('nested.nestedWithPrefixFalse.id')); } public function testInlineEmbeddableEmptyPrefix(): void { $metadata = $this->_em->getClassMetadata(DDC3028PersonEmptyPrefix::class); - $this->assertEquals('id_id', $metadata->getColumnName('id.id')); - $this->assertEquals('nested_foo_id', $metadata->getColumnName('nested.nestedWithPrefix.id')); - $this->assertEquals('nested_nestedWithEmptyPrefix_id', $metadata->getColumnName('nested.nestedWithEmptyPrefix.id')); - $this->assertEquals('nested_id', $metadata->getColumnName('nested.nestedWithPrefixFalse.id')); + self::assertEquals('id_id', $metadata->getColumnName('id.id')); + self::assertEquals('nested_foo_id', $metadata->getColumnName('nested.nestedWithPrefix.id')); + self::assertEquals('nested_nestedWithEmptyPrefix_id', $metadata->getColumnName('nested.nestedWithEmptyPrefix.id')); + self::assertEquals('nested_id', $metadata->getColumnName('nested.nestedWithPrefixFalse.id')); } public function testInlineEmbeddablePrefixFalse(): void @@ -319,7 +319,7 @@ public function testInlineEmbeddablePrefixFalse(): void ->getClassMetadata(DDC3028PersonPrefixFalse::class) ->getColumnName('id.id'); - $this->assertEquals($expectedColumnName, $actualColumnName); + self::assertEquals($expectedColumnName, $actualColumnName); } public function testInlineEmbeddableInMappedSuperClass(): void @@ -328,7 +328,7 @@ public function testInlineEmbeddableInMappedSuperClass(): void ->getClassMetadata(DDC3027Dog::class) ->hasField('address.street'); - $this->assertTrue($isFieldMapped); + self::assertTrue($isFieldMapped); } /** diff --git a/tests/Doctrine/Tests/ORM/Functional/VersionedOneToOneTest.php b/tests/Doctrine/Tests/ORM/Functional/VersionedOneToOneTest.php index f970f965752..483d2e587b0 100644 --- a/tests/Doctrine/Tests/ORM/Functional/VersionedOneToOneTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/VersionedOneToOneTest.php @@ -56,8 +56,8 @@ public function testSetVersionOnCreate(): void $secondEntity = $this->_em->getRepository(SecondRelatedEntity::class) ->findOneBy(['name' => 'Bob']); - $this->assertSame($firstRelatedEntity, $firstEntity); - $this->assertSame($secondRelatedEntity, $secondEntity); - $this->assertSame($firstEntity->secondEntity, $secondEntity); + self::assertSame($firstRelatedEntity, $firstEntity); + self::assertSame($secondRelatedEntity, $secondEntity); + self::assertSame($firstEntity->secondEntity, $secondEntity); } } diff --git a/tests/Doctrine/Tests/ORM/Hydration/ArrayHydratorTest.php b/tests/Doctrine/Tests/ORM/Hydration/ArrayHydratorTest.php index 201614953c2..23219fdd97c 100644 --- a/tests/Doctrine/Tests/ORM/Hydration/ArrayHydratorTest.php +++ b/tests/Doctrine/Tests/ORM/Hydration/ArrayHydratorTest.php @@ -60,14 +60,14 @@ public function testSimpleEntityQuery(): void $hydrator = new ArrayHydrator($this->entityManager); $result = $hydrator->hydrateAll($stmt, $rsm); - $this->assertEquals(2, count($result)); - $this->assertTrue(is_array($result)); + self::assertEquals(2, count($result)); + self::assertTrue(is_array($result)); - $this->assertEquals(1, $result[0]['id']); - $this->assertEquals('romanb', $result[0]['name']); + self::assertEquals(1, $result[0]['id']); + self::assertEquals('romanb', $result[0]['name']); - $this->assertEquals(2, $result[1]['id']); - $this->assertEquals('jwage', $result[1]['name']); + self::assertEquals(2, $result[1]['id']); + self::assertEquals('jwage', $result[1]['name']); } /** @@ -104,24 +104,24 @@ public function testSimpleEntityWithScalarQuery($userEntityKey): void $hydrator = new ArrayHydrator($this->entityManager); $result = $hydrator->hydrateAll($stmt, $rsm); - $this->assertEquals(2, count($result)); - $this->assertTrue(is_array($result)); + self::assertEquals(2, count($result)); + self::assertTrue(is_array($result)); - $this->assertArrayHasKey('nameUpper', $result[0]); - $this->assertArrayNotHasKey('id', $result[0]); - $this->assertArrayNotHasKey('name', $result[0]); + self::assertArrayHasKey('nameUpper', $result[0]); + self::assertArrayNotHasKey('id', $result[0]); + self::assertArrayNotHasKey('name', $result[0]); - $this->assertArrayHasKey(0, $result[0]); - $this->assertArrayHasKey('id', $result[0][0]); - $this->assertArrayHasKey('name', $result[0][0]); + self::assertArrayHasKey(0, $result[0]); + self::assertArrayHasKey('id', $result[0][0]); + self::assertArrayHasKey('name', $result[0][0]); - $this->assertArrayHasKey('nameUpper', $result[1]); - $this->assertArrayNotHasKey('id', $result[1]); - $this->assertArrayNotHasKey('name', $result[1]); + self::assertArrayHasKey('nameUpper', $result[1]); + self::assertArrayNotHasKey('id', $result[1]); + self::assertArrayNotHasKey('name', $result[1]); - $this->assertArrayHasKey(0, $result[1]); - $this->assertArrayHasKey('id', $result[1][0]); - $this->assertArrayHasKey('name', $result[1][0]); + self::assertArrayHasKey(0, $result[1]); + self::assertArrayHasKey('id', $result[1][0]); + self::assertArrayHasKey('name', $result[1][0]); } /** @@ -152,16 +152,16 @@ public function testSimpleEntityQueryWithAliasedUserEntity(): void $hydrator = new ArrayHydrator($this->entityManager); $result = $hydrator->hydrateAll($stmt, $rsm); - $this->assertEquals(2, count($result)); - $this->assertTrue(is_array($result)); + self::assertEquals(2, count($result)); + self::assertTrue(is_array($result)); - $this->assertArrayHasKey('user', $result[0]); - $this->assertEquals(1, $result[0]['user']['id']); - $this->assertEquals('romanb', $result[0]['user']['name']); + self::assertArrayHasKey('user', $result[0]); + self::assertEquals(1, $result[0]['user']['id']); + self::assertEquals('romanb', $result[0]['user']['name']); - $this->assertArrayHasKey('user', $result[1]); - $this->assertEquals(2, $result[1]['user']['id']); - $this->assertEquals('jwage', $result[1]['user']['name']); + self::assertArrayHasKey('user', $result[1]); + self::assertEquals(2, $result[1]['user']['id']); + self::assertEquals('jwage', $result[1]['user']['name']); } /** @@ -199,19 +199,19 @@ public function testSimpleMultipleRootEntityQuery(): void $hydrator = new ArrayHydrator($this->entityManager); $result = $hydrator->hydrateAll($stmt, $rsm); - $this->assertEquals(4, count($result)); + self::assertEquals(4, count($result)); - $this->assertEquals(1, $result[0]['id']); - $this->assertEquals('romanb', $result[0]['name']); + self::assertEquals(1, $result[0]['id']); + self::assertEquals('romanb', $result[0]['name']); - $this->assertEquals(1, $result[1]['id']); - $this->assertEquals('Cool things.', $result[1]['topic']); + self::assertEquals(1, $result[1]['id']); + self::assertEquals('Cool things.', $result[1]['topic']); - $this->assertEquals(2, $result[2]['id']); - $this->assertEquals('jwage', $result[2]['name']); + self::assertEquals(2, $result[2]['id']); + self::assertEquals('jwage', $result[2]['name']); - $this->assertEquals(2, $result[3]['id']); - $this->assertEquals('Cool things II.', $result[3]['topic']); + self::assertEquals(2, $result[3]['id']); + self::assertEquals('Cool things II.', $result[3]['topic']); } /** @@ -249,23 +249,23 @@ public function testSimpleMultipleRootEntityQueryWithAliasedUserEntity(): void $hydrator = new ArrayHydrator($this->entityManager); $result = $hydrator->hydrateAll($stmt, $rsm); - $this->assertEquals(4, count($result)); + self::assertEquals(4, count($result)); - $this->assertArrayHasKey('user', $result[0]); - $this->assertEquals(1, $result[0]['user']['id']); - $this->assertEquals('romanb', $result[0]['user']['name']); + self::assertArrayHasKey('user', $result[0]); + self::assertEquals(1, $result[0]['user']['id']); + self::assertEquals('romanb', $result[0]['user']['name']); - $this->assertArrayHasKey(0, $result[1]); - $this->assertEquals(1, $result[1][0]['id']); - $this->assertEquals('Cool things.', $result[1][0]['topic']); + self::assertArrayHasKey(0, $result[1]); + self::assertEquals(1, $result[1][0]['id']); + self::assertEquals('Cool things.', $result[1][0]['topic']); - $this->assertArrayHasKey('user', $result[2]); - $this->assertEquals(2, $result[2]['user']['id']); - $this->assertEquals('jwage', $result[2]['user']['name']); + self::assertArrayHasKey('user', $result[2]); + self::assertEquals(2, $result[2]['user']['id']); + self::assertEquals('jwage', $result[2]['user']['name']); - $this->assertArrayHasKey(0, $result[3]); - $this->assertEquals(2, $result[3][0]['id']); - $this->assertEquals('Cool things II.', $result[3][0]['topic']); + self::assertArrayHasKey(0, $result[3]); + self::assertEquals(2, $result[3][0]['id']); + self::assertEquals('Cool things II.', $result[3][0]['topic']); } /** @@ -303,23 +303,23 @@ public function testSimpleMultipleRootEntityQueryWithAliasedArticleEntity(): voi $hydrator = new ArrayHydrator($this->entityManager); $result = $hydrator->hydrateAll($stmt, $rsm); - $this->assertEquals(4, count($result)); + self::assertEquals(4, count($result)); - $this->assertArrayHasKey(0, $result[0]); - $this->assertEquals(1, $result[0][0]['id']); - $this->assertEquals('romanb', $result[0][0]['name']); + self::assertArrayHasKey(0, $result[0]); + self::assertEquals(1, $result[0][0]['id']); + self::assertEquals('romanb', $result[0][0]['name']); - $this->assertArrayHasKey('article', $result[1]); - $this->assertEquals(1, $result[1]['article']['id']); - $this->assertEquals('Cool things.', $result[1]['article']['topic']); + self::assertArrayHasKey('article', $result[1]); + self::assertEquals(1, $result[1]['article']['id']); + self::assertEquals('Cool things.', $result[1]['article']['topic']); - $this->assertArrayHasKey(0, $result[2]); - $this->assertEquals(2, $result[2][0]['id']); - $this->assertEquals('jwage', $result[2][0]['name']); + self::assertArrayHasKey(0, $result[2]); + self::assertEquals(2, $result[2][0]['id']); + self::assertEquals('jwage', $result[2][0]['name']); - $this->assertArrayHasKey('article', $result[3]); - $this->assertEquals(2, $result[3]['article']['id']); - $this->assertEquals('Cool things II.', $result[3]['article']['topic']); + self::assertArrayHasKey('article', $result[3]); + self::assertEquals(2, $result[3]['article']['id']); + self::assertEquals('Cool things II.', $result[3]['article']['topic']); } /** @@ -357,23 +357,23 @@ public function testSimpleMultipleRootEntityQueryWithAliasedEntities(): void $hydrator = new ArrayHydrator($this->entityManager); $result = $hydrator->hydrateAll($stmt, $rsm); - $this->assertEquals(4, count($result)); + self::assertEquals(4, count($result)); - $this->assertArrayHasKey('user', $result[0]); - $this->assertEquals(1, $result[0]['user']['id']); - $this->assertEquals('romanb', $result[0]['user']['name']); + self::assertArrayHasKey('user', $result[0]); + self::assertEquals(1, $result[0]['user']['id']); + self::assertEquals('romanb', $result[0]['user']['name']); - $this->assertArrayHasKey('article', $result[1]); - $this->assertEquals(1, $result[1]['article']['id']); - $this->assertEquals('Cool things.', $result[1]['article']['topic']); + self::assertArrayHasKey('article', $result[1]); + self::assertEquals(1, $result[1]['article']['id']); + self::assertEquals('Cool things.', $result[1]['article']['topic']); - $this->assertArrayHasKey('user', $result[2]); - $this->assertEquals(2, $result[2]['user']['id']); - $this->assertEquals('jwage', $result[2]['user']['name']); + self::assertArrayHasKey('user', $result[2]); + self::assertEquals(2, $result[2]['user']['id']); + self::assertEquals('jwage', $result[2]['user']['name']); - $this->assertArrayHasKey('article', $result[3]); - $this->assertEquals(2, $result[3]['article']['id']); - $this->assertEquals('Cool things II.', $result[3]['article']['topic']); + self::assertArrayHasKey('article', $result[3]); + self::assertEquals(2, $result[3]['article']['id']); + self::assertEquals('Cool things II.', $result[3]['article']['topic']); } /** @@ -412,18 +412,18 @@ public function testMixedQueryNormalJoin($userEntityKey): void $hydrator = new ArrayHydrator($this->entityManager); $result = $hydrator->hydrateAll($stmt, $rsm); - $this->assertEquals(2, count($result)); - $this->assertTrue(is_array($result)); - $this->assertTrue(is_array($result[0])); - $this->assertTrue(is_array($result[1])); + self::assertEquals(2, count($result)); + self::assertTrue(is_array($result)); + self::assertTrue(is_array($result[0])); + self::assertTrue(is_array($result[1])); // first user => 2 phonenumbers - $this->assertArrayHasKey($userEntityKey, $result[0]); - $this->assertEquals(2, $result[0]['numPhones']); + self::assertArrayHasKey($userEntityKey, $result[0]); + self::assertEquals(2, $result[0]['numPhones']); // second user => 1 phonenumber - $this->assertArrayHasKey($userEntityKey, $result[1]); - $this->assertEquals(1, $result[1]['numPhones']); + self::assertArrayHasKey($userEntityKey, $result[1]); + self::assertEquals(1, $result[1]['numPhones']); } /** @@ -476,23 +476,23 @@ public function testMixedQueryFetchJoin($userEntityKey): void $hydrator = new ArrayHydrator($this->entityManager); $result = $hydrator->hydrateAll($stmt, $rsm); - $this->assertEquals(2, count($result)); + self::assertEquals(2, count($result)); - $this->assertTrue(is_array($result)); - $this->assertTrue(is_array($result[0])); - $this->assertTrue(is_array($result[1])); + self::assertTrue(is_array($result)); + self::assertTrue(is_array($result[0])); + self::assertTrue(is_array($result[1])); // first user => 2 phonenumbers - $this->assertEquals(2, count($result[0][$userEntityKey]['phonenumbers'])); - $this->assertEquals('ROMANB', $result[0]['nameUpper']); + self::assertEquals(2, count($result[0][$userEntityKey]['phonenumbers'])); + self::assertEquals('ROMANB', $result[0]['nameUpper']); // second user => 1 phonenumber - $this->assertEquals(1, count($result[1][$userEntityKey]['phonenumbers'])); - $this->assertEquals('JWAGE', $result[1]['nameUpper']); + self::assertEquals(1, count($result[1][$userEntityKey]['phonenumbers'])); + self::assertEquals('JWAGE', $result[1]['nameUpper']); - $this->assertEquals(42, $result[0][$userEntityKey]['phonenumbers'][0]['phonenumber']); - $this->assertEquals(43, $result[0][$userEntityKey]['phonenumbers'][1]['phonenumber']); - $this->assertEquals(91, $result[1][$userEntityKey]['phonenumbers'][0]['phonenumber']); + self::assertEquals(42, $result[0][$userEntityKey]['phonenumbers'][0]['phonenumber']); + self::assertEquals(43, $result[0][$userEntityKey]['phonenumbers'][1]['phonenumber']); + self::assertEquals(91, $result[1][$userEntityKey]['phonenumbers'][0]['phonenumber']); } /** @@ -549,26 +549,26 @@ public function testMixedQueryFetchJoinCustomIndex($userEntityKey): void $hydrator = new ArrayHydrator($this->entityManager); $result = $hydrator->hydrateAll($stmt, $rsm); - $this->assertEquals(2, count($result)); + self::assertEquals(2, count($result)); - $this->assertTrue(is_array($result)); - $this->assertTrue(is_array($result[1])); - $this->assertTrue(is_array($result[2])); + self::assertTrue(is_array($result)); + self::assertTrue(is_array($result[1])); + self::assertTrue(is_array($result[2])); // test the scalar values - $this->assertEquals('ROMANB', $result[1]['nameUpper']); - $this->assertEquals('JWAGE', $result[2]['nameUpper']); + self::assertEquals('ROMANB', $result[1]['nameUpper']); + self::assertEquals('JWAGE', $result[2]['nameUpper']); // first user => 2 phonenumbers. notice the custom indexing by user id - $this->assertEquals(2, count($result[1][$userEntityKey]['phonenumbers'])); + self::assertEquals(2, count($result[1][$userEntityKey]['phonenumbers'])); // second user => 1 phonenumber. notice the custom indexing by user id - $this->assertEquals(1, count($result[2][$userEntityKey]['phonenumbers'])); + self::assertEquals(1, count($result[2][$userEntityKey]['phonenumbers'])); // test the custom indexing of the phonenumbers - $this->assertTrue(isset($result[1][$userEntityKey]['phonenumbers']['42'])); - $this->assertTrue(isset($result[1][$userEntityKey]['phonenumbers']['43'])); - $this->assertTrue(isset($result[2][$userEntityKey]['phonenumbers']['91'])); + self::assertTrue(isset($result[1][$userEntityKey]['phonenumbers']['42'])); + self::assertTrue(isset($result[1][$userEntityKey]['phonenumbers']['43'])); + self::assertTrue(isset($result[2][$userEntityKey]['phonenumbers']['91'])); } /** @@ -663,27 +663,27 @@ public function testMixedQueryMultipleFetchJoin(): void $hydrator = new ArrayHydrator($this->entityManager); $result = $hydrator->hydrateAll($stmt, $rsm); - $this->assertEquals(2, count($result)); - $this->assertTrue(is_array($result)); - $this->assertTrue(is_array($result[0])); - $this->assertTrue(is_array($result[1])); + self::assertEquals(2, count($result)); + self::assertTrue(is_array($result)); + self::assertTrue(is_array($result[0])); + self::assertTrue(is_array($result[1])); // first user => 2 phonenumbers, 2 articles - $this->assertEquals(2, count($result[0][0]['phonenumbers'])); - $this->assertEquals(2, count($result[0][0]['articles'])); - $this->assertEquals('ROMANB', $result[0]['nameUpper']); + self::assertEquals(2, count($result[0][0]['phonenumbers'])); + self::assertEquals(2, count($result[0][0]['articles'])); + self::assertEquals('ROMANB', $result[0]['nameUpper']); // second user => 1 phonenumber, 2 articles - $this->assertEquals(1, count($result[1][0]['phonenumbers'])); - $this->assertEquals(2, count($result[1][0]['articles'])); - $this->assertEquals('JWAGE', $result[1]['nameUpper']); - - $this->assertEquals(42, $result[0][0]['phonenumbers'][0]['phonenumber']); - $this->assertEquals(43, $result[0][0]['phonenumbers'][1]['phonenumber']); - $this->assertEquals(91, $result[1][0]['phonenumbers'][0]['phonenumber']); - - $this->assertEquals('Getting things done!', $result[0][0]['articles'][0]['topic']); - $this->assertEquals('ZendCon', $result[0][0]['articles'][1]['topic']); - $this->assertEquals('LINQ', $result[1][0]['articles'][0]['topic']); - $this->assertEquals('PHP7', $result[1][0]['articles'][1]['topic']); + self::assertEquals(1, count($result[1][0]['phonenumbers'])); + self::assertEquals(2, count($result[1][0]['articles'])); + self::assertEquals('JWAGE', $result[1]['nameUpper']); + + self::assertEquals(42, $result[0][0]['phonenumbers'][0]['phonenumber']); + self::assertEquals(43, $result[0][0]['phonenumbers'][1]['phonenumber']); + self::assertEquals(91, $result[1][0]['phonenumbers'][0]['phonenumber']); + + self::assertEquals('Getting things done!', $result[0][0]['articles'][0]['topic']); + self::assertEquals('ZendCon', $result[0][0]['articles'][1]['topic']); + self::assertEquals('LINQ', $result[1][0]['articles'][0]['topic']); + self::assertEquals('PHP7', $result[1][0]['articles'][1]['topic']); } /** @@ -802,41 +802,41 @@ public function testMixedQueryMultipleDeepMixedFetchJoin(): void $hydrator = new ArrayHydrator($this->entityManager); $result = $hydrator->hydrateAll($stmt, $rsm); - $this->assertEquals(2, count($result)); - $this->assertTrue(is_array($result)); - $this->assertTrue(is_array($result[0])); - $this->assertTrue(is_array($result[1])); + self::assertEquals(2, count($result)); + self::assertTrue(is_array($result)); + self::assertTrue(is_array($result[0])); + self::assertTrue(is_array($result[1])); // first user => 2 phonenumbers, 2 articles, 1 comment on first article - $this->assertEquals(2, count($result[0][0]['phonenumbers'])); - $this->assertEquals(2, count($result[0][0]['articles'])); - $this->assertEquals(1, count($result[0][0]['articles'][0]['comments'])); - $this->assertEquals('ROMANB', $result[0]['nameUpper']); + self::assertEquals(2, count($result[0][0]['phonenumbers'])); + self::assertEquals(2, count($result[0][0]['articles'])); + self::assertEquals(1, count($result[0][0]['articles'][0]['comments'])); + self::assertEquals('ROMANB', $result[0]['nameUpper']); // second user => 1 phonenumber, 2 articles, no comments - $this->assertEquals(1, count($result[1][0]['phonenumbers'])); - $this->assertEquals(2, count($result[1][0]['articles'])); - $this->assertEquals('JWAGE', $result[1]['nameUpper']); + self::assertEquals(1, count($result[1][0]['phonenumbers'])); + self::assertEquals(2, count($result[1][0]['articles'])); + self::assertEquals('JWAGE', $result[1]['nameUpper']); - $this->assertEquals(42, $result[0][0]['phonenumbers'][0]['phonenumber']); - $this->assertEquals(43, $result[0][0]['phonenumbers'][1]['phonenumber']); - $this->assertEquals(91, $result[1][0]['phonenumbers'][0]['phonenumber']); + self::assertEquals(42, $result[0][0]['phonenumbers'][0]['phonenumber']); + self::assertEquals(43, $result[0][0]['phonenumbers'][1]['phonenumber']); + self::assertEquals(91, $result[1][0]['phonenumbers'][0]['phonenumber']); - $this->assertEquals('Getting things done!', $result[0][0]['articles'][0]['topic']); - $this->assertEquals('ZendCon', $result[0][0]['articles'][1]['topic']); - $this->assertEquals('LINQ', $result[1][0]['articles'][0]['topic']); - $this->assertEquals('PHP7', $result[1][0]['articles'][1]['topic']); + self::assertEquals('Getting things done!', $result[0][0]['articles'][0]['topic']); + self::assertEquals('ZendCon', $result[0][0]['articles'][1]['topic']); + self::assertEquals('LINQ', $result[1][0]['articles'][0]['topic']); + self::assertEquals('PHP7', $result[1][0]['articles'][1]['topic']); - $this->assertEquals('First!', $result[0][0]['articles'][0]['comments'][0]['topic']); + self::assertEquals('First!', $result[0][0]['articles'][0]['comments'][0]['topic']); - $this->assertTrue(isset($result[0][0]['articles'][0]['comments'])); + self::assertTrue(isset($result[0][0]['articles'][0]['comments'])); // empty comment collections - $this->assertTrue(is_array($result[0][0]['articles'][1]['comments'])); - $this->assertEquals(0, count($result[0][0]['articles'][1]['comments'])); - $this->assertTrue(is_array($result[1][0]['articles'][0]['comments'])); - $this->assertEquals(0, count($result[1][0]['articles'][0]['comments'])); - $this->assertTrue(is_array($result[1][0]['articles'][1]['comments'])); - $this->assertEquals(0, count($result[1][0]['articles'][1]['comments'])); + self::assertTrue(is_array($result[0][0]['articles'][1]['comments'])); + self::assertEquals(0, count($result[0][0]['articles'][1]['comments'])); + self::assertTrue(is_array($result[1][0]['articles'][0]['comments'])); + self::assertEquals(0, count($result[1][0]['articles'][0]['comments'])); + self::assertTrue(is_array($result[1][0]['articles'][1]['comments'])); + self::assertEquals(0, count($result[1][0]['articles'][1]['comments'])); } /** @@ -916,14 +916,14 @@ public function testEntityQueryCustomResultSetOrder(): void $hydrator = new ArrayHydrator($this->entityManager); $result = $hydrator->hydrateAll($stmt, $rsm); - $this->assertEquals(2, count($result)); - $this->assertTrue(is_array($result)); - $this->assertTrue(is_array($result[0])); - $this->assertTrue(is_array($result[1])); - $this->assertTrue(isset($result[0]['boards'])); - $this->assertEquals(3, count($result[0]['boards'])); - $this->assertTrue(isset($result[1]['boards'])); - $this->assertEquals(1, count($result[1]['boards'])); + self::assertEquals(2, count($result)); + self::assertTrue(is_array($result)); + self::assertTrue(is_array($result[0])); + self::assertTrue(is_array($result[1])); + self::assertTrue(isset($result[0]['boards'])); + self::assertEquals(3, count($result[0]['boards'])); + self::assertTrue(isset($result[1]['boards'])); + self::assertEquals(1, count($result[1]['boards'])); } /** @@ -979,25 +979,25 @@ public function testChainedJoinWithScalars($entityKey): void $hydrator = new ArrayHydrator($this->entityManager); $result = $hydrator->hydrateAll($stmt, $rsm); - $this->assertEquals(3, count($result)); - - $this->assertEquals(2, count($result[0][$entityKey])); // User array - $this->assertEquals(1, $result[0]['id']); - $this->assertEquals('The First', $result[0]['topic']); - $this->assertEquals(1, $result[0]['cid']); - $this->assertEquals('First Comment', $result[0]['ctopic']); - - $this->assertEquals(2, count($result[1][$entityKey])); // User array, duplicated - $this->assertEquals(1, $result[1]['id']); // duplicated - $this->assertEquals('The First', $result[1]['topic']); // duplicated - $this->assertEquals(2, $result[1]['cid']); - $this->assertEquals('Second Comment', $result[1]['ctopic']); - - $this->assertEquals(2, count($result[2][$entityKey])); // User array, duplicated - $this->assertEquals(42, $result[2]['id']); - $this->assertEquals('The Answer', $result[2]['topic']); - $this->assertNull($result[2]['cid']); - $this->assertNull($result[2]['ctopic']); + self::assertEquals(3, count($result)); + + self::assertEquals(2, count($result[0][$entityKey])); // User array + self::assertEquals(1, $result[0]['id']); + self::assertEquals('The First', $result[0]['topic']); + self::assertEquals(1, $result[0]['cid']); + self::assertEquals('First Comment', $result[0]['ctopic']); + + self::assertEquals(2, count($result[1][$entityKey])); // User array, duplicated + self::assertEquals(1, $result[1]['id']); // duplicated + self::assertEquals('The First', $result[1]['topic']); // duplicated + self::assertEquals(2, $result[1]['cid']); + self::assertEquals('Second Comment', $result[1]['ctopic']); + + self::assertEquals(2, count($result[2][$entityKey])); // User array, duplicated + self::assertEquals(42, $result[2]['id']); + self::assertEquals('The Answer', $result[2]['topic']); + self::assertNull($result[2]['cid']); + self::assertNull($result[2]['ctopic']); } /** @@ -1030,15 +1030,15 @@ public function testResultIteration(): void $rowNum = 0; while (($row = $iterator->next()) !== false) { - $this->assertEquals(1, count($row)); - $this->assertTrue(is_array($row[0])); + self::assertEquals(1, count($row)); + self::assertTrue(is_array($row[0])); if ($rowNum === 0) { - $this->assertEquals(1, $row[0]['id']); - $this->assertEquals('romanb', $row[0]['name']); + self::assertEquals(1, $row[0]['id']); + self::assertEquals('romanb', $row[0]['name']); } elseif ($rowNum === 1) { - $this->assertEquals(2, $row[0]['id']); - $this->assertEquals('jwage', $row[0]['name']); + self::assertEquals(2, $row[0]['id']); + self::assertEquals('jwage', $row[0]['name']); } ++$rowNum; @@ -1075,16 +1075,16 @@ public function testResultIterationWithAliasedUserEntity(): void $rowNum = 0; while (($row = $iterator->next()) !== false) { - $this->assertEquals(1, count($row)); - $this->assertArrayHasKey(0, $row); - $this->assertArrayHasKey('user', $row[0]); + self::assertEquals(1, count($row)); + self::assertArrayHasKey(0, $row); + self::assertArrayHasKey('user', $row[0]); if ($rowNum === 0) { - $this->assertEquals(1, $row[0]['user']['id']); - $this->assertEquals('romanb', $row[0]['user']['name']); + self::assertEquals(1, $row[0]['user']['id']); + self::assertEquals('romanb', $row[0]['user']['name']); } elseif ($rowNum === 1) { - $this->assertEquals(2, $row[0]['user']['id']); - $this->assertEquals('jwage', $row[0]['user']['name']); + self::assertEquals(2, $row[0]['user']['id']); + self::assertEquals('jwage', $row[0]['user']['name']); } ++$rowNum; @@ -1118,10 +1118,10 @@ public function testSkipUnknownColumns(): void $hydrator = new ArrayHydrator($this->entityManager); $result = $hydrator->hydrateAll($stmt, $rsm); - $this->assertEquals(1, count($result)); - $this->assertArrayHasKey('id', $result[0]); - $this->assertArrayHasKey('name', $result[0]); - $this->assertArrayNotHasKey('foo', $result[0]); + self::assertEquals(1, count($result)); + self::assertArrayHasKey('id', $result[0]); + self::assertArrayHasKey('name', $result[0]); + self::assertArrayNotHasKey('foo', $result[0]); } /** @@ -1169,17 +1169,17 @@ public function testMissingIdForRootEntity($userEntityKey): void $hydrator = new ArrayHydrator($this->entityManager); $result = $hydrator->hydrateAll($stmt, $rsm); - $this->assertEquals(4, count($result), 'Should hydrate four results.'); + self::assertEquals(4, count($result), 'Should hydrate four results.'); - $this->assertEquals('ROMANB', $result[0]['nameUpper']); - $this->assertEquals('ROMANB', $result[1]['nameUpper']); - $this->assertEquals('JWAGE', $result[2]['nameUpper']); - $this->assertEquals('JWAGE', $result[3]['nameUpper']); + self::assertEquals('ROMANB', $result[0]['nameUpper']); + self::assertEquals('ROMANB', $result[1]['nameUpper']); + self::assertEquals('JWAGE', $result[2]['nameUpper']); + self::assertEquals('JWAGE', $result[3]['nameUpper']); - $this->assertEquals(['id' => 1, 'status' => 'developer'], $result[0][$userEntityKey]); - $this->assertNull($result[1][$userEntityKey]); - $this->assertEquals(['id' => 2, 'status' => 'developer'], $result[2][$userEntityKey]); - $this->assertNull($result[3][$userEntityKey]); + self::assertEquals(['id' => 1, 'status' => 'developer'], $result[0][$userEntityKey]); + self::assertNull($result[1][$userEntityKey]); + self::assertEquals(['id' => 2, 'status' => 'developer'], $result[2][$userEntityKey]); + self::assertNull($result[3][$userEntityKey]); } /** @@ -1219,12 +1219,12 @@ public function testIndexByAndMixedResult($userEntityKey): void $hydrator = new ArrayHydrator($this->entityManager); $result = $hydrator->hydrateAll($stmt, $rsm); - $this->assertEquals(2, count($result)); + self::assertEquals(2, count($result)); - $this->assertTrue(isset($result[1])); - $this->assertEquals(1, $result[1][$userEntityKey]['id']); + self::assertTrue(isset($result[1])); + self::assertEquals(1, $result[1][$userEntityKey]['id']); - $this->assertTrue(isset($result[2])); - $this->assertEquals(2, $result[2][$userEntityKey]['id']); + self::assertTrue(isset($result[2])); + self::assertEquals(2, $result[2][$userEntityKey]['id']); } } diff --git a/tests/Doctrine/Tests/ORM/Hydration/CustomHydratorTest.php b/tests/Doctrine/Tests/ORM/Hydration/CustomHydratorTest.php index 1fd09f7e765..d5e9ad7d96f 100644 --- a/tests/Doctrine/Tests/ORM/Hydration/CustomHydratorTest.php +++ b/tests/Doctrine/Tests/ORM/Hydration/CustomHydratorTest.php @@ -15,8 +15,8 @@ public function testCustomHydrator(): void $config->addCustomHydrationMode('CustomHydrator', CustomHydrator::class); $hydrator = $em->newHydrator('CustomHydrator'); - $this->assertInstanceOf(CustomHydrator::class, $hydrator); - $this->assertNull($config->getCustomHydrationMode('does not exist')); + self::assertInstanceOf(CustomHydrator::class, $hydrator); + self::assertNull($config->getCustomHydrationMode('does not exist')); } } diff --git a/tests/Doctrine/Tests/ORM/Hydration/ObjectHydratorTest.php b/tests/Doctrine/Tests/ORM/Hydration/ObjectHydratorTest.php index 4869d9337f2..ebf4046f9a1 100644 --- a/tests/Doctrine/Tests/ORM/Hydration/ObjectHydratorTest.php +++ b/tests/Doctrine/Tests/ORM/Hydration/ObjectHydratorTest.php @@ -94,16 +94,16 @@ public function testSimpleEntityQuery(): void $hydrator = new ObjectHydrator($this->entityManager); $result = $hydrator->hydrateAll($stmt, $rsm, [Query::HINT_FORCE_PARTIAL_LOAD => true]); - $this->assertEquals(2, count($result)); + self::assertEquals(2, count($result)); - $this->assertInstanceOf(CmsUser::class, $result[0]); - $this->assertInstanceOf(CmsUser::class, $result[1]); + self::assertInstanceOf(CmsUser::class, $result[0]); + self::assertInstanceOf(CmsUser::class, $result[1]); - $this->assertEquals(1, $result[0]->id); - $this->assertEquals('romanb', $result[0]->name); + self::assertEquals(1, $result[0]->id); + self::assertEquals('romanb', $result[0]->name); - $this->assertEquals(2, $result[1]->id); - $this->assertEquals('jwage', $result[1]->name); + self::assertEquals(2, $result[1]->id); + self::assertEquals('jwage', $result[1]->name); } /** @@ -133,19 +133,19 @@ public function testSimpleEntityQueryWithAliasedUserEntity(): void $hydrator = new ObjectHydrator($this->entityManager); $result = $hydrator->hydrateAll($stmt, $rsm, [Query::HINT_FORCE_PARTIAL_LOAD => true]); - $this->assertEquals(2, count($result)); + self::assertEquals(2, count($result)); - $this->assertArrayHasKey('user', $result[0]); - $this->assertInstanceOf(CmsUser::class, $result[0]['user']); + self::assertArrayHasKey('user', $result[0]); + self::assertInstanceOf(CmsUser::class, $result[0]['user']); - $this->assertArrayHasKey('user', $result[1]); - $this->assertInstanceOf(CmsUser::class, $result[1]['user']); + self::assertArrayHasKey('user', $result[1]); + self::assertInstanceOf(CmsUser::class, $result[1]['user']); - $this->assertEquals(1, $result[0]['user']->id); - $this->assertEquals('romanb', $result[0]['user']->name); + self::assertEquals(1, $result[0]['user']->id); + self::assertEquals('romanb', $result[0]['user']->name); - $this->assertEquals(2, $result[1]['user']->id); - $this->assertEquals('jwage', $result[1]['user']->name); + self::assertEquals(2, $result[1]['user']->id); + self::assertEquals('jwage', $result[1]['user']->name); } /** @@ -182,24 +182,24 @@ public function testSimpleMultipleRootEntityQuery(): void $hydrator = new ObjectHydrator($this->entityManager); $result = $hydrator->hydrateAll($stmt, $rsm, [Query::HINT_FORCE_PARTIAL_LOAD => true]); - $this->assertEquals(4, count($result)); + self::assertEquals(4, count($result)); - $this->assertInstanceOf(CmsUser::class, $result[0]); - $this->assertInstanceOf(CmsArticle::class, $result[1]); - $this->assertInstanceOf(CmsUser::class, $result[2]); - $this->assertInstanceOf(CmsArticle::class, $result[3]); + self::assertInstanceOf(CmsUser::class, $result[0]); + self::assertInstanceOf(CmsArticle::class, $result[1]); + self::assertInstanceOf(CmsUser::class, $result[2]); + self::assertInstanceOf(CmsArticle::class, $result[3]); - $this->assertEquals(1, $result[0]->id); - $this->assertEquals('romanb', $result[0]->name); + self::assertEquals(1, $result[0]->id); + self::assertEquals('romanb', $result[0]->name); - $this->assertEquals(1, $result[1]->id); - $this->assertEquals('Cool things.', $result[1]->topic); + self::assertEquals(1, $result[1]->id); + self::assertEquals('Cool things.', $result[1]->topic); - $this->assertEquals(2, $result[2]->id); - $this->assertEquals('jwage', $result[2]->name); + self::assertEquals(2, $result[2]->id); + self::assertEquals('jwage', $result[2]->name); - $this->assertEquals(2, $result[3]->id); - $this->assertEquals('Cool things II.', $result[3]->topic); + self::assertEquals(2, $result[3]->id); + self::assertEquals('Cool things II.', $result[3]->topic); } /** @@ -236,31 +236,31 @@ public function testSimpleMultipleRootEntityQueryWithAliasedUserEntity(): void $hydrator = new ObjectHydrator($this->entityManager); $result = $hydrator->hydrateAll($stmt, $rsm, [Query::HINT_FORCE_PARTIAL_LOAD => true]); - $this->assertEquals(4, count($result)); - - $this->assertArrayHasKey('user', $result[0]); - $this->assertArrayNotHasKey(0, $result[0]); - $this->assertInstanceOf(CmsUser::class, $result[0]['user']); - $this->assertEquals(1, $result[0]['user']->id); - $this->assertEquals('romanb', $result[0]['user']->name); - - $this->assertArrayHasKey(0, $result[1]); - $this->assertArrayNotHasKey('user', $result[1]); - $this->assertInstanceOf(CmsArticle::class, $result[1][0]); - $this->assertEquals(1, $result[1][0]->id); - $this->assertEquals('Cool things.', $result[1][0]->topic); - - $this->assertArrayHasKey('user', $result[2]); - $this->assertArrayNotHasKey(0, $result[2]); - $this->assertInstanceOf(CmsUser::class, $result[2]['user']); - $this->assertEquals(2, $result[2]['user']->id); - $this->assertEquals('jwage', $result[2]['user']->name); - - $this->assertArrayHasKey(0, $result[3]); - $this->assertArrayNotHasKey('user', $result[3]); - $this->assertInstanceOf(CmsArticle::class, $result[3][0]); - $this->assertEquals(2, $result[3][0]->id); - $this->assertEquals('Cool things II.', $result[3][0]->topic); + self::assertEquals(4, count($result)); + + self::assertArrayHasKey('user', $result[0]); + self::assertArrayNotHasKey(0, $result[0]); + self::assertInstanceOf(CmsUser::class, $result[0]['user']); + self::assertEquals(1, $result[0]['user']->id); + self::assertEquals('romanb', $result[0]['user']->name); + + self::assertArrayHasKey(0, $result[1]); + self::assertArrayNotHasKey('user', $result[1]); + self::assertInstanceOf(CmsArticle::class, $result[1][0]); + self::assertEquals(1, $result[1][0]->id); + self::assertEquals('Cool things.', $result[1][0]->topic); + + self::assertArrayHasKey('user', $result[2]); + self::assertArrayNotHasKey(0, $result[2]); + self::assertInstanceOf(CmsUser::class, $result[2]['user']); + self::assertEquals(2, $result[2]['user']->id); + self::assertEquals('jwage', $result[2]['user']->name); + + self::assertArrayHasKey(0, $result[3]); + self::assertArrayNotHasKey('user', $result[3]); + self::assertInstanceOf(CmsArticle::class, $result[3][0]); + self::assertEquals(2, $result[3][0]->id); + self::assertEquals('Cool things II.', $result[3][0]->topic); } /** @@ -297,31 +297,31 @@ public function testSimpleMultipleRootEntityQueryWithAliasedArticleEntity(): voi $hydrator = new ObjectHydrator($this->entityManager); $result = $hydrator->hydrateAll($stmt, $rsm, [Query::HINT_FORCE_PARTIAL_LOAD => true]); - $this->assertEquals(4, count($result)); - - $this->assertArrayHasKey(0, $result[0]); - $this->assertArrayNotHasKey('article', $result[0]); - $this->assertInstanceOf(CmsUser::class, $result[0][0]); - $this->assertEquals(1, $result[0][0]->id); - $this->assertEquals('romanb', $result[0][0]->name); - - $this->assertArrayHasKey('article', $result[1]); - $this->assertArrayNotHasKey(0, $result[1]); - $this->assertInstanceOf(CmsArticle::class, $result[1]['article']); - $this->assertEquals(1, $result[1]['article']->id); - $this->assertEquals('Cool things.', $result[1]['article']->topic); - - $this->assertArrayHasKey(0, $result[2]); - $this->assertArrayNotHasKey('article', $result[2]); - $this->assertInstanceOf(CmsUser::class, $result[2][0]); - $this->assertEquals(2, $result[2][0]->id); - $this->assertEquals('jwage', $result[2][0]->name); - - $this->assertArrayHasKey('article', $result[3]); - $this->assertArrayNotHasKey(0, $result[3]); - $this->assertInstanceOf(CmsArticle::class, $result[3]['article']); - $this->assertEquals(2, $result[3]['article']->id); - $this->assertEquals('Cool things II.', $result[3]['article']->topic); + self::assertEquals(4, count($result)); + + self::assertArrayHasKey(0, $result[0]); + self::assertArrayNotHasKey('article', $result[0]); + self::assertInstanceOf(CmsUser::class, $result[0][0]); + self::assertEquals(1, $result[0][0]->id); + self::assertEquals('romanb', $result[0][0]->name); + + self::assertArrayHasKey('article', $result[1]); + self::assertArrayNotHasKey(0, $result[1]); + self::assertInstanceOf(CmsArticle::class, $result[1]['article']); + self::assertEquals(1, $result[1]['article']->id); + self::assertEquals('Cool things.', $result[1]['article']->topic); + + self::assertArrayHasKey(0, $result[2]); + self::assertArrayNotHasKey('article', $result[2]); + self::assertInstanceOf(CmsUser::class, $result[2][0]); + self::assertEquals(2, $result[2][0]->id); + self::assertEquals('jwage', $result[2][0]->name); + + self::assertArrayHasKey('article', $result[3]); + self::assertArrayNotHasKey(0, $result[3]); + self::assertInstanceOf(CmsArticle::class, $result[3]['article']); + self::assertEquals(2, $result[3]['article']->id); + self::assertEquals('Cool things II.', $result[3]['article']->topic); } /** @@ -358,31 +358,31 @@ public function testSimpleMultipleRootEntityQueryWithAliasedEntities(): void $hydrator = new ObjectHydrator($this->entityManager); $result = $hydrator->hydrateAll($stmt, $rsm, [Query::HINT_FORCE_PARTIAL_LOAD => true]); - $this->assertEquals(4, count($result)); - - $this->assertArrayHasKey('user', $result[0]); - $this->assertArrayNotHasKey('article', $result[0]); - $this->assertInstanceOf(CmsUser::class, $result[0]['user']); - $this->assertEquals(1, $result[0]['user']->id); - $this->assertEquals('romanb', $result[0]['user']->name); - - $this->assertArrayHasKey('article', $result[1]); - $this->assertArrayNotHasKey('user', $result[1]); - $this->assertInstanceOf(CmsArticle::class, $result[1]['article']); - $this->assertEquals(1, $result[1]['article']->id); - $this->assertEquals('Cool things.', $result[1]['article']->topic); - - $this->assertArrayHasKey('user', $result[2]); - $this->assertArrayNotHasKey('article', $result[2]); - $this->assertInstanceOf(CmsUser::class, $result[2]['user']); - $this->assertEquals(2, $result[2]['user']->id); - $this->assertEquals('jwage', $result[2]['user']->name); - - $this->assertArrayHasKey('article', $result[3]); - $this->assertArrayNotHasKey('user', $result[3]); - $this->assertInstanceOf(CmsArticle::class, $result[3]['article']); - $this->assertEquals(2, $result[3]['article']->id); - $this->assertEquals('Cool things II.', $result[3]['article']->topic); + self::assertEquals(4, count($result)); + + self::assertArrayHasKey('user', $result[0]); + self::assertArrayNotHasKey('article', $result[0]); + self::assertInstanceOf(CmsUser::class, $result[0]['user']); + self::assertEquals(1, $result[0]['user']->id); + self::assertEquals('romanb', $result[0]['user']->name); + + self::assertArrayHasKey('article', $result[1]); + self::assertArrayNotHasKey('user', $result[1]); + self::assertInstanceOf(CmsArticle::class, $result[1]['article']); + self::assertEquals(1, $result[1]['article']->id); + self::assertEquals('Cool things.', $result[1]['article']->topic); + + self::assertArrayHasKey('user', $result[2]); + self::assertArrayNotHasKey('article', $result[2]); + self::assertInstanceOf(CmsUser::class, $result[2]['user']); + self::assertEquals(2, $result[2]['user']->id); + self::assertEquals('jwage', $result[2]['user']->name); + + self::assertArrayHasKey('article', $result[3]); + self::assertArrayNotHasKey('user', $result[3]); + self::assertInstanceOf(CmsArticle::class, $result[3]['article']); + self::assertEquals(2, $result[3]['article']->id); + self::assertEquals('Cool things II.', $result[3]['article']->topic); } /** @@ -420,19 +420,19 @@ public function testMixedQueryNormalJoin($userEntityKey): void $hydrator = new ObjectHydrator($this->entityManager); $result = $hydrator->hydrateAll($stmt, $rsm, [Query::HINT_FORCE_PARTIAL_LOAD => true]); - $this->assertEquals(2, count($result)); + self::assertEquals(2, count($result)); - $this->assertIsArray($result); - $this->assertIsArray($result[0]); - $this->assertIsArray($result[1]); + self::assertIsArray($result); + self::assertIsArray($result[0]); + self::assertIsArray($result[1]); // first user => 2 phonenumbers - $this->assertEquals(2, $result[0]['numPhones']); - $this->assertInstanceOf(CmsUser::class, $result[0][$userEntityKey]); + self::assertEquals(2, $result[0]['numPhones']); + self::assertInstanceOf(CmsUser::class, $result[0][$userEntityKey]); // second user => 1 phonenumber - $this->assertEquals(1, $result[1]['numPhones']); - $this->assertInstanceOf(CmsUser::class, $result[1][$userEntityKey]); + self::assertEquals(1, $result[1]['numPhones']); + self::assertInstanceOf(CmsUser::class, $result[1][$userEntityKey]); } /** @@ -484,31 +484,31 @@ public function testMixedQueryFetchJoin($userEntityKey): void $hydrator = new ObjectHydrator($this->entityManager); $result = $hydrator->hydrateAll($stmt, $rsm, [Query::HINT_FORCE_PARTIAL_LOAD => true]); - $this->assertEquals(2, count($result)); + self::assertEquals(2, count($result)); - $this->assertIsArray($result); - $this->assertIsArray($result[0]); - $this->assertIsArray($result[1]); + self::assertIsArray($result); + self::assertIsArray($result[0]); + self::assertIsArray($result[1]); - $this->assertInstanceOf(CmsUser::class, $result[0][$userEntityKey]); - $this->assertInstanceOf(PersistentCollection::class, $result[0][$userEntityKey]->phonenumbers); - $this->assertInstanceOf(CmsPhonenumber::class, $result[0][$userEntityKey]->phonenumbers[0]); + self::assertInstanceOf(CmsUser::class, $result[0][$userEntityKey]); + self::assertInstanceOf(PersistentCollection::class, $result[0][$userEntityKey]->phonenumbers); + self::assertInstanceOf(CmsPhonenumber::class, $result[0][$userEntityKey]->phonenumbers[0]); - $this->assertInstanceOf(CmsUser::class, $result[1][$userEntityKey]); - $this->assertInstanceOf(PersistentCollection::class, $result[1][$userEntityKey]->phonenumbers); - $this->assertInstanceOf(CmsPhonenumber::class, $result[0][$userEntityKey]->phonenumbers[1]); + self::assertInstanceOf(CmsUser::class, $result[1][$userEntityKey]); + self::assertInstanceOf(PersistentCollection::class, $result[1][$userEntityKey]->phonenumbers); + self::assertInstanceOf(CmsPhonenumber::class, $result[0][$userEntityKey]->phonenumbers[1]); // first user => 2 phonenumbers - $this->assertEquals(2, count($result[0][$userEntityKey]->phonenumbers)); - $this->assertEquals('ROMANB', $result[0]['nameUpper']); + self::assertEquals(2, count($result[0][$userEntityKey]->phonenumbers)); + self::assertEquals('ROMANB', $result[0]['nameUpper']); // second user => 1 phonenumber - $this->assertEquals(1, count($result[1][$userEntityKey]->phonenumbers)); - $this->assertEquals('JWAGE', $result[1]['nameUpper']); + self::assertEquals(1, count($result[1][$userEntityKey]->phonenumbers)); + self::assertEquals('JWAGE', $result[1]['nameUpper']); - $this->assertEquals(42, $result[0][$userEntityKey]->phonenumbers[0]->phonenumber); - $this->assertEquals(43, $result[0][$userEntityKey]->phonenumbers[1]->phonenumber); - $this->assertEquals(91, $result[1][$userEntityKey]->phonenumbers[0]->phonenumber); + self::assertEquals(42, $result[0][$userEntityKey]->phonenumbers[0]->phonenumber); + self::assertEquals(43, $result[0][$userEntityKey]->phonenumbers[1]->phonenumber); + self::assertEquals(91, $result[1][$userEntityKey]->phonenumbers[0]->phonenumber); } /** @@ -564,30 +564,30 @@ public function testMixedQueryFetchJoinCustomIndex($userEntityKey): void $hydrator = new ObjectHydrator($this->entityManager); $result = $hydrator->hydrateAll($stmt, $rsm, [Query::HINT_FORCE_PARTIAL_LOAD => true]); - $this->assertEquals(2, count($result)); + self::assertEquals(2, count($result)); - $this->assertIsArray($result); - $this->assertIsArray($result[1]); - $this->assertIsArray($result[2]); + self::assertIsArray($result); + self::assertIsArray($result[1]); + self::assertIsArray($result[2]); // test the scalar values - $this->assertEquals('ROMANB', $result[1]['nameUpper']); - $this->assertEquals('JWAGE', $result[2]['nameUpper']); + self::assertEquals('ROMANB', $result[1]['nameUpper']); + self::assertEquals('JWAGE', $result[2]['nameUpper']); - $this->assertInstanceOf(CmsUser::class, $result[1][$userEntityKey]); - $this->assertInstanceOf(CmsUser::class, $result[2][$userEntityKey]); - $this->assertInstanceOf(PersistentCollection::class, $result[1][$userEntityKey]->phonenumbers); + self::assertInstanceOf(CmsUser::class, $result[1][$userEntityKey]); + self::assertInstanceOf(CmsUser::class, $result[2][$userEntityKey]); + self::assertInstanceOf(PersistentCollection::class, $result[1][$userEntityKey]->phonenumbers); // first user => 2 phonenumbers. notice the custom indexing by user id - $this->assertEquals(2, count($result[1][$userEntityKey]->phonenumbers)); + self::assertEquals(2, count($result[1][$userEntityKey]->phonenumbers)); // second user => 1 phonenumber. notice the custom indexing by user id - $this->assertEquals(1, count($result[2][$userEntityKey]->phonenumbers)); + self::assertEquals(1, count($result[2][$userEntityKey]->phonenumbers)); // test the custom indexing of the phonenumbers - $this->assertTrue(isset($result[1][$userEntityKey]->phonenumbers['42'])); - $this->assertTrue(isset($result[1][$userEntityKey]->phonenumbers['43'])); - $this->assertTrue(isset($result[2][$userEntityKey]->phonenumbers['91'])); + self::assertTrue(isset($result[1][$userEntityKey]->phonenumbers['42'])); + self::assertTrue(isset($result[1][$userEntityKey]->phonenumbers['43'])); + self::assertTrue(isset($result[2][$userEntityKey]->phonenumbers['91'])); } /** @@ -678,25 +678,25 @@ public function testMixedQueryMultipleFetchJoin($userEntityKey): void $hydrator = new ObjectHydrator($this->entityManager); $result = $hydrator->hydrateAll($stmt, $rsm, [Query::HINT_FORCE_PARTIAL_LOAD => true]); - $this->assertEquals(2, count($result)); - - $this->assertTrue(is_array($result)); - $this->assertTrue(is_array($result[0])); - $this->assertTrue(is_array($result[1])); - - $this->assertInstanceOf(CmsUser::class, $result[0][$userEntityKey]); - $this->assertInstanceOf(PersistentCollection::class, $result[0][$userEntityKey]->phonenumbers); - $this->assertInstanceOf(CmsPhonenumber::class, $result[0][$userEntityKey]->phonenumbers[0]); - $this->assertInstanceOf(CmsPhonenumber::class, $result[0][$userEntityKey]->phonenumbers[1]); - $this->assertInstanceOf(PersistentCollection::class, $result[0][$userEntityKey]->articles); - $this->assertInstanceOf(CmsArticle::class, $result[0][$userEntityKey]->articles[0]); - $this->assertInstanceOf(CmsArticle::class, $result[0][$userEntityKey]->articles[1]); - - $this->assertInstanceOf(CmsUser::class, $result[1][$userEntityKey]); - $this->assertInstanceOf(PersistentCollection::class, $result[1][$userEntityKey]->phonenumbers); - $this->assertInstanceOf(CmsPhonenumber::class, $result[1][$userEntityKey]->phonenumbers[0]); - $this->assertInstanceOf(CmsArticle::class, $result[1][$userEntityKey]->articles[0]); - $this->assertInstanceOf(CmsArticle::class, $result[1][$userEntityKey]->articles[1]); + self::assertEquals(2, count($result)); + + self::assertTrue(is_array($result)); + self::assertTrue(is_array($result[0])); + self::assertTrue(is_array($result[1])); + + self::assertInstanceOf(CmsUser::class, $result[0][$userEntityKey]); + self::assertInstanceOf(PersistentCollection::class, $result[0][$userEntityKey]->phonenumbers); + self::assertInstanceOf(CmsPhonenumber::class, $result[0][$userEntityKey]->phonenumbers[0]); + self::assertInstanceOf(CmsPhonenumber::class, $result[0][$userEntityKey]->phonenumbers[1]); + self::assertInstanceOf(PersistentCollection::class, $result[0][$userEntityKey]->articles); + self::assertInstanceOf(CmsArticle::class, $result[0][$userEntityKey]->articles[0]); + self::assertInstanceOf(CmsArticle::class, $result[0][$userEntityKey]->articles[1]); + + self::assertInstanceOf(CmsUser::class, $result[1][$userEntityKey]); + self::assertInstanceOf(PersistentCollection::class, $result[1][$userEntityKey]->phonenumbers); + self::assertInstanceOf(CmsPhonenumber::class, $result[1][$userEntityKey]->phonenumbers[0]); + self::assertInstanceOf(CmsArticle::class, $result[1][$userEntityKey]->articles[0]); + self::assertInstanceOf(CmsArticle::class, $result[1][$userEntityKey]->articles[1]); } /** @@ -808,43 +808,43 @@ public function testMixedQueryMultipleDeepMixedFetchJoin($userEntityKey): void $hydrator = new ObjectHydrator($this->entityManager); $result = $hydrator->hydrateAll($stmt, $rsm, [Query::HINT_FORCE_PARTIAL_LOAD => true]); - $this->assertEquals(2, count($result)); + self::assertEquals(2, count($result)); - $this->assertTrue(is_array($result)); - $this->assertTrue(is_array($result[0])); - $this->assertTrue(is_array($result[1])); + self::assertTrue(is_array($result)); + self::assertTrue(is_array($result[0])); + self::assertTrue(is_array($result[1])); - $this->assertInstanceOf(CmsUser::class, $result[0][$userEntityKey]); - $this->assertInstanceOf(CmsUser::class, $result[1][$userEntityKey]); + self::assertInstanceOf(CmsUser::class, $result[0][$userEntityKey]); + self::assertInstanceOf(CmsUser::class, $result[1][$userEntityKey]); // phonenumbers - $this->assertInstanceOf(PersistentCollection::class, $result[0][$userEntityKey]->phonenumbers); - $this->assertInstanceOf(CmsPhonenumber::class, $result[0][$userEntityKey]->phonenumbers[0]); - $this->assertInstanceOf(CmsPhonenumber::class, $result[0][$userEntityKey]->phonenumbers[1]); + self::assertInstanceOf(PersistentCollection::class, $result[0][$userEntityKey]->phonenumbers); + self::assertInstanceOf(CmsPhonenumber::class, $result[0][$userEntityKey]->phonenumbers[0]); + self::assertInstanceOf(CmsPhonenumber::class, $result[0][$userEntityKey]->phonenumbers[1]); - $this->assertInstanceOf(PersistentCollection::class, $result[1][$userEntityKey]->phonenumbers); - $this->assertInstanceOf(CmsPhonenumber::class, $result[1][$userEntityKey]->phonenumbers[0]); + self::assertInstanceOf(PersistentCollection::class, $result[1][$userEntityKey]->phonenumbers); + self::assertInstanceOf(CmsPhonenumber::class, $result[1][$userEntityKey]->phonenumbers[0]); // articles - $this->assertInstanceOf(PersistentCollection::class, $result[0][$userEntityKey]->articles); - $this->assertInstanceOf(CmsArticle::class, $result[0][$userEntityKey]->articles[0]); - $this->assertInstanceOf(CmsArticle::class, $result[0][$userEntityKey]->articles[1]); + self::assertInstanceOf(PersistentCollection::class, $result[0][$userEntityKey]->articles); + self::assertInstanceOf(CmsArticle::class, $result[0][$userEntityKey]->articles[0]); + self::assertInstanceOf(CmsArticle::class, $result[0][$userEntityKey]->articles[1]); - $this->assertInstanceOf(CmsArticle::class, $result[1][$userEntityKey]->articles[0]); - $this->assertInstanceOf(CmsArticle::class, $result[1][$userEntityKey]->articles[1]); + self::assertInstanceOf(CmsArticle::class, $result[1][$userEntityKey]->articles[0]); + self::assertInstanceOf(CmsArticle::class, $result[1][$userEntityKey]->articles[1]); // article comments - $this->assertInstanceOf(PersistentCollection::class, $result[0][$userEntityKey]->articles[0]->comments); - $this->assertInstanceOf(CmsComment::class, $result[0][$userEntityKey]->articles[0]->comments[0]); + self::assertInstanceOf(PersistentCollection::class, $result[0][$userEntityKey]->articles[0]->comments); + self::assertInstanceOf(CmsComment::class, $result[0][$userEntityKey]->articles[0]->comments[0]); // empty comment collections - $this->assertInstanceOf(PersistentCollection::class, $result[0][$userEntityKey]->articles[1]->comments); - $this->assertEquals(0, count($result[0][$userEntityKey]->articles[1]->comments)); + self::assertInstanceOf(PersistentCollection::class, $result[0][$userEntityKey]->articles[1]->comments); + self::assertEquals(0, count($result[0][$userEntityKey]->articles[1]->comments)); - $this->assertInstanceOf(PersistentCollection::class, $result[1][$userEntityKey]->articles[0]->comments); - $this->assertEquals(0, count($result[1][$userEntityKey]->articles[0]->comments)); - $this->assertInstanceOf(PersistentCollection::class, $result[1][$userEntityKey]->articles[1]->comments); - $this->assertEquals(0, count($result[1][$userEntityKey]->articles[1]->comments)); + self::assertInstanceOf(PersistentCollection::class, $result[1][$userEntityKey]->articles[0]->comments); + self::assertEquals(0, count($result[1][$userEntityKey]->articles[0]->comments)); + self::assertInstanceOf(PersistentCollection::class, $result[1][$userEntityKey]->articles[1]->comments); + self::assertEquals(0, count($result[1][$userEntityKey]->articles[1]->comments)); } /** @@ -921,21 +921,21 @@ public function testEntityQueryCustomResultSetOrder(): void $hydrator = new ObjectHydrator($this->entityManager); $result = $hydrator->hydrateAll($stmt, $rsm, [Query::HINT_FORCE_PARTIAL_LOAD => true]); - $this->assertEquals(2, count($result)); + self::assertEquals(2, count($result)); - $this->assertInstanceOf(ForumCategory::class, $result[0]); - $this->assertInstanceOf(ForumCategory::class, $result[1]); + self::assertInstanceOf(ForumCategory::class, $result[0]); + self::assertInstanceOf(ForumCategory::class, $result[1]); - $this->assertTrue($result[0] !== $result[1]); + self::assertTrue($result[0] !== $result[1]); - $this->assertEquals(1, $result[0]->getId()); - $this->assertEquals(2, $result[1]->getId()); + self::assertEquals(1, $result[0]->getId()); + self::assertEquals(2, $result[1]->getId()); - $this->assertTrue(isset($result[0]->boards)); - $this->assertEquals(3, count($result[0]->boards)); + self::assertTrue(isset($result[0]->boards)); + self::assertEquals(3, count($result[0]->boards)); - $this->assertTrue(isset($result[1]->boards)); - $this->assertEquals(1, count($result[1]->boards)); + self::assertTrue(isset($result[1]->boards)); + self::assertEquals(1, count($result[1]->boards)); } /** @@ -964,8 +964,8 @@ public function testSkipUnknownColumns(): void $hydrator = new ObjectHydrator($this->entityManager); $result = $hydrator->hydrateAll($stmt, $rsm, [Query::HINT_FORCE_PARTIAL_LOAD => true]); - $this->assertEquals(1, count($result)); - $this->assertInstanceOf(CmsUser::class, $result[0]); + self::assertEquals(1, count($result)); + self::assertInstanceOf(CmsUser::class, $result[0]); } /** @@ -997,16 +997,16 @@ public function testScalarQueryWithoutResultVariables($userEntityKey): void $hydrator = new ObjectHydrator($this->entityManager); $result = $hydrator->hydrateAll($stmt, $rsm, [Query::HINT_FORCE_PARTIAL_LOAD => true]); - $this->assertEquals(2, count($result)); + self::assertEquals(2, count($result)); - $this->assertIsArray($result[0]); - $this->assertIsArray($result[1]); + self::assertIsArray($result[0]); + self::assertIsArray($result[1]); - $this->assertEquals(1, $result[0]['id']); - $this->assertEquals('romanb', $result[0]['name']); + self::assertEquals(1, $result[0]['id']); + self::assertEquals('romanb', $result[0]['name']); - $this->assertEquals(2, $result[1]['id']); - $this->assertEquals('jwage', $result[1]['name']); + self::assertEquals(2, $result[1]['id']); + self::assertEquals('jwage', $result[1]['name']); } /** @@ -1038,10 +1038,10 @@ public function testCreatesProxyForLazyLoadingWithForeignKeys(): void ->disableOriginalConstructor() ->getMock(); - $proxyFactory->expects($this->once()) + $proxyFactory->expects(self::once()) ->method('getProxy') - ->with($this->equalTo(ECommerceShipping::class), ['id' => 42]) - ->will($this->returnValue($proxyInstance)); + ->with(self::equalTo(ECommerceShipping::class), ['id' => 42]) + ->will(self::returnValue($proxyInstance)); $this->entityManager->setProxyFactory($proxyFactory); @@ -1053,9 +1053,9 @@ public function testCreatesProxyForLazyLoadingWithForeignKeys(): void $hydrator = new ObjectHydrator($this->entityManager); $result = $hydrator->hydrateAll($stmt, $rsm); - $this->assertEquals(1, count($result)); + self::assertEquals(1, count($result)); - $this->assertInstanceOf(ECommerceProduct::class, $result[0]); + self::assertInstanceOf(ECommerceProduct::class, $result[0]); } /** @@ -1087,10 +1087,10 @@ public function testCreatesProxyForLazyLoadingWithForeignKeysWithAliasedProductE ->disableOriginalConstructor() ->getMock(); - $proxyFactory->expects($this->once()) + $proxyFactory->expects(self::once()) ->method('getProxy') - ->with($this->equalTo(ECommerceShipping::class), ['id' => 42]) - ->will($this->returnValue($proxyInstance)); + ->with(self::equalTo(ECommerceShipping::class), ['id' => 42]) + ->will(self::returnValue($proxyInstance)); $this->entityManager->setProxyFactory($proxyFactory); @@ -1102,10 +1102,10 @@ public function testCreatesProxyForLazyLoadingWithForeignKeysWithAliasedProductE $hydrator = new ObjectHydrator($this->entityManager); $result = $hydrator->hydrateAll($stmt, $rsm); - $this->assertEquals(1, count($result)); + self::assertEquals(1, count($result)); - $this->assertIsArray($result[0]); - $this->assertInstanceOf(ECommerceProduct::class, $result[0]['product']); + self::assertIsArray($result[0]); + self::assertInstanceOf(ECommerceProduct::class, $result[0]['product']); } /** @@ -1162,13 +1162,13 @@ public function testChainedJoinWithEmptyCollections(): void $hydrator = new ObjectHydrator($this->entityManager); $result = $hydrator->hydrateAll($stmt, $rsm, [Query::HINT_FORCE_PARTIAL_LOAD => true]); - $this->assertEquals(2, count($result)); + self::assertEquals(2, count($result)); - $this->assertInstanceOf(CmsUser::class, $result[0]); - $this->assertInstanceOf(CmsUser::class, $result[1]); + self::assertInstanceOf(CmsUser::class, $result[0]); + self::assertInstanceOf(CmsUser::class, $result[1]); - $this->assertEquals(0, $result[0]->articles->count()); - $this->assertEquals(0, $result[1]->articles->count()); + self::assertEquals(0, $result[0]->articles->count()); + self::assertEquals(0, $result[1]->articles->count()); } /** @@ -1225,16 +1225,16 @@ public function testChainedJoinWithEmptyCollectionsWithAliasedUserEntity(): void $hydrator = new ObjectHydrator($this->entityManager); $result = $hydrator->hydrateAll($stmt, $rsm, [Query::HINT_FORCE_PARTIAL_LOAD => true]); - $this->assertEquals(2, count($result)); + self::assertEquals(2, count($result)); - $this->assertIsArray($result[0]); - $this->assertInstanceOf(CmsUser::class, $result[0]['user']); + self::assertIsArray($result[0]); + self::assertInstanceOf(CmsUser::class, $result[0]['user']); - $this->assertIsArray($result[1]); - $this->assertInstanceOf(CmsUser::class, $result[1]['user']); + self::assertIsArray($result[1]); + self::assertInstanceOf(CmsUser::class, $result[1]['user']); - $this->assertEquals(0, $result[0]['user']->articles->count()); - $this->assertEquals(0, $result[1]['user']->articles->count()); + self::assertEquals(0, $result[0]['user']->articles->count()); + self::assertEquals(0, $result[1]['user']->articles->count()); } /** @@ -1270,15 +1270,15 @@ public function testResultIteration(): void $rowNum = 0; while (($row = $iterableResult->next()) !== false) { - $this->assertEquals(1, count($row)); - $this->assertInstanceOf(CmsUser::class, $row[0]); + self::assertEquals(1, count($row)); + self::assertInstanceOf(CmsUser::class, $row[0]); if ($rowNum === 0) { - $this->assertEquals(1, $row[0]->id); - $this->assertEquals('romanb', $row[0]->name); + self::assertEquals(1, $row[0]->id); + self::assertEquals('romanb', $row[0]->name); } elseif ($rowNum === 1) { - $this->assertEquals(2, $row[0]->id); - $this->assertEquals('jwage', $row[0]->name); + self::assertEquals(2, $row[0]->id); + self::assertEquals('jwage', $row[0]->name); } ++$rowNum; @@ -1344,17 +1344,17 @@ public function testResultIterationWithAliasedUserEntity(): void ); while (($row = $iterableResult->next()) !== false) { - $this->assertEquals(1, count($row)); - $this->assertArrayHasKey(0, $row); - $this->assertArrayHasKey('user', $row[0]); - $this->assertInstanceOf(CmsUser::class, $row[0]['user']); + self::assertEquals(1, count($row)); + self::assertArrayHasKey(0, $row); + self::assertArrayHasKey('user', $row[0]); + self::assertInstanceOf(CmsUser::class, $row[0]['user']); if ($rowNum === 0) { - $this->assertEquals(1, $row[0]['user']->id); - $this->assertEquals('romanb', $row[0]['user']->name); + self::assertEquals(1, $row[0]['user']->id); + self::assertEquals('romanb', $row[0]['user']->name); } elseif ($rowNum === 1) { - $this->assertEquals(2, $row[0]['user']->id); - $this->assertEquals('jwage', $row[0]['user']->name); + self::assertEquals(2, $row[0]['user']->id); + self::assertEquals('jwage', $row[0]['user']->name); } ++$rowNum; @@ -1502,15 +1502,15 @@ public function testManyToManyHydration(): void $hydrator = new ObjectHydrator($this->entityManager); $result = $hydrator->hydrateAll($stmt, $rsm, [Query::HINT_FORCE_PARTIAL_LOAD => true]); - $this->assertEquals(2, count($result)); + self::assertEquals(2, count($result)); - $this->assertContainsOnly(CmsUser::class, $result); + self::assertContainsOnly(CmsUser::class, $result); - $this->assertEquals(2, count($result[0]->groups)); - $this->assertEquals(2, count($result[0]->phonenumbers)); + self::assertEquals(2, count($result[0]->groups)); + self::assertEquals(2, count($result[0]->phonenumbers)); - $this->assertEquals(4, count($result[1]->groups)); - $this->assertEquals(2, count($result[1]->phonenumbers)); + self::assertEquals(4, count($result[1]->groups)); + self::assertEquals(2, count($result[1]->phonenumbers)); } /** @@ -1625,18 +1625,18 @@ public function testManyToManyHydrationWithAliasedUserEntity(): void $hydrator = new ObjectHydrator($this->entityManager); $result = $hydrator->hydrateAll($stmt, $rsm, [Query::HINT_FORCE_PARTIAL_LOAD => true]); - $this->assertEquals(2, count($result)); + self::assertEquals(2, count($result)); - $this->assertIsArray($result[0]); - $this->assertInstanceOf(CmsUser::class, $result[0]['user']); - $this->assertIsArray($result[1]); - $this->assertInstanceOf(CmsUser::class, $result[1]['user']); + self::assertIsArray($result[0]); + self::assertInstanceOf(CmsUser::class, $result[0]['user']); + self::assertIsArray($result[1]); + self::assertInstanceOf(CmsUser::class, $result[1]['user']); - $this->assertEquals(2, count($result[0]['user']->groups)); - $this->assertEquals(2, count($result[0]['user']->phonenumbers)); + self::assertEquals(2, count($result[0]['user']->groups)); + self::assertEquals(2, count($result[0]['user']->phonenumbers)); - $this->assertEquals(4, count($result[1]['user']->groups)); - $this->assertEquals(2, count($result[1]['user']->phonenumbers)); + self::assertEquals(4, count($result[1]['user']->groups)); + self::assertEquals(2, count($result[1]['user']->phonenumbers)); } /** @@ -1683,18 +1683,18 @@ public function testMissingIdForRootEntity($userEntityKey): void $hydrator = new ObjectHydrator($this->entityManager); $result = $hydrator->hydrateAll($stmt, $rsm, [Query::HINT_FORCE_PARTIAL_LOAD => true]); - $this->assertEquals(4, count($result), 'Should hydrate four results.'); + self::assertEquals(4, count($result), 'Should hydrate four results.'); - $this->assertEquals('ROMANB', $result[0]['nameUpper']); - $this->assertEquals('ROMANB', $result[1]['nameUpper']); - $this->assertEquals('JWAGE', $result[2]['nameUpper']); - $this->assertEquals('JWAGE', $result[3]['nameUpper']); + self::assertEquals('ROMANB', $result[0]['nameUpper']); + self::assertEquals('ROMANB', $result[1]['nameUpper']); + self::assertEquals('JWAGE', $result[2]['nameUpper']); + self::assertEquals('JWAGE', $result[3]['nameUpper']); - $this->assertInstanceOf(CmsUser::class, $result[0][$userEntityKey]); - $this->assertNull($result[1][$userEntityKey]); + self::assertInstanceOf(CmsUser::class, $result[0][$userEntityKey]); + self::assertNull($result[1][$userEntityKey]); - $this->assertInstanceOf(CmsUser::class, $result[2][$userEntityKey]); - $this->assertNull($result[3][$userEntityKey]); + self::assertInstanceOf(CmsUser::class, $result[2][$userEntityKey]); + self::assertNull($result[3][$userEntityKey]); } /** @@ -1753,10 +1753,10 @@ public function testMissingIdForCollectionValuedChildEntity($userEntityKey): voi $hydrator = new ObjectHydrator($this->entityManager); $result = $hydrator->hydrateAll($stmt, $rsm, [Query::HINT_FORCE_PARTIAL_LOAD => true]); - $this->assertEquals(2, count($result)); + self::assertEquals(2, count($result)); - $this->assertEquals(1, $result[0][$userEntityKey]->phonenumbers->count()); - $this->assertEquals(1, $result[1][$userEntityKey]->phonenumbers->count()); + self::assertEquals(1, $result[0][$userEntityKey]->phonenumbers->count()); + self::assertEquals(1, $result[1][$userEntityKey]->phonenumbers->count()); } /** @@ -1807,10 +1807,10 @@ public function testMissingIdForSingleValuedChildEntity($userEntityKey): void $hydrator = new ObjectHydrator($this->entityManager); $result = $hydrator->hydrateAll($stmt, $rsm, [Query::HINT_FORCE_PARTIAL_LOAD => true]); - $this->assertEquals(2, count($result)); + self::assertEquals(2, count($result)); - $this->assertInstanceOf(CmsAddress::class, $result[0][$userEntityKey]->address); - $this->assertNull($result[1][$userEntityKey]->address); + self::assertInstanceOf(CmsAddress::class, $result[0][$userEntityKey]->address); + self::assertNull($result[1][$userEntityKey]->address); } /** @@ -1849,13 +1849,13 @@ public function testIndexByAndMixedResult($userEntityKey): void $hydrator = new ObjectHydrator($this->entityManager); $result = $hydrator->hydrateAll($stmt, $rsm, [Query::HINT_FORCE_PARTIAL_LOAD => true]); - $this->assertEquals(2, count($result)); + self::assertEquals(2, count($result)); - $this->assertTrue(isset($result[1])); - $this->assertEquals(1, $result[1][$userEntityKey]->id); + self::assertTrue(isset($result[1])); + self::assertEquals(1, $result[1][$userEntityKey]->id); - $this->assertTrue(isset($result[2])); - $this->assertEquals(2, $result[2][$userEntityKey]->id); + self::assertTrue(isset($result[2])); + self::assertEquals(2, $result[2][$userEntityKey]->id); } /** @@ -1883,7 +1883,7 @@ public function testIndexByScalarsOnly($userEntityKey): void $hydrator = new ObjectHydrator($this->entityManager); $result = $hydrator->hydrateAll($stmt, $rsm, [Query::HINT_FORCE_PARTIAL_LOAD => true]); - $this->assertEquals( + self::assertEquals( [ 'ROMANB' => ['nameUpper' => 'ROMANB'], 'JWAGE' => ['nameUpper' => 'JWAGE'], @@ -1999,10 +1999,10 @@ public function testFetchJoinCollectionValuedAssociationWithDefaultArrayValue(): $hydrator = new ObjectHydrator($this->entityManager); $result = $hydrator->hydrateAll($stmt, $rsm); - $this->assertCount(1, $result); - $this->assertInstanceOf(EntityWithArrayDefaultArrayValueM2M::class, $result[0]); - $this->assertInstanceOf(PersistentCollection::class, $result[0]->collection); - $this->assertCount(1, $result[0]->collection); - $this->assertInstanceOf(SimpleEntity::class, $result[0]->collection[0]); + self::assertCount(1, $result); + self::assertInstanceOf(EntityWithArrayDefaultArrayValueM2M::class, $result[0]); + self::assertInstanceOf(PersistentCollection::class, $result[0]->collection); + self::assertCount(1, $result[0]->collection); + self::assertInstanceOf(SimpleEntity::class, $result[0]->collection[0]); } } diff --git a/tests/Doctrine/Tests/ORM/Hydration/ResultSetMappingTest.php b/tests/Doctrine/Tests/ORM/Hydration/ResultSetMappingTest.php index a33375fff89..27e240f2336 100644 --- a/tests/Doctrine/Tests/ORM/Hydration/ResultSetMappingTest.php +++ b/tests/Doctrine/Tests/ORM/Hydration/ResultSetMappingTest.php @@ -48,24 +48,24 @@ public function testBasicResultSetMapping(): void $this->_rsm->addFieldResult('u', 'username', 'username'); $this->_rsm->addFieldResult('u', 'name', 'name'); - $this->assertFalse($this->_rsm->isScalarResult('id')); - $this->assertFalse($this->_rsm->isScalarResult('status')); - $this->assertFalse($this->_rsm->isScalarResult('username')); - $this->assertFalse($this->_rsm->isScalarResult('name')); + self::assertFalse($this->_rsm->isScalarResult('id')); + self::assertFalse($this->_rsm->isScalarResult('status')); + self::assertFalse($this->_rsm->isScalarResult('username')); + self::assertFalse($this->_rsm->isScalarResult('name')); - $this->assertTrue($this->_rsm->getClassName('u') === CmsUser::class); + self::assertTrue($this->_rsm->getClassName('u') === CmsUser::class); $class = $this->_rsm->getDeclaringClass('id'); - $this->assertTrue($class === CmsUser::class); + self::assertTrue($class === CmsUser::class); - $this->assertEquals('u', $this->_rsm->getEntityAlias('id')); - $this->assertEquals('u', $this->_rsm->getEntityAlias('status')); - $this->assertEquals('u', $this->_rsm->getEntityAlias('username')); - $this->assertEquals('u', $this->_rsm->getEntityAlias('name')); + self::assertEquals('u', $this->_rsm->getEntityAlias('id')); + self::assertEquals('u', $this->_rsm->getEntityAlias('status')); + self::assertEquals('u', $this->_rsm->getEntityAlias('username')); + self::assertEquals('u', $this->_rsm->getEntityAlias('name')); - $this->assertEquals('id', $this->_rsm->getFieldName('id')); - $this->assertEquals('status', $this->_rsm->getFieldName('status')); - $this->assertEquals('username', $this->_rsm->getFieldName('username')); - $this->assertEquals('name', $this->_rsm->getFieldName('name')); + self::assertEquals('id', $this->_rsm->getFieldName('id')); + self::assertEquals('status', $this->_rsm->getFieldName('status')); + self::assertEquals('username', $this->_rsm->getFieldName('username')); + self::assertEquals('name', $this->_rsm->getFieldName('name')); } /** @@ -88,13 +88,13 @@ public function testFluentInterface(): void $this->_rsm->addScalarResult('sclr0', 'numPhones'); $this->_rsm->addMetaResult('a', 'user_id', 'user_id'); - $this->assertTrue($rms->hasIndexBy('id')); - $this->assertTrue($rms->isFieldResult('id')); - $this->assertTrue($rms->isFieldResult('name')); - $this->assertTrue($rms->isScalarResult('sclr0')); - $this->assertTrue($rms->isRelation('p')); - $this->assertTrue($rms->hasParentAlias('p')); - $this->assertTrue($rms->isMixedResult()); + self::assertTrue($rms->hasIndexBy('id')); + self::assertTrue($rms->isFieldResult('id')); + self::assertTrue($rms->isFieldResult('name')); + self::assertTrue($rms->isScalarResult('sclr0')); + self::assertTrue($rms->isRelation('p')); + self::assertTrue($rms->hasParentAlias('p')); + self::assertTrue($rms->isMixedResult()); } /** @@ -171,19 +171,19 @@ public function testAddNamedNativeQueryResultSetMapping(): void $rsm = new ResultSetMappingBuilder($this->entityManager); $rsm->addNamedNativeQueryMapping($cm, $queryMapping); - $this->assertEquals('scalarColumn', $rsm->getScalarAlias('scalarColumn')); + self::assertEquals('scalarColumn', $rsm->getScalarAlias('scalarColumn')); - $this->assertEquals('c0', $rsm->getEntityAlias('user_id')); - $this->assertEquals('c0', $rsm->getEntityAlias('name')); - $this->assertEquals(CmsUser::class, $rsm->getClassName('c0')); - $this->assertEquals(CmsUser::class, $rsm->getDeclaringClass('name')); - $this->assertEquals(CmsUser::class, $rsm->getDeclaringClass('user_id')); + self::assertEquals('c0', $rsm->getEntityAlias('user_id')); + self::assertEquals('c0', $rsm->getEntityAlias('name')); + self::assertEquals(CmsUser::class, $rsm->getClassName('c0')); + self::assertEquals(CmsUser::class, $rsm->getDeclaringClass('name')); + self::assertEquals(CmsUser::class, $rsm->getDeclaringClass('user_id')); - $this->assertEquals('c1', $rsm->getEntityAlias('email_id')); - $this->assertEquals('c1', $rsm->getEntityAlias('email')); - $this->assertEquals(CmsEmail::class, $rsm->getClassName('c1')); - $this->assertEquals(CmsEmail::class, $rsm->getDeclaringClass('email')); - $this->assertEquals(CmsEmail::class, $rsm->getDeclaringClass('email_id')); + self::assertEquals('c1', $rsm->getEntityAlias('email_id')); + self::assertEquals('c1', $rsm->getEntityAlias('email')); + self::assertEquals(CmsEmail::class, $rsm->getClassName('c1')); + self::assertEquals(CmsEmail::class, $rsm->getDeclaringClass('email')); + self::assertEquals(CmsEmail::class, $rsm->getDeclaringClass('email_id')); } /** @@ -219,16 +219,16 @@ public function testAddNamedNativeQueryResultSetMappingWithoutFields(): void $rsm->addNamedNativeQueryMapping($cm, $queryMapping); - $this->assertEquals('scalarColumn', $rsm->getScalarAlias('scalarColumn')); - $this->assertEquals('c0', $rsm->getEntityAlias('id')); - $this->assertEquals('c0', $rsm->getEntityAlias('name')); - $this->assertEquals('c0', $rsm->getEntityAlias('status')); - $this->assertEquals('c0', $rsm->getEntityAlias('username')); - $this->assertEquals(CmsUser::class, $rsm->getClassName('c0')); - $this->assertEquals(CmsUser::class, $rsm->getDeclaringClass('id')); - $this->assertEquals(CmsUser::class, $rsm->getDeclaringClass('name')); - $this->assertEquals(CmsUser::class, $rsm->getDeclaringClass('status')); - $this->assertEquals(CmsUser::class, $rsm->getDeclaringClass('username')); + self::assertEquals('scalarColumn', $rsm->getScalarAlias('scalarColumn')); + self::assertEquals('c0', $rsm->getEntityAlias('id')); + self::assertEquals('c0', $rsm->getEntityAlias('name')); + self::assertEquals('c0', $rsm->getEntityAlias('status')); + self::assertEquals('c0', $rsm->getEntityAlias('username')); + self::assertEquals(CmsUser::class, $rsm->getClassName('c0')); + self::assertEquals(CmsUser::class, $rsm->getDeclaringClass('id')); + self::assertEquals(CmsUser::class, $rsm->getDeclaringClass('name')); + self::assertEquals(CmsUser::class, $rsm->getDeclaringClass('status')); + self::assertEquals(CmsUser::class, $rsm->getDeclaringClass('username')); } /** @@ -253,15 +253,15 @@ public function testAddNamedNativeQueryResultClass(): void $rsm->addNamedNativeQueryMapping($cm, $queryMapping); - $this->assertEquals('c0', $rsm->getEntityAlias('id')); - $this->assertEquals('c0', $rsm->getEntityAlias('name')); - $this->assertEquals('c0', $rsm->getEntityAlias('status')); - $this->assertEquals('c0', $rsm->getEntityAlias('username')); - $this->assertEquals(CmsUser::class, $rsm->getClassName('c0')); - $this->assertEquals(CmsUser::class, $rsm->getDeclaringClass('id')); - $this->assertEquals(CmsUser::class, $rsm->getDeclaringClass('name')); - $this->assertEquals(CmsUser::class, $rsm->getDeclaringClass('status')); - $this->assertEquals(CmsUser::class, $rsm->getDeclaringClass('username')); + self::assertEquals('c0', $rsm->getEntityAlias('id')); + self::assertEquals('c0', $rsm->getEntityAlias('name')); + self::assertEquals('c0', $rsm->getEntityAlias('status')); + self::assertEquals('c0', $rsm->getEntityAlias('username')); + self::assertEquals(CmsUser::class, $rsm->getClassName('c0')); + self::assertEquals(CmsUser::class, $rsm->getDeclaringClass('id')); + self::assertEquals(CmsUser::class, $rsm->getDeclaringClass('name')); + self::assertEquals(CmsUser::class, $rsm->getDeclaringClass('status')); + self::assertEquals(CmsUser::class, $rsm->getDeclaringClass('username')); } /** @@ -275,6 +275,6 @@ public function testIndexByMetadataColumn(): void $this->_rsm->addMetaResult('lu', '_target', '_target', true, 'integer'); $this->_rsm->addIndexBy('lu', '_source'); - $this->assertTrue($this->_rsm->hasIndexBy('lu')); + self::assertTrue($this->_rsm->hasIndexBy('lu')); } } diff --git a/tests/Doctrine/Tests/ORM/Hydration/ScalarHydratorTest.php b/tests/Doctrine/Tests/ORM/Hydration/ScalarHydratorTest.php index 6f1404d5acc..3c8bf4f6178 100644 --- a/tests/Doctrine/Tests/ORM/Hydration/ScalarHydratorTest.php +++ b/tests/Doctrine/Tests/ORM/Hydration/ScalarHydratorTest.php @@ -38,12 +38,12 @@ public function testNewHydrationSimpleEntityQuery(): void $result = $hydrator->hydrateAll($stmt, $rsm); - $this->assertIsArray($result); - $this->assertCount(2, $result); - $this->assertEquals('romanb', $result[0]['u_name']); - $this->assertEquals(1, $result[0]['u_id']); - $this->assertEquals('jwage', $result[1]['u_name']); - $this->assertEquals(2, $result[1]['u_id']); + self::assertIsArray($result); + self::assertCount(2, $result); + self::assertEquals('romanb', $result[0]['u_name']); + self::assertEquals(1, $result[0]['u_id']); + self::assertEquals('jwage', $result[1]['u_name']); + self::assertEquals(2, $result[1]['u_id']); } /** diff --git a/tests/Doctrine/Tests/ORM/Hydration/SimpleObjectHydratorTest.php b/tests/Doctrine/Tests/ORM/Hydration/SimpleObjectHydratorTest.php index de78568314a..ebed56e15bc 100644 --- a/tests/Doctrine/Tests/ORM/Hydration/SimpleObjectHydratorTest.php +++ b/tests/Doctrine/Tests/ORM/Hydration/SimpleObjectHydratorTest.php @@ -67,7 +67,7 @@ public function testExtraFieldInResultSetShouldBeIgnore(): void $stmt = new HydratorMockResult($resultSet); $hydrator = new SimpleObjectHydrator($this->entityManager); $result = $hydrator->hydrateAll($stmt, $rsm); - $this->assertEquals($result[0], $expectedEntity); + self::assertEquals($result[0], $expectedEntity); } /** @@ -126,7 +126,7 @@ public function testNullValueShouldNotOverwriteFieldWithSameNameInJoinedInherita $stmt = new HydratorMockResult($resultSet); $hydrator = new SimpleObjectHydrator($this->entityManager); $result = $hydrator->hydrateAll($stmt, $rsm); - $this->assertEquals($result[0], $expectedEntity); + self::assertEquals($result[0], $expectedEntity); } public function testWrongValuesShouldNotBeConvertedToPhpValue(): void @@ -158,6 +158,6 @@ public function testWrongValuesShouldNotBeConvertedToPhpValue(): void $stmt = new HydratorMockResult($resultSet); $hydrator = new SimpleObjectHydrator($this->entityManager); $result = $hydrator->hydrateAll($stmt, $rsm); - $this->assertEquals($result[0], $expectedEntity); + self::assertEquals($result[0], $expectedEntity); } } diff --git a/tests/Doctrine/Tests/ORM/Hydration/SingleScalarHydratorTest.php b/tests/Doctrine/Tests/ORM/Hydration/SingleScalarHydratorTest.php index 9117289f61f..6d7d40d687b 100644 --- a/tests/Doctrine/Tests/ORM/Hydration/SingleScalarHydratorTest.php +++ b/tests/Doctrine/Tests/ORM/Hydration/SingleScalarHydratorTest.php @@ -70,14 +70,14 @@ public function testHydrateSingleScalar($name, $resultSet): void if ($name === 'result1') { $result = $hydrator->hydrateAll($stmt, $rsm); - $this->assertEquals('romanb', $result); + self::assertEquals('romanb', $result); return; } if ($name === 'result2') { $result = $hydrator->hydrateAll($stmt, $rsm); - $this->assertEquals(1, $result); + self::assertEquals(1, $result); return; } diff --git a/tests/Doctrine/Tests/ORM/Id/AssignedGeneratorTest.php b/tests/Doctrine/Tests/ORM/Id/AssignedGeneratorTest.php index 7ad28541565..54ec5668116 100644 --- a/tests/Doctrine/Tests/ORM/Id/AssignedGeneratorTest.php +++ b/tests/Doctrine/Tests/ORM/Id/AssignedGeneratorTest.php @@ -51,13 +51,13 @@ public function testCorrectIdGeneration(): void $entity = new AssignedSingleIdEntity(); $entity->myId = 1; $id = $this->assignedGen->generate($this->entityManager, $entity); - $this->assertEquals(['myId' => 1], $id); + self::assertEquals(['myId' => 1], $id); $entity = new AssignedCompositeIdEntity(); $entity->myId2 = 2; $entity->myId1 = 4; $id = $this->assignedGen->generate($this->entityManager, $entity); - $this->assertEquals(['myId1' => 4, 'myId2' => 2], $id); + self::assertEquals(['myId1' => 4, 'myId2' => 2], $id); } } diff --git a/tests/Doctrine/Tests/ORM/Internal/HydrationCompleteHandlerTest.php b/tests/Doctrine/Tests/ORM/Internal/HydrationCompleteHandlerTest.php index 9b48d8888fb..e59122e422e 100644 --- a/tests/Doctrine/Tests/ORM/Internal/HydrationCompleteHandlerTest.php +++ b/tests/Doctrine/Tests/ORM/Internal/HydrationCompleteHandlerTest.php @@ -52,22 +52,22 @@ public function testDefersPostLoadOfEntity(int $listenersFlag): void $this ->listenersInvoker - ->expects($this->any()) + ->expects(self::any()) ->method('getSubscribedSystems') ->with($metadata) - ->will($this->returnValue($listenersFlag)); + ->will(self::returnValue($listenersFlag)); $this->handler->deferPostLoadInvoking($metadata, $entity); $this ->listenersInvoker - ->expects($this->once()) + ->expects(self::once()) ->method('invoke') ->with( $metadata, Events::postLoad, $entity, - $this->callback(static function (LifecycleEventArgs $args) use ($entityManager, $entity) { + self::callback(static function (LifecycleEventArgs $args) use ($entityManager, $entity) { return $entity === $args->getEntity() && $entityManager === $args->getObjectManager(); }), $listenersFlag @@ -87,14 +87,14 @@ public function testDefersPostLoadOfEntityOnlyOnce(int $listenersFlag): void $this ->listenersInvoker - ->expects($this->any()) + ->expects(self::any()) ->method('getSubscribedSystems') ->with($metadata) - ->will($this->returnValue($listenersFlag)); + ->will(self::returnValue($listenersFlag)); $this->handler->deferPostLoadInvoking($metadata, $entity); - $this->listenersInvoker->expects($this->once())->method('invoke'); + $this->listenersInvoker->expects(self::once())->method('invoke'); $this->handler->hydrationComplete(); $this->handler->hydrationComplete(); @@ -113,23 +113,23 @@ public function testDefersMultiplePostLoadOfEntity(int $listenersFlag): void $this ->listenersInvoker - ->expects($this->any()) + ->expects(self::any()) ->method('getSubscribedSystems') - ->with($this->logicalOr($metadata1, $metadata2)) - ->will($this->returnValue($listenersFlag)); + ->with(self::logicalOr($metadata1, $metadata2)) + ->will(self::returnValue($listenersFlag)); $this->handler->deferPostLoadInvoking($metadata1, $entity1); $this->handler->deferPostLoadInvoking($metadata2, $entity2); $this ->listenersInvoker - ->expects($this->exactly(2)) + ->expects(self::exactly(2)) ->method('invoke') ->with( - $this->logicalOr($metadata1, $metadata2), + self::logicalOr($metadata1, $metadata2), Events::postLoad, - $this->logicalOr($entity1, $entity2), - $this->callback(static function (LifecycleEventArgs $args) use ($entityManager, $entity1, $entity2) { + self::logicalOr($entity1, $entity2), + self::callback(static function (LifecycleEventArgs $args) use ($entityManager, $entity1, $entity2) { return in_array($args->getEntity(), [$entity1, $entity2], true) && $entityManager === $args->getObjectManager(); }), @@ -147,14 +147,14 @@ public function testSkipsDeferredPostLoadOfMetadataWithNoInvokedListeners(): voi $this ->listenersInvoker - ->expects($this->any()) + ->expects(self::any()) ->method('getSubscribedSystems') ->with($metadata) - ->will($this->returnValue(ListenersInvoker::INVOKE_NONE)); + ->will(self::returnValue(ListenersInvoker::INVOKE_NONE)); $this->handler->deferPostLoadInvoking($metadata, $entity); - $this->listenersInvoker->expects($this->never())->method('invoke'); + $this->listenersInvoker->expects(self::never())->method('invoke'); $this->handler->hydrationComplete(); } diff --git a/tests/Doctrine/Tests/ORM/LazyCriteriaCollectionTest.php b/tests/Doctrine/Tests/ORM/LazyCriteriaCollectionTest.php index 412c4998d4a..7369b5165c8 100644 --- a/tests/Doctrine/Tests/ORM/LazyCriteriaCollectionTest.php +++ b/tests/Doctrine/Tests/ORM/LazyCriteriaCollectionTest.php @@ -35,37 +35,37 @@ protected function setUp(): void public function testCountIsCached(): void { - $this->persister->expects($this->once())->method('count')->with($this->criteria)->will($this->returnValue(10)); + $this->persister->expects(self::once())->method('count')->with($this->criteria)->will(self::returnValue(10)); - $this->assertSame(10, $this->lazyCriteriaCollection->count()); - $this->assertSame(10, $this->lazyCriteriaCollection->count()); - $this->assertSame(10, $this->lazyCriteriaCollection->count()); + self::assertSame(10, $this->lazyCriteriaCollection->count()); + self::assertSame(10, $this->lazyCriteriaCollection->count()); + self::assertSame(10, $this->lazyCriteriaCollection->count()); } public function testCountIsCachedEvenWithZeroResult(): void { - $this->persister->expects($this->once())->method('count')->with($this->criteria)->will($this->returnValue(0)); + $this->persister->expects(self::once())->method('count')->with($this->criteria)->will(self::returnValue(0)); - $this->assertSame(0, $this->lazyCriteriaCollection->count()); - $this->assertSame(0, $this->lazyCriteriaCollection->count()); - $this->assertSame(0, $this->lazyCriteriaCollection->count()); + self::assertSame(0, $this->lazyCriteriaCollection->count()); + self::assertSame(0, $this->lazyCriteriaCollection->count()); + self::assertSame(0, $this->lazyCriteriaCollection->count()); } public function testCountUsesWrappedCollectionWhenInitialized(): void { $this ->persister - ->expects($this->once()) + ->expects(self::once()) ->method('loadCriteria') ->with($this->criteria) - ->will($this->returnValue(['foo', 'bar', 'baz'])); + ->will(self::returnValue(['foo', 'bar', 'baz'])); // should never call the persister's count - $this->persister->expects($this->never())->method('count'); + $this->persister->expects(self::never())->method('count'); - $this->assertSame(['foo', 'bar', 'baz'], $this->lazyCriteriaCollection->toArray()); + self::assertSame(['foo', 'bar', 'baz'], $this->lazyCriteriaCollection->toArray()); - $this->assertSame(3, $this->lazyCriteriaCollection->count()); + self::assertSame(3, $this->lazyCriteriaCollection->count()); } public function testMatchingUsesThePersisterOnlyOnce(): void @@ -80,10 +80,10 @@ public function testMatchingUsesThePersisterOnlyOnce(): void $this ->persister - ->expects($this->once()) + ->expects(self::once()) ->method('loadCriteria') ->with($this->criteria) - ->will($this->returnValue([$foo, $bar, $baz])); + ->will(self::returnValue([$foo, $bar, $baz])); $criteria = new Criteria(); @@ -91,40 +91,40 @@ public function testMatchingUsesThePersisterOnlyOnce(): void $filtered = $this->lazyCriteriaCollection->matching($criteria); - $this->assertInstanceOf(Collection::class, $filtered); - $this->assertEquals([$foo], $filtered->toArray()); + self::assertInstanceOf(Collection::class, $filtered); + self::assertEquals([$foo], $filtered->toArray()); - $this->assertEquals([$foo], $this->lazyCriteriaCollection->matching($criteria)->toArray()); + self::assertEquals([$foo], $this->lazyCriteriaCollection->matching($criteria)->toArray()); } public function testIsEmptyUsesCountWhenNotInitialized(): void { - $this->persister->expects($this->once())->method('count')->with($this->criteria)->will($this->returnValue(0)); + $this->persister->expects(self::once())->method('count')->with($this->criteria)->will(self::returnValue(0)); - $this->assertTrue($this->lazyCriteriaCollection->isEmpty()); + self::assertTrue($this->lazyCriteriaCollection->isEmpty()); } public function testIsEmptyIsFalseIfCountIsNotZero(): void { - $this->persister->expects($this->once())->method('count')->with($this->criteria)->will($this->returnValue(1)); + $this->persister->expects(self::once())->method('count')->with($this->criteria)->will(self::returnValue(1)); - $this->assertFalse($this->lazyCriteriaCollection->isEmpty()); + self::assertFalse($this->lazyCriteriaCollection->isEmpty()); } public function testIsEmptyUsesWrappedCollectionWhenInitialized(): void { $this ->persister - ->expects($this->once()) + ->expects(self::once()) ->method('loadCriteria') ->with($this->criteria) - ->will($this->returnValue(['foo', 'bar', 'baz'])); + ->will(self::returnValue(['foo', 'bar', 'baz'])); // should never call the persister's count - $this->persister->expects($this->never())->method('count'); + $this->persister->expects(self::never())->method('count'); - $this->assertSame(['foo', 'bar', 'baz'], $this->lazyCriteriaCollection->toArray()); + self::assertSame(['foo', 'bar', 'baz'], $this->lazyCriteriaCollection->toArray()); - $this->assertFalse($this->lazyCriteriaCollection->isEmpty()); + self::assertFalse($this->lazyCriteriaCollection->isEmpty()); } } diff --git a/tests/Doctrine/Tests/ORM/Mapping/AbstractMappingDriverTest.php b/tests/Doctrine/Tests/ORM/Mapping/AbstractMappingDriverTest.php index 0d9038ae836..0031153d39f 100644 --- a/tests/Doctrine/Tests/ORM/Mapping/AbstractMappingDriverTest.php +++ b/tests/Doctrine/Tests/ORM/Mapping/AbstractMappingDriverTest.php @@ -111,8 +111,8 @@ public function testEntityTableNameAndInheritance(): ClassMetadata { $class = $this->createClassMetadata(User::class); - $this->assertEquals('cms_users', $class->getTableName()); - $this->assertEquals(ClassMetadata::INHERITANCE_TYPE_NONE, $class->inheritanceType); + self::assertEquals('cms_users', $class->getTableName()); + self::assertEquals(ClassMetadata::INHERITANCE_TYPE_NONE, $class->inheritanceType); return $class; } @@ -122,8 +122,8 @@ public function testEntityTableNameAndInheritance(): ClassMetadata */ public function testEntityIndexes(ClassMetadata $class): ClassMetadata { - $this->assertArrayHasKey('indexes', $class->table, 'ClassMetadata should have indexes key in table property.'); - $this->assertEquals( + self::assertArrayHasKey('indexes', $class->table, 'ClassMetadata should have indexes key in table property.'); + self::assertEquals( [ 'name_idx' => ['columns' => ['name']], 0 => ['columns' => ['user_email']], @@ -145,7 +145,7 @@ public function testEntityIndexFlagsAndPartialIndexes(): void { $class = $this->createClassMetadata(Comment::class); - $this->assertEquals( + self::assertEquals( [ 0 => [ 'columns' => ['content'], @@ -162,13 +162,13 @@ public function testEntityIndexFlagsAndPartialIndexes(): void */ public function testEntityUniqueConstraints(ClassMetadata $class): ClassMetadata { - $this->assertArrayHasKey( + self::assertArrayHasKey( 'uniqueConstraints', $class->table, 'ClassMetadata should have uniqueConstraints key in table property when Unique Constraints are set.' ); - $this->assertEquals( + self::assertEquals( [ 'search_idx' => ['columns' => ['name', 'user_email'], 'options' => ['where' => 'name IS NOT NULL']], 'phone_idx' => ['fields' => ['name', 'phone']], @@ -190,9 +190,9 @@ public function testEntityIncorrectUniqueContraint(): void */ public function testEntityOptions(ClassMetadata $class): ClassMetadata { - $this->assertArrayHasKey('options', $class->table, 'ClassMetadata should have options key in table property.'); + self::assertArrayHasKey('options', $class->table, 'ClassMetadata should have options key in table property.'); - $this->assertEquals( + self::assertEquals( [ 'foo' => 'bar', 'baz' => ['key' => 'val'], @@ -208,8 +208,8 @@ public function testEntityOptions(ClassMetadata $class): ClassMetadata */ public function testEntitySequence(ClassMetadata $class): void { - $this->assertIsArray($class->sequenceGeneratorDefinition, 'No Sequence Definition set on this driver.'); - $this->assertEquals( + self::assertIsArray($class->sequenceGeneratorDefinition, 'No Sequence Definition set on this driver.'); + self::assertEquals( [ 'sequenceName' => 'tablename_seq', 'allocationSize' => 100, @@ -223,12 +223,12 @@ public function testEntityCustomGenerator(): void { $class = $this->createClassMetadata(Animal::class); - $this->assertEquals( + self::assertEquals( ClassMetadata::GENERATOR_TYPE_CUSTOM, $class->generatorType, 'Generator Type' ); - $this->assertEquals( + self::assertEquals( ['class' => 'stdClass'], $class->customGeneratorDefinition, 'Custom Generator Definition' @@ -240,11 +240,11 @@ public function testEntityCustomGenerator(): void */ public function testFieldMappings(ClassMetadata $class): ClassMetadata { - $this->assertEquals(4, count($class->fieldMappings)); - $this->assertTrue(isset($class->fieldMappings['id'])); - $this->assertTrue(isset($class->fieldMappings['name'])); - $this->assertTrue(isset($class->fieldMappings['email'])); - $this->assertTrue(isset($class->fieldMappings['version'])); + self::assertEquals(4, count($class->fieldMappings)); + self::assertTrue(isset($class->fieldMappings['id'])); + self::assertTrue(isset($class->fieldMappings['name'])); + self::assertTrue(isset($class->fieldMappings['email'])); + self::assertTrue(isset($class->fieldMappings['version'])); return $class; } @@ -254,10 +254,10 @@ public function testFieldMappings(ClassMetadata $class): ClassMetadata */ public function testVersionedField(ClassMetadata $class): void { - $this->assertTrue($class->isVersioned); - $this->assertEquals('version', $class->versionField); + self::assertTrue($class->isVersioned); + self::assertEquals('version', $class->versionField); - $this->assertFalse(isset($class->fieldMappings['version']['version'])); + self::assertFalse(isset($class->fieldMappings['version']['version'])); } /** @@ -265,9 +265,9 @@ public function testVersionedField(ClassMetadata $class): void */ public function testFieldMappingsColumnNames(ClassMetadata $class): ClassMetadata { - $this->assertEquals('id', $class->fieldMappings['id']['columnName']); - $this->assertEquals('name', $class->fieldMappings['name']['columnName']); - $this->assertEquals('user_email', $class->fieldMappings['email']['columnName']); + self::assertEquals('id', $class->fieldMappings['id']['columnName']); + self::assertEquals('name', $class->fieldMappings['name']['columnName']); + self::assertEquals('user_email', $class->fieldMappings['email']['columnName']); return $class; } @@ -277,10 +277,10 @@ public function testFieldMappingsColumnNames(ClassMetadata $class): ClassMetadat */ public function testStringFieldMappings(ClassMetadata $class): ClassMetadata { - $this->assertEquals('string', $class->fieldMappings['name']['type']); - $this->assertEquals(50, $class->fieldMappings['name']['length']); - $this->assertTrue($class->fieldMappings['name']['nullable']); - $this->assertTrue($class->fieldMappings['name']['unique']); + self::assertEquals('string', $class->fieldMappings['name']['type']); + self::assertEquals(50, $class->fieldMappings['name']['length']); + self::assertTrue($class->fieldMappings['name']['nullable']); + self::assertTrue($class->fieldMappings['name']['unique']); return $class; } @@ -288,23 +288,23 @@ public function testStringFieldMappings(ClassMetadata $class): ClassMetadata public function testFieldTypeFromReflection(): void { if (PHP_VERSION_ID < 70400) { - $this->markTestSkipped('requies PHP 7.4'); + self::markTestSkipped('requies PHP 7.4'); } $class = $this->createClassMetadata(UserTyped::class); - $this->assertEquals('integer', $class->getTypeOfField('id')); - $this->assertEquals('string', $class->getTypeOfField('username')); - $this->assertEquals('dateinterval', $class->getTypeOfField('dateInterval')); - $this->assertEquals('datetime', $class->getTypeOfField('dateTime')); - $this->assertEquals('datetime_immutable', $class->getTypeOfField('dateTimeImmutable')); - $this->assertEquals('json', $class->getTypeOfField('array')); - $this->assertEquals('boolean', $class->getTypeOfField('boolean')); - $this->assertEquals('float', $class->getTypeOfField('float')); + self::assertEquals('integer', $class->getTypeOfField('id')); + self::assertEquals('string', $class->getTypeOfField('username')); + self::assertEquals('dateinterval', $class->getTypeOfField('dateInterval')); + self::assertEquals('datetime', $class->getTypeOfField('dateTime')); + self::assertEquals('datetime_immutable', $class->getTypeOfField('dateTimeImmutable')); + self::assertEquals('json', $class->getTypeOfField('array')); + self::assertEquals('boolean', $class->getTypeOfField('boolean')); + self::assertEquals('float', $class->getTypeOfField('float')); - $this->assertEquals(CmsEmail::class, $class->getAssociationMapping('email')['targetEntity']); - $this->assertEquals(CmsEmail::class, $class->getAssociationMapping('mainEmail')['targetEntity']); - $this->assertEquals(Contact::class, $class->embeddedClasses['contact']['class']); + self::assertEquals(CmsEmail::class, $class->getAssociationMapping('email')['targetEntity']); + self::assertEquals(CmsEmail::class, $class->getAssociationMapping('mainEmail')['targetEntity']); + self::assertEquals(Contact::class, $class->embeddedClasses['contact']['class']); } /** @@ -313,7 +313,7 @@ public function testFieldTypeFromReflection(): void public function testFieldOptions(ClassMetadata $class): ClassMetadata { $expected = ['foo' => 'bar', 'baz' => ['key' => 'val'], 'fixed' => false]; - $this->assertEquals($expected, $class->fieldMappings['name']['options']); + self::assertEquals($expected, $class->fieldMappings['name']['options']); return $class; } @@ -323,7 +323,7 @@ public function testFieldOptions(ClassMetadata $class): ClassMetadata */ public function testIdFieldOptions(ClassMetadata $class): ClassMetadata { - $this->assertEquals(['foo' => 'bar', 'unsigned' => false], $class->fieldMappings['id']['options']); + self::assertEquals(['foo' => 'bar', 'unsigned' => false], $class->fieldMappings['id']['options']); return $class; } @@ -333,9 +333,9 @@ public function testIdFieldOptions(ClassMetadata $class): ClassMetadata */ public function testIdentifier(ClassMetadata $class): ClassMetadata { - $this->assertEquals(['id'], $class->identifier); - $this->assertEquals('integer', $class->fieldMappings['id']['type']); - $this->assertEquals(ClassMetadata::GENERATOR_TYPE_AUTO, $class->generatorType, 'ID-Generator is not ClassMetadata::GENERATOR_TYPE_AUTO'); + self::assertEquals(['id'], $class->identifier); + self::assertEquals('integer', $class->fieldMappings['id']['type']); + self::assertEquals(ClassMetadata::GENERATOR_TYPE_AUTO, $class->generatorType, 'ID-Generator is not ClassMetadata::GENERATOR_TYPE_AUTO'); return $class; } @@ -347,11 +347,11 @@ public function testBooleanValuesForOptionIsSetCorrectly(): ClassMetadata { $class = $this->createClassMetadata(User::class); - $this->assertIsBool($class->fieldMappings['id']['options']['unsigned']); - $this->assertFalse($class->fieldMappings['id']['options']['unsigned']); + self::assertIsBool($class->fieldMappings['id']['options']['unsigned']); + self::assertFalse($class->fieldMappings['id']['options']['unsigned']); - $this->assertIsBool($class->fieldMappings['name']['options']['fixed']); - $this->assertFalse($class->fieldMappings['name']['options']['fixed']); + self::assertIsBool($class->fieldMappings['name']['options']['fixed']); + self::assertFalse($class->fieldMappings['name']['options']['fixed']); return $class; } @@ -361,7 +361,7 @@ public function testBooleanValuesForOptionIsSetCorrectly(): ClassMetadata */ public function testAssociations(ClassMetadata $class): ClassMetadata { - $this->assertEquals(3, count($class->associationMappings)); + self::assertEquals(3, count($class->associationMappings)); return $class; } @@ -371,15 +371,15 @@ public function testAssociations(ClassMetadata $class): ClassMetadata */ public function testOwningOneToOneAssociation(ClassMetadata $class): ClassMetadata { - $this->assertTrue(isset($class->associationMappings['address'])); - $this->assertTrue($class->associationMappings['address']['isOwningSide']); - $this->assertEquals('user', $class->associationMappings['address']['inversedBy']); + self::assertTrue(isset($class->associationMappings['address'])); + self::assertTrue($class->associationMappings['address']['isOwningSide']); + self::assertEquals('user', $class->associationMappings['address']['inversedBy']); // Check cascading - $this->assertTrue($class->associationMappings['address']['isCascadeRemove']); - $this->assertFalse($class->associationMappings['address']['isCascadePersist']); - $this->assertFalse($class->associationMappings['address']['isCascadeRefresh']); - $this->assertFalse($class->associationMappings['address']['isCascadeDetach']); - $this->assertFalse($class->associationMappings['address']['isCascadeMerge']); + self::assertTrue($class->associationMappings['address']['isCascadeRemove']); + self::assertFalse($class->associationMappings['address']['isCascadePersist']); + self::assertFalse($class->associationMappings['address']['isCascadeRefresh']); + self::assertFalse($class->associationMappings['address']['isCascadeDetach']); + self::assertFalse($class->associationMappings['address']['isCascadeMerge']); return $class; } @@ -389,17 +389,17 @@ public function testOwningOneToOneAssociation(ClassMetadata $class): ClassMetada */ public function testInverseOneToManyAssociation(ClassMetadata $class): ClassMetadata { - $this->assertTrue(isset($class->associationMappings['phonenumbers'])); - $this->assertFalse($class->associationMappings['phonenumbers']['isOwningSide']); - $this->assertTrue($class->associationMappings['phonenumbers']['isCascadePersist']); - $this->assertTrue($class->associationMappings['phonenumbers']['isCascadeRemove']); - $this->assertFalse($class->associationMappings['phonenumbers']['isCascadeRefresh']); - $this->assertFalse($class->associationMappings['phonenumbers']['isCascadeDetach']); - $this->assertFalse($class->associationMappings['phonenumbers']['isCascadeMerge']); - $this->assertTrue($class->associationMappings['phonenumbers']['orphanRemoval']); + self::assertTrue(isset($class->associationMappings['phonenumbers'])); + self::assertFalse($class->associationMappings['phonenumbers']['isOwningSide']); + self::assertTrue($class->associationMappings['phonenumbers']['isCascadePersist']); + self::assertTrue($class->associationMappings['phonenumbers']['isCascadeRemove']); + self::assertFalse($class->associationMappings['phonenumbers']['isCascadeRefresh']); + self::assertFalse($class->associationMappings['phonenumbers']['isCascadeDetach']); + self::assertFalse($class->associationMappings['phonenumbers']['isCascadeMerge']); + self::assertTrue($class->associationMappings['phonenumbers']['orphanRemoval']); // Test Order By - $this->assertEquals(['number' => 'ASC'], $class->associationMappings['phonenumbers']['orderBy']); + self::assertEquals(['number' => 'ASC'], $class->associationMappings['phonenumbers']['orderBy']); return $class; } @@ -409,16 +409,16 @@ public function testInverseOneToManyAssociation(ClassMetadata $class): ClassMeta */ public function testManyToManyAssociationWithCascadeAll(ClassMetadata $class): ClassMetadata { - $this->assertTrue(isset($class->associationMappings['groups'])); - $this->assertTrue($class->associationMappings['groups']['isOwningSide']); + self::assertTrue(isset($class->associationMappings['groups'])); + self::assertTrue($class->associationMappings['groups']['isOwningSide']); // Make sure that cascade-all works as expected - $this->assertTrue($class->associationMappings['groups']['isCascadeRemove']); - $this->assertTrue($class->associationMappings['groups']['isCascadePersist']); - $this->assertTrue($class->associationMappings['groups']['isCascadeRefresh']); - $this->assertTrue($class->associationMappings['groups']['isCascadeDetach']); - $this->assertTrue($class->associationMappings['groups']['isCascadeMerge']); + self::assertTrue($class->associationMappings['groups']['isCascadeRemove']); + self::assertTrue($class->associationMappings['groups']['isCascadePersist']); + self::assertTrue($class->associationMappings['groups']['isCascadeRefresh']); + self::assertTrue($class->associationMappings['groups']['isCascadeDetach']); + self::assertTrue($class->associationMappings['groups']['isCascadeMerge']); - $this->assertFalse(isset($class->associationMappings['groups']['orderBy'])); + self::assertFalse(isset($class->associationMappings['groups']['orderBy'])); return $class; } @@ -428,9 +428,9 @@ public function testManyToManyAssociationWithCascadeAll(ClassMetadata $class): C */ public function testLifecycleCallbacks(ClassMetadata $class): ClassMetadata { - $this->assertEquals(count($class->lifecycleCallbacks), 2); - $this->assertEquals($class->lifecycleCallbacks['prePersist'][0], 'doStuffOnPrePersist'); - $this->assertEquals($class->lifecycleCallbacks['postPersist'][0], 'doStuffOnPostPersist'); + self::assertEquals(count($class->lifecycleCallbacks), 2); + self::assertEquals($class->lifecycleCallbacks['prePersist'][0], 'doStuffOnPrePersist'); + self::assertEquals($class->lifecycleCallbacks['postPersist'][0], 'doStuffOnPostPersist'); return $class; } @@ -440,8 +440,8 @@ public function testLifecycleCallbacks(ClassMetadata $class): ClassMetadata */ public function testLifecycleCallbacksSupportMultipleMethodNames(ClassMetadata $class): ClassMetadata { - $this->assertEquals(count($class->lifecycleCallbacks['prePersist']), 2); - $this->assertEquals($class->lifecycleCallbacks['prePersist'][1], 'doOtherStuffOnPrePersistToo'); + self::assertEquals(count($class->lifecycleCallbacks['prePersist']), 2); + self::assertEquals($class->lifecycleCallbacks['prePersist'][1], 'doOtherStuffOnPrePersistToo'); return $class; } @@ -452,8 +452,8 @@ public function testLifecycleCallbacksSupportMultipleMethodNames(ClassMetadata $ public function testJoinColumnUniqueAndNullable(ClassMetadata $class): ClassMetadata { // Non-Nullability of Join Column - $this->assertFalse($class->associationMappings['groups']['joinTable']['joinColumns'][0]['nullable']); - $this->assertFalse($class->associationMappings['groups']['joinTable']['joinColumns'][0]['unique']); + self::assertFalse($class->associationMappings['groups']['joinTable']['joinColumns'][0]['nullable']); + self::assertFalse($class->associationMappings['groups']['joinTable']['joinColumns'][0]['unique']); return $class; } @@ -463,8 +463,8 @@ public function testJoinColumnUniqueAndNullable(ClassMetadata $class): ClassMeta */ public function testColumnDefinition(ClassMetadata $class): ClassMetadata { - $this->assertEquals('CHAR(32) NOT NULL', $class->fieldMappings['email']['columnDefinition']); - $this->assertEquals('INT NULL', $class->associationMappings['groups']['joinTable']['inverseJoinColumns'][0]['columnDefinition']); + self::assertEquals('CHAR(32) NOT NULL', $class->fieldMappings['email']['columnDefinition']); + self::assertEquals('INT NULL', $class->associationMappings['groups']['joinTable']['inverseJoinColumns'][0]['columnDefinition']); return $class; } @@ -474,7 +474,7 @@ public function testColumnDefinition(ClassMetadata $class): ClassMetadata */ public function testJoinColumnOnDelete(ClassMetadata $class): ClassMetadata { - $this->assertEquals('CASCADE', $class->associationMappings['address']['joinColumns'][0]['onDelete']); + self::assertEquals('CASCADE', $class->associationMappings['address']['joinColumns'][0]['onDelete']); return $class; } @@ -485,12 +485,12 @@ public function testJoinColumnOnDelete(ClassMetadata $class): ClassMetadata public function testDiscriminatorColumnDefaults(): void { if (strpos(static::class, 'PHPMappingDriver') !== false) { - $this->markTestSkipped('PHP Mapping Drivers have no defaults.'); + self::markTestSkipped('PHP Mapping Drivers have no defaults.'); } $class = $this->createClassMetadata(Animal::class); - $this->assertEquals( + self::assertEquals( ['name' => 'discr', 'type' => 'string', 'length' => '32', 'fieldName' => 'discr', 'columnDefinition' => null], $class->discriminatorColumn ); @@ -506,21 +506,21 @@ public function testMappedSuperclassWithRepository(): void $class = $factory->getMetadataFor(DDC869CreditCardPayment::class); - $this->assertTrue(isset($class->fieldMappings['id'])); - $this->assertTrue(isset($class->fieldMappings['value'])); - $this->assertTrue(isset($class->fieldMappings['creditCardNumber'])); - $this->assertEquals($class->customRepositoryClassName, DDC869PaymentRepository::class); - $this->assertInstanceOf(DDC869PaymentRepository::class, $em->getRepository(DDC869CreditCardPayment::class)); - $this->assertTrue($em->getRepository(DDC869ChequePayment::class)->isTrue()); + self::assertTrue(isset($class->fieldMappings['id'])); + self::assertTrue(isset($class->fieldMappings['value'])); + self::assertTrue(isset($class->fieldMappings['creditCardNumber'])); + self::assertEquals($class->customRepositoryClassName, DDC869PaymentRepository::class); + self::assertInstanceOf(DDC869PaymentRepository::class, $em->getRepository(DDC869CreditCardPayment::class)); + self::assertTrue($em->getRepository(DDC869ChequePayment::class)->isTrue()); $class = $factory->getMetadataFor(DDC869ChequePayment::class); - $this->assertTrue(isset($class->fieldMappings['id'])); - $this->assertTrue(isset($class->fieldMappings['value'])); - $this->assertTrue(isset($class->fieldMappings['serialNumber'])); - $this->assertEquals($class->customRepositoryClassName, DDC869PaymentRepository::class); - $this->assertInstanceOf(DDC869PaymentRepository::class, $em->getRepository(DDC869ChequePayment::class)); - $this->assertTrue($em->getRepository(DDC869ChequePayment::class)->isTrue()); + self::assertTrue(isset($class->fieldMappings['id'])); + self::assertTrue(isset($class->fieldMappings['value'])); + self::assertTrue(isset($class->fieldMappings['serialNumber'])); + self::assertEquals($class->customRepositoryClassName, DDC869PaymentRepository::class); + self::assertInstanceOf(DDC869PaymentRepository::class, $em->getRepository(DDC869ChequePayment::class)); + self::assertTrue($em->getRepository(DDC869ChequePayment::class)->isTrue()); } /** @@ -531,28 +531,28 @@ public function testDefaultFieldType(): void $factory = $this->createClassMetadataFactory(); $class = $factory->getMetadataFor(DDC1476EntityWithDefaultFieldType::class); - $this->assertArrayHasKey('id', $class->fieldMappings); - $this->assertArrayHasKey('name', $class->fieldMappings); + self::assertArrayHasKey('id', $class->fieldMappings); + self::assertArrayHasKey('name', $class->fieldMappings); - $this->assertArrayHasKey('type', $class->fieldMappings['id']); - $this->assertArrayHasKey('type', $class->fieldMappings['name']); + self::assertArrayHasKey('type', $class->fieldMappings['id']); + self::assertArrayHasKey('type', $class->fieldMappings['name']); - $this->assertEquals('string', $class->fieldMappings['id']['type']); - $this->assertEquals('string', $class->fieldMappings['name']['type']); + self::assertEquals('string', $class->fieldMappings['id']['type']); + self::assertEquals('string', $class->fieldMappings['name']['type']); - $this->assertArrayHasKey('fieldName', $class->fieldMappings['id']); - $this->assertArrayHasKey('fieldName', $class->fieldMappings['name']); + self::assertArrayHasKey('fieldName', $class->fieldMappings['id']); + self::assertArrayHasKey('fieldName', $class->fieldMappings['name']); - $this->assertEquals('id', $class->fieldMappings['id']['fieldName']); - $this->assertEquals('name', $class->fieldMappings['name']['fieldName']); + self::assertEquals('id', $class->fieldMappings['id']['fieldName']); + self::assertEquals('name', $class->fieldMappings['name']['fieldName']); - $this->assertArrayHasKey('columnName', $class->fieldMappings['id']); - $this->assertArrayHasKey('columnName', $class->fieldMappings['name']); + self::assertArrayHasKey('columnName', $class->fieldMappings['id']); + self::assertArrayHasKey('columnName', $class->fieldMappings['name']); - $this->assertEquals('id', $class->fieldMappings['id']['columnName']); - $this->assertEquals('name', $class->fieldMappings['name']['columnName']); + self::assertEquals('id', $class->fieldMappings['id']['columnName']); + self::assertEquals('name', $class->fieldMappings['name']['columnName']); - $this->assertEquals(ClassMetadataInfo::GENERATOR_TYPE_NONE, $class->generatorType); + self::assertEquals(ClassMetadataInfo::GENERATOR_TYPE_NONE, $class->generatorType); } /** @@ -562,14 +562,14 @@ public function testIdentifierColumnDefinition(): void { $class = $this->createClassMetadata(DDC1170Entity::class); - $this->assertArrayHasKey('id', $class->fieldMappings); - $this->assertArrayHasKey('value', $class->fieldMappings); + self::assertArrayHasKey('id', $class->fieldMappings); + self::assertArrayHasKey('value', $class->fieldMappings); - $this->assertArrayHasKey('columnDefinition', $class->fieldMappings['id']); - $this->assertArrayHasKey('columnDefinition', $class->fieldMappings['value']); + self::assertArrayHasKey('columnDefinition', $class->fieldMappings['id']); + self::assertArrayHasKey('columnDefinition', $class->fieldMappings['value']); - $this->assertEquals('int unsigned not null', strtolower($class->fieldMappings['id']['columnDefinition'])); - $this->assertEquals('varchar(255) not null', strtolower($class->fieldMappings['value']['columnDefinition'])); + self::assertEquals('int unsigned not null', strtolower($class->fieldMappings['id']['columnDefinition'])); + self::assertEquals('varchar(255) not null', strtolower($class->fieldMappings['value']['columnDefinition'])); } /** @@ -580,15 +580,15 @@ public function testNamingStrategy(): void $em = $this->getTestEntityManager(); $factory = $this->createClassMetadataFactory($em); - $this->assertInstanceOf(DefaultNamingStrategy::class, $em->getConfiguration()->getNamingStrategy()); + self::assertInstanceOf(DefaultNamingStrategy::class, $em->getConfiguration()->getNamingStrategy()); $em->getConfiguration()->setNamingStrategy(new UnderscoreNamingStrategy(CASE_UPPER)); - $this->assertInstanceOf(UnderscoreNamingStrategy::class, $em->getConfiguration()->getNamingStrategy()); + self::assertInstanceOf(UnderscoreNamingStrategy::class, $em->getConfiguration()->getNamingStrategy()); $class = $factory->getMetadataFor(DDC1476EntityWithDefaultFieldType::class); - $this->assertEquals('ID', $class->getColumnName('id')); - $this->assertEquals('NAME', $class->getColumnName('name')); - $this->assertEquals('DDC1476ENTITY_WITH_DEFAULT_FIELD_TYPE', $class->table['name']); + self::assertEquals('ID', $class->getColumnName('id')); + self::assertEquals('NAME', $class->getColumnName('name')); + self::assertEquals('DDC1476ENTITY_WITH_DEFAULT_FIELD_TYPE', $class->table['name']); } /** @@ -599,11 +599,11 @@ public function testDiscriminatorColumnDefinition(): void { $class = $this->createClassMetadata(DDC807Entity::class); - $this->assertArrayHasKey('columnDefinition', $class->discriminatorColumn); - $this->assertArrayHasKey('name', $class->discriminatorColumn); + self::assertArrayHasKey('columnDefinition', $class->discriminatorColumn); + self::assertArrayHasKey('name', $class->discriminatorColumn); - $this->assertEquals("ENUM('ONE','TWO')", $class->discriminatorColumn['columnDefinition']); - $this->assertEquals('dtype', $class->discriminatorColumn['name']); + self::assertEquals("ENUM('ONE','TWO')", $class->discriminatorColumn['columnDefinition']); + self::assertEquals('dtype', $class->discriminatorColumn['name']); } /** @@ -635,7 +635,7 @@ public function testNamedQuery(): void $driver = $this->loadDriver(); $class = $this->createClassMetadata(User::class); - $this->assertCount(1, $class->getNamedQueries(), sprintf('Named queries not processed correctly by driver %s', get_class($driver))); + self::assertCount(1, $class->getNamedQueries(), sprintf('Named queries not processed correctly by driver %s', get_class($driver))); } /** @@ -646,46 +646,46 @@ public function testNamedNativeQuery(): void $class = $this->createClassMetadata(CmsAddress::class); //named native query - $this->assertCount(3, $class->namedNativeQueries); - $this->assertArrayHasKey('find-all', $class->namedNativeQueries); - $this->assertArrayHasKey('find-by-id', $class->namedNativeQueries); + self::assertCount(3, $class->namedNativeQueries); + self::assertArrayHasKey('find-all', $class->namedNativeQueries); + self::assertArrayHasKey('find-by-id', $class->namedNativeQueries); $findAllQuery = $class->getNamedNativeQuery('find-all'); - $this->assertEquals('find-all', $findAllQuery['name']); - $this->assertEquals('mapping-find-all', $findAllQuery['resultSetMapping']); - $this->assertEquals('SELECT id, country, city FROM cms_addresses', $findAllQuery['query']); + self::assertEquals('find-all', $findAllQuery['name']); + self::assertEquals('mapping-find-all', $findAllQuery['resultSetMapping']); + self::assertEquals('SELECT id, country, city FROM cms_addresses', $findAllQuery['query']); $findByIdQuery = $class->getNamedNativeQuery('find-by-id'); - $this->assertEquals('find-by-id', $findByIdQuery['name']); - $this->assertEquals(CmsAddress::class, $findByIdQuery['resultClass']); - $this->assertEquals('SELECT * FROM cms_addresses WHERE id = ?', $findByIdQuery['query']); + self::assertEquals('find-by-id', $findByIdQuery['name']); + self::assertEquals(CmsAddress::class, $findByIdQuery['resultClass']); + self::assertEquals('SELECT * FROM cms_addresses WHERE id = ?', $findByIdQuery['query']); $countQuery = $class->getNamedNativeQuery('count'); - $this->assertEquals('count', $countQuery['name']); - $this->assertEquals('mapping-count', $countQuery['resultSetMapping']); - $this->assertEquals('SELECT COUNT(*) AS count FROM cms_addresses', $countQuery['query']); + self::assertEquals('count', $countQuery['name']); + self::assertEquals('mapping-count', $countQuery['resultSetMapping']); + self::assertEquals('SELECT COUNT(*) AS count FROM cms_addresses', $countQuery['query']); // result set mapping - $this->assertCount(3, $class->sqlResultSetMappings); - $this->assertArrayHasKey('mapping-count', $class->sqlResultSetMappings); - $this->assertArrayHasKey('mapping-find-all', $class->sqlResultSetMappings); - $this->assertArrayHasKey('mapping-without-fields', $class->sqlResultSetMappings); + self::assertCount(3, $class->sqlResultSetMappings); + self::assertArrayHasKey('mapping-count', $class->sqlResultSetMappings); + self::assertArrayHasKey('mapping-find-all', $class->sqlResultSetMappings); + self::assertArrayHasKey('mapping-without-fields', $class->sqlResultSetMappings); $findAllMapping = $class->getSqlResultSetMapping('mapping-find-all'); - $this->assertEquals('mapping-find-all', $findAllMapping['name']); - $this->assertEquals(CmsAddress::class, $findAllMapping['entities'][0]['entityClass']); - $this->assertEquals(['name' => 'id', 'column' => 'id'], $findAllMapping['entities'][0]['fields'][0]); - $this->assertEquals(['name' => 'city', 'column' => 'city'], $findAllMapping['entities'][0]['fields'][1]); - $this->assertEquals(['name' => 'country', 'column' => 'country'], $findAllMapping['entities'][0]['fields'][2]); + self::assertEquals('mapping-find-all', $findAllMapping['name']); + self::assertEquals(CmsAddress::class, $findAllMapping['entities'][0]['entityClass']); + self::assertEquals(['name' => 'id', 'column' => 'id'], $findAllMapping['entities'][0]['fields'][0]); + self::assertEquals(['name' => 'city', 'column' => 'city'], $findAllMapping['entities'][0]['fields'][1]); + self::assertEquals(['name' => 'country', 'column' => 'country'], $findAllMapping['entities'][0]['fields'][2]); $withoutFieldsMapping = $class->getSqlResultSetMapping('mapping-without-fields'); - $this->assertEquals('mapping-without-fields', $withoutFieldsMapping['name']); - $this->assertEquals(CmsAddress::class, $withoutFieldsMapping['entities'][0]['entityClass']); - $this->assertEquals([], $withoutFieldsMapping['entities'][0]['fields']); + self::assertEquals('mapping-without-fields', $withoutFieldsMapping['name']); + self::assertEquals(CmsAddress::class, $withoutFieldsMapping['entities'][0]['entityClass']); + self::assertEquals([], $withoutFieldsMapping['entities'][0]['fields']); $countMapping = $class->getSqlResultSetMapping('mapping-count'); - $this->assertEquals('mapping-count', $countMapping['name']); - $this->assertEquals(['name' => 'count'], $countMapping['columns'][0]); + self::assertEquals('mapping-count', $countMapping['name']); + self::assertEquals(['name' => 'count'], $countMapping['columns'][0]); } /** @@ -697,64 +697,64 @@ public function testSqlResultSetMapping(): void $personMetadata = $this->createClassMetadata(CompanyPerson::class); // user asserts - $this->assertCount(4, $userMetadata->getSqlResultSetMappings()); + self::assertCount(4, $userMetadata->getSqlResultSetMappings()); $mapping = $userMetadata->getSqlResultSetMapping('mappingJoinedAddress'); - $this->assertEquals([], $mapping['columns']); - $this->assertEquals('mappingJoinedAddress', $mapping['name']); - $this->assertNull($mapping['entities'][0]['discriminatorColumn']); - $this->assertEquals(['name' => 'id', 'column' => 'id'], $mapping['entities'][0]['fields'][0]); - $this->assertEquals(['name' => 'name', 'column' => 'name'], $mapping['entities'][0]['fields'][1]); - $this->assertEquals(['name' => 'status', 'column' => 'status'], $mapping['entities'][0]['fields'][2]); - $this->assertEquals(['name' => 'address.zip', 'column' => 'zip'], $mapping['entities'][0]['fields'][3]); - $this->assertEquals(['name' => 'address.city', 'column' => 'city'], $mapping['entities'][0]['fields'][4]); - $this->assertEquals(['name' => 'address.country', 'column' => 'country'], $mapping['entities'][0]['fields'][5]); - $this->assertEquals(['name' => 'address.id', 'column' => 'a_id'], $mapping['entities'][0]['fields'][6]); - $this->assertEquals($userMetadata->name, $mapping['entities'][0]['entityClass']); + self::assertEquals([], $mapping['columns']); + self::assertEquals('mappingJoinedAddress', $mapping['name']); + self::assertNull($mapping['entities'][0]['discriminatorColumn']); + self::assertEquals(['name' => 'id', 'column' => 'id'], $mapping['entities'][0]['fields'][0]); + self::assertEquals(['name' => 'name', 'column' => 'name'], $mapping['entities'][0]['fields'][1]); + self::assertEquals(['name' => 'status', 'column' => 'status'], $mapping['entities'][0]['fields'][2]); + self::assertEquals(['name' => 'address.zip', 'column' => 'zip'], $mapping['entities'][0]['fields'][3]); + self::assertEquals(['name' => 'address.city', 'column' => 'city'], $mapping['entities'][0]['fields'][4]); + self::assertEquals(['name' => 'address.country', 'column' => 'country'], $mapping['entities'][0]['fields'][5]); + self::assertEquals(['name' => 'address.id', 'column' => 'a_id'], $mapping['entities'][0]['fields'][6]); + self::assertEquals($userMetadata->name, $mapping['entities'][0]['entityClass']); $mapping = $userMetadata->getSqlResultSetMapping('mappingJoinedPhonenumber'); - $this->assertEquals([], $mapping['columns']); - $this->assertEquals('mappingJoinedPhonenumber', $mapping['name']); - $this->assertNull($mapping['entities'][0]['discriminatorColumn']); - $this->assertEquals(['name' => 'id', 'column' => 'id'], $mapping['entities'][0]['fields'][0]); - $this->assertEquals(['name' => 'name', 'column' => 'name'], $mapping['entities'][0]['fields'][1]); - $this->assertEquals(['name' => 'status', 'column' => 'status'], $mapping['entities'][0]['fields'][2]); - $this->assertEquals(['name' => 'phonenumbers.phonenumber', 'column' => 'number'], $mapping['entities'][0]['fields'][3]); - $this->assertEquals($userMetadata->name, $mapping['entities'][0]['entityClass']); + self::assertEquals([], $mapping['columns']); + self::assertEquals('mappingJoinedPhonenumber', $mapping['name']); + self::assertNull($mapping['entities'][0]['discriminatorColumn']); + self::assertEquals(['name' => 'id', 'column' => 'id'], $mapping['entities'][0]['fields'][0]); + self::assertEquals(['name' => 'name', 'column' => 'name'], $mapping['entities'][0]['fields'][1]); + self::assertEquals(['name' => 'status', 'column' => 'status'], $mapping['entities'][0]['fields'][2]); + self::assertEquals(['name' => 'phonenumbers.phonenumber', 'column' => 'number'], $mapping['entities'][0]['fields'][3]); + self::assertEquals($userMetadata->name, $mapping['entities'][0]['entityClass']); $mapping = $userMetadata->getSqlResultSetMapping('mappingUserPhonenumberCount'); - $this->assertEquals(['name' => 'numphones'], $mapping['columns'][0]); - $this->assertEquals('mappingUserPhonenumberCount', $mapping['name']); - $this->assertNull($mapping['entities'][0]['discriminatorColumn']); - $this->assertEquals(['name' => 'id', 'column' => 'id'], $mapping['entities'][0]['fields'][0]); - $this->assertEquals(['name' => 'name', 'column' => 'name'], $mapping['entities'][0]['fields'][1]); - $this->assertEquals(['name' => 'status', 'column' => 'status'], $mapping['entities'][0]['fields'][2]); - $this->assertEquals($userMetadata->name, $mapping['entities'][0]['entityClass']); + self::assertEquals(['name' => 'numphones'], $mapping['columns'][0]); + self::assertEquals('mappingUserPhonenumberCount', $mapping['name']); + self::assertNull($mapping['entities'][0]['discriminatorColumn']); + self::assertEquals(['name' => 'id', 'column' => 'id'], $mapping['entities'][0]['fields'][0]); + self::assertEquals(['name' => 'name', 'column' => 'name'], $mapping['entities'][0]['fields'][1]); + self::assertEquals(['name' => 'status', 'column' => 'status'], $mapping['entities'][0]['fields'][2]); + self::assertEquals($userMetadata->name, $mapping['entities'][0]['entityClass']); $mapping = $userMetadata->getSqlResultSetMapping('mappingMultipleJoinsEntityResults'); - $this->assertEquals(['name' => 'numphones'], $mapping['columns'][0]); - $this->assertEquals('mappingMultipleJoinsEntityResults', $mapping['name']); - $this->assertNull($mapping['entities'][0]['discriminatorColumn']); - $this->assertEquals(['name' => 'id', 'column' => 'u_id'], $mapping['entities'][0]['fields'][0]); - $this->assertEquals(['name' => 'name', 'column' => 'u_name'], $mapping['entities'][0]['fields'][1]); - $this->assertEquals(['name' => 'status', 'column' => 'u_status'], $mapping['entities'][0]['fields'][2]); - $this->assertEquals($userMetadata->name, $mapping['entities'][0]['entityClass']); - $this->assertNull($mapping['entities'][1]['discriminatorColumn']); - $this->assertEquals(['name' => 'id', 'column' => 'a_id'], $mapping['entities'][1]['fields'][0]); - $this->assertEquals(['name' => 'zip', 'column' => 'a_zip'], $mapping['entities'][1]['fields'][1]); - $this->assertEquals(['name' => 'country', 'column' => 'a_country'], $mapping['entities'][1]['fields'][2]); - $this->assertEquals(CmsAddress::class, $mapping['entities'][1]['entityClass']); + self::assertEquals(['name' => 'numphones'], $mapping['columns'][0]); + self::assertEquals('mappingMultipleJoinsEntityResults', $mapping['name']); + self::assertNull($mapping['entities'][0]['discriminatorColumn']); + self::assertEquals(['name' => 'id', 'column' => 'u_id'], $mapping['entities'][0]['fields'][0]); + self::assertEquals(['name' => 'name', 'column' => 'u_name'], $mapping['entities'][0]['fields'][1]); + self::assertEquals(['name' => 'status', 'column' => 'u_status'], $mapping['entities'][0]['fields'][2]); + self::assertEquals($userMetadata->name, $mapping['entities'][0]['entityClass']); + self::assertNull($mapping['entities'][1]['discriminatorColumn']); + self::assertEquals(['name' => 'id', 'column' => 'a_id'], $mapping['entities'][1]['fields'][0]); + self::assertEquals(['name' => 'zip', 'column' => 'a_zip'], $mapping['entities'][1]['fields'][1]); + self::assertEquals(['name' => 'country', 'column' => 'a_country'], $mapping['entities'][1]['fields'][2]); + self::assertEquals(CmsAddress::class, $mapping['entities'][1]['entityClass']); //person asserts - $this->assertCount(1, $personMetadata->getSqlResultSetMappings()); + self::assertCount(1, $personMetadata->getSqlResultSetMappings()); $mapping = $personMetadata->getSqlResultSetMapping('mappingFetchAll'); - $this->assertEquals([], $mapping['columns']); - $this->assertEquals('mappingFetchAll', $mapping['name']); - $this->assertEquals('discriminator', $mapping['entities'][0]['discriminatorColumn']); - $this->assertEquals(['name' => 'id', 'column' => 'id'], $mapping['entities'][0]['fields'][0]); - $this->assertEquals(['name' => 'name', 'column' => 'name'], $mapping['entities'][0]['fields'][1]); - $this->assertEquals($personMetadata->name, $mapping['entities'][0]['entityClass']); + self::assertEquals([], $mapping['columns']); + self::assertEquals('mappingFetchAll', $mapping['name']); + self::assertEquals('discriminator', $mapping['entities'][0]['discriminatorColumn']); + self::assertEquals(['name' => 'id', 'column' => 'id'], $mapping['entities'][0]['fields'][0]); + self::assertEquals(['name' => 'name', 'column' => 'name'], $mapping['entities'][0]['fields'][1]); + self::assertEquals($personMetadata->name, $mapping['entities'][0]['entityClass']); } /** @@ -767,72 +767,72 @@ public function testAssociationOverridesMapping(): void $guestMetadata = $factory->getMetadataFor(DDC964Guest::class); // assert groups association mappings - $this->assertArrayHasKey('groups', $guestMetadata->associationMappings); - $this->assertArrayHasKey('groups', $adminMetadata->associationMappings); + self::assertArrayHasKey('groups', $guestMetadata->associationMappings); + self::assertArrayHasKey('groups', $adminMetadata->associationMappings); $guestGroups = $guestMetadata->associationMappings['groups']; $adminGroups = $adminMetadata->associationMappings['groups']; // assert not override attributes - $this->assertEquals($guestGroups['fieldName'], $adminGroups['fieldName']); - $this->assertEquals($guestGroups['type'], $adminGroups['type']); - $this->assertEquals($guestGroups['mappedBy'], $adminGroups['mappedBy']); - $this->assertEquals($guestGroups['inversedBy'], $adminGroups['inversedBy']); - $this->assertEquals($guestGroups['isOwningSide'], $adminGroups['isOwningSide']); - $this->assertEquals($guestGroups['fetch'], $adminGroups['fetch']); - $this->assertEquals($guestGroups['isCascadeRemove'], $adminGroups['isCascadeRemove']); - $this->assertEquals($guestGroups['isCascadePersist'], $adminGroups['isCascadePersist']); - $this->assertEquals($guestGroups['isCascadeRefresh'], $adminGroups['isCascadeRefresh']); - $this->assertEquals($guestGroups['isCascadeMerge'], $adminGroups['isCascadeMerge']); - $this->assertEquals($guestGroups['isCascadeDetach'], $adminGroups['isCascadeDetach']); + self::assertEquals($guestGroups['fieldName'], $adminGroups['fieldName']); + self::assertEquals($guestGroups['type'], $adminGroups['type']); + self::assertEquals($guestGroups['mappedBy'], $adminGroups['mappedBy']); + self::assertEquals($guestGroups['inversedBy'], $adminGroups['inversedBy']); + self::assertEquals($guestGroups['isOwningSide'], $adminGroups['isOwningSide']); + self::assertEquals($guestGroups['fetch'], $adminGroups['fetch']); + self::assertEquals($guestGroups['isCascadeRemove'], $adminGroups['isCascadeRemove']); + self::assertEquals($guestGroups['isCascadePersist'], $adminGroups['isCascadePersist']); + self::assertEquals($guestGroups['isCascadeRefresh'], $adminGroups['isCascadeRefresh']); + self::assertEquals($guestGroups['isCascadeMerge'], $adminGroups['isCascadeMerge']); + self::assertEquals($guestGroups['isCascadeDetach'], $adminGroups['isCascadeDetach']); // assert not override attributes - $this->assertEquals('ddc964_users_groups', $guestGroups['joinTable']['name']); - $this->assertEquals('user_id', $guestGroups['joinTable']['joinColumns'][0]['name']); - $this->assertEquals('group_id', $guestGroups['joinTable']['inverseJoinColumns'][0]['name']); + self::assertEquals('ddc964_users_groups', $guestGroups['joinTable']['name']); + self::assertEquals('user_id', $guestGroups['joinTable']['joinColumns'][0]['name']); + self::assertEquals('group_id', $guestGroups['joinTable']['inverseJoinColumns'][0]['name']); - $this->assertEquals(['user_id' => 'id'], $guestGroups['relationToSourceKeyColumns']); - $this->assertEquals(['group_id' => 'id'], $guestGroups['relationToTargetKeyColumns']); - $this->assertEquals(['user_id', 'group_id'], $guestGroups['joinTableColumns']); + self::assertEquals(['user_id' => 'id'], $guestGroups['relationToSourceKeyColumns']); + self::assertEquals(['group_id' => 'id'], $guestGroups['relationToTargetKeyColumns']); + self::assertEquals(['user_id', 'group_id'], $guestGroups['joinTableColumns']); - $this->assertEquals('ddc964_users_admingroups', $adminGroups['joinTable']['name']); - $this->assertEquals('adminuser_id', $adminGroups['joinTable']['joinColumns'][0]['name']); - $this->assertEquals('admingroup_id', $adminGroups['joinTable']['inverseJoinColumns'][0]['name']); + self::assertEquals('ddc964_users_admingroups', $adminGroups['joinTable']['name']); + self::assertEquals('adminuser_id', $adminGroups['joinTable']['joinColumns'][0]['name']); + self::assertEquals('admingroup_id', $adminGroups['joinTable']['inverseJoinColumns'][0]['name']); - $this->assertEquals(['adminuser_id' => 'id'], $adminGroups['relationToSourceKeyColumns']); - $this->assertEquals(['admingroup_id' => 'id'], $adminGroups['relationToTargetKeyColumns']); - $this->assertEquals(['adminuser_id', 'admingroup_id'], $adminGroups['joinTableColumns']); + self::assertEquals(['adminuser_id' => 'id'], $adminGroups['relationToSourceKeyColumns']); + self::assertEquals(['admingroup_id' => 'id'], $adminGroups['relationToTargetKeyColumns']); + self::assertEquals(['adminuser_id', 'admingroup_id'], $adminGroups['joinTableColumns']); // assert address association mappings - $this->assertArrayHasKey('address', $guestMetadata->associationMappings); - $this->assertArrayHasKey('address', $adminMetadata->associationMappings); + self::assertArrayHasKey('address', $guestMetadata->associationMappings); + self::assertArrayHasKey('address', $adminMetadata->associationMappings); $guestAddress = $guestMetadata->associationMappings['address']; $adminAddress = $adminMetadata->associationMappings['address']; // assert not override attributes - $this->assertEquals($guestAddress['fieldName'], $adminAddress['fieldName']); - $this->assertEquals($guestAddress['type'], $adminAddress['type']); - $this->assertEquals($guestAddress['mappedBy'], $adminAddress['mappedBy']); - $this->assertEquals($guestAddress['inversedBy'], $adminAddress['inversedBy']); - $this->assertEquals($guestAddress['isOwningSide'], $adminAddress['isOwningSide']); - $this->assertEquals($guestAddress['fetch'], $adminAddress['fetch']); - $this->assertEquals($guestAddress['isCascadeRemove'], $adminAddress['isCascadeRemove']); - $this->assertEquals($guestAddress['isCascadePersist'], $adminAddress['isCascadePersist']); - $this->assertEquals($guestAddress['isCascadeRefresh'], $adminAddress['isCascadeRefresh']); - $this->assertEquals($guestAddress['isCascadeMerge'], $adminAddress['isCascadeMerge']); - $this->assertEquals($guestAddress['isCascadeDetach'], $adminAddress['isCascadeDetach']); + self::assertEquals($guestAddress['fieldName'], $adminAddress['fieldName']); + self::assertEquals($guestAddress['type'], $adminAddress['type']); + self::assertEquals($guestAddress['mappedBy'], $adminAddress['mappedBy']); + self::assertEquals($guestAddress['inversedBy'], $adminAddress['inversedBy']); + self::assertEquals($guestAddress['isOwningSide'], $adminAddress['isOwningSide']); + self::assertEquals($guestAddress['fetch'], $adminAddress['fetch']); + self::assertEquals($guestAddress['isCascadeRemove'], $adminAddress['isCascadeRemove']); + self::assertEquals($guestAddress['isCascadePersist'], $adminAddress['isCascadePersist']); + self::assertEquals($guestAddress['isCascadeRefresh'], $adminAddress['isCascadeRefresh']); + self::assertEquals($guestAddress['isCascadeMerge'], $adminAddress['isCascadeMerge']); + self::assertEquals($guestAddress['isCascadeDetach'], $adminAddress['isCascadeDetach']); // assert override - $this->assertEquals('address_id', $guestAddress['joinColumns'][0]['name']); - $this->assertEquals(['address_id' => 'id'], $guestAddress['sourceToTargetKeyColumns']); - $this->assertEquals(['address_id' => 'address_id'], $guestAddress['joinColumnFieldNames']); - $this->assertEquals(['id' => 'address_id'], $guestAddress['targetToSourceKeyColumns']); + self::assertEquals('address_id', $guestAddress['joinColumns'][0]['name']); + self::assertEquals(['address_id' => 'id'], $guestAddress['sourceToTargetKeyColumns']); + self::assertEquals(['address_id' => 'address_id'], $guestAddress['joinColumnFieldNames']); + self::assertEquals(['id' => 'address_id'], $guestAddress['targetToSourceKeyColumns']); - $this->assertEquals('adminaddress_id', $adminAddress['joinColumns'][0]['name']); - $this->assertEquals(['adminaddress_id' => 'id'], $adminAddress['sourceToTargetKeyColumns']); - $this->assertEquals(['adminaddress_id' => 'adminaddress_id'], $adminAddress['joinColumnFieldNames']); - $this->assertEquals(['id' => 'adminaddress_id'], $adminAddress['targetToSourceKeyColumns']); + self::assertEquals('adminaddress_id', $adminAddress['joinColumns'][0]['name']); + self::assertEquals(['adminaddress_id' => 'id'], $adminAddress['sourceToTargetKeyColumns']); + self::assertEquals(['adminaddress_id' => 'adminaddress_id'], $adminAddress['joinColumnFieldNames']); + self::assertEquals(['id' => 'adminaddress_id'], $adminAddress['targetToSourceKeyColumns']); } /** @@ -844,11 +844,11 @@ public function testInversedByOverrideMapping(): void $adminMetadata = $factory->getMetadataFor(DDC3579Admin::class); // assert groups association mappings - $this->assertArrayHasKey('groups', $adminMetadata->associationMappings); + self::assertArrayHasKey('groups', $adminMetadata->associationMappings); $adminGroups = $adminMetadata->associationMappings['groups']; // assert override - $this->assertEquals('admins', $adminGroups['inversedBy']); + self::assertEquals('admins', $adminGroups['inversedBy']); } /** @@ -859,8 +859,8 @@ public function testFetchOverrideMapping(): void // check override metadata $contractMetadata = $this->createClassMetadataFactory()->getMetadataFor(DDC5934Contract::class); - $this->assertArrayHasKey('members', $contractMetadata->associationMappings); - $this->assertSame(ClassMetadata::FETCH_EXTRA_LAZY, $contractMetadata->associationMappings['members']['fetch']); + self::assertArrayHasKey('members', $contractMetadata->associationMappings); + self::assertSame(ClassMetadata::FETCH_EXTRA_LAZY, $contractMetadata->associationMappings['members']['fetch']); } /** @@ -872,31 +872,31 @@ public function testAttributeOverridesMapping(): void $guestMetadata = $factory->getMetadataFor(DDC964Guest::class); $adminMetadata = $factory->getMetadataFor(DDC964Admin::class); - $this->assertTrue($adminMetadata->fieldMappings['id']['id']); - $this->assertEquals('id', $adminMetadata->fieldMappings['id']['fieldName']); - $this->assertEquals('user_id', $adminMetadata->fieldMappings['id']['columnName']); - $this->assertEquals(['user_id' => 'id', 'user_name' => 'name'], $adminMetadata->fieldNames); - $this->assertEquals(['id' => 'user_id', 'name' => 'user_name'], $adminMetadata->columnNames); - $this->assertEquals(150, $adminMetadata->fieldMappings['id']['length']); + self::assertTrue($adminMetadata->fieldMappings['id']['id']); + self::assertEquals('id', $adminMetadata->fieldMappings['id']['fieldName']); + self::assertEquals('user_id', $adminMetadata->fieldMappings['id']['columnName']); + self::assertEquals(['user_id' => 'id', 'user_name' => 'name'], $adminMetadata->fieldNames); + self::assertEquals(['id' => 'user_id', 'name' => 'user_name'], $adminMetadata->columnNames); + self::assertEquals(150, $adminMetadata->fieldMappings['id']['length']); - $this->assertEquals('name', $adminMetadata->fieldMappings['name']['fieldName']); - $this->assertEquals('user_name', $adminMetadata->fieldMappings['name']['columnName']); - $this->assertEquals(250, $adminMetadata->fieldMappings['name']['length']); - $this->assertTrue($adminMetadata->fieldMappings['name']['nullable']); - $this->assertFalse($adminMetadata->fieldMappings['name']['unique']); + self::assertEquals('name', $adminMetadata->fieldMappings['name']['fieldName']); + self::assertEquals('user_name', $adminMetadata->fieldMappings['name']['columnName']); + self::assertEquals(250, $adminMetadata->fieldMappings['name']['length']); + self::assertTrue($adminMetadata->fieldMappings['name']['nullable']); + self::assertFalse($adminMetadata->fieldMappings['name']['unique']); - $this->assertTrue($guestMetadata->fieldMappings['id']['id']); - $this->assertEquals('guest_id', $guestMetadata->fieldMappings['id']['columnName']); - $this->assertEquals('id', $guestMetadata->fieldMappings['id']['fieldName']); - $this->assertEquals(['guest_id' => 'id', 'guest_name' => 'name'], $guestMetadata->fieldNames); - $this->assertEquals(['id' => 'guest_id', 'name' => 'guest_name'], $guestMetadata->columnNames); - $this->assertEquals(140, $guestMetadata->fieldMappings['id']['length']); + self::assertTrue($guestMetadata->fieldMappings['id']['id']); + self::assertEquals('guest_id', $guestMetadata->fieldMappings['id']['columnName']); + self::assertEquals('id', $guestMetadata->fieldMappings['id']['fieldName']); + self::assertEquals(['guest_id' => 'id', 'guest_name' => 'name'], $guestMetadata->fieldNames); + self::assertEquals(['id' => 'guest_id', 'name' => 'guest_name'], $guestMetadata->columnNames); + self::assertEquals(140, $guestMetadata->fieldMappings['id']['length']); - $this->assertEquals('name', $guestMetadata->fieldMappings['name']['fieldName']); - $this->assertEquals('guest_name', $guestMetadata->fieldMappings['name']['columnName']); - $this->assertEquals(240, $guestMetadata->fieldMappings['name']['length']); - $this->assertFalse($guestMetadata->fieldMappings['name']['nullable']); - $this->assertTrue($guestMetadata->fieldMappings['name']['unique']); + self::assertEquals('name', $guestMetadata->fieldMappings['name']['fieldName']); + self::assertEquals('guest_name', $guestMetadata->fieldMappings['name']['columnName']); + self::assertEquals(240, $guestMetadata->fieldMappings['name']['length']); + self::assertFalse($guestMetadata->fieldMappings['name']['nullable']); + self::assertTrue($guestMetadata->fieldMappings['name']['unique']); } /** @@ -911,23 +911,23 @@ public function testEntityListeners(): void $fixClass = $factory->getMetadataFor(CompanyFlexContract::class); $ultraClass = $factory->getMetadataFor(CompanyFlexUltraContract::class); - $this->assertArrayHasKey(Events::prePersist, $superClass->entityListeners); - $this->assertArrayHasKey(Events::postPersist, $superClass->entityListeners); + self::assertArrayHasKey(Events::prePersist, $superClass->entityListeners); + self::assertArrayHasKey(Events::postPersist, $superClass->entityListeners); - $this->assertCount(1, $superClass->entityListeners[Events::prePersist]); - $this->assertCount(1, $superClass->entityListeners[Events::postPersist]); + self::assertCount(1, $superClass->entityListeners[Events::prePersist]); + self::assertCount(1, $superClass->entityListeners[Events::postPersist]); $postPersist = $superClass->entityListeners[Events::postPersist][0]; $prePersist = $superClass->entityListeners[Events::prePersist][0]; - $this->assertEquals(CompanyContractListener::class, $postPersist['class']); - $this->assertEquals(CompanyContractListener::class, $prePersist['class']); - $this->assertEquals('postPersistHandler', $postPersist['method']); - $this->assertEquals('prePersistHandler', $prePersist['method']); + self::assertEquals(CompanyContractListener::class, $postPersist['class']); + self::assertEquals(CompanyContractListener::class, $prePersist['class']); + self::assertEquals('postPersistHandler', $postPersist['method']); + self::assertEquals('prePersistHandler', $prePersist['method']); //Inherited listeners - $this->assertEquals($fixClass->entityListeners, $superClass->entityListeners); - $this->assertEquals($flexClass->entityListeners, $superClass->entityListeners); + self::assertEquals($fixClass->entityListeners, $superClass->entityListeners); + self::assertEquals($flexClass->entityListeners, $superClass->entityListeners); } /** @@ -940,27 +940,27 @@ public function testEntityListenersOverride(): void $ultraClass = $factory->getMetadataFor(CompanyFlexUltraContract::class); //overridden listeners - $this->assertArrayHasKey(Events::postPersist, $ultraClass->entityListeners); - $this->assertArrayHasKey(Events::prePersist, $ultraClass->entityListeners); + self::assertArrayHasKey(Events::postPersist, $ultraClass->entityListeners); + self::assertArrayHasKey(Events::prePersist, $ultraClass->entityListeners); - $this->assertCount(1, $ultraClass->entityListeners[Events::postPersist]); - $this->assertCount(3, $ultraClass->entityListeners[Events::prePersist]); + self::assertCount(1, $ultraClass->entityListeners[Events::postPersist]); + self::assertCount(3, $ultraClass->entityListeners[Events::prePersist]); $postPersist = $ultraClass->entityListeners[Events::postPersist][0]; $prePersist = $ultraClass->entityListeners[Events::prePersist][0]; - $this->assertEquals(CompanyContractListener::class, $postPersist['class']); - $this->assertEquals(CompanyContractListener::class, $prePersist['class']); - $this->assertEquals('postPersistHandler', $postPersist['method']); - $this->assertEquals('prePersistHandler', $prePersist['method']); + self::assertEquals(CompanyContractListener::class, $postPersist['class']); + self::assertEquals(CompanyContractListener::class, $prePersist['class']); + self::assertEquals('postPersistHandler', $postPersist['method']); + self::assertEquals('prePersistHandler', $prePersist['method']); $prePersist = $ultraClass->entityListeners[Events::prePersist][1]; - $this->assertEquals(CompanyFlexUltraContractListener::class, $prePersist['class']); - $this->assertEquals('prePersistHandler1', $prePersist['method']); + self::assertEquals(CompanyFlexUltraContractListener::class, $prePersist['class']); + self::assertEquals('prePersistHandler1', $prePersist['method']); $prePersist = $ultraClass->entityListeners[Events::prePersist][2]; - $this->assertEquals(CompanyFlexUltraContractListener::class, $prePersist['class']); - $this->assertEquals('prePersistHandler2', $prePersist['method']); + self::assertEquals(CompanyFlexUltraContractListener::class, $prePersist['class']); + self::assertEquals('prePersistHandler2', $prePersist['method']); } /** @@ -972,23 +972,23 @@ public function testEntityListenersNamingConvention(): void $factory = $this->createClassMetadataFactory($em); $metadata = $factory->getMetadataFor(CmsAddress::class); - $this->assertArrayHasKey(Events::postPersist, $metadata->entityListeners); - $this->assertArrayHasKey(Events::prePersist, $metadata->entityListeners); - $this->assertArrayHasKey(Events::postUpdate, $metadata->entityListeners); - $this->assertArrayHasKey(Events::preUpdate, $metadata->entityListeners); - $this->assertArrayHasKey(Events::postRemove, $metadata->entityListeners); - $this->assertArrayHasKey(Events::preRemove, $metadata->entityListeners); - $this->assertArrayHasKey(Events::postLoad, $metadata->entityListeners); - $this->assertArrayHasKey(Events::preFlush, $metadata->entityListeners); - - $this->assertCount(1, $metadata->entityListeners[Events::postPersist]); - $this->assertCount(1, $metadata->entityListeners[Events::prePersist]); - $this->assertCount(1, $metadata->entityListeners[Events::postUpdate]); - $this->assertCount(1, $metadata->entityListeners[Events::preUpdate]); - $this->assertCount(1, $metadata->entityListeners[Events::postRemove]); - $this->assertCount(1, $metadata->entityListeners[Events::preRemove]); - $this->assertCount(1, $metadata->entityListeners[Events::postLoad]); - $this->assertCount(1, $metadata->entityListeners[Events::preFlush]); + self::assertArrayHasKey(Events::postPersist, $metadata->entityListeners); + self::assertArrayHasKey(Events::prePersist, $metadata->entityListeners); + self::assertArrayHasKey(Events::postUpdate, $metadata->entityListeners); + self::assertArrayHasKey(Events::preUpdate, $metadata->entityListeners); + self::assertArrayHasKey(Events::postRemove, $metadata->entityListeners); + self::assertArrayHasKey(Events::preRemove, $metadata->entityListeners); + self::assertArrayHasKey(Events::postLoad, $metadata->entityListeners); + self::assertArrayHasKey(Events::preFlush, $metadata->entityListeners); + + self::assertCount(1, $metadata->entityListeners[Events::postPersist]); + self::assertCount(1, $metadata->entityListeners[Events::prePersist]); + self::assertCount(1, $metadata->entityListeners[Events::postUpdate]); + self::assertCount(1, $metadata->entityListeners[Events::preUpdate]); + self::assertCount(1, $metadata->entityListeners[Events::postRemove]); + self::assertCount(1, $metadata->entityListeners[Events::preRemove]); + self::assertCount(1, $metadata->entityListeners[Events::postLoad]); + self::assertCount(1, $metadata->entityListeners[Events::preFlush]); $postPersist = $metadata->entityListeners[Events::postPersist][0]; $prePersist = $metadata->entityListeners[Events::prePersist][0]; @@ -999,23 +999,23 @@ public function testEntityListenersNamingConvention(): void $postLoad = $metadata->entityListeners[Events::postLoad][0]; $preFlush = $metadata->entityListeners[Events::preFlush][0]; - $this->assertEquals(CmsAddressListener::class, $postPersist['class']); - $this->assertEquals(CmsAddressListener::class, $prePersist['class']); - $this->assertEquals(CmsAddressListener::class, $postUpdate['class']); - $this->assertEquals(CmsAddressListener::class, $preUpdate['class']); - $this->assertEquals(CmsAddressListener::class, $postRemove['class']); - $this->assertEquals(CmsAddressListener::class, $preRemove['class']); - $this->assertEquals(CmsAddressListener::class, $postLoad['class']); - $this->assertEquals(CmsAddressListener::class, $preFlush['class']); + self::assertEquals(CmsAddressListener::class, $postPersist['class']); + self::assertEquals(CmsAddressListener::class, $prePersist['class']); + self::assertEquals(CmsAddressListener::class, $postUpdate['class']); + self::assertEquals(CmsAddressListener::class, $preUpdate['class']); + self::assertEquals(CmsAddressListener::class, $postRemove['class']); + self::assertEquals(CmsAddressListener::class, $preRemove['class']); + self::assertEquals(CmsAddressListener::class, $postLoad['class']); + self::assertEquals(CmsAddressListener::class, $preFlush['class']); - $this->assertEquals(Events::postPersist, $postPersist['method']); - $this->assertEquals(Events::prePersist, $prePersist['method']); - $this->assertEquals(Events::postUpdate, $postUpdate['method']); - $this->assertEquals(Events::preUpdate, $preUpdate['method']); - $this->assertEquals(Events::postRemove, $postRemove['method']); - $this->assertEquals(Events::preRemove, $preRemove['method']); - $this->assertEquals(Events::postLoad, $postLoad['method']); - $this->assertEquals(Events::preFlush, $preFlush['method']); + self::assertEquals(Events::postPersist, $postPersist['method']); + self::assertEquals(Events::prePersist, $prePersist['method']); + self::assertEquals(Events::postUpdate, $postUpdate['method']); + self::assertEquals(Events::preUpdate, $preUpdate['method']); + self::assertEquals(Events::postRemove, $postRemove['method']); + self::assertEquals(Events::preRemove, $preRemove['method']); + self::assertEquals(Events::postLoad, $postLoad['method']); + self::assertEquals(Events::preFlush, $preFlush['method']); } /** @@ -1026,24 +1026,24 @@ public function testSecondLevelCacheMapping(): void $em = $this->getTestEntityManager(); $factory = $this->createClassMetadataFactory($em); $class = $factory->getMetadataFor(City::class); - $this->assertArrayHasKey('usage', $class->cache); - $this->assertArrayHasKey('region', $class->cache); - $this->assertEquals(ClassMetadata::CACHE_USAGE_READ_ONLY, $class->cache['usage']); - $this->assertEquals('doctrine_tests_models_cache_city', $class->cache['region']); + self::assertArrayHasKey('usage', $class->cache); + self::assertArrayHasKey('region', $class->cache); + self::assertEquals(ClassMetadata::CACHE_USAGE_READ_ONLY, $class->cache['usage']); + self::assertEquals('doctrine_tests_models_cache_city', $class->cache['region']); - $this->assertArrayHasKey('state', $class->associationMappings); - $this->assertArrayHasKey('cache', $class->associationMappings['state']); - $this->assertArrayHasKey('usage', $class->associationMappings['state']['cache']); - $this->assertArrayHasKey('region', $class->associationMappings['state']['cache']); - $this->assertEquals(ClassMetadata::CACHE_USAGE_READ_ONLY, $class->associationMappings['state']['cache']['usage']); - $this->assertEquals('doctrine_tests_models_cache_city__state', $class->associationMappings['state']['cache']['region']); + self::assertArrayHasKey('state', $class->associationMappings); + self::assertArrayHasKey('cache', $class->associationMappings['state']); + self::assertArrayHasKey('usage', $class->associationMappings['state']['cache']); + self::assertArrayHasKey('region', $class->associationMappings['state']['cache']); + self::assertEquals(ClassMetadata::CACHE_USAGE_READ_ONLY, $class->associationMappings['state']['cache']['usage']); + self::assertEquals('doctrine_tests_models_cache_city__state', $class->associationMappings['state']['cache']['region']); - $this->assertArrayHasKey('attractions', $class->associationMappings); - $this->assertArrayHasKey('cache', $class->associationMappings['attractions']); - $this->assertArrayHasKey('usage', $class->associationMappings['attractions']['cache']); - $this->assertArrayHasKey('region', $class->associationMappings['attractions']['cache']); - $this->assertEquals(ClassMetadata::CACHE_USAGE_READ_ONLY, $class->associationMappings['attractions']['cache']['usage']); - $this->assertEquals('doctrine_tests_models_cache_city__attractions', $class->associationMappings['attractions']['cache']['region']); + self::assertArrayHasKey('attractions', $class->associationMappings); + self::assertArrayHasKey('cache', $class->associationMappings['attractions']); + self::assertArrayHasKey('usage', $class->associationMappings['attractions']['cache']); + self::assertArrayHasKey('region', $class->associationMappings['attractions']['cache']); + self::assertEquals(ClassMetadata::CACHE_USAGE_READ_ONLY, $class->associationMappings['attractions']['cache']['usage']); + self::assertEquals('doctrine_tests_models_cache_city__attractions', $class->associationMappings['attractions']['cache']['region']); } /** @@ -1055,8 +1055,8 @@ public function testSchemaDefinitionViaExplicitTableSchemaAnnotationProperty(): $metadata = $this->createClassMetadataFactory()->getMetadataFor(ExplicitSchemaAndTable::class); assert($metadata instanceof ClassMetadata); - $this->assertSame('explicit_schema', $metadata->getSchemaName()); - $this->assertSame('explicit_table', $metadata->getTableName()); + self::assertSame('explicit_schema', $metadata->getSchemaName()); + self::assertSame('explicit_table', $metadata->getTableName()); } /** @@ -1068,8 +1068,8 @@ public function testSchemaDefinitionViaSchemaDefinedInTableNameInTableAnnotation $metadata = $this->createClassMetadataFactory()->getMetadataFor(SchemaAndTableInTableName::class); assert($metadata instanceof ClassMetadata); - $this->assertSame('implicit_schema', $metadata->getSchemaName()); - $this->assertSame('implicit_table', $metadata->getTableName()); + self::assertSame('implicit_schema', $metadata->getSchemaName()); + self::assertSame('implicit_table', $metadata->getTableName()); } /** @@ -1079,13 +1079,13 @@ public function testSchemaDefinitionViaSchemaDefinedInTableNameInTableAnnotation public function testDiscriminatorColumnDefaultLength(): void { if (strpos(static::class, 'PHPMappingDriver') !== false) { - $this->markTestSkipped('PHP Mapping Drivers have no defaults.'); + self::markTestSkipped('PHP Mapping Drivers have no defaults.'); } $class = $this->createClassMetadata(SingleTableEntityNoDiscriminatorColumnMapping::class); - $this->assertEquals(255, $class->discriminatorColumn['length']); + self::assertEquals(255, $class->discriminatorColumn['length']); $class = $this->createClassMetadata(SingleTableEntityIncompleteDiscriminatorColumnMapping::class); - $this->assertEquals(255, $class->discriminatorColumn['length']); + self::assertEquals(255, $class->discriminatorColumn['length']); } /** @@ -1095,13 +1095,13 @@ public function testDiscriminatorColumnDefaultLength(): void public function testDiscriminatorColumnDefaultType(): void { if (strpos(static::class, 'PHPMappingDriver') !== false) { - $this->markTestSkipped('PHP Mapping Drivers have no defaults.'); + self::markTestSkipped('PHP Mapping Drivers have no defaults.'); } $class = $this->createClassMetadata(SingleTableEntityNoDiscriminatorColumnMapping::class); - $this->assertEquals('string', $class->discriminatorColumn['type']); + self::assertEquals('string', $class->discriminatorColumn['type']); $class = $this->createClassMetadata(SingleTableEntityIncompleteDiscriminatorColumnMapping::class); - $this->assertEquals('string', $class->discriminatorColumn['type']); + self::assertEquals('string', $class->discriminatorColumn['type']); } /** @@ -1111,13 +1111,13 @@ public function testDiscriminatorColumnDefaultType(): void public function testDiscriminatorColumnDefaultName(): void { if (strpos(static::class, 'PHPMappingDriver') !== false) { - $this->markTestSkipped('PHP Mapping Drivers have no defaults.'); + self::markTestSkipped('PHP Mapping Drivers have no defaults.'); } $class = $this->createClassMetadata(SingleTableEntityNoDiscriminatorColumnMapping::class); - $this->assertEquals('dtype', $class->discriminatorColumn['name']); + self::assertEquals('dtype', $class->discriminatorColumn['name']); $class = $this->createClassMetadata(SingleTableEntityIncompleteDiscriminatorColumnMapping::class); - $this->assertEquals('dtype', $class->discriminatorColumn['name']); + self::assertEquals('dtype', $class->discriminatorColumn['name']); } } diff --git a/tests/Doctrine/Tests/ORM/Mapping/AnnotationDriverTest.php b/tests/Doctrine/Tests/ORM/Mapping/AnnotationDriverTest.php index c06e5ed8753..00a9c6b127e 100644 --- a/tests/Doctrine/Tests/ORM/Mapping/AnnotationDriverTest.php +++ b/tests/Doctrine/Tests/ORM/Mapping/AnnotationDriverTest.php @@ -71,7 +71,7 @@ public function testColumnWithMissingTypeDefaultsToString(): void $annotationDriver = $this->loadDriver(); $annotationDriver->loadMetadataForClass(Mapping\InvalidColumn::class, $cm); - $this->assertEquals('string', $cm->fieldMappings['id']['type']); + self::assertEquals('string', $cm->fieldMappings['id']['type']); } /** @@ -85,7 +85,7 @@ public function testGetAllClassNamesIsIdempotent(): void $annotationDriver = $this->loadDriverForCMSModels(); $afterTestReset = $annotationDriver->getAllClassNames(); - $this->assertEquals($original, $afterTestReset); + self::assertEquals($original, $afterTestReset); } /** @@ -99,7 +99,7 @@ public function testGetAllClassNamesIsIdempotentEvenWithDifferentDriverInstances $annotationDriver = $this->loadDriverForCMSModels(); $afterTestReset = $annotationDriver->getAllClassNames(); - $this->assertEquals($original, $afterTestReset); + self::assertEquals($original, $afterTestReset); } /** @@ -112,7 +112,7 @@ public function testGetAllClassNamesReturnsAlreadyLoadedClassesIfAppropriate(): $annotationDriver = $this->loadDriverForCMSModels(); $classes = $annotationDriver->getAllClassNames(); - $this->assertContains(CmsUser::class, $classes); + self::assertContains(CmsUser::class, $classes); } /** @@ -125,7 +125,7 @@ public function testGetClassNamesReturnsOnlyTheAppropriateClasses(): void $annotationDriver = $this->loadDriverForCMSModels(); $classes = $annotationDriver->getAllClassNames(); - $this->assertNotContains(ECommerceCart::class, $classes); + self::assertNotContains(ECommerceCart::class, $classes); } protected function loadDriverForCMSModels(): AnnotationDriver @@ -165,10 +165,10 @@ public function testJoinTablesWithMappedSuperclassForAnnotationDriver(): void $factory->setEntityManager($em); $classPage = $factory->getMetadataFor(File::class); - $this->assertEquals(File::class, $classPage->associationMappings['parentDirectory']['sourceEntity']); + self::assertEquals(File::class, $classPage->associationMappings['parentDirectory']['sourceEntity']); $classDirectory = $factory->getMetadataFor(Directory::class); - $this->assertEquals(Directory::class, $classDirectory->associationMappings['parentDirectory']['sourceEntity']); + self::assertEquals(Directory::class, $classDirectory->associationMappings['parentDirectory']['sourceEntity']); } /** @@ -226,10 +226,10 @@ public function testInheritanceSkipsParentLifecycleCallbacks(): void $factory->setEntityManager($em); $cm = $factory->getMetadataFor(AnnotationChild::class); - $this->assertEquals(['postLoad' => ['postLoad'], 'preUpdate' => ['preUpdate']], $cm->lifecycleCallbacks); + self::assertEquals(['postLoad' => ['postLoad'], 'preUpdate' => ['preUpdate']], $cm->lifecycleCallbacks); $cm = $factory->getMetadataFor(AnnotationParent::class); - $this->assertEquals(['postLoad' => ['postLoad'], 'preUpdate' => ['preUpdate']], $cm->lifecycleCallbacks); + self::assertEquals(['postLoad' => ['postLoad'], 'preUpdate' => ['preUpdate']], $cm->lifecycleCallbacks); } /** @@ -270,10 +270,10 @@ public function testAttributeOverridesMappingWithTrait(): void $metadataWithoutOverride = $factory->getMetadataFor(DDC1872ExampleEntityWithoutOverride::class); $metadataWithOverride = $factory->getMetadataFor(DDC1872ExampleEntityWithOverride::class); - $this->assertEquals('trait_foo', $metadataWithoutOverride->fieldMappings['foo']['columnName']); - $this->assertEquals('foo_overridden', $metadataWithOverride->fieldMappings['foo']['columnName']); - $this->assertArrayHasKey('example_trait_bar_id', $metadataWithoutOverride->associationMappings['bar']['joinColumnFieldNames']); - $this->assertArrayHasKey('example_entity_overridden_bar_id', $metadataWithOverride->associationMappings['bar']['joinColumnFieldNames']); + self::assertEquals('trait_foo', $metadataWithoutOverride->fieldMappings['foo']['columnName']); + self::assertEquals('foo_overridden', $metadataWithOverride->fieldMappings['foo']['columnName']); + self::assertArrayHasKey('example_trait_bar_id', $metadataWithoutOverride->associationMappings['bar']['joinColumnFieldNames']); + self::assertArrayHasKey('example_entity_overridden_bar_id', $metadataWithOverride->associationMappings['bar']['joinColumnFieldNames']); } } diff --git a/tests/Doctrine/Tests/ORM/Mapping/AnsiQuoteStrategyTest.php b/tests/Doctrine/Tests/ORM/Mapping/AnsiQuoteStrategyTest.php index d162f8b3df2..683c8b09223 100644 --- a/tests/Doctrine/Tests/ORM/Mapping/AnsiQuoteStrategyTest.php +++ b/tests/Doctrine/Tests/ORM/Mapping/AnsiQuoteStrategyTest.php @@ -50,8 +50,8 @@ public function testGetColumnName(): void $class->mapField(['fieldName' => 'name', 'columnName' => 'name']); $class->mapField(['fieldName' => 'id', 'columnName' => 'id', 'id' => true]); - $this->assertEquals('id', $this->strategy->getColumnName('id', $class, $this->platform)); - $this->assertEquals('name', $this->strategy->getColumnName('name', $class, $this->platform)); + self::assertEquals('id', $this->strategy->getColumnName('id', $class, $this->platform)); + self::assertEquals('name', $this->strategy->getColumnName('name', $class, $this->platform)); } public function testGetTableName(): void @@ -59,7 +59,7 @@ public function testGetTableName(): void $class = $this->createClassMetadata(CmsUser::class); $class->setPrimaryTable(['name' => 'cms_user']); - $this->assertEquals('cms_user', $this->strategy->getTableName($class, $this->platform)); + self::assertEquals('cms_user', $this->strategy->getTableName($class, $this->platform)); } public function testJoinTableName(): void @@ -75,7 +75,7 @@ public function testJoinTableName(): void ] ); - $this->assertEquals('cmsaddress_cmsuser', $this->strategy->getJoinTableName($class->associationMappings['user'], $class, $this->platform)); + self::assertEquals('cmsaddress_cmsuser', $this->strategy->getJoinTableName($class->associationMappings['user'], $class, $this->platform)); } public function testIdentifierColumnNames(): void @@ -90,12 +90,12 @@ public function testIdentifierColumnNames(): void ] ); - $this->assertEquals(['id'], $this->strategy->getIdentifierColumnNames($class, $this->platform)); + self::assertEquals(['id'], $this->strategy->getIdentifierColumnNames($class, $this->platform)); } public function testColumnAlias(): void { - $this->assertEquals('columnName_1', $this->strategy->getColumnAlias('columnName', 1, $this->platform)); + self::assertEquals('columnName_1', $this->strategy->getColumnAlias('columnName', 1, $this->platform)); } public function testJoinColumnName(): void @@ -114,7 +114,7 @@ public function testJoinColumnName(): void ); $joinColumn = $class->associationMappings['article']['joinColumns'][0]; - $this->assertEquals('article', $this->strategy->getJoinColumnName($joinColumn, $class, $this->platform)); + self::assertEquals('article', $this->strategy->getJoinColumnName($joinColumn, $class, $this->platform)); } public function testReferencedJoinColumnName(): void @@ -133,7 +133,7 @@ public function testReferencedJoinColumnName(): void ); $joinColumn = $cm->associationMappings['article']['joinColumns'][0]; - $this->assertEquals('id', $this->strategy->getReferencedJoinColumnName($joinColumn, $cm, $this->platform)); + self::assertEquals('id', $this->strategy->getReferencedJoinColumnName($joinColumn, $cm, $this->platform)); } public function testGetSequenceName(): void @@ -147,6 +147,6 @@ public function testGetSequenceName(): void $class->setSequenceGeneratorDefinition($definition); - $this->assertEquals('user_id_seq', $this->strategy->getSequenceName($definition, $class, $this->platform)); + self::assertEquals('user_id_seq', $this->strategy->getSequenceName($definition, $class, $this->platform)); } } diff --git a/tests/Doctrine/Tests/ORM/Mapping/AttributeDriverTest.php b/tests/Doctrine/Tests/ORM/Mapping/AttributeDriverTest.php index 8ba496a621c..01f6d365b18 100644 --- a/tests/Doctrine/Tests/ORM/Mapping/AttributeDriverTest.php +++ b/tests/Doctrine/Tests/ORM/Mapping/AttributeDriverTest.php @@ -19,7 +19,7 @@ class AttributeDriverTest extends AbstractMappingDriverTest public function requiresPhp8Assertion(): void { if (PHP_VERSION_ID < 80000) { - $this->markTestSkipped('requires PHP 8.0'); + self::markTestSkipped('requires PHP 8.0'); } } @@ -32,37 +32,37 @@ protected function loadDriver(): MappingDriver public function testNamedQuery(): void { - $this->markTestSkipped('AttributeDriver does not support named queries.'); + self::markTestSkipped('AttributeDriver does not support named queries.'); } public function testNamedNativeQuery(): void { - $this->markTestSkipped('AttributeDriver does not support named native queries.'); + self::markTestSkipped('AttributeDriver does not support named native queries.'); } public function testSqlResultSetMapping(): void { - $this->markTestSkipped('AttributeDriver does not support named sql resultset mapping.'); + self::markTestSkipped('AttributeDriver does not support named sql resultset mapping.'); } public function testAssociationOverridesMapping(): void { - $this->markTestSkipped('AttributeDriver does not support association overrides.'); + self::markTestSkipped('AttributeDriver does not support association overrides.'); } public function testInversedByOverrideMapping(): void { - $this->markTestSkipped('AttributeDriver does not support association overrides.'); + self::markTestSkipped('AttributeDriver does not support association overrides.'); } public function testFetchOverrideMapping(): void { - $this->markTestSkipped('AttributeDriver does not support association overrides.'); + self::markTestSkipped('AttributeDriver does not support association overrides.'); } public function testAttributeOverridesMapping(): void { - $this->markTestSkipped('AttributeDriver does not support association overrides.'); + self::markTestSkipped('AttributeDriver does not support association overrides.'); } public function testOriginallyNestedAttributesDeclaredWithoutOriginalParent(): void @@ -71,7 +71,7 @@ public function testOriginallyNestedAttributesDeclaredWithoutOriginalParent(): v $metadata = $factory->getMetadataFor(AttributeEntityWithoutOriginalParents::class); - $this->assertEquals( + self::assertEquals( [ 'name' => 'AttributeEntityWithoutOriginalParents', 'uniqueConstraints' => ['foo' => ['columns' => ['id']]], @@ -79,20 +79,20 @@ public function testOriginallyNestedAttributesDeclaredWithoutOriginalParent(): v ], $metadata->table ); - $this->assertEquals(['assoz_id', 'assoz_id'], $metadata->associationMappings['assoc']['joinTableColumns']); + self::assertEquals(['assoz_id', 'assoz_id'], $metadata->associationMappings['assoc']['joinTableColumns']); } public function testIsTransient(): void { $driver = $this->loadDriver(); - $this->assertTrue($driver->isTransient(stdClass::class)); + self::assertTrue($driver->isTransient(stdClass::class)); - $this->assertTrue($driver->isTransient(AttributeTransientClass::class)); + self::assertTrue($driver->isTransient(AttributeTransientClass::class)); - $this->assertFalse($driver->isTransient(AttributeEntityWithoutOriginalParents::class)); + self::assertFalse($driver->isTransient(AttributeEntityWithoutOriginalParents::class)); - $this->assertFalse($driver->isTransient(AttributeEntityStartingWithRepeatableAttributes::class)); + self::assertFalse($driver->isTransient(AttributeEntityStartingWithRepeatableAttributes::class)); } } diff --git a/tests/Doctrine/Tests/ORM/Mapping/BasicInheritanceMappingTest.php b/tests/Doctrine/Tests/ORM/Mapping/BasicInheritanceMappingTest.php index 0fa13a2b225..8c5560268b2 100644 --- a/tests/Doctrine/Tests/ORM/Mapping/BasicInheritanceMappingTest.php +++ b/tests/Doctrine/Tests/ORM/Mapping/BasicInheritanceMappingTest.php @@ -56,29 +56,29 @@ public function testGetMetadataForSubclassWithTransientBaseClass(): void { $class = $this->cmf->getMetadataFor(EntitySubClass::class); - $this->assertEmpty($class->subClasses); - $this->assertEmpty($class->parentClasses); - $this->assertArrayHasKey('id', $class->fieldMappings); - $this->assertArrayHasKey('name', $class->fieldMappings); + self::assertEmpty($class->subClasses); + self::assertEmpty($class->parentClasses); + self::assertArrayHasKey('id', $class->fieldMappings); + self::assertArrayHasKey('name', $class->fieldMappings); } public function testGetMetadataForSubclassWithMappedSuperclass(): void { $class = $this->cmf->getMetadataFor(EntitySubClass2::class); - $this->assertEmpty($class->subClasses); - $this->assertEmpty($class->parentClasses); + self::assertEmpty($class->subClasses); + self::assertEmpty($class->parentClasses); - $this->assertArrayHasKey('mapped1', $class->fieldMappings); - $this->assertArrayHasKey('mapped2', $class->fieldMappings); - $this->assertArrayHasKey('id', $class->fieldMappings); - $this->assertArrayHasKey('name', $class->fieldMappings); + self::assertArrayHasKey('mapped1', $class->fieldMappings); + self::assertArrayHasKey('mapped2', $class->fieldMappings); + self::assertArrayHasKey('id', $class->fieldMappings); + self::assertArrayHasKey('name', $class->fieldMappings); - $this->assertArrayNotHasKey('inherited', $class->fieldMappings['mapped1']); - $this->assertArrayNotHasKey('inherited', $class->fieldMappings['mapped2']); - $this->assertArrayNotHasKey('transient', $class->fieldMappings); + self::assertArrayNotHasKey('inherited', $class->fieldMappings['mapped1']); + self::assertArrayNotHasKey('inherited', $class->fieldMappings['mapped2']); + self::assertArrayNotHasKey('transient', $class->fieldMappings); - $this->assertArrayHasKey('mappedRelated1', $class->associationMappings); + self::assertArrayHasKey('mappedRelated1', $class->associationMappings); } /** @@ -88,24 +88,24 @@ public function testGetMetadataForSubclassWithMappedSuperclassWithRepository(): { $class = $this->cmf->getMetadataFor(DDC869CreditCardPayment::class); - $this->assertArrayHasKey('id', $class->fieldMappings); - $this->assertArrayHasKey('value', $class->fieldMappings); - $this->assertArrayHasKey('creditCardNumber', $class->fieldMappings); - $this->assertEquals($class->customRepositoryClassName, DDC869PaymentRepository::class); + self::assertArrayHasKey('id', $class->fieldMappings); + self::assertArrayHasKey('value', $class->fieldMappings); + self::assertArrayHasKey('creditCardNumber', $class->fieldMappings); + self::assertEquals($class->customRepositoryClassName, DDC869PaymentRepository::class); $class = $this->cmf->getMetadataFor(DDC869ChequePayment::class); - $this->assertArrayHasKey('id', $class->fieldMappings); - $this->assertArrayHasKey('value', $class->fieldMappings); - $this->assertArrayHasKey('serialNumber', $class->fieldMappings); - $this->assertEquals($class->customRepositoryClassName, DDC869PaymentRepository::class); + self::assertArrayHasKey('id', $class->fieldMappings); + self::assertArrayHasKey('value', $class->fieldMappings); + self::assertArrayHasKey('serialNumber', $class->fieldMappings); + self::assertEquals($class->customRepositoryClassName, DDC869PaymentRepository::class); // override repositoryClass $class = $this->cmf->getMetadataFor(SubclassWithRepository::class); - $this->assertArrayHasKey('id', $class->fieldMappings); - $this->assertArrayHasKey('value', $class->fieldMappings); - $this->assertEquals($class->customRepositoryClassName, EntityRepository::class); + self::assertArrayHasKey('id', $class->fieldMappings); + self::assertArrayHasKey('value', $class->fieldMappings); + self::assertEquals($class->customRepositoryClassName, EntityRepository::class); } /** @@ -118,9 +118,9 @@ public function testSerializationWithPrivateFieldsFromMappedSuperclass(): void $class2 = unserialize(serialize($class)); $class2->wakeupReflection(new RuntimeReflectionService()); - $this->assertArrayHasKey('mapped1', $class2->reflFields); - $this->assertArrayHasKey('mapped2', $class2->reflFields); - $this->assertArrayHasKey('mappedRelated1', $class2->reflFields); + self::assertArrayHasKey('mapped1', $class2->reflFields); + self::assertArrayHasKey('mapped2', $class2->reflFields); + self::assertArrayHasKey('mappedRelated1', $class2->reflFields); } /** @@ -130,9 +130,9 @@ public function testUnmappedSuperclassInHierarchy(): void { $class = $this->cmf->getMetadataFor(HierarchyD::class); - $this->assertArrayHasKey('id', $class->fieldMappings); - $this->assertArrayHasKey('a', $class->fieldMappings); - $this->assertArrayHasKey('d', $class->fieldMappings); + self::assertArrayHasKey('id', $class->fieldMappings); + self::assertArrayHasKey('a', $class->fieldMappings); + self::assertArrayHasKey('d', $class->fieldMappings); } /** @@ -159,7 +159,7 @@ public function testMappedSuperclassWithId(): void { $class = $this->cmf->getMetadataFor(SuperclassEntity::class); - $this->assertArrayHasKey('id', $class->fieldMappings); + self::assertArrayHasKey('id', $class->fieldMappings); } /** @@ -171,8 +171,8 @@ public function testGeneratedValueFromMappedSuperclass(): void $class = $this->cmf->getMetadataFor(SuperclassEntity::class); assert($class instanceof ClassMetadata); - $this->assertInstanceOf(IdSequenceGenerator::class, $class->idGenerator); - $this->assertEquals( + self::assertInstanceOf(IdSequenceGenerator::class, $class->idGenerator); + self::assertEquals( ['allocationSize' => 1, 'initialValue' => 10, 'sequenceName' => 'foo'], $class->sequenceGeneratorDefinition ); @@ -187,8 +187,8 @@ public function testSequenceDefinitionInHierarchyWithSandwichMappedSuperclass(): $class = $this->cmf->getMetadataFor(HierarchyD::class); assert($class instanceof ClassMetadata); - $this->assertInstanceOf(IdSequenceGenerator::class, $class->idGenerator); - $this->assertEquals( + self::assertInstanceOf(IdSequenceGenerator::class, $class->idGenerator); + self::assertEquals( ['allocationSize' => 1, 'initialValue' => 10, 'sequenceName' => 'foo'], $class->sequenceGeneratorDefinition ); @@ -203,8 +203,8 @@ public function testMultipleMappedSuperclasses(): void $class = $this->cmf->getMetadataFor(MediumSuperclassEntity::class); assert($class instanceof ClassMetadata); - $this->assertInstanceOf(IdSequenceGenerator::class, $class->idGenerator); - $this->assertEquals( + self::assertInstanceOf(IdSequenceGenerator::class, $class->idGenerator); + self::assertEquals( ['allocationSize' => 1, 'initialValue' => 10, 'sequenceName' => 'foo'], $class->sequenceGeneratorDefinition ); @@ -220,10 +220,10 @@ public function testMappedSuperclassIndex(): void $class = $this->cmf->getMetadataFor(EntityIndexSubClass::class); assert($class instanceof ClassMetadata); - $this->assertArrayHasKey('mapped1', $class->fieldMappings); - $this->assertArrayHasKey('IDX_NAME_INDEX', $class->table['uniqueConstraints']); - $this->assertArrayHasKey('IDX_MAPPED1_INDEX', $class->table['uniqueConstraints']); - $this->assertArrayHasKey('IDX_MAPPED2_INDEX', $class->table['indexes']); + self::assertArrayHasKey('mapped1', $class->fieldMappings); + self::assertArrayHasKey('IDX_NAME_INDEX', $class->table['uniqueConstraints']); + self::assertArrayHasKey('IDX_MAPPED1_INDEX', $class->table['uniqueConstraints']); + self::assertArrayHasKey('IDX_MAPPED2_INDEX', $class->table['indexes']); } } diff --git a/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataBuilderTest.php b/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataBuilderTest.php index c2e690cc65f..c73f9503c84 100644 --- a/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataBuilderTest.php +++ b/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataBuilderTest.php @@ -35,22 +35,22 @@ protected function setUp(): void public function testSetMappedSuperClass(): void { $this->assertIsFluent($this->builder->setMappedSuperClass()); - $this->assertTrue($this->cm->isMappedSuperclass); - $this->assertFalse($this->cm->isEmbeddedClass); + self::assertTrue($this->cm->isMappedSuperclass); + self::assertFalse($this->cm->isEmbeddedClass); } public function testSetEmbedable(): void { $this->assertIsFluent($this->builder->setEmbeddable()); - $this->assertTrue($this->cm->isEmbeddedClass); - $this->assertFalse($this->cm->isMappedSuperclass); + self::assertTrue($this->cm->isEmbeddedClass); + self::assertFalse($this->cm->isMappedSuperclass); } public function testAddEmbeddedWithOnlyRequiredParams(): void { $this->assertIsFluent($this->builder->addEmbedded('name', Name::class)); - $this->assertEquals( + self::assertEquals( [ 'name' => [ 'class' => Name::class, @@ -73,7 +73,7 @@ public function testAddEmbeddedWithPrefix(): void ) ); - $this->assertEquals( + self::assertEquals( [ 'name' => [ 'class' => Name::class, @@ -89,12 +89,12 @@ public function testAddEmbeddedWithPrefix(): void public function testCreateEmbeddedWithoutExtraParams(): void { $embeddedBuilder = $this->builder->createEmbedded('name', Name::class); - $this->assertInstanceOf(EmbeddedBuilder::class, $embeddedBuilder); + self::assertInstanceOf(EmbeddedBuilder::class, $embeddedBuilder); - $this->assertFalse(isset($this->cm->embeddedClasses['name'])); + self::assertFalse(isset($this->cm->embeddedClasses['name'])); $this->assertIsFluent($embeddedBuilder->build()); - $this->assertEquals( + self::assertEquals( [ 'class' => Name::class, 'columnPrefix' => null, @@ -109,11 +109,11 @@ public function testCreateEmbeddedWithColumnPrefix(): void { $embeddedBuilder = $this->builder->createEmbedded('name', Name::class); - $this->assertEquals($embeddedBuilder, $embeddedBuilder->setColumnPrefix('nm_')); + self::assertEquals($embeddedBuilder, $embeddedBuilder->setColumnPrefix('nm_')); $this->assertIsFluent($embeddedBuilder->build()); - $this->assertEquals( + self::assertEquals( [ 'class' => Name::class, 'columnPrefix' => 'nm_', @@ -127,31 +127,31 @@ public function testCreateEmbeddedWithColumnPrefix(): void public function testSetCustomRepositoryClass(): void { $this->assertIsFluent($this->builder->setCustomRepositoryClass(CmsGroup::class)); - $this->assertEquals(CmsGroup::class, $this->cm->customRepositoryClassName); + self::assertEquals(CmsGroup::class, $this->cm->customRepositoryClassName); } public function testSetReadOnly(): void { $this->assertIsFluent($this->builder->setReadOnly()); - $this->assertTrue($this->cm->isReadOnly); + self::assertTrue($this->cm->isReadOnly); } public function testSetTable(): void { $this->assertIsFluent($this->builder->setTable('users')); - $this->assertEquals('users', $this->cm->table['name']); + self::assertEquals('users', $this->cm->table['name']); } public function testAddIndex(): void { $this->assertIsFluent($this->builder->addIndex(['username', 'name'], 'users_idx')); - $this->assertEquals(['users_idx' => ['columns' => ['username', 'name']]], $this->cm->table['indexes']); + self::assertEquals(['users_idx' => ['columns' => ['username', 'name']]], $this->cm->table['indexes']); } public function testAddUniqueConstraint(): void { $this->assertIsFluent($this->builder->addUniqueConstraint(['username', 'name'], 'users_idx')); - $this->assertEquals(['users_idx' => ['columns' => ['username', 'name']]], $this->cm->table['uniqueConstraints']); + self::assertEquals(['users_idx' => ['columns' => ['username', 'name']]], $this->cm->table['uniqueConstraints']); } public function testSetPrimaryTableRelated(): void @@ -160,7 +160,7 @@ public function testSetPrimaryTableRelated(): void $this->builder->addIndex(['username', 'name'], 'users_idx'); $this->builder->setTable('users'); - $this->assertEquals( + self::assertEquals( [ 'name' => 'users', 'indexes' => ['users_idx' => ['columns' => ['username', 'name']]], @@ -173,19 +173,19 @@ public function testSetPrimaryTableRelated(): void public function testSetInheritanceJoined(): void { $this->assertIsFluent($this->builder->setJoinedTableInheritance()); - $this->assertEquals(ClassMetadata::INHERITANCE_TYPE_JOINED, $this->cm->inheritanceType); + self::assertEquals(ClassMetadata::INHERITANCE_TYPE_JOINED, $this->cm->inheritanceType); } public function testSetInheritanceSingleTable(): void { $this->assertIsFluent($this->builder->setSingleTableInheritance()); - $this->assertEquals(ClassMetadata::INHERITANCE_TYPE_SINGLE_TABLE, $this->cm->inheritanceType); + self::assertEquals(ClassMetadata::INHERITANCE_TYPE_SINGLE_TABLE, $this->cm->inheritanceType); } public function testSetDiscriminatorColumn(): void { $this->assertIsFluent($this->builder->setDiscriminatorColumn('discr', 'string', '124')); - $this->assertEquals(['fieldName' => 'discr', 'name' => 'discr', 'type' => 'string', 'length' => '124'], $this->cm->discriminatorColumn); + self::assertEquals(['fieldName' => 'discr', 'name' => 'discr', 'type' => 'string', 'length' => '124'], $this->cm->discriminatorColumn); } public function testAddDiscriminatorMapClass(): void @@ -193,45 +193,45 @@ public function testAddDiscriminatorMapClass(): void $this->assertIsFluent($this->builder->addDiscriminatorMapClass('test', CmsUser::class)); $this->assertIsFluent($this->builder->addDiscriminatorMapClass('test2', CmsGroup::class)); - $this->assertEquals( + self::assertEquals( ['test' => CmsUser::class, 'test2' => CmsGroup::class], $this->cm->discriminatorMap ); - $this->assertEquals('test', $this->cm->discriminatorValue); + self::assertEquals('test', $this->cm->discriminatorValue); } public function testChangeTrackingPolicyExplicit(): void { $this->assertIsFluent($this->builder->setChangeTrackingPolicyDeferredExplicit()); - $this->assertEquals(ClassMetadata::CHANGETRACKING_DEFERRED_EXPLICIT, $this->cm->changeTrackingPolicy); + self::assertEquals(ClassMetadata::CHANGETRACKING_DEFERRED_EXPLICIT, $this->cm->changeTrackingPolicy); } public function testChangeTrackingPolicyNotify(): void { $this->assertIsFluent($this->builder->setChangeTrackingPolicyNotify()); - $this->assertEquals(ClassMetadata::CHANGETRACKING_NOTIFY, $this->cm->changeTrackingPolicy); + self::assertEquals(ClassMetadata::CHANGETRACKING_NOTIFY, $this->cm->changeTrackingPolicy); } public function testAddField(): void { $this->assertIsFluent($this->builder->addField('name', 'string')); - $this->assertEquals(['columnName' => 'name', 'fieldName' => 'name', 'type' => 'string'], $this->cm->fieldMappings['name']); + self::assertEquals(['columnName' => 'name', 'fieldName' => 'name', 'type' => 'string'], $this->cm->fieldMappings['name']); } public function testCreateField(): void { $fieldBuilder = $this->builder->createField('name', 'string'); - $this->assertInstanceOf(FieldBuilder::class, $fieldBuilder); + self::assertInstanceOf(FieldBuilder::class, $fieldBuilder); - $this->assertFalse(isset($this->cm->fieldMappings['name'])); + self::assertFalse(isset($this->cm->fieldMappings['name'])); $this->assertIsFluent($fieldBuilder->build()); - $this->assertEquals(['columnName' => 'name', 'fieldName' => 'name', 'type' => 'string'], $this->cm->fieldMappings['name']); + self::assertEquals(['columnName' => 'name', 'fieldName' => 'name', 'type' => 'string'], $this->cm->fieldMappings['name']); } public function testCreateVersionedField(): void { $this->builder->createField('name', 'integer')->columnName('username')->length(124)->nullable()->columnDefinition('foobar')->unique()->isVersionField()->build(); - $this->assertEquals( + self::assertEquals( [ 'columnDefinition' => 'foobar', 'columnName' => 'username', @@ -250,15 +250,15 @@ public function testCreatePrimaryField(): void { $this->builder->createField('id', 'integer')->makePrimaryKey()->generatedValue()->build(); - $this->assertEquals(['id'], $this->cm->identifier); - $this->assertEquals(['columnName' => 'id', 'fieldName' => 'id', 'id' => true, 'type' => 'integer'], $this->cm->fieldMappings['id']); + self::assertEquals(['id'], $this->cm->identifier); + self::assertEquals(['columnName' => 'id', 'fieldName' => 'id', 'id' => true, 'type' => 'integer'], $this->cm->fieldMappings['id']); } public function testCreateUnsignedOptionField(): void { $this->builder->createField('state', 'integer')->option('unsigned', true)->build(); - $this->assertEquals( + self::assertEquals( ['fieldName' => 'state', 'type' => 'integer', 'options' => ['unsigned' => true], 'columnName' => 'state'], $this->cm->fieldMappings['state'] ); @@ -268,7 +268,7 @@ public function testAddLifecycleEvent(): void { $this->builder->addLifecycleEvent('getStatus', 'postLoad'); - $this->assertEquals(['postLoad' => ['getStatus']], $this->cm->lifecycleCallbacks); + self::assertEquals(['postLoad' => ['getStatus']], $this->cm->lifecycleCallbacks); } public function testCreateManyToOne(): void @@ -281,7 +281,7 @@ public function testCreateManyToOne(): void ->build() ); - $this->assertEquals( + self::assertEquals( [ 'groups' => [ 'fieldName' => 'groups', @@ -341,7 +341,7 @@ public function testCreateManyToOneWithIdentity(): void ->build() ); - $this->assertEquals( + self::assertEquals( [ 'groups' => [ 'fieldName' => 'groups', @@ -399,7 +399,7 @@ public function testCreateOneToOne(): void ->build() ); - $this->assertEquals( + self::assertEquals( [ 'groups' => [ 'fieldName' => 'groups', @@ -459,7 +459,7 @@ public function testCreateOneToOneWithIdentity(): void ->build() ); - $this->assertEquals( + self::assertEquals( [ 'groups' => [ 'fieldName' => 'groups', @@ -532,7 +532,7 @@ public function testCreateManyToMany(): void ->build() ); - $this->assertEquals( + self::assertEquals( [ 'groups' => [ @@ -626,7 +626,7 @@ public function testCreateOneToMany(): void ->build() ); - $this->assertEquals( + self::assertEquals( [ 'groups' => [ @@ -677,7 +677,7 @@ public function testOrphanRemovalOnCreateOneToOne(): void ->build() ); - $this->assertEquals( + self::assertEquals( [ 'groups' => [ 'fieldName' => 'groups', @@ -728,7 +728,7 @@ public function testOrphanRemovalOnCreateOneToMany(): void ->build() ); - $this->assertEquals( + self::assertEquals( [ 'groups' => [ @@ -772,7 +772,7 @@ public function testOrphanRemovalOnManyToMany(): void ->orphanRemoval() ->build(); - $this->assertEquals( + self::assertEquals( [ 'groups' => [ 'fieldName' => 'groups', @@ -825,6 +825,6 @@ public function testOrphanRemovalOnManyToMany(): void public function assertIsFluent($ret): void { - $this->assertSame($this->builder, $ret, 'Return Value has to be same instance as used builder'); + self::assertSame($this->builder, $ret, 'Return Value has to be same instance as used builder'); } } diff --git a/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataFactoryTest.php b/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataFactoryTest.php index 28d3d6f5115..a1b6e756d63 100644 --- a/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataFactoryTest.php +++ b/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataFactoryTest.php @@ -70,21 +70,21 @@ public function testGetMetadataForSingleClass(): void $cmf->setMetadataFor($cm1->name, $cm1); // Prechecks - $this->assertEquals([], $cm1->parentClasses); - $this->assertEquals(ClassMetadata::INHERITANCE_TYPE_NONE, $cm1->inheritanceType); - $this->assertTrue($cm1->hasField('name')); - $this->assertEquals(2, count($cm1->associationMappings)); - $this->assertEquals(ClassMetadata::GENERATOR_TYPE_AUTO, $cm1->generatorType); - $this->assertEquals('group', $cm1->table['name']); + self::assertEquals([], $cm1->parentClasses); + self::assertEquals(ClassMetadata::INHERITANCE_TYPE_NONE, $cm1->inheritanceType); + self::assertTrue($cm1->hasField('name')); + self::assertEquals(2, count($cm1->associationMappings)); + self::assertEquals(ClassMetadata::GENERATOR_TYPE_AUTO, $cm1->generatorType); + self::assertEquals('group', $cm1->table['name']); // Go $cmMap1 = $cmf->getMetadataFor($cm1->name); - $this->assertSame($cm1, $cmMap1); - $this->assertEquals('group', $cmMap1->table['name']); - $this->assertTrue($cmMap1->table['quoted']); - $this->assertEquals([], $cmMap1->parentClasses); - $this->assertTrue($cmMap1->hasField('name')); + self::assertSame($cm1, $cmMap1); + self::assertEquals('group', $cmMap1->table['name']); + self::assertTrue($cmMap1->table['quoted']); + self::assertEquals([], $cmMap1->parentClasses); + self::assertTrue($cmMap1->hasField('name')); } public function testGetMetadataForReturnsLoadedCustomIdGenerator(): void @@ -97,8 +97,8 @@ public function testGetMetadataForReturnsLoadedCustomIdGenerator(): void $actual = $cmf->getMetadataFor($cm1->name); - $this->assertEquals(ClassMetadata::GENERATOR_TYPE_CUSTOM, $actual->generatorType); - $this->assertInstanceOf(CustomIdGenerator::class, $actual->idGenerator); + self::assertEquals(ClassMetadata::GENERATOR_TYPE_CUSTOM, $actual->generatorType); + self::assertInstanceOf(CustomIdGenerator::class, $actual->idGenerator); } public function testGetMetadataForThrowsExceptionOnUnknownCustomGeneratorClass(): void @@ -138,9 +138,9 @@ public function testHasGetMetadataNamespaceSeparatorIsNotNormalized(): void $h2 = $mf->hasMetadataFor('\\' . DoctrineGlobalArticle::class); $m2 = $mf->getMetadataFor('\\' . DoctrineGlobalArticle::class); - $this->assertNotSame($m1, $m2); - $this->assertFalse($h2); - $this->assertTrue($h1); + self::assertNotSame($m1, $m2); + self::assertFalse($h2); + self::assertTrue($h1); } /** @@ -150,7 +150,7 @@ public function testIsTransient(): void { $cmf = new ClassMetadataFactory(); $driver = $this->createMock(MappingDriver::class); - $driver->expects($this->exactly(2)) + $driver->expects(self::exactly(2)) ->method('isTransient') ->withConsecutive( [CmsUser::class], @@ -165,8 +165,8 @@ public function testIsTransient(): void $em = $this->createEntityManager($driver); - $this->assertTrue($em->getMetadataFactory()->isTransient(CmsUser::class)); - $this->assertFalse($em->getMetadataFactory()->isTransient(CmsArticle::class)); + self::assertTrue($em->getMetadataFactory()->isTransient(CmsUser::class)); + self::assertFalse($em->getMetadataFactory()->isTransient(CmsArticle::class)); } /** @@ -176,7 +176,7 @@ public function testIsTransientEntityNamespace(): void { $cmf = new ClassMetadataFactory(); $driver = $this->createMock(MappingDriver::class); - $driver->expects($this->exactly(2)) + $driver->expects(self::exactly(2)) ->method('isTransient') ->withConsecutive( [CmsUser::class], @@ -192,8 +192,8 @@ public function testIsTransientEntityNamespace(): void $em = $this->createEntityManager($driver); $em->getConfiguration()->addEntityNamespace('CMS', 'Doctrine\Tests\Models\CMS'); - $this->assertTrue($em->getMetadataFactory()->isTransient('CMS:CmsUser')); - $this->assertFalse($em->getMetadataFactory()->isTransient('CMS:CmsArticle')); + self::assertTrue($em->getMetadataFactory()->isTransient('CMS:CmsUser')); + self::assertFalse($em->getMetadataFactory()->isTransient('CMS:CmsArticle')); } public function testAddDefaultDiscriminatorMap(): void @@ -220,18 +220,18 @@ public function testAddDefaultDiscriminatorMap(): void $childClassKey = array_search($childClass, $rootDiscriminatorMap, true); $anotherChildClassKey = array_search($anotherChildClass, $rootDiscriminatorMap, true); - $this->assertEquals('rootclass', $rootClassKey); - $this->assertEquals('childclass', $childClassKey); - $this->assertEquals('anotherchildclass', $anotherChildClassKey); + self::assertEquals('rootclass', $rootClassKey); + self::assertEquals('childclass', $childClassKey); + self::assertEquals('anotherchildclass', $anotherChildClassKey); - $this->assertEquals($childDiscriminatorMap, $rootDiscriminatorMap); - $this->assertEquals($anotherChildDiscriminatorMap, $rootDiscriminatorMap); + self::assertEquals($childDiscriminatorMap, $rootDiscriminatorMap); + self::assertEquals($anotherChildDiscriminatorMap, $rootDiscriminatorMap); // ClassMetadataFactory::addDefaultDiscriminatorMap shouldn't be called again, because the // discriminator map is already cached $cmf = $this->getMockBuilder(ClassMetadataFactory::class)->setMethods(['addDefaultDiscriminatorMap'])->getMock(); $cmf->setEntityManager($em); - $cmf->expects($this->never()) + $cmf->expects(self::never()) ->method('addDefaultDiscriminatorMap'); $rootMetadata = $cmf->getMetadataFor(RootClass::class); @@ -244,9 +244,9 @@ public function testGetAllMetadataWorksWithBadConnection(): void $mockDriver = new MetadataDriverMock(); $em = $this->createEntityManager($mockDriver, $conn); - $conn->expects($this->any()) + $conn->expects(self::any()) ->method('getDatabasePlatform') - ->will($this->throwException(new Exception('Exception thrown in test when calling getDatabasePlatform'))); + ->will(self::throwException(new Exception('Exception thrown in test when calling getDatabasePlatform'))); $cmf = new ClassMetadataFactory(); $cmf->setEntityManager($em); @@ -254,7 +254,7 @@ public function testGetAllMetadataWorksWithBadConnection(): void // getting all the metadata should work, even if get DatabasePlatform blows up $metadata = $cmf->getAllMetadata(); // this will just be an empty array - there was no error - $this->assertEquals([], $metadata); + self::assertEquals([], $metadata); } protected function createEntityManager(MappingDriver $metadataDriver, $conn = null): EntityManagerMock @@ -324,60 +324,60 @@ public function testQuoteMetadata(): void $addressMetadata = $cmf->getMetadataFor(Quote\Address::class); // Phone Class Metadata - $this->assertTrue($phoneMetadata->fieldMappings['number']['quoted']); - $this->assertEquals('phone-number', $phoneMetadata->fieldMappings['number']['columnName']); + self::assertTrue($phoneMetadata->fieldMappings['number']['quoted']); + self::assertEquals('phone-number', $phoneMetadata->fieldMappings['number']['columnName']); $user = $phoneMetadata->associationMappings['user']; - $this->assertTrue($user['joinColumns'][0]['quoted']); - $this->assertEquals('user-id', $user['joinColumns'][0]['name']); - $this->assertEquals('user-id', $user['joinColumns'][0]['referencedColumnName']); + self::assertTrue($user['joinColumns'][0]['quoted']); + self::assertEquals('user-id', $user['joinColumns'][0]['name']); + self::assertEquals('user-id', $user['joinColumns'][0]['referencedColumnName']); // User Group Metadata - $this->assertTrue($groupMetadata->fieldMappings['id']['quoted']); - $this->assertTrue($groupMetadata->fieldMappings['name']['quoted']); + self::assertTrue($groupMetadata->fieldMappings['id']['quoted']); + self::assertTrue($groupMetadata->fieldMappings['name']['quoted']); - $this->assertEquals('user-id', $userMetadata->fieldMappings['id']['columnName']); - $this->assertEquals('user-name', $userMetadata->fieldMappings['name']['columnName']); + self::assertEquals('user-id', $userMetadata->fieldMappings['id']['columnName']); + self::assertEquals('user-name', $userMetadata->fieldMappings['name']['columnName']); $user = $groupMetadata->associationMappings['parent']; - $this->assertTrue($user['joinColumns'][0]['quoted']); - $this->assertEquals('parent-id', $user['joinColumns'][0]['name']); - $this->assertEquals('group-id', $user['joinColumns'][0]['referencedColumnName']); + self::assertTrue($user['joinColumns'][0]['quoted']); + self::assertEquals('parent-id', $user['joinColumns'][0]['name']); + self::assertEquals('group-id', $user['joinColumns'][0]['referencedColumnName']); // Address Class Metadata - $this->assertTrue($addressMetadata->fieldMappings['id']['quoted']); - $this->assertTrue($addressMetadata->fieldMappings['zip']['quoted']); + self::assertTrue($addressMetadata->fieldMappings['id']['quoted']); + self::assertTrue($addressMetadata->fieldMappings['zip']['quoted']); - $this->assertEquals('address-id', $addressMetadata->fieldMappings['id']['columnName']); - $this->assertEquals('address-zip', $addressMetadata->fieldMappings['zip']['columnName']); + self::assertEquals('address-id', $addressMetadata->fieldMappings['id']['columnName']); + self::assertEquals('address-zip', $addressMetadata->fieldMappings['zip']['columnName']); $user = $addressMetadata->associationMappings['user']; - $this->assertTrue($user['joinColumns'][0]['quoted']); - $this->assertEquals('user-id', $user['joinColumns'][0]['name']); - $this->assertEquals('user-id', $user['joinColumns'][0]['referencedColumnName']); + self::assertTrue($user['joinColumns'][0]['quoted']); + self::assertEquals('user-id', $user['joinColumns'][0]['name']); + self::assertEquals('user-id', $user['joinColumns'][0]['referencedColumnName']); // User Class Metadata - $this->assertTrue($userMetadata->fieldMappings['id']['quoted']); - $this->assertTrue($userMetadata->fieldMappings['name']['quoted']); + self::assertTrue($userMetadata->fieldMappings['id']['quoted']); + self::assertTrue($userMetadata->fieldMappings['name']['quoted']); - $this->assertEquals('user-id', $userMetadata->fieldMappings['id']['columnName']); - $this->assertEquals('user-name', $userMetadata->fieldMappings['name']['columnName']); + self::assertEquals('user-id', $userMetadata->fieldMappings['id']['columnName']); + self::assertEquals('user-name', $userMetadata->fieldMappings['name']['columnName']); $address = $userMetadata->associationMappings['address']; - $this->assertTrue($address['joinColumns'][0]['quoted']); - $this->assertEquals('address-id', $address['joinColumns'][0]['name']); - $this->assertEquals('address-id', $address['joinColumns'][0]['referencedColumnName']); + self::assertTrue($address['joinColumns'][0]['quoted']); + self::assertEquals('address-id', $address['joinColumns'][0]['name']); + self::assertEquals('address-id', $address['joinColumns'][0]['referencedColumnName']); $groups = $userMetadata->associationMappings['groups']; - $this->assertTrue($groups['joinTable']['quoted']); - $this->assertTrue($groups['joinTable']['joinColumns'][0]['quoted']); - $this->assertEquals('quote-users-groups', $groups['joinTable']['name']); - $this->assertEquals('user-id', $groups['joinTable']['joinColumns'][0]['name']); - $this->assertEquals('user-id', $groups['joinTable']['joinColumns'][0]['referencedColumnName']); - - $this->assertTrue($groups['joinTable']['inverseJoinColumns'][0]['quoted']); - $this->assertEquals('group-id', $groups['joinTable']['inverseJoinColumns'][0]['name']); - $this->assertEquals('group-id', $groups['joinTable']['inverseJoinColumns'][0]['referencedColumnName']); + self::assertTrue($groups['joinTable']['quoted']); + self::assertTrue($groups['joinTable']['joinColumns'][0]['quoted']); + self::assertEquals('quote-users-groups', $groups['joinTable']['name']); + self::assertEquals('user-id', $groups['joinTable']['joinColumns'][0]['name']); + self::assertEquals('user-id', $groups['joinTable']['joinColumns'][0]['referencedColumnName']); + + self::assertTrue($groups['joinTable']['inverseJoinColumns'][0]['quoted']); + self::assertEquals('group-id', $groups['joinTable']['inverseJoinColumns'][0]['name']); + self::assertEquals('group-id', $groups['joinTable']['inverseJoinColumns'][0]['referencedColumnName']); } /** @@ -399,9 +399,9 @@ public function testFallbackLoadingCausesEventTriggeringThatCanModifyFetchedMeta $cmf->setEntityManager($em); $listener - ->expects($this->any()) + ->expects(self::any()) ->method('onClassMetadataNotFound') - ->will($this->returnCallback(static function (OnClassMetadataNotFoundEventArgs $args) use ($metadata, $em): void { + ->will(self::returnCallback(static function (OnClassMetadataNotFoundEventArgs $args) use ($metadata, $em): void { self::assertNull($args->getFoundMetadata()); self::assertSame('Foo', $args->getClassName()); self::assertSame($em, $args->getObjectManager()); @@ -411,7 +411,7 @@ public function testFallbackLoadingCausesEventTriggeringThatCanModifyFetchedMeta $eventManager->addEventListener([Events::onClassMetadataNotFound], $listener); - $this->assertSame($metadata, $cmf->getMetadataFor('Foo')); + self::assertSame($metadata, $cmf->getMetadataFor('Foo')); } /** @@ -428,7 +428,7 @@ public function testAcceptsEntityManagerInterfaceInstances(): void $class = new ReflectionClass(ClassMetadataFactory::class); $property = $class->getProperty('em'); $property->setAccessible(true); - $this->assertSame($entityManager, $property->getValue($classMetadataFactory)); + self::assertSame($entityManager, $property->getValue($classMetadataFactory)); } /** @@ -468,7 +468,7 @@ public function testInheritsIdGeneratorMappingFromEmbeddable(): void $userMetadata = $cmf->getMetadataFor(DDC4006User::class); - $this->assertTrue($userMetadata->isIdGeneratorIdentity()); + self::assertTrue($userMetadata->isIdGeneratorIdentity()); } public function testInvalidSubClassCase(): void diff --git a/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataLoadEventTest.php b/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataLoadEventTest.php index 5036981e95e..c3b3ec43bd9 100644 --- a/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataLoadEventTest.php +++ b/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataLoadEventTest.php @@ -25,9 +25,9 @@ public function testEvent(): void $evm = $em->getEventManager(); $evm->addEventListener(Events::loadClassMetadata, $this); $classMetadata = $metadataFactory->getMetadataFor(LoadEventTestEntity::class); - $this->assertTrue($classMetadata->hasField('about')); - $this->assertArrayHasKey('about', $classMetadata->reflFields); - $this->assertInstanceOf('ReflectionProperty', $classMetadata->reflFields['about']); + self::assertTrue($classMetadata->hasField('about')); + self::assertArrayHasKey('about', $classMetadata->reflFields); + self::assertInstanceOf('ReflectionProperty', $classMetadata->reflFields['about']); } public function loadClassMetadata(LoadClassMetadataEventArgs $eventArgs): void diff --git a/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataTest.php b/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataTest.php index 900790fa182..309de6304bf 100644 --- a/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataTest.php +++ b/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataTest.php @@ -52,13 +52,13 @@ public function testClassMetadataInstanceSerialization(): void $cm->initializeReflection(new RuntimeReflectionService()); // Test initial state - $this->assertTrue(count($cm->getReflectionProperties()) === 0); - $this->assertInstanceOf('ReflectionClass', $cm->reflClass); - $this->assertEquals(CMS\CmsUser::class, $cm->name); - $this->assertEquals(CMS\CmsUser::class, $cm->rootEntityName); - $this->assertEquals([], $cm->subClasses); - $this->assertEquals([], $cm->parentClasses); - $this->assertEquals(ClassMetadata::INHERITANCE_TYPE_NONE, $cm->inheritanceType); + self::assertTrue(count($cm->getReflectionProperties()) === 0); + self::assertInstanceOf('ReflectionClass', $cm->reflClass); + self::assertEquals(CMS\CmsUser::class, $cm->name); + self::assertEquals(CMS\CmsUser::class, $cm->rootEntityName); + self::assertEquals([], $cm->subClasses); + self::assertEquals([], $cm->parentClasses); + self::assertEquals(ClassMetadata::INHERITANCE_TYPE_NONE, $cm->inheritanceType); // Customize state $cm->setInheritanceType(ClassMetadata::INHERITANCE_TYPE_SINGLE_TABLE); @@ -69,30 +69,30 @@ public function testClassMetadataInstanceSerialization(): void $cm->mapOneToOne(['fieldName' => 'phonenumbers', 'targetEntity' => 'CmsAddress', 'mappedBy' => 'foo']); $cm->markReadOnly(); $cm->addNamedQuery(['name' => 'dql', 'query' => 'foo']); - $this->assertEquals(1, count($cm->associationMappings)); + self::assertEquals(1, count($cm->associationMappings)); $serialized = serialize($cm); $cm = unserialize($serialized); $cm->wakeupReflection(new RuntimeReflectionService()); // Check state - $this->assertTrue(count($cm->getReflectionProperties()) > 0); - $this->assertEquals('Doctrine\Tests\Models\CMS', $cm->namespace); - $this->assertInstanceOf(ReflectionClass::class, $cm->reflClass); - $this->assertEquals(CMS\CmsUser::class, $cm->name); - $this->assertEquals('UserParent', $cm->rootEntityName); - $this->assertEquals([CMS\One::class, CMS\Two::class, CMS\Three::class], $cm->subClasses); - $this->assertEquals(['UserParent'], $cm->parentClasses); - $this->assertEquals(CMS\UserRepository::class, $cm->customRepositoryClassName); - $this->assertEquals(['name' => 'disc', 'type' => 'integer', 'fieldName' => 'disc'], $cm->discriminatorColumn); - $this->assertTrue($cm->associationMappings['phonenumbers']['type'] === ClassMetadata::ONE_TO_ONE); - $this->assertEquals(1, count($cm->associationMappings)); + self::assertTrue(count($cm->getReflectionProperties()) > 0); + self::assertEquals('Doctrine\Tests\Models\CMS', $cm->namespace); + self::assertInstanceOf(ReflectionClass::class, $cm->reflClass); + self::assertEquals(CMS\CmsUser::class, $cm->name); + self::assertEquals('UserParent', $cm->rootEntityName); + self::assertEquals([CMS\One::class, CMS\Two::class, CMS\Three::class], $cm->subClasses); + self::assertEquals(['UserParent'], $cm->parentClasses); + self::assertEquals(CMS\UserRepository::class, $cm->customRepositoryClassName); + self::assertEquals(['name' => 'disc', 'type' => 'integer', 'fieldName' => 'disc'], $cm->discriminatorColumn); + self::assertTrue($cm->associationMappings['phonenumbers']['type'] === ClassMetadata::ONE_TO_ONE); + self::assertEquals(1, count($cm->associationMappings)); $oneOneMapping = $cm->getAssociationMapping('phonenumbers'); - $this->assertTrue($oneOneMapping['fetch'] === ClassMetadata::FETCH_LAZY); - $this->assertEquals('phonenumbers', $oneOneMapping['fieldName']); - $this->assertEquals(CMS\CmsAddress::class, $oneOneMapping['targetEntity']); - $this->assertTrue($cm->isReadOnly); - $this->assertEquals(['dql' => ['name' => 'dql', 'query' => 'foo', 'dql' => 'foo']], $cm->namedQueries); + self::assertTrue($oneOneMapping['fetch'] === ClassMetadata::FETCH_LAZY); + self::assertEquals('phonenumbers', $oneOneMapping['fieldName']); + self::assertEquals(CMS\CmsAddress::class, $oneOneMapping['targetEntity']); + self::assertTrue($cm->isReadOnly); + self::assertEquals(['dql' => ['name' => 'dql', 'query' => 'foo', 'dql' => 'foo']], $cm->namedQueries); } public function testFieldIsNullable(): void @@ -102,40 +102,40 @@ public function testFieldIsNullable(): void // Explicit Nullable $cm->mapField(['fieldName' => 'status', 'nullable' => true, 'type' => 'string', 'length' => 50]); - $this->assertTrue($cm->isNullable('status')); + self::assertTrue($cm->isNullable('status')); // Explicit Not Nullable $cm->mapField(['fieldName' => 'username', 'nullable' => false, 'type' => 'string', 'length' => 50]); - $this->assertFalse($cm->isNullable('username')); + self::assertFalse($cm->isNullable('username')); // Implicit Not Nullable $cm->mapField(['fieldName' => 'name', 'type' => 'string', 'length' => 50]); - $this->assertFalse($cm->isNullable('name'), 'By default a field should not be nullable.'); + self::assertFalse($cm->isNullable('name'), 'By default a field should not be nullable.'); } public function testFieldIsNullableByType(): void { if (PHP_VERSION_ID < 70400) { - $this->markTestSkipped('requies PHP 7.4'); + self::markTestSkipped('requies PHP 7.4'); } $cm = new ClassMetadata(TypedProperties\UserTyped::class); $cm->initializeReflection(new RuntimeReflectionService()); $cm->mapOneToOne(['fieldName' => 'email', 'joinColumns' => [[]]]); - $this->assertEquals(CmsEmail::class, $cm->getAssociationMapping('email')['targetEntity']); + self::assertEquals(CmsEmail::class, $cm->getAssociationMapping('email')['targetEntity']); $cm->mapManyToOne(['fieldName' => 'mainEmail']); - $this->assertEquals(CmsEmail::class, $cm->getAssociationMapping('mainEmail')['targetEntity']); + self::assertEquals(CmsEmail::class, $cm->getAssociationMapping('mainEmail')['targetEntity']); $cm->mapEmbedded(['fieldName' => 'contact']); - $this->assertEquals(TypedProperties\Contact::class, $cm->embeddedClasses['contact']['class']); + self::assertEquals(TypedProperties\Contact::class, $cm->embeddedClasses['contact']['class']); } public function testFieldTypeFromReflection(): void { if (PHP_VERSION_ID < 70400) { - $this->markTestSkipped('requies PHP 7.4'); + self::markTestSkipped('requies PHP 7.4'); } $cm = new ClassMetadata(TypedProperties\UserTyped::class); @@ -143,35 +143,35 @@ public function testFieldTypeFromReflection(): void // Integer $cm->mapField(['fieldName' => 'id']); - $this->assertEquals('integer', $cm->getTypeOfField('id')); + self::assertEquals('integer', $cm->getTypeOfField('id')); // String $cm->mapField(['fieldName' => 'username', 'length' => 50]); - $this->assertEquals('string', $cm->getTypeOfField('username')); + self::assertEquals('string', $cm->getTypeOfField('username')); // DateInterval object $cm->mapField(['fieldName' => 'dateInterval']); - $this->assertEquals('dateinterval', $cm->getTypeOfField('dateInterval')); + self::assertEquals('dateinterval', $cm->getTypeOfField('dateInterval')); // DateTime object $cm->mapField(['fieldName' => 'dateTime']); - $this->assertEquals('datetime', $cm->getTypeOfField('dateTime')); + self::assertEquals('datetime', $cm->getTypeOfField('dateTime')); // DateTimeImmutable object $cm->mapField(['fieldName' => 'dateTimeImmutable']); - $this->assertEquals('datetime_immutable', $cm->getTypeOfField('dateTimeImmutable')); + self::assertEquals('datetime_immutable', $cm->getTypeOfField('dateTimeImmutable')); // array as JSON $cm->mapField(['fieldName' => 'array']); - $this->assertEquals('json', $cm->getTypeOfField('array')); + self::assertEquals('json', $cm->getTypeOfField('array')); // bool $cm->mapField(['fieldName' => 'boolean']); - $this->assertEquals('boolean', $cm->getTypeOfField('boolean')); + self::assertEquals('boolean', $cm->getTypeOfField('boolean')); // float $cm->mapField(['fieldName' => 'float']); - $this->assertEquals('float', $cm->getTypeOfField('float')); + self::assertEquals('float', $cm->getTypeOfField('float')); } /** @@ -195,7 +195,7 @@ public function testMapAssociationInGlobalNamespace(): void ] ); - $this->assertEquals('DoctrineGlobalUser', $cm->associationMappings['author']['targetEntity']); + self::assertEquals('DoctrineGlobalUser', $cm->associationMappings['author']['targetEntity']); } public function testMapManyToManyJoinTableDefaults(): void @@ -210,7 +210,7 @@ public function testMapManyToManyJoinTableDefaults(): void ); $assoc = $cm->associationMappings['groups']; - $this->assertEquals( + self::assertEquals( [ 'name' => 'cmsuser_cmsgroup', 'joinColumns' => [['name' => 'cmsuser_id', 'referencedColumnName' => 'id', 'onDelete' => 'CASCADE']], @@ -218,7 +218,7 @@ public function testMapManyToManyJoinTableDefaults(): void ], $assoc['joinTable'] ); - $this->assertTrue($assoc['isOnDeleteCascade']); + self::assertTrue($assoc['isOnDeleteCascade']); } public function testSerializeManyToManyJoinTableCascade(): void @@ -235,7 +235,7 @@ public function testSerializeManyToManyJoinTableCascade(): void $assoc = $cm->associationMappings['groups']; $assoc = unserialize(serialize($assoc)); - $this->assertTrue($assoc['isOnDeleteCascade']); + self::assertTrue($assoc['isOnDeleteCascade']); } /** @@ -249,8 +249,8 @@ public function testSetDiscriminatorMapInGlobalNamespace(): void $cm->initializeReflection(new RuntimeReflectionService()); $cm->setDiscriminatorMap(['descr' => 'DoctrineGlobalArticle', 'foo' => 'DoctrineGlobalUser']); - $this->assertEquals('DoctrineGlobalArticle', $cm->discriminatorMap['descr']); - $this->assertEquals('DoctrineGlobalUser', $cm->discriminatorMap['foo']); + self::assertEquals('DoctrineGlobalArticle', $cm->discriminatorMap['descr']); + self::assertEquals('DoctrineGlobalUser', $cm->discriminatorMap['foo']); } /** @@ -264,7 +264,7 @@ public function testSetSubClassesInGlobalNamespace(): void $cm->initializeReflection(new RuntimeReflectionService()); $cm->setSubclasses(['DoctrineGlobalArticle']); - $this->assertEquals('DoctrineGlobalArticle', $cm->subClasses[0]); + self::assertEquals('DoctrineGlobalArticle', $cm->subClasses[0]); } /** @@ -380,7 +380,7 @@ public function testGetTemporaryTableNameSchema(): void $cm->setTableName('foo.bar'); - $this->assertEquals('foo_bar_id_tmp', $cm->getTemporaryIdTableName()); + self::assertEquals('foo_bar_id_tmp', $cm->getTemporaryIdTableName()); } public function testDefaultTableName(): void @@ -392,8 +392,8 @@ public function testDefaultTableName(): void $primaryTable = []; $cm->setPrimaryTable($primaryTable); - $this->assertEquals('CmsUser', $cm->getTableName()); - $this->assertEquals('CmsUser', $cm->table['name']); + self::assertEquals('CmsUser', $cm->getTableName()); + self::assertEquals('CmsUser', $cm->table['name']); $cm = new ClassMetadata(CMS\CmsAddress::class); $cm->initializeReflection(new RuntimeReflectionService()); @@ -409,7 +409,7 @@ public function testDefaultTableName(): void ], ] ); - $this->assertEquals('cmsaddress_cmsuser', $cm->associationMappings['user']['joinTable']['name']); + self::assertEquals('cmsaddress_cmsuser', $cm->associationMappings['user']['joinTable']['name']); } public function testDefaultJoinColumnName(): void @@ -426,7 +426,7 @@ public function testDefaultJoinColumnName(): void 'joinColumns' => [['referencedColumnName' => 'id']], ] ); - $this->assertEquals('user_id', $cm->associationMappings['user']['joinColumns'][0]['name']); + self::assertEquals('user_id', $cm->associationMappings['user']['joinColumns'][0]['name']); $cm = new ClassMetadata(CMS\CmsAddress::class); $cm->initializeReflection(new RuntimeReflectionService()); @@ -442,8 +442,8 @@ public function testDefaultJoinColumnName(): void ], ] ); - $this->assertEquals('cmsaddress_id', $cm->associationMappings['user']['joinTable']['joinColumns'][0]['name']); - $this->assertEquals('cmsuser_id', $cm->associationMappings['user']['joinTable']['inverseJoinColumns'][0]['name']); + self::assertEquals('cmsaddress_id', $cm->associationMappings['user']['joinTable']['joinColumns'][0]['name']); + self::assertEquals('cmsuser_id', $cm->associationMappings['user']['joinTable']['inverseJoinColumns'][0]['name']); } /** @@ -469,28 +469,28 @@ public function testUnderscoreNamingStrategyDefaults(): void ] ); - $this->assertEquals(['USER_ID' => 'ID'], $oneToOneMetadata->associationMappings['user']['sourceToTargetKeyColumns']); - $this->assertEquals(['USER_ID' => 'USER_ID'], $oneToOneMetadata->associationMappings['user']['joinColumnFieldNames']); - $this->assertEquals(['ID' => 'USER_ID'], $oneToOneMetadata->associationMappings['user']['targetToSourceKeyColumns']); + self::assertEquals(['USER_ID' => 'ID'], $oneToOneMetadata->associationMappings['user']['sourceToTargetKeyColumns']); + self::assertEquals(['USER_ID' => 'USER_ID'], $oneToOneMetadata->associationMappings['user']['joinColumnFieldNames']); + self::assertEquals(['ID' => 'USER_ID'], $oneToOneMetadata->associationMappings['user']['targetToSourceKeyColumns']); - $this->assertEquals('USER_ID', $oneToOneMetadata->associationMappings['user']['joinColumns'][0]['name']); - $this->assertEquals('ID', $oneToOneMetadata->associationMappings['user']['joinColumns'][0]['referencedColumnName']); + self::assertEquals('USER_ID', $oneToOneMetadata->associationMappings['user']['joinColumns'][0]['name']); + self::assertEquals('ID', $oneToOneMetadata->associationMappings['user']['joinColumns'][0]['referencedColumnName']); - $this->assertEquals('CMS_ADDRESS_CMS_USER', $manyToManyMetadata->associationMappings['user']['joinTable']['name']); + self::assertEquals('CMS_ADDRESS_CMS_USER', $manyToManyMetadata->associationMappings['user']['joinTable']['name']); - $this->assertEquals(['CMS_ADDRESS_ID', 'CMS_USER_ID'], $manyToManyMetadata->associationMappings['user']['joinTableColumns']); - $this->assertEquals(['CMS_ADDRESS_ID' => 'ID'], $manyToManyMetadata->associationMappings['user']['relationToSourceKeyColumns']); - $this->assertEquals(['CMS_USER_ID' => 'ID'], $manyToManyMetadata->associationMappings['user']['relationToTargetKeyColumns']); + self::assertEquals(['CMS_ADDRESS_ID', 'CMS_USER_ID'], $manyToManyMetadata->associationMappings['user']['joinTableColumns']); + self::assertEquals(['CMS_ADDRESS_ID' => 'ID'], $manyToManyMetadata->associationMappings['user']['relationToSourceKeyColumns']); + self::assertEquals(['CMS_USER_ID' => 'ID'], $manyToManyMetadata->associationMappings['user']['relationToTargetKeyColumns']); - $this->assertEquals('CMS_ADDRESS_ID', $manyToManyMetadata->associationMappings['user']['joinTable']['joinColumns'][0]['name']); - $this->assertEquals('CMS_USER_ID', $manyToManyMetadata->associationMappings['user']['joinTable']['inverseJoinColumns'][0]['name']); + self::assertEquals('CMS_ADDRESS_ID', $manyToManyMetadata->associationMappings['user']['joinTable']['joinColumns'][0]['name']); + self::assertEquals('CMS_USER_ID', $manyToManyMetadata->associationMappings['user']['joinTable']['inverseJoinColumns'][0]['name']); - $this->assertEquals('ID', $manyToManyMetadata->associationMappings['user']['joinTable']['joinColumns'][0]['referencedColumnName']); - $this->assertEquals('ID', $manyToManyMetadata->associationMappings['user']['joinTable']['inverseJoinColumns'][0]['referencedColumnName']); + self::assertEquals('ID', $manyToManyMetadata->associationMappings['user']['joinTable']['joinColumns'][0]['referencedColumnName']); + self::assertEquals('ID', $manyToManyMetadata->associationMappings['user']['joinTable']['inverseJoinColumns'][0]['referencedColumnName']); $cm = new ClassMetadata('DoctrineGlobalArticle', $namingStrategy); $cm->mapManyToMany(['fieldName' => 'author', 'targetEntity' => CMS\CmsUser::class]); - $this->assertEquals('DOCTRINE_GLOBAL_ARTICLE_CMS_USER', $cm->associationMappings['author']['joinTable']['name']); + self::assertEquals('DOCTRINE_GLOBAL_ARTICLE_CMS_USER', $cm->associationMappings['author']['joinTable']['name']); } /** @@ -505,7 +505,7 @@ public function testSetMultipleIdentifierSetsComposite(): void $cm->mapField(['fieldName' => 'username']); $cm->setIdentifier(['name', 'username']); - $this->assertTrue($cm->isIdentifierComposite); + self::assertTrue($cm->isIdentifierComposite); } /** @@ -532,7 +532,7 @@ public function testJoinTableMappingDefaults(): void $cm->mapManyToMany(['fieldName' => 'author', 'targetEntity' => CMS\CmsUser::class]); - $this->assertEquals('doctrineglobalarticle_cmsuser', $cm->associationMappings['author']['joinTable']['name']); + self::assertEquals('doctrineglobalarticle_cmsuser', $cm->associationMappings['author']['joinTable']['name']); } /** @@ -552,8 +552,8 @@ public function testMapIdentifierAssociation(): void ] ); - $this->assertTrue($cm->containsForeignIdentifier, "Identifier Association should set 'containsForeignIdentifier' boolean flag."); - $this->assertEquals(['article'], $cm->identifier); + self::assertTrue($cm->containsForeignIdentifier, "Identifier Association should set 'containsForeignIdentifier' boolean flag."); + self::assertEquals(['article'], $cm->identifier); } /** @@ -640,7 +640,7 @@ public function testRetrievalOfNamedQueries(): void $cm = new ClassMetadata(CMS\CmsUser::class); $cm->initializeReflection(new RuntimeReflectionService()); - $this->assertEquals(0, count($cm->getNamedQueries())); + self::assertEquals(0, count($cm->getNamedQueries())); $cm->addNamedQuery( [ @@ -649,7 +649,7 @@ public function testRetrievalOfNamedQueries(): void ] ); - $this->assertEquals(1, count($cm->getNamedQueries())); + self::assertEquals(1, count($cm->getNamedQueries())); } /** @@ -660,7 +660,7 @@ public function testRetrievalOfResultSetMappings(): void $cm = new ClassMetadata(CMS\CmsUser::class); $cm->initializeReflection(new RuntimeReflectionService()); - $this->assertEquals(0, count($cm->getSqlResultSetMappings())); + self::assertEquals(0, count($cm->getSqlResultSetMappings())); $cm->addSqlResultSetMapping( [ @@ -673,7 +673,7 @@ public function testRetrievalOfResultSetMappings(): void ] ); - $this->assertEquals(1, count($cm->getSqlResultSetMappings())); + self::assertEquals(1, count($cm->getSqlResultSetMappings())); } public function testExistanceOfNamedQuery(): void @@ -688,8 +688,8 @@ public function testExistanceOfNamedQuery(): void ] ); - $this->assertTrue($cm->hasNamedQuery('all')); - $this->assertFalse($cm->hasNamedQuery('userById')); + self::assertTrue($cm->hasNamedQuery('all')); + self::assertFalse($cm->hasNamedQuery('userById')); } /** @@ -719,14 +719,14 @@ public function testRetrieveOfNamedNativeQuery(): void ); $mapping = $cm->getNamedNativeQuery('find-all'); - $this->assertEquals('SELECT * FROM cms_users', $mapping['query']); - $this->assertEquals('result-mapping-name', $mapping['resultSetMapping']); - $this->assertEquals(CMS\CmsUser::class, $mapping['resultClass']); + self::assertEquals('SELECT * FROM cms_users', $mapping['query']); + self::assertEquals('result-mapping-name', $mapping['resultSetMapping']); + self::assertEquals(CMS\CmsUser::class, $mapping['resultClass']); $mapping = $cm->getNamedNativeQuery('find-by-id'); - $this->assertEquals('SELECT * FROM cms_users WHERE id = ?', $mapping['query']); - $this->assertEquals('result-mapping-name', $mapping['resultSetMapping']); - $this->assertEquals(CMS\CmsUser::class, $mapping['resultClass']); + self::assertEquals('SELECT * FROM cms_users WHERE id = ?', $mapping['query']); + self::assertEquals('result-mapping-name', $mapping['resultSetMapping']); + self::assertEquals(CMS\CmsUser::class, $mapping['resultClass']); } /** @@ -776,15 +776,15 @@ public function testRetrieveOfSqlResultSetMapping(): void $mapping = $cm->getSqlResultSetMapping('find-all'); - $this->assertEquals(CMS\CmsUser::class, $mapping['entities'][0]['entityClass']); - $this->assertEquals(['name' => 'id', 'column' => 'id'], $mapping['entities'][0]['fields'][0]); - $this->assertEquals(['name' => 'name', 'column' => 'name'], $mapping['entities'][0]['fields'][1]); + self::assertEquals(CMS\CmsUser::class, $mapping['entities'][0]['entityClass']); + self::assertEquals(['name' => 'id', 'column' => 'id'], $mapping['entities'][0]['fields'][0]); + self::assertEquals(['name' => 'name', 'column' => 'name'], $mapping['entities'][0]['fields'][1]); - $this->assertEquals(CMS\CmsEmail::class, $mapping['entities'][1]['entityClass']); - $this->assertEquals(['name' => 'id', 'column' => 'id'], $mapping['entities'][1]['fields'][0]); - $this->assertEquals(['name' => 'email', 'column' => 'email'], $mapping['entities'][1]['fields'][1]); + self::assertEquals(CMS\CmsEmail::class, $mapping['entities'][1]['entityClass']); + self::assertEquals(['name' => 'id', 'column' => 'id'], $mapping['entities'][1]['fields'][0]); + self::assertEquals(['name' => 'email', 'column' => 'email'], $mapping['entities'][1]['fields'][1]); - $this->assertEquals('scalarColumn', $mapping['columns'][0]['name']); + self::assertEquals('scalarColumn', $mapping['columns'][0]['name']); } /** @@ -806,8 +806,8 @@ public function testExistanceOfSqlResultSetMapping(): void ] ); - $this->assertTrue($cm->hasSqlResultSetMapping('find-all')); - $this->assertFalse($cm->hasSqlResultSetMapping('find-by-id')); + self::assertTrue($cm->hasSqlResultSetMapping('find-all')); + self::assertFalse($cm->hasSqlResultSetMapping('find-by-id')); } /** @@ -827,8 +827,8 @@ public function testExistanceOfNamedNativeQuery(): void ] ); - $this->assertTrue($cm->hasNamedNativeQuery('find-all')); - $this->assertFalse($cm->hasNamedNativeQuery('find-by-id')); + self::assertTrue($cm->hasNamedNativeQuery('find-all')); + self::assertFalse($cm->hasNamedNativeQuery('find-by-id')); } public function testRetrieveOfNamedQuery(): void @@ -843,7 +843,7 @@ public function testRetrieveOfNamedQuery(): void ] ); - $this->assertEquals('SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.id = ?1', $cm->getNamedQuery('userById')); + self::assertEquals('SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.id = ?1', $cm->getNamedQuery('userById')); } /** @@ -854,7 +854,7 @@ public function testRetrievalOfNamedNativeQueries(): void $cm = new ClassMetadata(CMS\CmsUser::class); $cm->initializeReflection(new RuntimeReflectionService()); - $this->assertEquals(0, count($cm->getNamedNativeQueries())); + self::assertEquals(0, count($cm->getNamedNativeQueries())); $cm->addNamedNativeQuery( [ @@ -865,7 +865,7 @@ public function testRetrievalOfNamedNativeQueries(): void ] ); - $this->assertEquals(1, count($cm->getNamedNativeQueries())); + self::assertEquals(1, count($cm->getNamedNativeQueries())); } /** @@ -882,7 +882,7 @@ public function testSerializeEntityListeners(): void $serialize = serialize($metadata); $unserialize = unserialize($serialize); - $this->assertEquals($metadata->entityListeners, $unserialize->entityListeners); + self::assertEquals($metadata->entityListeners, $unserialize->entityListeners); } public function testNamingCollisionNamedQueryShouldThrowException(): void @@ -978,7 +978,7 @@ public function testClassCaseSensitivity(): void $cm = new ClassMetadata(strtoupper(CMS\CmsUser::class)); $cm->initializeReflection(new RuntimeReflectionService()); - $this->assertEquals(CMS\CmsUser::class, $cm->name); + self::assertEquals(CMS\CmsUser::class, $cm->name); } /** @@ -1103,9 +1103,9 @@ public function testFullyQualifiedClassNameShouldBeGivenToNamingStrategy(): void ] ); - $this->assertEquals('routing_routingleg', $routingMetadata->table['name']); - $this->assertEquals('cms_cmsaddress_cms_cmsuser', $addressMetadata->associationMappings['user']['joinTable']['name']); - $this->assertEquals('doctrineglobalarticle_cms_cmsuser', $articleMetadata->associationMappings['author']['joinTable']['name']); + self::assertEquals('routing_routingleg', $routingMetadata->table['name']); + self::assertEquals('cms_cmsaddress_cms_cmsuser', $addressMetadata->associationMappings['user']['joinTable']['name']); + self::assertEquals('doctrineglobalarticle_cms_cmsuser', $articleMetadata->associationMappings['author']['joinTable']['name']); } /** @@ -1122,7 +1122,7 @@ public function testFullyQualifiedClassNameShouldBeGivenToNamingStrategyProperty $metadata->mapField(['fieldName' => 'country']); $metadata->mapField(['fieldName' => 'city']); - $this->assertEquals($metadata->fieldNames, [ + self::assertEquals($metadata->fieldNames, [ 'cmsaddress_country' => 'country', 'cmsaddress_city' => 'city', ]); @@ -1221,7 +1221,7 @@ public function testManyToManySelfReferencingNamingStrategyDefaults(): void ] ); - $this->assertEquals( + self::assertEquals( [ 'name' => 'customtypeparent_customtypeparent', 'joinColumns' => [['name' => 'customtypeparent_source', 'referencedColumnName' => 'id', 'onDelete' => 'CASCADE']], @@ -1229,9 +1229,9 @@ public function testManyToManySelfReferencingNamingStrategyDefaults(): void ], $cm->associationMappings['friendsWithMe']['joinTable'] ); - $this->assertEquals(['customtypeparent_source', 'customtypeparent_target'], $cm->associationMappings['friendsWithMe']['joinTableColumns']); - $this->assertEquals(['customtypeparent_source' => 'id'], $cm->associationMappings['friendsWithMe']['relationToSourceKeyColumns']); - $this->assertEquals(['customtypeparent_target' => 'id'], $cm->associationMappings['friendsWithMe']['relationToTargetKeyColumns']); + self::assertEquals(['customtypeparent_source', 'customtypeparent_target'], $cm->associationMappings['friendsWithMe']['joinTableColumns']); + self::assertEquals(['customtypeparent_source' => 'id'], $cm->associationMappings['friendsWithMe']['relationToSourceKeyColumns']); + self::assertEquals(['customtypeparent_target' => 'id'], $cm->associationMappings['friendsWithMe']['relationToTargetKeyColumns']); } /** @@ -1270,7 +1270,7 @@ public function testIsIdentifierMappedSuperClass(): void { $class = new ClassMetadata(DDC2700MappedSuperClass::class); - $this->assertFalse($class->isIdentifier('foo')); + self::assertFalse($class->isIdentifier('foo')); } /** @@ -1280,7 +1280,7 @@ public function testCanInstantiateInternalPhpClassSubclass(): void { $classMetadata = new ClassMetadata(MyArrayObjectEntity::class); - $this->assertInstanceOf(MyArrayObjectEntity::class, $classMetadata->newInstance()); + self::assertInstanceOf(MyArrayObjectEntity::class, $classMetadata->newInstance()); } /** @@ -1293,7 +1293,7 @@ public function testCanInstantiateInternalPhpClassSubclassFromUnserializedMetada $classMetadata->wakeupReflection(new RuntimeReflectionService()); - $this->assertInstanceOf(MyArrayObjectEntity::class, $classMetadata->newInstance()); + self::assertInstanceOf(MyArrayObjectEntity::class, $classMetadata->newInstance()); } public function testWakeupReflectionWithEmbeddableAndStaticReflectionService(): void @@ -1319,7 +1319,7 @@ public function testWakeupReflectionWithEmbeddableAndStaticReflectionService(): $classMetadata->mapField($field); $classMetadata->wakeupReflection(new StaticReflectionService()); - $this->assertEquals(['test' => null, 'test.embeddedProperty' => null], $classMetadata->getReflectionProperties()); + self::assertEquals(['test' => null, 'test.embeddedProperty' => null], $classMetadata->getReflectionProperties()); } public function testGetColumnNamesWithGivenFieldNames(): void @@ -1349,7 +1349,7 @@ public function testInlineEmbeddable(): void ] ); - $this->assertTrue($classMetadata->hasField('test')); + self::assertTrue($classMetadata->hasField('test')); } } diff --git a/tests/Doctrine/Tests/ORM/Mapping/DefaultQuoteStrategyTest.php b/tests/Doctrine/Tests/ORM/Mapping/DefaultQuoteStrategyTest.php index 8d063c161ab..f42857f3cc6 100644 --- a/tests/Doctrine/Tests/ORM/Mapping/DefaultQuoteStrategyTest.php +++ b/tests/Doctrine/Tests/ORM/Mapping/DefaultQuoteStrategyTest.php @@ -28,7 +28,7 @@ public function testGetJoinTableName(): void $platform = $this->getMockForAbstractClass(AbstractPlatform::class); assert($platform instanceof AbstractPlatform); - $this->assertSame( + self::assertSame( 'readers.author_reader', $strategy->getJoinTableName($metadata->associationMappings['readers'], $metadata, $platform) ); diff --git a/tests/Doctrine/Tests/ORM/Mapping/EntityListenerResolverTest.php b/tests/Doctrine/Tests/ORM/Mapping/EntityListenerResolverTest.php index 237f80dc9e7..135ac62a956 100644 --- a/tests/Doctrine/Tests/ORM/Mapping/EntityListenerResolverTest.php +++ b/tests/Doctrine/Tests/ORM/Mapping/EntityListenerResolverTest.php @@ -26,8 +26,8 @@ public function testResolve(): void $className = '\Doctrine\Tests\Models\Company\CompanyContractListener'; $object = $this->resolver->resolve($className); - $this->assertInstanceOf($className, $object); - $this->assertSame($object, $this->resolver->resolve($className)); + self::assertInstanceOf($className, $object); + self::assertSame($object, $this->resolver->resolve($className)); } public function testRegisterAndResolve(): void @@ -37,7 +37,7 @@ public function testRegisterAndResolve(): void $this->resolver->register($object); - $this->assertSame($object, $this->resolver->resolve($className)); + self::assertSame($object, $this->resolver->resolve($className)); } public function testClearOne(): void @@ -48,19 +48,19 @@ public function testClearOne(): void $obj1 = $this->resolver->resolve($className1); $obj2 = $this->resolver->resolve($className2); - $this->assertInstanceOf($className1, $obj1); - $this->assertInstanceOf($className2, $obj2); + self::assertInstanceOf($className1, $obj1); + self::assertInstanceOf($className2, $obj2); - $this->assertSame($obj1, $this->resolver->resolve($className1)); - $this->assertSame($obj2, $this->resolver->resolve($className2)); + self::assertSame($obj1, $this->resolver->resolve($className1)); + self::assertSame($obj2, $this->resolver->resolve($className2)); $this->resolver->clear($className1); - $this->assertInstanceOf($className1, $this->resolver->resolve($className1)); - $this->assertInstanceOf($className2, $this->resolver->resolve($className2)); + self::assertInstanceOf($className1, $this->resolver->resolve($className1)); + self::assertInstanceOf($className2, $this->resolver->resolve($className2)); - $this->assertNotSame($obj1, $this->resolver->resolve($className1)); - $this->assertSame($obj2, $this->resolver->resolve($className2)); + self::assertNotSame($obj1, $this->resolver->resolve($className1)); + self::assertSame($obj2, $this->resolver->resolve($className2)); } public function testClearAll(): void @@ -71,19 +71,19 @@ public function testClearAll(): void $obj1 = $this->resolver->resolve($className1); $obj2 = $this->resolver->resolve($className2); - $this->assertInstanceOf($className1, $obj1); - $this->assertInstanceOf($className2, $obj2); + self::assertInstanceOf($className1, $obj1); + self::assertInstanceOf($className2, $obj2); - $this->assertSame($obj1, $this->resolver->resolve($className1)); - $this->assertSame($obj2, $this->resolver->resolve($className2)); + self::assertSame($obj1, $this->resolver->resolve($className1)); + self::assertSame($obj2, $this->resolver->resolve($className2)); $this->resolver->clear(); - $this->assertInstanceOf($className1, $this->resolver->resolve($className1)); - $this->assertInstanceOf($className2, $this->resolver->resolve($className2)); + self::assertInstanceOf($className1, $this->resolver->resolve($className1)); + self::assertInstanceOf($className2, $this->resolver->resolve($className2)); - $this->assertNotSame($obj1, $this->resolver->resolve($className1)); - $this->assertNotSame($obj2, $this->resolver->resolve($className2)); + self::assertNotSame($obj1, $this->resolver->resolve($className1)); + self::assertNotSame($obj2, $this->resolver->resolve($className2)); } public function testRegisterStringException(): void diff --git a/tests/Doctrine/Tests/ORM/Mapping/FieldBuilderTest.php b/tests/Doctrine/Tests/ORM/Mapping/FieldBuilderTest.php index 88fd2c7624d..c73a287ed00 100644 --- a/tests/Doctrine/Tests/ORM/Mapping/FieldBuilderTest.php +++ b/tests/Doctrine/Tests/ORM/Mapping/FieldBuilderTest.php @@ -22,7 +22,7 @@ public function testCustomIdGeneratorCanBeSet(): void $fieldBuilder->build(); - $this->assertEquals(ClassMetadataInfo::GENERATOR_TYPE_CUSTOM, $cmBuilder->getClassMetadata()->generatorType); - $this->assertEquals(['class' => 'stdClass'], $cmBuilder->getClassMetadata()->customGeneratorDefinition); + self::assertEquals(ClassMetadataInfo::GENERATOR_TYPE_CUSTOM, $cmBuilder->getClassMetadata()->generatorType); + self::assertEquals(['class' => 'stdClass'], $cmBuilder->getClassMetadata()->customGeneratorDefinition); } } diff --git a/tests/Doctrine/Tests/ORM/Mapping/QuoteStrategyTest.php b/tests/Doctrine/Tests/ORM/Mapping/QuoteStrategyTest.php index 73ad972b334..bd0d5ab99d3 100644 --- a/tests/Doctrine/Tests/ORM/Mapping/QuoteStrategyTest.php +++ b/tests/Doctrine/Tests/ORM/Mapping/QuoteStrategyTest.php @@ -47,13 +47,13 @@ public function testConfiguration(): void $em = $this->getTestEntityManager(); $config = $em->getConfiguration(); - $this->assertInstanceOf(QuoteStrategy::class, $config->getQuoteStrategy()); - $this->assertInstanceOf(DefaultQuoteStrategy::class, $config->getQuoteStrategy()); + self::assertInstanceOf(QuoteStrategy::class, $config->getQuoteStrategy()); + self::assertInstanceOf(DefaultQuoteStrategy::class, $config->getQuoteStrategy()); $config->setQuoteStrategy(new MyQuoteStrategy()); - $this->assertInstanceOf(QuoteStrategy::class, $config->getQuoteStrategy()); - $this->assertInstanceOf(MyQuoteStrategy::class, $config->getQuoteStrategy()); + self::assertInstanceOf(QuoteStrategy::class, $config->getQuoteStrategy()); + self::assertInstanceOf(MyQuoteStrategy::class, $config->getQuoteStrategy()); } public function testGetColumnName(): void @@ -62,20 +62,20 @@ public function testGetColumnName(): void $cm->mapField(['fieldName' => 'name', 'columnName' => '`name`']); $cm->mapField(['fieldName' => 'id', 'columnName' => 'id']); - $this->assertEquals('id', $this->strategy->getColumnName('id', $cm, $this->platform)); - $this->assertEquals('"name"', $this->strategy->getColumnName('name', $cm, $this->platform)); + self::assertEquals('id', $this->strategy->getColumnName('id', $cm, $this->platform)); + self::assertEquals('"name"', $this->strategy->getColumnName('name', $cm, $this->platform)); } public function testGetTableName(): void { $cm = $this->createClassMetadata(CmsUser::class); $cm->setPrimaryTable(['name' => '`cms_user`']); - $this->assertEquals('"cms_user"', $this->strategy->getTableName($cm, $this->platform)); + self::assertEquals('"cms_user"', $this->strategy->getTableName($cm, $this->platform)); $cm = new ClassMetadata(CmsUser::class); $cm->initializeReflection(new RuntimeReflectionService()); $cm->setPrimaryTable(['name' => 'cms_user']); - $this->assertEquals('cms_user', $this->strategy->getTableName($cm, $this->platform)); + self::assertEquals('cms_user', $this->strategy->getTableName($cm, $this->platform)); } public function testJoinTableName(): void @@ -101,8 +101,8 @@ public function testJoinTableName(): void ] ); - $this->assertEquals('"cmsaddress_cmsuser"', $this->strategy->getJoinTableName($cm1->associationMappings['user'], $cm1, $this->platform)); - $this->assertEquals('cmsaddress_cmsuser', $this->strategy->getJoinTableName($cm2->associationMappings['user'], $cm2, $this->platform)); + self::assertEquals('"cmsaddress_cmsuser"', $this->strategy->getJoinTableName($cm1->associationMappings['user'], $cm1, $this->platform)); + self::assertEquals('cmsaddress_cmsuser', $this->strategy->getJoinTableName($cm2->associationMappings['user'], $cm2, $this->platform)); } public function testIdentifierColumnNames(): void @@ -126,17 +126,17 @@ public function testIdentifierColumnNames(): void ] ); - $this->assertEquals(['"id"'], $this->strategy->getIdentifierColumnNames($cm1, $this->platform)); - $this->assertEquals(['id'], $this->strategy->getIdentifierColumnNames($cm2, $this->platform)); + self::assertEquals(['"id"'], $this->strategy->getIdentifierColumnNames($cm1, $this->platform)); + self::assertEquals(['id'], $this->strategy->getIdentifierColumnNames($cm2, $this->platform)); } public function testColumnAlias(): void { $i = 0; - $this->assertEquals('columnName_0', $this->strategy->getColumnAlias('columnName', $i++, $this->platform)); - $this->assertEquals('column_name_1', $this->strategy->getColumnAlias('column_name', $i++, $this->platform)); - $this->assertEquals('COLUMN_NAME_2', $this->strategy->getColumnAlias('COLUMN_NAME', $i++, $this->platform)); - $this->assertEquals('COLUMNNAME_3', $this->strategy->getColumnAlias('COLUMN-NAME-', $i++, $this->platform)); + self::assertEquals('columnName_0', $this->strategy->getColumnAlias('columnName', $i++, $this->platform)); + self::assertEquals('column_name_1', $this->strategy->getColumnAlias('column_name', $i++, $this->platform)); + self::assertEquals('COLUMN_NAME_2', $this->strategy->getColumnAlias('COLUMN_NAME', $i++, $this->platform)); + self::assertEquals('COLUMNNAME_3', $this->strategy->getColumnAlias('COLUMN-NAME-', $i++, $this->platform)); } public function testQuoteIdentifierJoinColumns(): void @@ -154,7 +154,7 @@ public function testQuoteIdentifierJoinColumns(): void ] ); - $this->assertEquals(['"article"'], $this->strategy->getIdentifierColumnNames($cm, $this->platform)); + self::assertEquals(['"article"'], $this->strategy->getIdentifierColumnNames($cm, $this->platform)); } public function testJoinColumnName(): void @@ -173,7 +173,7 @@ public function testJoinColumnName(): void ); $joinColumn = $cm->associationMappings['article']['joinColumns'][0]; - $this->assertEquals('"article"', $this->strategy->getJoinColumnName($joinColumn, $cm, $this->platform)); + self::assertEquals('"article"', $this->strategy->getJoinColumnName($joinColumn, $cm, $this->platform)); } public function testReferencedJoinColumnName(): void @@ -192,7 +192,7 @@ public function testReferencedJoinColumnName(): void ); $joinColumn = $cm->associationMappings['article']['joinColumns'][0]; - $this->assertEquals('"id"', $this->strategy->getReferencedJoinColumnName($joinColumn, $cm, $this->platform)); + self::assertEquals('"id"', $this->strategy->getReferencedJoinColumnName($joinColumn, $cm, $this->platform)); } } diff --git a/tests/Doctrine/Tests/ORM/Mapping/Reflection/ReflectionPropertiesGetterTest.php b/tests/Doctrine/Tests/ORM/Mapping/Reflection/ReflectionPropertiesGetterTest.php index 387c2ea32d0..d608b939efc 100644 --- a/tests/Doctrine/Tests/ORM/Mapping/Reflection/ReflectionPropertiesGetterTest.php +++ b/tests/Doctrine/Tests/ORM/Mapping/Reflection/ReflectionPropertiesGetterTest.php @@ -27,10 +27,10 @@ public function testRetrievesProperties(): void $properties = (new ReflectionPropertiesGetter(new RuntimeReflectionService())) ->getProperties(ClassWithMixedProperties::class); - $this->assertCount(5, $properties); + self::assertCount(5, $properties); foreach ($properties as $property) { - $this->assertInstanceOf('ReflectionProperty', $property); + self::assertInstanceOf('ReflectionProperty', $property); } } @@ -40,7 +40,7 @@ public function testRetrievedInstancesAreNotStatic(): void ->getProperties(ClassWithMixedProperties::class); foreach ($properties as $property) { - $this->assertFalse($property->isStatic()); + self::assertFalse($property->isStatic()); } } @@ -49,23 +49,23 @@ public function testExpectedKeys(): void $properties = (new ReflectionPropertiesGetter(new RuntimeReflectionService())) ->getProperties(ClassWithMixedProperties::class); - $this->assertArrayHasKey( + self::assertArrayHasKey( "\0" . ClassWithMixedProperties::class . "\0" . 'privateProperty', $properties ); - $this->assertArrayHasKey( + self::assertArrayHasKey( "\0" . ClassWithMixedProperties::class . "\0" . 'privatePropertyOverride', $properties ); - $this->assertArrayHasKey( + self::assertArrayHasKey( "\0" . ParentClass::class . "\0" . 'privatePropertyOverride', $properties ); - $this->assertArrayHasKey( + self::assertArrayHasKey( "\0*\0protectedProperty", $properties ); - $this->assertArrayHasKey( + self::assertArrayHasKey( 'publicProperty', $properties ); @@ -78,7 +78,7 @@ public function testPropertiesAreAccessible(): void ->getProperties(ClassWithMixedProperties::class); foreach ($properties as $property) { - $this->assertSame($property->getName(), $property->getValue($object)); + self::assertSame($property->getName(), $property->getValue($object)); } } @@ -86,7 +86,7 @@ public function testPropertyGetterIsIdempotent(): void { $getter = (new ReflectionPropertiesGetter(new RuntimeReflectionService())); - $this->assertSame( + self::assertSame( $getter->getProperties(ClassWithMixedProperties::class), $getter->getProperties(ClassWithMixedProperties::class) ); @@ -98,21 +98,21 @@ public function testPropertyGetterWillSkipPropertiesNotRetrievedByTheRuntimeRefl assert($reflectionService instanceof ReflectionService || $reflectionService instanceof MockObject); $reflectionService - ->expects($this->exactly(2)) + ->expects(self::exactly(2)) ->method('getClass') - ->with($this->logicalOr(ClassWithMixedProperties::class, ParentClass::class)) - ->will($this->returnValueMap([ + ->with(self::logicalOr(ClassWithMixedProperties::class, ParentClass::class)) + ->will(self::returnValueMap([ [ClassWithMixedProperties::class, new ReflectionClass(ClassWithMixedProperties::class)], [ParentClass::class, new ReflectionClass(ParentClass::class)], ])); $reflectionService - ->expects($this->atLeastOnce()) + ->expects(self::atLeastOnce()) ->method('getAccessibleProperty'); $getter = (new ReflectionPropertiesGetter($reflectionService)); - $this->assertEmpty($getter->getProperties(ClassWithMixedProperties::class)); + self::assertEmpty($getter->getProperties(ClassWithMixedProperties::class)); } public function testPropertyGetterWillSkipClassesNotRetrievedByTheRuntimeReflectionService(): void @@ -121,14 +121,14 @@ public function testPropertyGetterWillSkipClassesNotRetrievedByTheRuntimeReflect assert($reflectionService instanceof ReflectionService || $reflectionService instanceof MockObject); $reflectionService - ->expects($this->once()) + ->expects(self::once()) ->method('getClass') ->with(ClassWithMixedProperties::class); - $reflectionService->expects($this->never())->method('getAccessibleProperty'); + $reflectionService->expects(self::never())->method('getAccessibleProperty'); $getter = (new ReflectionPropertiesGetter($reflectionService)); - $this->assertEmpty($getter->getProperties(ClassWithMixedProperties::class)); + self::assertEmpty($getter->getProperties(ClassWithMixedProperties::class)); } } diff --git a/tests/Doctrine/Tests/ORM/Mapping/ReflectionEmbeddedPropertyTest.php b/tests/Doctrine/Tests/ORM/Mapping/ReflectionEmbeddedPropertyTest.php index a5037ce901c..07ffb89463c 100644 --- a/tests/Doctrine/Tests/ORM/Mapping/ReflectionEmbeddedPropertyTest.php +++ b/tests/Doctrine/Tests/ORM/Mapping/ReflectionEmbeddedPropertyTest.php @@ -40,11 +40,11 @@ public function testCanSetAndGetEmbeddedProperty( $embeddedPropertyReflection->setValue($object, 'newValue'); - $this->assertSame('newValue', $embeddedPropertyReflection->getValue($object)); + self::assertSame('newValue', $embeddedPropertyReflection->getValue($object)); $embeddedPropertyReflection->setValue($object, 'changedValue'); - $this->assertSame('changedValue', $embeddedPropertyReflection->getValue($object)); + self::assertSame('changedValue', $embeddedPropertyReflection->getValue($object)); } /** @@ -63,7 +63,7 @@ public function testWillSkipReadingPropertiesFromNullEmbeddable( $instantiator = new Instantiator(); - $this->assertNull($embeddedPropertyReflection->getValue( + self::assertNull($embeddedPropertyReflection->getValue( $instantiator->instantiate($parentProperty->getDeclaringClass()->getName()) )); } diff --git a/tests/Doctrine/Tests/ORM/Mapping/StaticPHPMappingDriverTest.php b/tests/Doctrine/Tests/ORM/Mapping/StaticPHPMappingDriverTest.php index ffb752908b3..7b2660b2fb0 100644 --- a/tests/Doctrine/Tests/ORM/Mapping/StaticPHPMappingDriverTest.php +++ b/tests/Doctrine/Tests/ORM/Mapping/StaticPHPMappingDriverTest.php @@ -34,7 +34,7 @@ public function testinvalidEntityOrMappedSuperClassShouldMentionParentClasses(): */ public function testSchemaDefinitionViaExplicitTableSchemaAnnotationProperty(): void { - $this->markTestIncomplete(); + self::markTestIncomplete(); } /** @@ -43,7 +43,7 @@ public function testSchemaDefinitionViaExplicitTableSchemaAnnotationProperty(): */ public function testSchemaDefinitionViaSchemaDefinedInTableNameInTableAnnotationProperty(): void { - $this->markTestIncomplete(); + self::markTestIncomplete(); } public function testEntityIncorrectIndexes(): void diff --git a/tests/Doctrine/Tests/ORM/Mapping/Symfony/AbstractDriverTest.php b/tests/Doctrine/Tests/ORM/Mapping/Symfony/AbstractDriverTest.php index 8dccd62a5d4..cfc5ab1a913 100644 --- a/tests/Doctrine/Tests/ORM/Mapping/Symfony/AbstractDriverTest.php +++ b/tests/Doctrine/Tests/ORM/Mapping/Symfony/AbstractDriverTest.php @@ -31,7 +31,7 @@ public function testFindMappingFile(): void ); touch($filename = $this->dir . '/Foo' . $this->getFileExtension()); - $this->assertEquals($filename, $driver->getLocator()->findMappingFile('MyNamespace\MySubnamespace\Entity\Foo')); + self::assertEquals($filename, $driver->getLocator()->findMappingFile('MyNamespace\MySubnamespace\Entity\Foo')); } public function testFindMappingFileInSubnamespace(): void @@ -43,7 +43,7 @@ public function testFindMappingFileInSubnamespace(): void ); touch($filename = $this->dir . '/Foo.Bar' . $this->getFileExtension()); - $this->assertEquals($filename, $driver->getLocator()->findMappingFile('MyNamespace\MySubnamespace\Entity\Foo\Bar')); + self::assertEquals($filename, $driver->getLocator()->findMappingFile('MyNamespace\MySubnamespace\Entity\Foo\Bar')); } public function testFindMappingFileNamespacedFoundFileNotFound(): void diff --git a/tests/Doctrine/Tests/ORM/Mapping/XmlMappingDriverTest.php b/tests/Doctrine/Tests/ORM/Mapping/XmlMappingDriverTest.php index b6b2954a4e5..8ef6c2eacee 100644 --- a/tests/Doctrine/Tests/ORM/Mapping/XmlMappingDriverTest.php +++ b/tests/Doctrine/Tests/ORM/Mapping/XmlMappingDriverTest.php @@ -55,8 +55,8 @@ public function testClassTableInheritanceDiscriminatorMap(): void 'baz' => CTIBaz::class, ]; - $this->assertEquals(3, count($class->discriminatorMap)); - $this->assertEquals($expectedMap, $class->discriminatorMap); + self::assertEquals(3, count($class->discriminatorMap)); + self::assertEquals($expectedMap, $class->discriminatorMap); } public function testFailingSecondLevelCacheAssociation(): void @@ -80,18 +80,18 @@ public function testIdentifierWithAssociationKey(): void $class = $factory->getMetadataFor(DDC117Translation::class); - $this->assertEquals(['language', 'article'], $class->identifier); - $this->assertArrayHasKey('article', $class->associationMappings); + self::assertEquals(['language', 'article'], $class->identifier); + self::assertArrayHasKey('article', $class->associationMappings); - $this->assertArrayHasKey('id', $class->associationMappings['article']); - $this->assertTrue($class->associationMappings['article']['id']); + self::assertArrayHasKey('id', $class->associationMappings['article']); + self::assertTrue($class->associationMappings['article']['id']); } public function testEmbeddableMapping(): void { $class = $this->createClassMetadata(Name::class); - $this->assertEquals(true, $class->isEmbeddedClass); + self::assertEquals(true, $class->isEmbeddedClass); } /** @@ -107,7 +107,7 @@ public function testEmbeddedMappingsWithUseColumnPrefix(): void $em->getConfiguration()->setMetadataDriverImpl($this->loadDriver()); $factory->setEntityManager($em); - $this->assertEquals( + self::assertEquals( '__prefix__', $factory->getMetadataFor(DDC3293UserPrefixed::class) ->embeddedClasses['address']['columnPrefix'] @@ -127,7 +127,7 @@ public function testEmbeddedMappingsWithFalseUseColumnPrefix(): void $em->getConfiguration()->setMetadataDriverImpl($this->loadDriver()); $factory->setEntityManager($em); - $this->assertFalse( + self::assertFalse( $factory->getMetadataFor(DDC3293User::class) ->embeddedClasses['address']['columnPrefix'] ); @@ -137,7 +137,7 @@ public function testEmbeddedMapping(): void { $class = $this->createClassMetadata(Person::class); - $this->assertEquals( + self::assertEquals( [ 'name' => [ 'class' => Name::class, @@ -171,7 +171,7 @@ public function testValidateXmlSchema(string $xmlMappingFile): void $dom->load($xmlMappingFile); - $this->assertTrue($dom->schemaValidate($xsdSchemaFile)); + self::assertTrue($dom->schemaValidate($xsdSchemaFile)); } /** @@ -203,7 +203,7 @@ public function testOneToManyDefaultOrderByAsc(): void $class->initializeReflection(new RuntimeReflectionService()); $driver->loadMetadataForClass(GH7141Article::class, $class); - $this->assertEquals( + self::assertEquals( Criteria::ASC, $class->getMetadataValue('associationMappings')['tags']['orderBy']['position'] ); diff --git a/tests/Doctrine/Tests/ORM/Mapping/YamlMappingDriverTest.php b/tests/Doctrine/Tests/ORM/Mapping/YamlMappingDriverTest.php index 72d217f3627..fa0b54d7d81 100644 --- a/tests/Doctrine/Tests/ORM/Mapping/YamlMappingDriverTest.php +++ b/tests/Doctrine/Tests/ORM/Mapping/YamlMappingDriverTest.php @@ -22,7 +22,7 @@ class YamlMappingDriverTest extends AbstractMappingDriverTest protected function loadDriver(): MappingDriver { if (! class_exists(Yaml::class, true)) { - $this->markTestSkipped('Please install Symfony YAML Component into the include path of your PHP installation.'); + self::markTestSkipped('Please install Symfony YAML Component into the include path of your PHP installation.'); } return new YamlDriver(__DIR__ . DIRECTORY_SEPARATOR . 'yaml'); @@ -45,11 +45,11 @@ public function testJoinTablesWithMappedSuperclassForYamlDriver(): void $classPage = new ClassMetadata(File::class); $classPage = $factory->getMetadataFor(File::class); - $this->assertEquals(File::class, $classPage->associationMappings['parentDirectory']['sourceEntity']); + self::assertEquals(File::class, $classPage->associationMappings['parentDirectory']['sourceEntity']); $classDirectory = new ClassMetadata(Directory::class); $classDirectory = $factory->getMetadataFor(Directory::class); - $this->assertEquals(Directory::class, $classDirectory->associationMappings['parentDirectory']['sourceEntity']); + self::assertEquals(Directory::class, $classDirectory->associationMappings['parentDirectory']['sourceEntity']); } /** @@ -74,14 +74,14 @@ public function testSpacesShouldBeIgnoredWhenUseExplode(): void $nameField = $metadata->fieldMappings['name']; $valueField = $metadata->fieldMappings['value']; - $this->assertEquals('name', $unique[0]); - $this->assertEquals('value', $unique[1]); + self::assertEquals('name', $unique[0]); + self::assertEquals('value', $unique[1]); - $this->assertEquals('value', $indexes[0]); - $this->assertEquals('name', $indexes[1]); + self::assertEquals('value', $indexes[0]); + self::assertEquals('name', $indexes[1]); - $this->assertEquals(255, $nameField['length']); - $this->assertEquals(255, $valueField['length']); + self::assertEquals(255, $nameField['length']); + self::assertEquals(255, $valueField['length']); } } diff --git a/tests/Doctrine/Tests/ORM/Performance/SecondLevelCacheTest.php b/tests/Doctrine/Tests/ORM/Performance/SecondLevelCacheTest.php index 31efa95a281..db1e4a1aa03 100644 --- a/tests/Doctrine/Tests/ORM/Performance/SecondLevelCacheTest.php +++ b/tests/Doctrine/Tests/ORM/Performance/SecondLevelCacheTest.php @@ -54,7 +54,7 @@ public function testFindEntityWithoutCache(): void $this->findEntity($em, __FUNCTION__); - $this->assertEquals(6002, $this->countQuery($em)); + self::assertEquals(6002, $this->countQuery($em)); } public function testFindEntityWithCache(): void @@ -65,7 +65,7 @@ public function testFindEntityWithCache(): void $this->findEntity($em, __FUNCTION__); - $this->assertEquals(502, $this->countQuery($em)); + self::assertEquals(502, $this->countQuery($em)); } public function testFindAllEntityWithoutCache(): void @@ -74,7 +74,7 @@ public function testFindAllEntityWithoutCache(): void $this->findAllEntity($em, __FUNCTION__); - $this->assertEquals(153, $this->countQuery($em)); + self::assertEquals(153, $this->countQuery($em)); } public function testFindAllEntityWithCache(): void @@ -85,7 +85,7 @@ public function testFindAllEntityWithCache(): void $this->findAllEntity($em, __FUNCTION__); - $this->assertEquals(53, $this->countQuery($em)); + self::assertEquals(53, $this->countQuery($em)); } public function testFindEntityOneToManyWithoutCache(): void @@ -94,7 +94,7 @@ public function testFindEntityOneToManyWithoutCache(): void $this->findEntityOneToMany($em, __FUNCTION__); - $this->assertEquals(502, $this->countQuery($em)); + self::assertEquals(502, $this->countQuery($em)); } public function testFindEntityOneToManyWithCache(): void @@ -105,7 +105,7 @@ public function testFindEntityOneToManyWithCache(): void $this->findEntityOneToMany($em, __FUNCTION__); - $this->assertEquals(472, $this->countQuery($em)); + self::assertEquals(472, $this->countQuery($em)); } public function testQueryEntityWithoutCache(): void @@ -114,7 +114,7 @@ public function testQueryEntityWithoutCache(): void $this->queryEntity($em, __FUNCTION__); - $this->assertEquals(602, $this->countQuery($em)); + self::assertEquals(602, $this->countQuery($em)); } public function testQueryEntityWithCache(): void @@ -125,7 +125,7 @@ public function testQueryEntityWithCache(): void $this->queryEntity($em, __FUNCTION__); - $this->assertEquals(503, $this->countQuery($em)); + self::assertEquals(503, $this->countQuery($em)); } private function queryEntity(EntityManagerInterface $em, string $label): void @@ -275,7 +275,7 @@ private function findAllEntity(EntityManagerInterface $em, string $label): void $list = $rep->findAll(); $em->clear(); - $this->assertCount($size, $list); + self::assertCount($size, $list); } printf("\n[%s] find %s countries (%s times)", number_format(microtime(true) - $startFind, 6), $size, $times); diff --git a/tests/Doctrine/Tests/ORM/PersistentCollectionTest.php b/tests/Doctrine/Tests/ORM/PersistentCollectionTest.php index 990419f9fb9..5daff2d7ee3 100644 --- a/tests/Doctrine/Tests/ORM/PersistentCollectionTest.php +++ b/tests/Doctrine/Tests/ORM/PersistentCollectionTest.php @@ -55,7 +55,7 @@ public function testCanBePutInLazyLoadingMode(): void $class = $this->_emMock->getClassMetadata(ECommerceProduct::class); $collection = new PersistentCollection($this->_emMock, $class, new ArrayCollection()); $collection->setInitialized(false); - $this->assertFalse($collection->isInitialized()); + self::assertFalse($collection->isInitialized()); } /** @@ -64,7 +64,7 @@ public function testCanBePutInLazyLoadingMode(): void public function testCurrentInitializesCollection(): void { $this->collection->current(); - $this->assertTrue($this->collection->isInitialized()); + self::assertTrue($this->collection->isInitialized()); } /** @@ -73,7 +73,7 @@ public function testCurrentInitializesCollection(): void public function testKeyInitializesCollection(): void { $this->collection->key(); - $this->assertTrue($this->collection->isInitialized()); + self::assertTrue($this->collection->isInitialized()); } /** @@ -82,7 +82,7 @@ public function testKeyInitializesCollection(): void public function testNextInitializesCollection(): void { $this->collection->next(); - $this->assertTrue($this->collection->isInitialized()); + self::assertTrue($this->collection->isInitialized()); } /** @@ -90,11 +90,11 @@ public function testNextInitializesCollection(): void */ public function testNonObjects(): void { - $this->assertEmpty($this->collection); + self::assertEmpty($this->collection); $this->collection->add('dummy'); - $this->assertNotEmpty($this->collection); + self::assertNotEmpty($this->collection); $product = new ECommerceProduct(); @@ -102,9 +102,9 @@ public function testNonObjects(): void $this->collection->set(2, 'dummy'); $this->collection->set(3, null); - $this->assertSame($product, $this->collection->get(1)); - $this->assertSame('dummy', $this->collection->get(2)); - $this->assertSame(null, $this->collection->get(3)); + self::assertSame($product, $this->collection->get(1)); + self::assertSame('dummy', $this->collection->get(2)); + self::assertSame(null, $this->collection->get(3)); } /** @@ -115,10 +115,10 @@ public function testRemovingElementsAlsoRemovesKeys(): void $dummy = new stdClass(); $this->collection->add($dummy); - $this->assertEquals([0], array_keys($this->collection->toArray())); + self::assertEquals([0], array_keys($this->collection->toArray())); $this->collection->removeElement($dummy); - $this->assertEquals([], array_keys($this->collection->toArray())); + self::assertEquals([], array_keys($this->collection->toArray())); } /** @@ -128,7 +128,7 @@ public function testClearWillAlsoClearKeys(): void { $this->collection->add(new stdClass()); $this->collection->clear(); - $this->assertEquals([], array_keys($this->collection->toArray())); + self::assertEquals([], array_keys($this->collection->toArray())); } /** @@ -142,7 +142,7 @@ public function testClearWillAlsoResetKeyPositions(): void $this->collection->removeElement($dummy); $this->collection->clear(); $this->collection->add($dummy); - $this->assertEquals([0], array_keys($this->collection->toArray())); + self::assertEquals([0], array_keys($this->collection->toArray())); } /** diff --git a/tests/Doctrine/Tests/ORM/Persisters/BasicEntityPersisterCompositeTypeParametersTest.php b/tests/Doctrine/Tests/ORM/Persisters/BasicEntityPersisterCompositeTypeParametersTest.php index 576a1abcfed..805d7483913 100644 --- a/tests/Doctrine/Tests/ORM/Persisters/BasicEntityPersisterCompositeTypeParametersTest.php +++ b/tests/Doctrine/Tests/ORM/Persisters/BasicEntityPersisterCompositeTypeParametersTest.php @@ -40,8 +40,8 @@ public function testExpandParametersWillExpandCompositeEntityKeys(): void [$values, $types] = $this->persister->expandParameters(['admin1' => $admin1]); - $this->assertEquals(['integer', 'string'], $types); - $this->assertEquals([10, 'IT'], $values); + self::assertEquals(['integer', 'string'], $types); + self::assertEquals([10, 'IT'], $values); } public function testExpandCriteriaParametersWillExpandCompositeEntityKeys(): void @@ -54,7 +54,7 @@ public function testExpandCriteriaParametersWillExpandCompositeEntityKeys(): voi [$values, $types] = $this->persister->expandCriteriaParameters($criteria); - $this->assertEquals(['integer', 'string'], $types); - $this->assertEquals([10, 'IT'], $values); + self::assertEquals(['integer', 'string'], $types); + self::assertEquals([10, 'IT'], $values); } } diff --git a/tests/Doctrine/Tests/ORM/Persisters/BasicEntityPersisterCompositeTypeSqlTest.php b/tests/Doctrine/Tests/ORM/Persisters/BasicEntityPersisterCompositeTypeSqlTest.php index 9183d9f3916..e0a6b20be2b 100644 --- a/tests/Doctrine/Tests/ORM/Persisters/BasicEntityPersisterCompositeTypeSqlTest.php +++ b/tests/Doctrine/Tests/ORM/Persisters/BasicEntityPersisterCompositeTypeSqlTest.php @@ -32,19 +32,19 @@ protected function setUp(): void public function testSelectConditionStatementEq(): void { $statement = $this->persister->getSelectConditionStatementSQL('admin1', 1, [], Comparison::EQ); - $this->assertEquals('t0.admin1 = ? AND t0.country = ?', $statement); + self::assertEquals('t0.admin1 = ? AND t0.country = ?', $statement); } public function testSelectConditionStatementEqNull(): void { $statement = $this->persister->getSelectConditionStatementSQL('admin1', null, [], Comparison::IS); - $this->assertEquals('t0.admin1 IS NULL AND t0.country IS NULL', $statement); + self::assertEquals('t0.admin1 IS NULL AND t0.country IS NULL', $statement); } public function testSelectConditionStatementNeqNull(): void { $statement = $this->persister->getSelectConditionStatementSQL('admin1', null, [], Comparison::NEQ); - $this->assertEquals('t0.admin1 IS NOT NULL AND t0.country IS NOT NULL', $statement); + self::assertEquals('t0.admin1 IS NOT NULL AND t0.country IS NOT NULL', $statement); } public function testSelectConditionStatementIn(): void diff --git a/tests/Doctrine/Tests/ORM/Persisters/BasicEntityPersisterTypeValueSqlTest.php b/tests/Doctrine/Tests/ORM/Persisters/BasicEntityPersisterTypeValueSqlTest.php index bf5284f1964..647ed645172 100644 --- a/tests/Doctrine/Tests/ORM/Persisters/BasicEntityPersisterTypeValueSqlTest.php +++ b/tests/Doctrine/Tests/ORM/Persisters/BasicEntityPersisterTypeValueSqlTest.php @@ -53,7 +53,7 @@ public function testGetInsertSQLUsesTypeValuesSQL(): void $sql = $method->invoke($this->persister); - $this->assertEquals('INSERT INTO customtype_parents (customInteger, child_id) VALUES (ABS(?), ?)', $sql); + self::assertEquals('INSERT INTO customtype_parents (customInteger, child_id) VALUES (ABS(?), ?)', $sql); } public function testUpdateUsesTypeValuesSQL(): void @@ -74,7 +74,7 @@ public function testUpdateUsesTypeValuesSQL(): void $executeStatements = $this->entityManager->getConnection()->getExecuteStatements(); - $this->assertEquals('UPDATE customtype_parents SET customInteger = ABS(?), child_id = ? WHERE id = ?', $executeStatements[0]['sql']); + self::assertEquals('UPDATE customtype_parents SET customInteger = ABS(?), child_id = ? WHERE id = ?', $executeStatements[0]['sql']); } public function testGetSelectConditionSQLUsesTypeValuesSQL(): void @@ -84,7 +84,7 @@ public function testGetSelectConditionSQLUsesTypeValuesSQL(): void $sql = $method->invoke($this->persister, ['customInteger' => 1, 'child' => 1]); - $this->assertEquals('t0.customInteger = ABS(?) AND t0.child_id = ?', $sql); + self::assertEquals('t0.customInteger = ABS(?) AND t0.child_id = ?', $sql); } /** @@ -96,7 +96,7 @@ public function testStripNonAlphanumericCharactersFromSelectColumnListSQL(): voi $method = new ReflectionMethod($persister, 'getSelectColumnsSQL'); $method->setAccessible(true); - $this->assertEquals('t0."simple-entity-id" AS simpleentityid_1, t0."simple-entity-value" AS simpleentityvalue_2', $method->invoke($persister)); + self::assertEquals('t0."simple-entity-id" AS simpleentityid_1, t0."simple-entity-value" AS simpleentityvalue_2', $method->invoke($persister)); } /** @@ -105,19 +105,19 @@ public function testStripNonAlphanumericCharactersFromSelectColumnListSQL(): voi public function testSelectConditionStatementIsNull(): void { $statement = $this->persister->getSelectConditionStatementSQL('test', null, [], Comparison::IS); - $this->assertEquals('test IS NULL', $statement); + self::assertEquals('test IS NULL', $statement); } public function testSelectConditionStatementEqNull(): void { $statement = $this->persister->getSelectConditionStatementSQL('test', null, [], Comparison::EQ); - $this->assertEquals('test IS NULL', $statement); + self::assertEquals('test IS NULL', $statement); } public function testSelectConditionStatementNeqNull(): void { $statement = $this->persister->getSelectConditionStatementSQL('test', null, [], Comparison::NEQ); - $this->assertEquals('test IS NOT NULL', $statement); + self::assertEquals('test IS NOT NULL', $statement); } /** @@ -125,17 +125,17 @@ public function testSelectConditionStatementNeqNull(): void */ public function testSelectConditionStatementWithMultipleValuesContainingNull(): void { - $this->assertEquals( + self::assertEquals( '(t0.id IN (?) OR t0.id IS NULL)', $this->persister->getSelectConditionStatementSQL('id', [null]) ); - $this->assertEquals( + self::assertEquals( '(t0.id IN (?) OR t0.id IS NULL)', $this->persister->getSelectConditionStatementSQL('id', [null, 123]) ); - $this->assertEquals( + self::assertEquals( '(t0.id IN (?) OR t0.id IS NULL)', $this->persister->getSelectConditionStatementSQL('id', [123, null]) ); @@ -147,17 +147,17 @@ public function testCountCondition(): void // Using a criteria as array $statement = $persister->getCountSQL(['value' => 'bar']); - $this->assertEquals('SELECT COUNT(*) FROM "not-a-simple-entity" t0 WHERE t0."simple-entity-value" = ?', $statement); + self::assertEquals('SELECT COUNT(*) FROM "not-a-simple-entity" t0 WHERE t0."simple-entity-value" = ?', $statement); // Using a criteria object $criteria = new Criteria(Criteria::expr()->eq('value', 'bar')); $statement = $persister->getCountSQL($criteria); - $this->assertEquals('SELECT COUNT(*) FROM "not-a-simple-entity" t0 WHERE t0."simple-entity-value" = ?', $statement); + self::assertEquals('SELECT COUNT(*) FROM "not-a-simple-entity" t0 WHERE t0."simple-entity-value" = ?', $statement); } public function testCountEntities(): void { - $this->assertEquals(0, $this->persister->count()); + self::assertEquals(0, $this->persister->count()); } public function testDeleteManyToManyUsesTypeValuesSQL(): void diff --git a/tests/Doctrine/Tests/ORM/Persisters/JoinedSubclassPersisterTest.php b/tests/Doctrine/Tests/ORM/Persisters/JoinedSubclassPersisterTest.php index 81873272e1b..31411d306bf 100644 --- a/tests/Doctrine/Tests/ORM/Persisters/JoinedSubclassPersisterTest.php +++ b/tests/Doctrine/Tests/ORM/Persisters/JoinedSubclassPersisterTest.php @@ -35,6 +35,6 @@ protected function setUp(): void */ public function testExecuteInsertsWillReturnEmptySetWithNoQueuedInserts(): void { - $this->assertSame([], $this->persister->executeInserts()); + self::assertSame([], $this->persister->executeInserts()); } } diff --git a/tests/Doctrine/Tests/ORM/Proxy/ProxyFactoryTest.php b/tests/Doctrine/Tests/ORM/Proxy/ProxyFactoryTest.php index a1024fab0e6..309eb927fca 100644 --- a/tests/Doctrine/Tests/ORM/Proxy/ProxyFactoryTest.php +++ b/tests/Doctrine/Tests/ORM/Proxy/ProxyFactoryTest.php @@ -63,10 +63,10 @@ public function testReferenceProxyDelegatesLoadingToThePersister(): void $proxy = $this->proxyFactory->getProxy(ECommerceFeature::class, $identifier); $persister - ->expects($this->atLeastOnce()) + ->expects(self::atLeastOnce()) ->method('load') - ->with($this->equalTo($identifier), $this->isInstanceOf($proxyClass)) - ->will($this->returnValue(new stdClass())); + ->with(self::equalTo($identifier), self::isInstanceOf($proxyClass)) + ->will(self::returnValue(new stdClass())); $proxy->getDescription(); } @@ -105,11 +105,11 @@ public function testSkipAbstractClassesOnGeneration(): void { $cm = new ClassMetadata(AbstractClass::class); $cm->initializeReflection(new RuntimeReflectionService()); - $this->assertNotNull($cm->reflClass); + self::assertNotNull($cm->reflClass); $num = $this->proxyFactory->generateProxyClasses([$cm]); - $this->assertEquals(0, $num, 'No proxies generated.'); + self::assertEquals(0, $num, 'No proxies generated.'); } /** @@ -124,19 +124,19 @@ public function testFailedProxyLoadingDoesNotMarkTheProxyAsInitialized(): void assert($proxy instanceof Proxy); $persister - ->expects($this->atLeastOnce()) + ->expects(self::atLeastOnce()) ->method('load') - ->will($this->returnValue(null)); + ->will(self::returnValue(null)); try { $proxy->getDescription(); - $this->fail('An exception was expected to be raised'); + self::fail('An exception was expected to be raised'); } catch (EntityNotFoundException $exception) { } - $this->assertFalse($proxy->__isInitialized()); - $this->assertInstanceOf('Closure', $proxy->__getInitializer(), 'The initializer wasn\'t removed'); - $this->assertInstanceOf('Closure', $proxy->__getCloner(), 'The cloner wasn\'t removed'); + self::assertFalse($proxy->__isInitialized()); + self::assertInstanceOf('Closure', $proxy->__getInitializer(), 'The initializer wasn\'t removed'); + self::assertInstanceOf('Closure', $proxy->__getCloner(), 'The cloner wasn\'t removed'); } /** @@ -151,19 +151,19 @@ public function testFailedProxyCloningDoesNotMarkTheProxyAsInitialized(): void assert($proxy instanceof Proxy); $persister - ->expects($this->atLeastOnce()) + ->expects(self::atLeastOnce()) ->method('load') - ->will($this->returnValue(null)); + ->will(self::returnValue(null)); try { $cloned = clone $proxy; - $this->fail('An exception was expected to be raised'); + self::fail('An exception was expected to be raised'); } catch (EntityNotFoundException $exception) { } - $this->assertFalse($proxy->__isInitialized()); - $this->assertInstanceOf('Closure', $proxy->__getInitializer(), 'The initializer wasn\'t removed'); - $this->assertInstanceOf('Closure', $proxy->__getCloner(), 'The cloner wasn\'t removed'); + self::assertFalse($proxy->__isInitialized()); + self::assertInstanceOf('Closure', $proxy->__getInitializer(), 'The initializer wasn\'t removed'); + self::assertInstanceOf('Closure', $proxy->__getCloner(), 'The cloner wasn\'t removed'); } public function testProxyClonesParentFields(): void diff --git a/tests/Doctrine/Tests/ORM/Query/CustomTreeWalkersJoinTest.php b/tests/Doctrine/Tests/ORM/Query/CustomTreeWalkersJoinTest.php index f4dd6a12e29..8816970874e 100644 --- a/tests/Doctrine/Tests/ORM/Query/CustomTreeWalkersJoinTest.php +++ b/tests/Doctrine/Tests/ORM/Query/CustomTreeWalkersJoinTest.php @@ -33,10 +33,10 @@ public function assertSqlGeneration(string $dqlToBeTested, string $sqlToBeConfir $query->setHint(Query::HINT_CUSTOM_TREE_WALKERS, [CustomTreeWalkerJoin::class]) ->useQueryCache(false); - $this->assertEquals($sqlToBeConfirmed, $query->getSql()); + self::assertEquals($sqlToBeConfirmed, $query->getSql()); $query->free(); } catch (Exception $e) { - $this->fail($e->getMessage() . ' at "' . $e->getFile() . '" on line ' . $e->getLine()); + self::fail($e->getMessage() . ' at "' . $e->getFile() . '" on line ' . $e->getLine()); } } diff --git a/tests/Doctrine/Tests/ORM/Query/CustomTreeWalkersTest.php b/tests/Doctrine/Tests/ORM/Query/CustomTreeWalkersTest.php index 95332788e6b..fb1028a727d 100644 --- a/tests/Doctrine/Tests/ORM/Query/CustomTreeWalkersTest.php +++ b/tests/Doctrine/Tests/ORM/Query/CustomTreeWalkersTest.php @@ -60,9 +60,9 @@ public function assertSqlGeneration( ?string $outputWalker = null ): void { try { - $this->assertEquals($sqlToBeConfirmed, $this->generateSql($dqlToBeTested, $treeWalkers, $outputWalker)); + self::assertEquals($sqlToBeConfirmed, $this->generateSql($dqlToBeTested, $treeWalkers, $outputWalker)); } catch (Exception $e) { - $this->fail($e->getMessage() . ' at "' . $e->getFile() . '" on line ' . $e->getLine()); + self::fail($e->getMessage() . ' at "' . $e->getFile() . '" on line ' . $e->getLine()); } } diff --git a/tests/Doctrine/Tests/ORM/Query/DeleteSqlGenerationTest.php b/tests/Doctrine/Tests/ORM/Query/DeleteSqlGenerationTest.php index d2b76a63717..002b64c4521 100644 --- a/tests/Doctrine/Tests/ORM/Query/DeleteSqlGenerationTest.php +++ b/tests/Doctrine/Tests/ORM/Query/DeleteSqlGenerationTest.php @@ -34,7 +34,7 @@ public function assertSqlGeneration(string $dqlToBeTested, string $sqlToBeConfir parent::assertEquals($sqlToBeConfirmed, $query->getSql()); $query->free(); } catch (Exception $e) { - $this->fail($e->getMessage()); + self::fail($e->getMessage()); } } diff --git a/tests/Doctrine/Tests/ORM/Query/ExprTest.php b/tests/Doctrine/Tests/ORM/Query/ExprTest.php index e2614aa3f48..4cd6c43e2bc 100644 --- a/tests/Doctrine/Tests/ORM/Query/ExprTest.php +++ b/tests/Doctrine/Tests/ORM/Query/ExprTest.php @@ -32,32 +32,32 @@ protected function setUp(): void public function testAvgExpr(): void { - $this->assertEquals('AVG(u.id)', (string) $this->expr->avg('u.id')); + self::assertEquals('AVG(u.id)', (string) $this->expr->avg('u.id')); } public function testMaxExpr(): void { - $this->assertEquals('MAX(u.id)', (string) $this->expr->max('u.id')); + self::assertEquals('MAX(u.id)', (string) $this->expr->max('u.id')); } public function testMinExpr(): void { - $this->assertEquals('MIN(u.id)', (string) $this->expr->min('u.id')); + self::assertEquals('MIN(u.id)', (string) $this->expr->min('u.id')); } public function testCountExpr(): void { - $this->assertEquals('MAX(u.id)', (string) $this->expr->max('u.id')); + self::assertEquals('MAX(u.id)', (string) $this->expr->max('u.id')); } public function testCountDistinctExpr(): void { - $this->assertEquals('COUNT(DISTINCT u.id)', (string) $this->expr->countDistinct('u.id')); + self::assertEquals('COUNT(DISTINCT u.id)', (string) $this->expr->countDistinct('u.id')); } public function testCountDistinctExprMulti(): void { - $this->assertEquals('COUNT(DISTINCT u.id, u.name)', (string) $this->expr->countDistinct('u.id', 'u.name')); + self::assertEquals('COUNT(DISTINCT u.id, u.name)', (string) $this->expr->countDistinct('u.id', 'u.name')); } public function testExistsExpr(): void @@ -65,7 +65,7 @@ public function testExistsExpr(): void $qb = $this->entityManager->createQueryBuilder(); $qb->select('u')->from('User', 'u')->where('u.name = ?1'); - $this->assertEquals('EXISTS(SELECT u FROM User u WHERE u.name = ?1)', (string) $this->expr->exists($qb)); + self::assertEquals('EXISTS(SELECT u FROM User u WHERE u.name = ?1)', (string) $this->expr->exists($qb)); } public function testAllExpr(): void @@ -73,7 +73,7 @@ public function testAllExpr(): void $qb = $this->entityManager->createQueryBuilder(); $qb->select('u')->from('User', 'u')->where('u.name = ?1'); - $this->assertEquals('ALL(SELECT u FROM User u WHERE u.name = ?1)', (string) $this->expr->all($qb)); + self::assertEquals('ALL(SELECT u FROM User u WHERE u.name = ?1)', (string) $this->expr->all($qb)); } public function testSomeExpr(): void @@ -81,7 +81,7 @@ public function testSomeExpr(): void $qb = $this->entityManager->createQueryBuilder(); $qb->select('u')->from('User', 'u')->where('u.name = ?1'); - $this->assertEquals('SOME(SELECT u FROM User u WHERE u.name = ?1)', (string) $this->expr->some($qb)); + self::assertEquals('SOME(SELECT u FROM User u WHERE u.name = ?1)', (string) $this->expr->some($qb)); } public function testAnyExpr(): void @@ -89,7 +89,7 @@ public function testAnyExpr(): void $qb = $this->entityManager->createQueryBuilder(); $qb->select('u')->from('User', 'u')->where('u.name = ?1'); - $this->assertEquals('ANY(SELECT u FROM User u WHERE u.name = ?1)', (string) $this->expr->any($qb)); + self::assertEquals('ANY(SELECT u FROM User u WHERE u.name = ?1)', (string) $this->expr->any($qb)); } public function testNotExpr(): void @@ -97,17 +97,17 @@ public function testNotExpr(): void $qb = $this->entityManager->createQueryBuilder(); $qb->select('u')->from('User', 'u')->where('u.name = ?1'); - $this->assertEquals('NOT(SELECT u FROM User u WHERE u.name = ?1)', (string) $this->expr->not($qb)); + self::assertEquals('NOT(SELECT u FROM User u WHERE u.name = ?1)', (string) $this->expr->not($qb)); } public function testAndExpr(): void { - $this->assertEquals('1 = 1 AND 2 = 2', (string) $this->expr->andX((string) $this->expr->eq(1, 1), (string) $this->expr->eq(2, 2))); + self::assertEquals('1 = 1 AND 2 = 2', (string) $this->expr->andX((string) $this->expr->eq(1, 1), (string) $this->expr->eq(2, 2))); } public function testIntelligentParenthesisPreventionAndExpr(): void { - $this->assertEquals( + self::assertEquals( '1 = 1 AND 2 = 2', (string) $this->expr->andX($this->expr->orX($this->expr->andX($this->expr->eq(1, 1))), (string) $this->expr->eq(2, 2)) ); @@ -115,69 +115,69 @@ public function testIntelligentParenthesisPreventionAndExpr(): void public function testOrExpr(): void { - $this->assertEquals('1 = 1 OR 2 = 2', (string) $this->expr->orX((string) $this->expr->eq(1, 1), (string) $this->expr->eq(2, 2))); + self::assertEquals('1 = 1 OR 2 = 2', (string) $this->expr->orX((string) $this->expr->eq(1, 1), (string) $this->expr->eq(2, 2))); } public function testAbsExpr(): void { - $this->assertEquals('ABS(1)', (string) $this->expr->abs(1)); + self::assertEquals('ABS(1)', (string) $this->expr->abs(1)); } public function testProdExpr(): void { - $this->assertEquals('1 * 2', (string) $this->expr->prod(1, 2)); + self::assertEquals('1 * 2', (string) $this->expr->prod(1, 2)); } public function testDiffExpr(): void { - $this->assertEquals('1 - 2', (string) $this->expr->diff(1, 2)); + self::assertEquals('1 - 2', (string) $this->expr->diff(1, 2)); } public function testSumExpr(): void { - $this->assertEquals('1 + 2', (string) $this->expr->sum(1, 2)); + self::assertEquals('1 + 2', (string) $this->expr->sum(1, 2)); } public function testQuotientExpr(): void { - $this->assertEquals('10 / 2', (string) $this->expr->quot(10, 2)); + self::assertEquals('10 / 2', (string) $this->expr->quot(10, 2)); } public function testScopeInArithmeticExpr(): void { - $this->assertEquals('(100 - 20) / 2', (string) $this->expr->quot($this->expr->diff(100, 20), 2)); - $this->assertEquals('100 - (20 / 2)', (string) $this->expr->diff(100, $this->expr->quot(20, 2))); + self::assertEquals('(100 - 20) / 2', (string) $this->expr->quot($this->expr->diff(100, 20), 2)); + self::assertEquals('100 - (20 / 2)', (string) $this->expr->diff(100, $this->expr->quot(20, 2))); } public function testSquareRootExpr(): void { - $this->assertEquals('SQRT(1)', (string) $this->expr->sqrt(1)); + self::assertEquals('SQRT(1)', (string) $this->expr->sqrt(1)); } public function testEqualExpr(): void { - $this->assertEquals('1 = 1', (string) $this->expr->eq(1, 1)); + self::assertEquals('1 = 1', (string) $this->expr->eq(1, 1)); } public function testLikeExpr(): void { - $this->assertEquals('a.description LIKE :description', (string) $this->expr->like('a.description', ':description')); + self::assertEquals('a.description LIKE :description', (string) $this->expr->like('a.description', ':description')); } public function testNotLikeExpr(): void { - $this->assertEquals('a.description NOT LIKE :description', (string) $this->expr->notLike('a.description', ':description')); + self::assertEquals('a.description NOT LIKE :description', (string) $this->expr->notLike('a.description', ':description')); } public function testConcatExpr(): void { - $this->assertEquals('CONCAT(u.first_name, u.last_name)', (string) $this->expr->concat('u.first_name', 'u.last_name')); - $this->assertEquals('CONCAT(u.first_name, u.middle_name, u.last_name)', (string) $this->expr->concat('u.first_name', 'u.middle_name', 'u.last_name')); + self::assertEquals('CONCAT(u.first_name, u.last_name)', (string) $this->expr->concat('u.first_name', 'u.last_name')); + self::assertEquals('CONCAT(u.first_name, u.middle_name, u.last_name)', (string) $this->expr->concat('u.first_name', 'u.middle_name', 'u.last_name')); } public function testSubstringExpr(): void { - $this->assertEquals('SUBSTRING(a.title, 0, 25)', (string) $this->expr->substring('a.title', 0, 25)); + self::assertEquals('SUBSTRING(a.title, 0, 25)', (string) $this->expr->substring('a.title', 0, 25)); } public function testModExpr(): void @@ -191,42 +191,42 @@ public function testModExpr(): void */ public function testSubstringExprAcceptsTwoArguments(): void { - $this->assertEquals('SUBSTRING(a.title, 5)', (string) $this->expr->substring('a.title', 5)); + self::assertEquals('SUBSTRING(a.title, 5)', (string) $this->expr->substring('a.title', 5)); } public function testLowerExpr(): void { - $this->assertEquals('LOWER(u.first_name)', (string) $this->expr->lower('u.first_name')); + self::assertEquals('LOWER(u.first_name)', (string) $this->expr->lower('u.first_name')); } public function testUpperExpr(): void { - $this->assertEquals('UPPER(u.first_name)', (string) $this->expr->upper('u.first_name')); + self::assertEquals('UPPER(u.first_name)', (string) $this->expr->upper('u.first_name')); } public function testLengthExpr(): void { - $this->assertEquals('LENGTH(u.first_name)', (string) $this->expr->length('u.first_name')); + self::assertEquals('LENGTH(u.first_name)', (string) $this->expr->length('u.first_name')); } public function testGreaterThanExpr(): void { - $this->assertEquals('5 > 2', (string) $this->expr->gt(5, 2)); + self::assertEquals('5 > 2', (string) $this->expr->gt(5, 2)); } public function testLessThanExpr(): void { - $this->assertEquals('2 < 5', (string) $this->expr->lt(2, 5)); + self::assertEquals('2 < 5', (string) $this->expr->lt(2, 5)); } public function testStringLiteralExpr(): void { - $this->assertEquals("'word'", (string) $this->expr->literal('word')); + self::assertEquals("'word'", (string) $this->expr->literal('word')); } public function testNumericLiteralExpr(): void { - $this->assertEquals(5, (string) $this->expr->literal(5)); + self::assertEquals(5, (string) $this->expr->literal(5)); } /** @@ -235,47 +235,47 @@ public function testNumericLiteralExpr(): void */ public function testLiteralExprProperlyQuotesStrings(): void { - $this->assertEquals("'00010001'", (string) $this->expr->literal('00010001')); + self::assertEquals("'00010001'", (string) $this->expr->literal('00010001')); } public function testGreaterThanOrEqualToExpr(): void { - $this->assertEquals('5 >= 2', (string) $this->expr->gte(5, 2)); + self::assertEquals('5 >= 2', (string) $this->expr->gte(5, 2)); } public function testLessThanOrEqualTo(): void { - $this->assertEquals('2 <= 5', (string) $this->expr->lte(2, 5)); + self::assertEquals('2 <= 5', (string) $this->expr->lte(2, 5)); } public function testBetweenExpr(): void { - $this->assertEquals('u.id BETWEEN 3 AND 6', (string) $this->expr->between('u.id', 3, 6)); + self::assertEquals('u.id BETWEEN 3 AND 6', (string) $this->expr->between('u.id', 3, 6)); } public function testTrimExpr(): void { - $this->assertEquals('TRIM(u.id)', (string) $this->expr->trim('u.id')); + self::assertEquals('TRIM(u.id)', (string) $this->expr->trim('u.id')); } public function testIsNullExpr(): void { - $this->assertEquals('u.id IS NULL', (string) $this->expr->isNull('u.id')); + self::assertEquals('u.id IS NULL', (string) $this->expr->isNull('u.id')); } public function testIsNotNullExpr(): void { - $this->assertEquals('u.id IS NOT NULL', (string) $this->expr->isNotNull('u.id')); + self::assertEquals('u.id IS NOT NULL', (string) $this->expr->isNotNull('u.id')); } public function testIsInstanceOfExpr(): void { - $this->assertEquals('u INSTANCE OF Doctrine\Tests\Models\Company\CompanyEmployee', (string) $this->expr->isInstanceOf('u', CompanyEmployee::class)); + self::assertEquals('u INSTANCE OF Doctrine\Tests\Models\Company\CompanyEmployee', (string) $this->expr->isInstanceOf('u', CompanyEmployee::class)); } public function testIsMemberOfExpr(): void { - $this->assertEquals(':groupId MEMBER OF u.groups', (string) $this->expr->isMemberOf(':groupId', 'u.groups')); + self::assertEquals(':groupId MEMBER OF u.groups', (string) $this->expr->isMemberOf(':groupId', 'u.groups')); } public function provideIterableValue(): Generator @@ -340,7 +340,7 @@ public function testAndxOrxExpr(): void $orExpr->add($andExpr); $orExpr->add($this->expr->eq(1, 1)); - $this->assertEquals('(1 = 1 AND 1 < 5) OR 1 = 1', (string) $orExpr); + self::assertEquals('(1 = 1 AND 1 < 5) OR 1 = 1', (string) $orExpr); } public function testOrxExpr(): void @@ -349,27 +349,27 @@ public function testOrxExpr(): void $orExpr->add($this->expr->eq(1, 1)); $orExpr->add($this->expr->lt(1, 5)); - $this->assertEquals('1 = 1 OR 1 < 5', (string) $orExpr); + self::assertEquals('1 = 1 OR 1 < 5', (string) $orExpr); } public function testOrderByCountExpr(): void { $orderExpr = $this->expr->desc('u.username'); - $this->assertEquals($orderExpr->count(), 1); - $this->assertEquals('u.username DESC', (string) $orderExpr); + self::assertEquals($orderExpr->count(), 1); + self::assertEquals('u.username DESC', (string) $orderExpr); } public function testOrderByOrder(): void { $orderExpr = $this->expr->desc('u.username'); - $this->assertEquals('u.username DESC', (string) $orderExpr); + self::assertEquals('u.username DESC', (string) $orderExpr); } public function testOrderByAsc(): void { $orderExpr = $this->expr->asc('u.username'); - $this->assertEquals('u.username ASC', (string) $orderExpr); + self::assertEquals('u.username ASC', (string) $orderExpr); } public function testAddThrowsException(): void @@ -384,8 +384,8 @@ public function testAddThrowsException(): void */ public function testBooleanLiteral(): void { - $this->assertEquals('true', $this->expr->literal(true)); - $this->assertEquals('false', $this->expr->literal(false)); + self::assertEquals('true', $this->expr->literal(true)); + self::assertEquals('false', $this->expr->literal(false)); } /** @@ -395,59 +395,59 @@ public function testExpressionGetter(): void { // Andx $andx = new Expr\Andx(['1 = 1', '2 = 2']); - $this->assertEquals(['1 = 1', '2 = 2'], $andx->getParts()); + self::assertEquals(['1 = 1', '2 = 2'], $andx->getParts()); // Comparison $comparison = new Expr\Comparison('foo', Expr\Comparison::EQ, 'bar'); - $this->assertEquals('foo', $comparison->getLeftExpr()); - $this->assertEquals('bar', $comparison->getRightExpr()); - $this->assertEquals(Expr\Comparison::EQ, $comparison->getOperator()); + self::assertEquals('foo', $comparison->getLeftExpr()); + self::assertEquals('bar', $comparison->getRightExpr()); + self::assertEquals(Expr\Comparison::EQ, $comparison->getOperator()); // From $from = new Expr\From('Foo', 'f', 'f.id'); - $this->assertEquals('f', $from->getAlias()); - $this->assertEquals('Foo', $from->getFrom()); - $this->assertEquals('f.id', $from->getIndexBy()); + self::assertEquals('f', $from->getAlias()); + self::assertEquals('Foo', $from->getFrom()); + self::assertEquals('f.id', $from->getIndexBy()); // Func $func = new Expr\Func('MAX', ['f.id']); - $this->assertEquals('MAX', $func->getName()); - $this->assertEquals(['f.id'], $func->getArguments()); + self::assertEquals('MAX', $func->getName()); + self::assertEquals(['f.id'], $func->getArguments()); // GroupBy $group = new Expr\GroupBy(['foo DESC', 'bar ASC']); - $this->assertEquals(['foo DESC', 'bar ASC'], $group->getParts()); + self::assertEquals(['foo DESC', 'bar ASC'], $group->getParts()); // Join $join = new Expr\Join(Expr\Join::INNER_JOIN, 'f.bar', 'b', Expr\Join::ON, 'b.bar_id = 1', 'b.bar_id'); - $this->assertEquals(Expr\Join::INNER_JOIN, $join->getJoinType()); - $this->assertEquals(Expr\Join::ON, $join->getConditionType()); - $this->assertEquals('b.bar_id = 1', $join->getCondition()); - $this->assertEquals('b.bar_id', $join->getIndexBy()); - $this->assertEquals('f.bar', $join->getJoin()); - $this->assertEquals('b', $join->getAlias()); + self::assertEquals(Expr\Join::INNER_JOIN, $join->getJoinType()); + self::assertEquals(Expr\Join::ON, $join->getConditionType()); + self::assertEquals('b.bar_id = 1', $join->getCondition()); + self::assertEquals('b.bar_id', $join->getIndexBy()); + self::assertEquals('f.bar', $join->getJoin()); + self::assertEquals('b', $join->getAlias()); // Literal $literal = new Expr\Literal(['foo']); - $this->assertEquals(['foo'], $literal->getParts()); + self::assertEquals(['foo'], $literal->getParts()); // Math $math = new Expr\Math(10, '+', 20); - $this->assertEquals(10, $math->getLeftExpr()); - $this->assertEquals(20, $math->getRightExpr()); - $this->assertEquals('+', $math->getOperator()); + self::assertEquals(10, $math->getLeftExpr()); + self::assertEquals(20, $math->getRightExpr()); + self::assertEquals('+', $math->getOperator()); // OrderBy $order = new Expr\OrderBy('foo', 'DESC'); - $this->assertEquals(['foo DESC'], $order->getParts()); + self::assertEquals(['foo DESC'], $order->getParts()); // Andx $orx = new Expr\Orx(['foo = 1', 'bar = 2']); - $this->assertEquals(['foo = 1', 'bar = 2'], $orx->getParts()); + self::assertEquals(['foo = 1', 'bar = 2'], $orx->getParts()); // Select $select = new Expr\Select(['foo', 'bar']); - $this->assertEquals(['foo', 'bar'], $select->getParts()); + self::assertEquals(['foo', 'bar'], $select->getParts()); } public function testAddEmpty(): void @@ -455,7 +455,7 @@ public function testAddEmpty(): void $andExpr = $this->expr->andX(); $andExpr->add($this->expr->andX()); - $this->assertEquals(0, $andExpr->count()); + self::assertEquals(0, $andExpr->count()); } public function testAddNull(): void @@ -463,6 +463,6 @@ public function testAddNull(): void $andExpr = $this->expr->andX(); $andExpr->add(null); - $this->assertEquals(0, $andExpr->count()); + self::assertEquals(0, $andExpr->count()); } } diff --git a/tests/Doctrine/Tests/ORM/Query/FilterCollectionTest.php b/tests/Doctrine/Tests/ORM/Query/FilterCollectionTest.php index 4629b46566f..f8ff65f433f 100644 --- a/tests/Doctrine/Tests/ORM/Query/FilterCollectionTest.php +++ b/tests/Doctrine/Tests/ORM/Query/FilterCollectionTest.php @@ -27,25 +27,25 @@ public function testEnable(): void { $filterCollection = $this->em->getFilters(); - $this->assertCount(0, $filterCollection->getEnabledFilters()); + self::assertCount(0, $filterCollection->getEnabledFilters()); $filterCollection->enable('testFilter'); $enabledFilters = $filterCollection->getEnabledFilters(); - $this->assertCount(1, $enabledFilters); - $this->assertContainsOnly(MyFilter::class, $enabledFilters); + self::assertCount(1, $enabledFilters); + self::assertContainsOnly(MyFilter::class, $enabledFilters); $filterCollection->disable('testFilter'); - $this->assertCount(0, $filterCollection->getEnabledFilters()); + self::assertCount(0, $filterCollection->getEnabledFilters()); } public function testHasFilter(): void { $filterCollection = $this->em->getFilters(); - $this->assertTrue($filterCollection->has('testFilter')); - $this->assertFalse($filterCollection->has('fakeFilter')); + self::assertTrue($filterCollection->has('testFilter')); + self::assertFalse($filterCollection->has('fakeFilter')); } /** @@ -55,11 +55,11 @@ public function testIsEnabled(): void { $filterCollection = $this->em->getFilters(); - $this->assertFalse($filterCollection->isEnabled('testFilter')); + self::assertFalse($filterCollection->isEnabled('testFilter')); $filterCollection->enable('testFilter'); - $this->assertTrue($filterCollection->isEnabled('testFilter')); + self::assertTrue($filterCollection->isEnabled('testFilter')); } public function testGetFilterInvalidArgument(): void @@ -74,7 +74,7 @@ public function testGetFilter(): void $filterCollection = $this->em->getFilters(); $filterCollection->enable('testFilter'); - $this->assertInstanceOf(MyFilter::class, $filterCollection->getFilter('testFilter')); + self::assertInstanceOf(MyFilter::class, $filterCollection->getFilter('testFilter')); } } diff --git a/tests/Doctrine/Tests/ORM/Query/LanguageRecognitionTest.php b/tests/Doctrine/Tests/ORM/Query/LanguageRecognitionTest.php index 123feeed2ac..819ca683c11 100644 --- a/tests/Doctrine/Tests/ORM/Query/LanguageRecognitionTest.php +++ b/tests/Doctrine/Tests/ORM/Query/LanguageRecognitionTest.php @@ -38,7 +38,7 @@ public function assertValidDQL($dql, $debug = false): void echo $e->getTraceAsString() . PHP_EOL; } - $this->fail($e->getMessage()); + self::fail($e->getMessage()); } } @@ -47,7 +47,7 @@ public function assertInvalidDQL($dql, $debug = false): void try { $parserResult = $this->parseDql($dql); - $this->fail('No syntax errors were detected, when syntax errors were expected'); + self::fail('No syntax errors were detected, when syntax errors were expected'); } catch (QueryException $e) { if ($debug) { echo $e->getMessage() . PHP_EOL; diff --git a/tests/Doctrine/Tests/ORM/Query/LexerTest.php b/tests/Doctrine/Tests/ORM/Query/LexerTest.php index 585160c84fe..15afd69e320 100644 --- a/tests/Doctrine/Tests/ORM/Query/LexerTest.php +++ b/tests/Doctrine/Tests/ORM/Query/LexerTest.php @@ -19,8 +19,8 @@ public function testScannerRecognizesTokens($type, $value): void $lexer->moveNext(); $token = $lexer->lookahead; - $this->assertEquals($type, $token['type']); - $this->assertEquals($value, $token['value']); + self::assertEquals($type, $token['type']); + self::assertEquals($value, $token['value']); } public function testScannerRecognizesTerminalString(): void @@ -36,7 +36,7 @@ public function testScannerRecognizesTerminalString(): void $lexer->moveNext(); $token = $lexer->lookahead; - $this->assertEquals(Lexer::T_ALL, $token['type']); + self::assertEquals(Lexer::T_ALL, $token['type']); } public function testScannerRecognizesDecimalInteger(): void @@ -44,8 +44,8 @@ public function testScannerRecognizesDecimalInteger(): void $lexer = new Lexer('1234'); $lexer->moveNext(); $token = $lexer->lookahead; - $this->assertEquals(Lexer::T_INTEGER, $token['type']); - $this->assertEquals(1234, $token['value']); + self::assertEquals(Lexer::T_INTEGER, $token['type']); + self::assertEquals(1234, $token['value']); } public function testScannerRecognizesFloat(): void @@ -53,8 +53,8 @@ public function testScannerRecognizesFloat(): void $lexer = new Lexer('1.234'); $lexer->moveNext(); $token = $lexer->lookahead; - $this->assertEquals(Lexer::T_FLOAT, $token['type']); - $this->assertEquals(1.234, $token['value']); + self::assertEquals(Lexer::T_FLOAT, $token['type']); + self::assertEquals(1.234, $token['value']); } public function testScannerRecognizesFloatWithExponent(): void @@ -62,8 +62,8 @@ public function testScannerRecognizesFloatWithExponent(): void $lexer = new Lexer('1.2e3'); $lexer->moveNext(); $token = $lexer->lookahead; - $this->assertEquals(Lexer::T_FLOAT, $token['type']); - $this->assertEquals(1.2e3, $token['value']); + self::assertEquals(Lexer::T_FLOAT, $token['type']); + self::assertEquals(1.2e3, $token['value']); } public function testScannerRecognizesFloatWithExponent2(): void @@ -71,8 +71,8 @@ public function testScannerRecognizesFloatWithExponent2(): void $lexer = new Lexer('0.2e3'); $lexer->moveNext(); $token = $lexer->lookahead; - $this->assertEquals(Lexer::T_FLOAT, $token['type']); - $this->assertEquals(.2e3, $token['value']); + self::assertEquals(Lexer::T_FLOAT, $token['type']); + self::assertEquals(.2e3, $token['value']); } public function testScannerRecognizesFloatWithNegativeExponent(): void @@ -80,8 +80,8 @@ public function testScannerRecognizesFloatWithNegativeExponent(): void $lexer = new Lexer('7E-10'); $lexer->moveNext(); $token = $lexer->lookahead; - $this->assertEquals(Lexer::T_FLOAT, $token['type']); - $this->assertEquals(7E-10, $token['value']); + self::assertEquals(Lexer::T_FLOAT, $token['type']); + self::assertEquals(7E-10, $token['value']); } public function testScannerRecognizesFloatBig(): void @@ -89,8 +89,8 @@ public function testScannerRecognizesFloatBig(): void $lexer = new Lexer('123456789.01'); $lexer->moveNext(); $token = $lexer->lookahead; - $this->assertEquals(Lexer::T_FLOAT, $token['type']); - $this->assertEquals(1.2345678901e8, $token['value']); + self::assertEquals(Lexer::T_FLOAT, $token['type']); + self::assertEquals(1.2345678901e8, $token['value']); } public function testScannerRecognizesFloatContainingWhitespace(): void @@ -98,14 +98,14 @@ public function testScannerRecognizesFloatContainingWhitespace(): void $lexer = new Lexer('- 1.234e2'); $lexer->moveNext(); $token = $lexer->lookahead; - $this->assertEquals(Lexer::T_MINUS, $token['type']); - $this->assertEquals('-', $token['value']); + self::assertEquals(Lexer::T_MINUS, $token['type']); + self::assertEquals('-', $token['value']); $lexer->moveNext(); $token = $lexer->lookahead; - $this->assertEquals(Lexer::T_FLOAT, $token['type']); - $this->assertNotEquals(-1.234e2, $token['value']); - $this->assertEquals(1.234e2, $token['value']); + self::assertEquals(Lexer::T_FLOAT, $token['type']); + self::assertNotEquals(-1.234e2, $token['value']); + self::assertEquals(1.234e2, $token['value']); } public function testScannerRecognizesStringContainingWhitespace(): void @@ -113,8 +113,8 @@ public function testScannerRecognizesStringContainingWhitespace(): void $lexer = new Lexer("'This is a string.'"); $lexer->moveNext(); $token = $lexer->lookahead; - $this->assertEquals(Lexer::T_STRING, $token['type']); - $this->assertEquals('This is a string.', $token['value']); + self::assertEquals(Lexer::T_STRING, $token['type']); + self::assertEquals('This is a string.', $token['value']); } public function testScannerRecognizesStringContainingSingleQuotes(): void @@ -122,8 +122,8 @@ public function testScannerRecognizesStringContainingSingleQuotes(): void $lexer = new Lexer("'abc''defg'''"); $lexer->moveNext(); $token = $lexer->lookahead; - $this->assertEquals(Lexer::T_STRING, $token['type']); - $this->assertEquals("abc'defg'", $token['value']); + self::assertEquals(Lexer::T_STRING, $token['type']); + self::assertEquals("abc'defg'", $token['value']); } public function testScannerRecognizesInputParameter(): void @@ -131,8 +131,8 @@ public function testScannerRecognizesInputParameter(): void $lexer = new Lexer('?1'); $lexer->moveNext(); $token = $lexer->lookahead; - $this->assertEquals(Lexer::T_INPUT_PARAMETER, $token['type']); - $this->assertEquals('?1', $token['value']); + self::assertEquals(Lexer::T_INPUT_PARAMETER, $token['type']); + self::assertEquals('?1', $token['value']); } public function testScannerRecognizesNamedInputParameter(): void @@ -140,8 +140,8 @@ public function testScannerRecognizesNamedInputParameter(): void $lexer = new Lexer(':name'); $lexer->moveNext(); $token = $lexer->lookahead; - $this->assertEquals(Lexer::T_INPUT_PARAMETER, $token['type']); - $this->assertEquals(':name', $token['value']); + self::assertEquals(Lexer::T_INPUT_PARAMETER, $token['type']); + self::assertEquals(':name', $token['value']); } public function testScannerRecognizesNamedInputParameterStartingWithUnderscore(): void @@ -149,8 +149,8 @@ public function testScannerRecognizesNamedInputParameterStartingWithUnderscore() $lexer = new Lexer(':_name'); $lexer->moveNext(); $token = $lexer->lookahead; - $this->assertEquals(Lexer::T_INPUT_PARAMETER, $token['type']); - $this->assertEquals(':_name', $token['value']); + self::assertEquals(Lexer::T_INPUT_PARAMETER, $token['type']); + self::assertEquals(':_name', $token['value']); } public function testScannerTokenizesASimpleQueryCorrectly(): void @@ -219,12 +219,12 @@ public function testScannerTokenizesASimpleQueryCorrectly(): void foreach ($tokens as $expected) { $lexer->moveNext(); $actual = $lexer->lookahead; - $this->assertEquals($expected['value'], $actual['value']); - $this->assertEquals($expected['type'], $actual['type']); - $this->assertEquals($expected['position'], $actual['position']); + self::assertEquals($expected['value'], $actual['value']); + self::assertEquals($expected['type'], $actual['type']); + self::assertEquals($expected['position'], $actual['position']); } - $this->assertFalse($lexer->moveNext()); + self::assertFalse($lexer->moveNext()); } /** @psalm-return list */ diff --git a/tests/Doctrine/Tests/ORM/Query/ParameterTypeInfererTest.php b/tests/Doctrine/Tests/ORM/Query/ParameterTypeInfererTest.php index df279c1a97d..5de9fca26b8 100644 --- a/tests/Doctrine/Tests/ORM/Query/ParameterTypeInfererTest.php +++ b/tests/Doctrine/Tests/ORM/Query/ParameterTypeInfererTest.php @@ -41,6 +41,6 @@ public function providerParameterTypeInferer(): array */ public function testParameterTypeInferer($value, $expected): void { - $this->assertEquals($expected, ParameterTypeInferer::inferType($value)); + self::assertEquals($expected, ParameterTypeInferer::inferType($value)); } } diff --git a/tests/Doctrine/Tests/ORM/Query/ParserResultTest.php b/tests/Doctrine/Tests/ORM/Query/ParserResultTest.php index 2bfc593d606..506b499d60c 100644 --- a/tests/Doctrine/Tests/ORM/Query/ParserResultTest.php +++ b/tests/Doctrine/Tests/ORM/Query/ParserResultTest.php @@ -21,31 +21,31 @@ protected function setUp(): void public function testGetRsm(): void { - $this->assertInstanceOf(ResultSetMapping::class, $this->parserResult->getResultSetMapping()); + self::assertInstanceOf(ResultSetMapping::class, $this->parserResult->getResultSetMapping()); } public function testSetGetSqlExecutor(): void { - $this->assertNull($this->parserResult->getSqlExecutor()); + self::assertNull($this->parserResult->getSqlExecutor()); $executor = $this->getMockBuilder(AbstractSqlExecutor::class)->setMethods(['execute'])->getMock(); $this->parserResult->setSqlExecutor($executor); - $this->assertSame($executor, $this->parserResult->getSqlExecutor()); + self::assertSame($executor, $this->parserResult->getSqlExecutor()); } public function testGetSqlParameterPosition(): void { $this->parserResult->addParameterMapping(1, 1); $this->parserResult->addParameterMapping(1, 2); - $this->assertEquals([1, 2], $this->parserResult->getSqlParameterPositions(1)); + self::assertEquals([1, 2], $this->parserResult->getSqlParameterPositions(1)); } public function testGetParameterMappings(): void { - $this->assertIsArray($this->parserResult->getParameterMappings()); + self::assertIsArray($this->parserResult->getParameterMappings()); $this->parserResult->addParameterMapping(1, 1); $this->parserResult->addParameterMapping(1, 2); - $this->assertEquals([1 => [1, 2]], $this->parserResult->getParameterMappings()); + self::assertEquals([1 => [1, 2]], $this->parserResult->getParameterMappings()); } } diff --git a/tests/Doctrine/Tests/ORM/Query/ParserTest.php b/tests/Doctrine/Tests/ORM/Query/ParserTest.php index 99e5fca3e00..f29065dd828 100644 --- a/tests/Doctrine/Tests/ORM/Query/ParserTest.php +++ b/tests/Doctrine/Tests/ORM/Query/ParserTest.php @@ -22,7 +22,7 @@ public function testAbstractSchemaNameSupportsFQCN(): void { $parser = $this->createParser(CmsUser::class); - $this->assertEquals(CmsUser::class, $parser->AbstractSchemaName()); + self::assertEquals(CmsUser::class, $parser->AbstractSchemaName()); } /** @@ -33,7 +33,7 @@ public function testAbstractSchemaNameSupportsClassnamesWithLeadingBackslash(): { $parser = $this->createParser('\\' . CmsUser::class); - $this->assertEquals('\\' . CmsUser::class, $parser->AbstractSchemaName()); + self::assertEquals('\\' . CmsUser::class, $parser->AbstractSchemaName()); } /** @@ -44,7 +44,7 @@ public function testAbstractSchemaNameSupportsIdentifier(): void { $parser = $this->createParser(stdClass::class); - $this->assertEquals(stdClass::class, $parser->AbstractSchemaName()); + self::assertEquals(stdClass::class, $parser->AbstractSchemaName()); } /** @@ -57,7 +57,7 @@ public function testAbstractSchemaNameSupportsNamespaceAlias(): void $parser->getEntityManager()->getConfiguration()->addEntityNamespace('CMS', 'Doctrine\Tests\Models\CMS'); - $this->assertEquals(CmsUser::class, $parser->AbstractSchemaName()); + self::assertEquals(CmsUser::class, $parser->AbstractSchemaName()); } /** @@ -70,7 +70,7 @@ public function testAbstractSchemaNameSupportsNamespaceAliasWithRelativeClassnam $parser->getEntityManager()->getConfiguration()->addEntityNamespace('Model', 'Doctrine\Tests\Models'); - $this->assertEquals(CmsUser::class, $parser->AbstractSchemaName()); + self::assertEquals(CmsUser::class, $parser->AbstractSchemaName()); } /** diff --git a/tests/Doctrine/Tests/ORM/Query/QueryExpressionVisitorTest.php b/tests/Doctrine/Tests/ORM/Query/QueryExpressionVisitorTest.php index 45d5150b387..c06586fff20 100644 --- a/tests/Doctrine/Tests/ORM/Query/QueryExpressionVisitorTest.php +++ b/tests/Doctrine/Tests/ORM/Query/QueryExpressionVisitorTest.php @@ -33,9 +33,9 @@ protected function setUp(): void */ public function testWalkComparison(CriteriaComparison $criteriaExpr, $queryExpr, ?Parameter $parameter = null): void { - $this->assertEquals($queryExpr, $this->visitor->walkComparison($criteriaExpr)); + self::assertEquals($queryExpr, $this->visitor->walkComparison($criteriaExpr)); if ($parameter) { - $this->assertEquals(new ArrayCollection([$parameter]), $this->visitor->getParameters()); + self::assertEquals(new ArrayCollection([$parameter]), $this->visitor->getParameters()); } } @@ -85,8 +85,8 @@ public function testWalkAndCompositeExpression(): void ) ); - $this->assertInstanceOf(QueryBuilder\Andx::class, $expr); - $this->assertCount(2, $expr->getParts()); + self::assertInstanceOf(QueryBuilder\Andx::class, $expr); + self::assertCount(2, $expr->getParts()); } public function testWalkOrCompositeExpression(): void @@ -99,13 +99,13 @@ public function testWalkOrCompositeExpression(): void ) ); - $this->assertInstanceOf(QueryBuilder\Orx::class, $expr); - $this->assertCount(2, $expr->getParts()); + self::assertInstanceOf(QueryBuilder\Orx::class, $expr); + self::assertCount(2, $expr->getParts()); } public function testWalkValue(): void { - $this->assertEquals('value', $this->visitor->walkValue(new Value('value'))); + self::assertEquals('value', $this->visitor->walkValue(new Value('value'))); } public function testClearParameters(): void @@ -114,6 +114,6 @@ public function testClearParameters(): void $this->visitor->clearParameters(); - $this->assertCount(0, $this->visitor->getParameters()); + self::assertCount(0, $this->visitor->getParameters()); } } diff --git a/tests/Doctrine/Tests/ORM/Query/QueryTest.php b/tests/Doctrine/Tests/ORM/Query/QueryTest.php index 226490524e6..bcd234991c7 100644 --- a/tests/Doctrine/Tests/ORM/Query/QueryTest.php +++ b/tests/Doctrine/Tests/ORM/Query/QueryTest.php @@ -45,7 +45,7 @@ public function testGetParameters(): void $parameters = new ArrayCollection(); - $this->assertEquals($parameters, $query->getParameters()); + self::assertEquals($parameters, $query->getParameters()); } public function testGetParametersHasSomeAlready(): void @@ -56,7 +56,7 @@ public function testGetParametersHasSomeAlready(): void $parameters = new ArrayCollection(); $parameters->add(new Parameter(2, 84)); - $this->assertEquals($parameters, $query->getParameters()); + self::assertEquals($parameters, $query->getParameters()); } public function testSetParameters(): void @@ -69,7 +69,7 @@ public function testSetParameters(): void $query->setParameters($parameters); - $this->assertEquals($parameters, $query->getParameters()); + self::assertEquals($parameters, $query->getParameters()); } public function testFree(): void @@ -79,7 +79,7 @@ public function testFree(): void $query->free(); - $this->assertEquals(0, count($query->getParameters())); + self::assertEquals(0, count($query->getParameters())); } public function testClone(): void @@ -92,9 +92,9 @@ public function testClone(): void $cloned = clone $query; - $this->assertEquals($dql, $cloned->getDQL()); - $this->assertEquals(0, count($cloned->getParameters())); - $this->assertFalse($cloned->getHint('foo')); + self::assertEquals($dql, $cloned->getDQL()); + self::assertEquals(0, count($cloned->getParameters())); + self::assertFalse($cloned->getHint('foo')); } public function testFluentQueryInterface(): void @@ -114,7 +114,7 @@ public function testFluentQueryInterface(): void ->setFirstResult(10) ->setMaxResults(10); - $this->assertSame($q2, $q); + self::assertSame($q2, $q); } /** @@ -125,11 +125,11 @@ public function testHints(): void $q = $this->entityManager->createQuery('select a from Doctrine\Tests\Models\CMS\CmsArticle a'); $q->setHint('foo', 'bar')->setHint('bar', 'baz'); - $this->assertEquals('bar', $q->getHint('foo')); - $this->assertEquals('baz', $q->getHint('bar')); - $this->assertEquals(['foo' => 'bar', 'bar' => 'baz'], $q->getHints()); - $this->assertTrue($q->hasHint('foo')); - $this->assertFalse($q->hasHint('barFooBaz')); + self::assertEquals('bar', $q->getHint('foo')); + self::assertEquals('baz', $q->getHint('bar')); + self::assertEquals(['foo' => 'bar', 'bar' => 'baz'], $q->getHints()); + self::assertTrue($q->hasHint('foo')); + self::assertFalse($q->hasHint('barFooBaz')); } /** @@ -140,7 +140,7 @@ public function testQueryDefaultResultCache(): void $this->entityManager->getConfiguration()->setResultCacheImpl(DoctrineProvider::wrap(new ArrayAdapter())); $q = $this->entityManager->createQuery('select a from Doctrine\Tests\Models\CMS\CmsArticle a'); $q->enableResultCache(); - $this->assertSame($this->entityManager->getConfiguration()->getResultCacheImpl(), $q->getQueryCacheProfile()->getResultCacheDriver()); + self::assertSame($this->entityManager->getConfiguration()->getResultCacheImpl(), $q->getQueryCacheProfile()->getResultCacheDriver()); } public function testIterateWithNoDistinctAndWrongSelectClause(): void @@ -211,8 +211,8 @@ public function testCollectionParameters(): void $parameters = $query->getParameters(); $parameter = $parameters->first(); - $this->assertEquals('cities', $parameter->getName()); - $this->assertEquals($cities, $parameter->getValue()); + self::assertEquals('cities', $parameter->getName()); + self::assertEquals($cities, $parameter->getValue()); } public function provideProcessParameterValueIterable(): Generator @@ -263,7 +263,7 @@ public function testProcessParameterValueWithIterableEntityShouldNotBeTreatedAsI public function testProcessParameterValueClassMetadata(): void { $query = $this->entityManager->createQuery('SELECT a FROM Doctrine\Tests\Models\CMS\CmsAddress a WHERE a.city IN (:cities)'); - $this->assertEquals( + self::assertEquals( CmsAddress::class, $query->processParameterValue($this->entityManager->getClassMetadata(CmsAddress::class)) ); @@ -312,11 +312,11 @@ public function testDefaultQueryHints(): void $config->setDefaultQueryHints($defaultHints); $query = $this->entityManager->createQuery(); - $this->assertSame($config->getDefaultQueryHints(), $query->getHints()); + self::assertSame($config->getDefaultQueryHints(), $query->getHints()); $this->entityManager->getConfiguration()->setDefaultQueryHint('hint_name_1', 'hint_another_value_1'); - $this->assertNotSame($config->getDefaultQueryHints(), $query->getHints()); + self::assertNotSame($config->getDefaultQueryHints(), $query->getHints()); $q2 = clone $query; - $this->assertSame($config->getDefaultQueryHints(), $q2->getHints()); + self::assertSame($config->getDefaultQueryHints(), $q2->getHints()); } /** @@ -338,7 +338,7 @@ public function testResultCacheCaching(): void //let it cache ->getResult(); - $this->assertCount(1, $res); + self::assertCount(1, $res); $driverConnectionMock->setStatementMock(null); @@ -346,7 +346,7 @@ public function testResultCacheCaching(): void ->useQueryCache(true) ->disableResultCache() ->getResult(); - $this->assertCount(0, $res); + self::assertCount(0, $res); } /** @@ -356,7 +356,7 @@ public function testSetHydrationCacheProfileNull(): void { $query = $this->entityManager->createQuery(); $query->setHydrationCacheProfile(null); - $this->assertNull($query->getHydrationCacheProfile()); + self::assertNull($query->getHydrationCacheProfile()); } /** diff --git a/tests/Doctrine/Tests/ORM/Query/SelectSqlGenerationTest.php b/tests/Doctrine/Tests/ORM/Query/SelectSqlGenerationTest.php index 1b3ef50c846..b05fbfaeb9e 100644 --- a/tests/Doctrine/Tests/ORM/Query/SelectSqlGenerationTest.php +++ b/tests/Doctrine/Tests/ORM/Query/SelectSqlGenerationTest.php @@ -77,7 +77,7 @@ public function assertSqlGeneration( $query->free(); } catch (Exception $e) { - $this->fail($e->getMessage() . "\n" . $e->getTraceAsString()); + self::fail($e->getMessage() . "\n" . $e->getTraceAsString()); } } @@ -109,7 +109,7 @@ public function assertInvalidSqlGeneration( $query->free(); // If we reached here, test failed - $this->fail($sql); + self::fail($sql); } /** @@ -696,7 +696,7 @@ public function testSupportsMemberOfExpressionOneToMany(): void $phone->phonenumber = 101; $q->setParameter('param', $phone); - $this->assertEquals( + self::assertEquals( 'SELECT c0_.id AS id_0 FROM cms_users c0_ WHERE EXISTS (SELECT 1 FROM cms_phonenumbers c1_ WHERE c0_.id = c1_.user_id AND c1_.phonenumber = ?)', $q->getSql() ); @@ -712,7 +712,7 @@ public function testSupportsMemberOfExpressionManyToMany(): void $group->id = 101; $q->setParameter('param', $group); - $this->assertEquals( + self::assertEquals( 'SELECT c0_.id AS id_0 FROM cms_users c0_ WHERE EXISTS (SELECT 1 FROM cms_users_groups c1_ WHERE c1_.user_id = c0_.id AND c1_.group_id IN (?))', $q->getSql() ); @@ -729,7 +729,7 @@ public function testSupportsMemberOfExpressionManyToManyParameterArray(): void $group2->id = 105; $q->setParameter('param', [$group, $group2]); - $this->assertEquals( + self::assertEquals( 'SELECT c0_.id AS id_0 FROM cms_users c0_ WHERE EXISTS (SELECT 1 FROM cms_users_groups c1_ WHERE c1_.user_id = c0_.id AND c1_.group_id IN (?))', $q->getSql() ); @@ -743,7 +743,7 @@ public function testSupportsMemberOfExpressionSelfReferencing(): void $person = new CompanyPerson(); $this->entityManager->getClassMetadata(get_class($person))->setIdentifierValues($person, ['id' => 101]); $q->setParameter('param', $person); - $this->assertEquals( + self::assertEquals( 'SELECT c0_.id AS id_0, c0_.name AS name_1, c1_.title AS title_2, c2_.salary AS salary_3, c2_.department AS department_4, c2_.startDate AS startDate_5, c0_.discr AS discr_6, c0_.spouse_id AS spouse_id_7, c1_.car_id AS car_id_8 FROM company_persons c0_ LEFT JOIN company_managers c1_ ON c0_.id = c1_.id LEFT JOIN company_employees c2_ ON c0_.id = c2_.id WHERE EXISTS (SELECT 1 FROM company_persons_friends c3_ WHERE c3_.person_id = c0_.id AND c3_.friend_id IN (?))', $q->getSql() ); @@ -754,7 +754,7 @@ public function testSupportsMemberOfWithSingleValuedAssociation(): void // Impossible example, but it illustrates the purpose $q = $this->entityManager->createQuery('SELECT u.id FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.email MEMBER OF u.groups'); - $this->assertEquals( + self::assertEquals( 'SELECT c0_.id AS id_0 FROM cms_users c0_ WHERE EXISTS (SELECT 1 FROM cms_users_groups c1_ WHERE c1_.user_id = c0_.id AND c1_.group_id IN (c0_.email_id))', $q->getSql() ); @@ -765,7 +765,7 @@ public function testSupportsMemberOfWithIdentificationVariable(): void // Impossible example, but it illustrates the purpose $q = $this->entityManager->createQuery('SELECT u.id FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u MEMBER OF u.groups'); - $this->assertEquals( + self::assertEquals( 'SELECT c0_.id AS id_0 FROM cms_users c0_ WHERE EXISTS (SELECT 1 FROM cms_users_groups c1_ WHERE c1_.user_id = c0_.id AND c1_.group_id IN (c0_.id))', $q->getSql() ); @@ -775,21 +775,21 @@ public function testSupportsCurrentDateFunction(): void { $q = $this->entityManager->createQuery('SELECT d.id FROM Doctrine\Tests\Models\Generic\DateTimeModel d WHERE d.datetime > current_date()'); $q->setHint(ORMQuery::HINT_FORCE_PARTIAL_LOAD, true); - $this->assertEquals('SELECT d0_.id AS id_0 FROM date_time_model d0_ WHERE d0_.col_datetime > CURRENT_DATE', $q->getSql()); + self::assertEquals('SELECT d0_.id AS id_0 FROM date_time_model d0_ WHERE d0_.col_datetime > CURRENT_DATE', $q->getSql()); } public function testSupportsCurrentTimeFunction(): void { $q = $this->entityManager->createQuery('SELECT d.id FROM Doctrine\Tests\Models\Generic\DateTimeModel d WHERE d.time > current_time()'); $q->setHint(ORMQuery::HINT_FORCE_PARTIAL_LOAD, true); - $this->assertEquals('SELECT d0_.id AS id_0 FROM date_time_model d0_ WHERE d0_.col_time > CURRENT_TIME', $q->getSql()); + self::assertEquals('SELECT d0_.id AS id_0 FROM date_time_model d0_ WHERE d0_.col_time > CURRENT_TIME', $q->getSql()); } public function testSupportsCurrentTimestampFunction(): void { $q = $this->entityManager->createQuery('SELECT d.id FROM Doctrine\Tests\Models\Generic\DateTimeModel d WHERE d.datetime > current_timestamp()'); $q->setHint(ORMQuery::HINT_FORCE_PARTIAL_LOAD, true); - $this->assertEquals('SELECT d0_.id AS id_0 FROM date_time_model d0_ WHERE d0_.col_datetime > CURRENT_TIMESTAMP', $q->getSql()); + self::assertEquals('SELECT d0_.id AS id_0 FROM date_time_model d0_ WHERE d0_.col_datetime > CURRENT_TIMESTAMP', $q->getSql()); } public function testExistsExpressionInWhereCorrelatedSubqueryAssocCondition(): void @@ -834,7 +834,7 @@ public function testLimitFromQueryClass(): void ->createQuery('SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u') ->setMaxResults(10); - $this->assertEquals('SELECT c0_.id AS id_0, c0_.status AS status_1, c0_.username AS username_2, c0_.name AS name_3, c0_.email_id AS email_id_4 FROM cms_users c0_ LIMIT 10', $q->getSql()); + self::assertEquals('SELECT c0_.id AS id_0, c0_.status AS status_1, c0_.username AS username_2, c0_.name AS name_3, c0_.email_id AS email_id_4 FROM cms_users c0_ LIMIT 10', $q->getSql()); } public function testLimitAndOffsetFromQueryClass(): void @@ -1075,7 +1075,7 @@ public function testSubselectInSelect(): void public function testPessimisticWriteLockQueryHint(): void { if ($this->entityManager->getConnection()->getDatabasePlatform() instanceof SqlitePlatform) { - $this->markTestSkipped('SqLite does not support Row locking at all.'); + self::markTestSkipped('SqLite does not support Row locking at all.'); } $this->assertSqlGeneration( @@ -1247,7 +1247,7 @@ public function testIdVariableResultVariableReuse(): void $exceptionThrown = true; } - $this->assertTrue($exceptionThrown); + self::assertTrue($exceptionThrown); } public function testSubSelectAliasesFromOuterQuery(): void diff --git a/tests/Doctrine/Tests/ORM/Query/SqlWalkerTest.php b/tests/Doctrine/Tests/ORM/Query/SqlWalkerTest.php index 1bbb397b11e..40fc7aa8dd6 100644 --- a/tests/Doctrine/Tests/ORM/Query/SqlWalkerTest.php +++ b/tests/Doctrine/Tests/ORM/Query/SqlWalkerTest.php @@ -29,7 +29,7 @@ protected function setUp(): void */ public function testGetSQLTableAlias($tableName, $expectedAlias): void { - $this->assertSame($expectedAlias, $this->sqlWalker->getSQLTableAlias($tableName)); + self::assertSame($expectedAlias, $this->sqlWalker->getSQLTableAlias($tableName)); } /** @@ -37,7 +37,7 @@ public function testGetSQLTableAlias($tableName, $expectedAlias): void */ public function testGetSQLTableAliasIsSameForMultipleCalls($tableName): void { - $this->assertSame( + self::assertSame( $this->sqlWalker->getSQLTableAlias($tableName), $this->sqlWalker->getSQLTableAlias($tableName) ); diff --git a/tests/Doctrine/Tests/ORM/Query/UpdateSqlGenerationTest.php b/tests/Doctrine/Tests/ORM/Query/UpdateSqlGenerationTest.php index 193de786abb..da694ea1a16 100644 --- a/tests/Doctrine/Tests/ORM/Query/UpdateSqlGenerationTest.php +++ b/tests/Doctrine/Tests/ORM/Query/UpdateSqlGenerationTest.php @@ -42,7 +42,7 @@ public function assertSqlGeneration($dqlToBeTested, $sqlToBeConfirmed): void parent::assertEquals($sqlToBeConfirmed, $query->getSql()); $query->free(); } catch (Exception $e) { - $this->fail($e->getMessage()); + self::fail($e->getMessage()); } } diff --git a/tests/Doctrine/Tests/ORM/QueryBuilderTest.php b/tests/Doctrine/Tests/ORM/QueryBuilderTest.php index 247349d9562..566c3ea34f8 100644 --- a/tests/Doctrine/Tests/ORM/QueryBuilderTest.php +++ b/tests/Doctrine/Tests/ORM/QueryBuilderTest.php @@ -42,7 +42,7 @@ protected function assertValidQueryBuilder(QueryBuilder $qb, $expectedDql): void $dql = $qb->getDQL(); $q = $qb->getQuery(); - $this->assertEquals($expectedDql, $dql); + self::assertEquals($expectedDql, $dql); } public function testSelectSetsType(): void @@ -51,7 +51,7 @@ public function testSelectSetsType(): void ->delete(CmsUser::class, 'u') ->select('u.id', 'u.username'); - $this->assertEquals($qb->getType(), QueryBuilder::SELECT); + self::assertEquals($qb->getType(), QueryBuilder::SELECT); } public function testEmptySelectSetsType(): void @@ -60,7 +60,7 @@ public function testEmptySelectSetsType(): void ->delete(CmsUser::class, 'u') ->select(); - $this->assertEquals($qb->getType(), QueryBuilder::SELECT); + self::assertEquals($qb->getType(), QueryBuilder::SELECT); } public function testDeleteSetsType(): void @@ -69,7 +69,7 @@ public function testDeleteSetsType(): void ->from(CmsUser::class, 'u') ->delete(); - $this->assertEquals($qb->getType(), QueryBuilder::DELETE); + self::assertEquals($qb->getType(), QueryBuilder::DELETE); } public function testUpdateSetsType(): void @@ -78,7 +78,7 @@ public function testUpdateSetsType(): void ->from(CmsUser::class, 'u') ->update(); - $this->assertEquals($qb->getType(), QueryBuilder::UPDATE); + self::assertEquals($qb->getType(), QueryBuilder::UPDATE); } public function testSimpleSelect(): void @@ -428,8 +428,8 @@ public function testAddCriteriaWhere(): void $qb->addCriteria($criteria); - $this->assertEquals('u.field = :field', (string) $qb->getDQLPart('where')); - $this->assertNotNull($qb->getParameter('field')); + self::assertEquals('u.field = :field', (string) $qb->getDQLPart('where')); + self::assertNotNull($qb->getParameter('field')); } public function testAddMultipleSameCriteriaWhere(): void @@ -445,9 +445,9 @@ public function testAddMultipleSameCriteriaWhere(): void $qb->addCriteria($criteria); - $this->assertEquals('alias1.field = :field AND alias1.field = :field_1', (string) $qb->getDQLPart('where')); - $this->assertNotNull($qb->getParameter('field')); - $this->assertNotNull($qb->getParameter('field_1')); + self::assertEquals('alias1.field = :field AND alias1.field = :field_1', (string) $qb->getDQLPart('where')); + self::assertNotNull($qb->getParameter('field')); + self::assertNotNull($qb->getParameter('field_1')); } /** @@ -464,9 +464,9 @@ public function testAddCriteriaWhereWithMultipleParametersWithSameField(): void $qb->addCriteria($criteria); - $this->assertEquals('alias1.field = :field AND alias1.field > :field_1', (string) $qb->getDQLPart('where')); - $this->assertSame('value1', $qb->getParameter('field')->getValue()); - $this->assertSame('value2', $qb->getParameter('field_1')->getValue()); + self::assertEquals('alias1.field = :field AND alias1.field > :field_1', (string) $qb->getDQLPart('where')); + self::assertSame('value1', $qb->getParameter('field')->getValue()); + self::assertSame('value2', $qb->getParameter('field_1')->getValue()); } /** @@ -483,9 +483,9 @@ public function testAddCriteriaWhereWithMultipleParametersWithDifferentFields(): $qb->addCriteria($criteria); - $this->assertEquals('alias1.field1 = :field1 AND alias1.field2 > :field2', (string) $qb->getDQLPart('where')); - $this->assertSame('value1', $qb->getParameter('field1')->getValue()); - $this->assertSame('value2', $qb->getParameter('field2')->getValue()); + self::assertEquals('alias1.field1 = :field1 AND alias1.field2 > :field2', (string) $qb->getDQLPart('where')); + self::assertSame('value1', $qb->getParameter('field1')->getValue()); + self::assertSame('value2', $qb->getParameter('field2')->getValue()); } /** @@ -502,9 +502,9 @@ public function testAddCriteriaWhereWithMultipleParametersWithSubpathsAndDiffere $qb->addCriteria($criteria); - $this->assertEquals('alias1.field1 = :field1 AND alias1.field2 > :field2', (string) $qb->getDQLPart('where')); - $this->assertSame('value1', $qb->getParameter('field1')->getValue()); - $this->assertSame('value2', $qb->getParameter('field2')->getValue()); + self::assertEquals('alias1.field1 = :field1 AND alias1.field2 > :field2', (string) $qb->getDQLPart('where')); + self::assertSame('value1', $qb->getParameter('field1')->getValue()); + self::assertSame('value2', $qb->getParameter('field2')->getValue()); } /** @@ -521,9 +521,9 @@ public function testAddCriteriaWhereWithMultipleParametersWithSubpathsAndSamePro $qb->addCriteria($criteria); - $this->assertEquals('alias1.field1 = :field1 AND alias1.field1 > :field1_1', (string) $qb->getDQLPart('where')); - $this->assertSame('value1', $qb->getParameter('field1')->getValue()); - $this->assertSame('value2', $qb->getParameter('field1_1')->getValue()); + self::assertEquals('alias1.field1 = :field1 AND alias1.field1 > :field1_1', (string) $qb->getDQLPart('where')); + self::assertSame('value1', $qb->getParameter('field1')->getValue()); + self::assertSame('value2', $qb->getParameter('field1_1')->getValue()); } public function testAddCriteriaOrder(): void @@ -537,8 +537,8 @@ public function testAddCriteriaOrder(): void $qb->addCriteria($criteria); - $this->assertCount(1, $orderBy = $qb->getDQLPart('orderBy')); - $this->assertEquals('u.field DESC', (string) $orderBy[0]); + self::assertCount(1, $orderBy = $qb->getDQLPart('orderBy')); + self::assertEquals('u.field DESC', (string) $orderBy[0]); } /** @@ -556,8 +556,8 @@ public function testAddCriteriaOrderOnJoinAlias(): void $qb->addCriteria($criteria); - $this->assertCount(1, $orderBy = $qb->getDQLPart('orderBy')); - $this->assertEquals('a.field DESC', (string) $orderBy[0]); + self::assertCount(1, $orderBy = $qb->getDQLPart('orderBy')); + self::assertEquals('a.field DESC', (string) $orderBy[0]); } public function testAddCriteriaLimit(): void @@ -572,8 +572,8 @@ public function testAddCriteriaLimit(): void $qb->addCriteria($criteria); - $this->assertEquals(2, $qb->getFirstResult()); - $this->assertEquals(10, $qb->getMaxResults()); + self::assertEquals(2, $qb->getFirstResult()); + self::assertEquals(10, $qb->getMaxResults()); } public function testAddCriteriaUndefinedLimit(): void @@ -588,8 +588,8 @@ public function testAddCriteriaUndefinedLimit(): void $qb->addCriteria($criteria); - $this->assertEquals(2, $qb->getFirstResult()); - $this->assertEquals(10, $qb->getMaxResults()); + self::assertEquals(2, $qb->getFirstResult()); + self::assertEquals(10, $qb->getMaxResults()); } public function testGetQuery(): void @@ -599,7 +599,7 @@ public function testGetQuery(): void ->from(CmsUser::class, 'u'); $q = $qb->getQuery(); - $this->assertEquals(Query::class, get_class($q)); + self::assertEquals(Query::class, get_class($q)); } public function testSetParameter(): void @@ -631,7 +631,7 @@ public function testSetParameters(): void $qb->setParameters($parameters); - $this->assertEquals($parameters, $qb->getQuery()->getParameters()); + self::assertEquals($parameters, $qb->getQuery()->getParameters()); } public function testGetParameters(): void @@ -646,7 +646,7 @@ public function testGetParameters(): void $qb->setParameters($parameters); - $this->assertEquals($parameters, $qb->getParameters()); + self::assertEquals($parameters, $qb->getParameters()); } public function testGetParameter(): void @@ -661,7 +661,7 @@ public function testGetParameter(): void $qb->setParameters($parameters); - $this->assertEquals($parameters->first(), $qb->getParameter('id')); + self::assertEquals($parameters->first(), $qb->getParameter('id')); } public function testMultipleWhere(): void @@ -775,8 +775,8 @@ public function testMultipleIsolatedQueryConstruction(): void $q1 = $qb->getQuery(); - $this->assertEquals('SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.name = :name', $q1->getDQL()); - $this->assertEquals(1, count($q1->getParameters())); + self::assertEquals('SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.name = :name', $q1->getDQL()); + self::assertEquals(1, count($q1->getParameters())); // add another condition and construct a second query $qb->andWhere($expr->eq('u.id', ':id')); @@ -784,22 +784,22 @@ public function testMultipleIsolatedQueryConstruction(): void $q2 = $qb->getQuery(); - $this->assertEquals('SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.name = :name AND u.id = :id', $q2->getDQL()); - $this->assertTrue($q1 !== $q2); // two different, independent queries - $this->assertEquals(2, count($q2->getParameters())); - $this->assertEquals(1, count($q1->getParameters())); // $q1 unaffected + self::assertEquals('SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.name = :name AND u.id = :id', $q2->getDQL()); + self::assertTrue($q1 !== $q2); // two different, independent queries + self::assertEquals(2, count($q2->getParameters())); + self::assertEquals(1, count($q1->getParameters())); // $q1 unaffected } public function testGetEntityManager(): void { $qb = $this->entityManager->createQueryBuilder(); - $this->assertEquals($this->entityManager, $qb->getEntityManager()); + self::assertEquals($this->entityManager, $qb->getEntityManager()); } public function testInitialStateIsClean(): void { $qb = $this->entityManager->createQueryBuilder(); - $this->assertEquals(QueryBuilder::STATE_CLEAN, $qb->getState()); + self::assertEquals(QueryBuilder::STATE_CLEAN, $qb->getState()); } public function testAlteringQueryChangesStateToDirty(): void @@ -808,7 +808,7 @@ public function testAlteringQueryChangesStateToDirty(): void ->select('u') ->from(CmsUser::class, 'u'); - $this->assertEquals(QueryBuilder::STATE_DIRTY, $qb->getState()); + self::assertEquals(QueryBuilder::STATE_DIRTY, $qb->getState()); } public function testSelectWithFuncExpression(): void @@ -827,13 +827,13 @@ public function testResetDQLPart(): void ->from(CmsUser::class, 'u') ->where('u.username = ?1')->orderBy('u.username'); - $this->assertEquals('u.username = ?1', (string) $qb->getDQLPart('where')); - $this->assertEquals(1, count($qb->getDQLPart('orderBy'))); + self::assertEquals('u.username = ?1', (string) $qb->getDQLPart('where')); + self::assertEquals(1, count($qb->getDQLPart('orderBy'))); $qb->resetDQLPart('where')->resetDQLPart('orderBy'); - $this->assertNull($qb->getDQLPart('where')); - $this->assertEquals(0, count($qb->getDQLPart('orderBy'))); + self::assertNull($qb->getDQLPart('where')); + self::assertEquals(0, count($qb->getDQLPart('orderBy'))); } public function testResetDQLParts(): void @@ -845,9 +845,9 @@ public function testResetDQLParts(): void $qb->resetDQLParts(['where', 'orderBy']); - $this->assertEquals(1, count($qb->getDQLPart('select'))); - $this->assertNull($qb->getDQLPart('where')); - $this->assertEquals(0, count($qb->getDQLPart('orderBy'))); + self::assertEquals(1, count($qb->getDQLPart('select'))); + self::assertNull($qb->getDQLPart('where')); + self::assertEquals(0, count($qb->getDQLPart('orderBy'))); } public function testResetAllDQLParts(): void @@ -859,9 +859,9 @@ public function testResetAllDQLParts(): void $qb->resetDQLParts(); - $this->assertEquals(0, count($qb->getDQLPart('select'))); - $this->assertNull($qb->getDQLPart('where')); - $this->assertEquals(0, count($qb->getDQLPart('orderBy'))); + self::assertEquals(0, count($qb->getDQLPart('select'))); + self::assertNull($qb->getDQLPart('where')); + self::assertEquals(0, count($qb->getDQLPart('orderBy'))); } /** @@ -876,12 +876,12 @@ public function testDeepClone(): void ->andWhere('u.status = ?2'); $expr = $qb->getDQLPart('where'); - $this->assertEquals(2, $expr->count(), 'Modifying the second query should affect the first one.'); + self::assertEquals(2, $expr->count(), 'Modifying the second query should affect the first one.'); $qb2 = clone $qb; $qb2->andWhere('u.name = ?3'); - $this->assertEquals(2, $expr->count(), 'Modifying the second query should affect the first one.'); + self::assertEquals(2, $expr->count(), 'Modifying the second query should affect the first one.'); } /** @@ -899,9 +899,9 @@ public function testAddCriteriaWhereWithJoinAlias(): void $qb->addCriteria($criteria); - $this->assertEquals('alias1.field = :field AND alias2.field > :alias2_field', (string) $qb->getDQLPart('where')); - $this->assertSame('value1', $qb->getParameter('field')->getValue()); - $this->assertSame('value2', $qb->getParameter('alias2_field')->getValue()); + self::assertEquals('alias1.field = :field AND alias2.field > :alias2_field', (string) $qb->getDQLPart('where')); + self::assertSame('value1', $qb->getParameter('field')->getValue()); + self::assertSame('value2', $qb->getParameter('alias2_field')->getValue()); } /** @@ -919,9 +919,9 @@ public function testAddCriteriaWhereWithDefaultAndJoinAlias(): void $qb->addCriteria($criteria); - $this->assertEquals('alias1.field = :alias1_field AND alias2.field > :alias2_field', (string) $qb->getDQLPart('where')); - $this->assertSame('value1', $qb->getParameter('alias1_field')->getValue()); - $this->assertSame('value2', $qb->getParameter('alias2_field')->getValue()); + self::assertEquals('alias1.field = :alias1_field AND alias2.field > :alias2_field', (string) $qb->getDQLPart('where')); + self::assertSame('value1', $qb->getParameter('alias1_field')->getValue()); + self::assertSame('value2', $qb->getParameter('alias2_field')->getValue()); } /** @@ -940,10 +940,10 @@ public function testAddCriteriaWhereOnJoinAliasWithDuplicateFields(): void $qb->addCriteria($criteria); - $this->assertEquals('(alias1.field = :alias1_field AND alias2.field > :alias2_field) AND alias2.field < :alias2_field_2', (string) $qb->getDQLPart('where')); - $this->assertSame('value1', $qb->getParameter('alias1_field')->getValue()); - $this->assertSame('value2', $qb->getParameter('alias2_field')->getValue()); - $this->assertSame('value3', $qb->getParameter('alias2_field_2')->getValue()); + self::assertEquals('(alias1.field = :alias1_field AND alias2.field > :alias2_field) AND alias2.field < :alias2_field_2', (string) $qb->getDQLPart('where')); + self::assertSame('value1', $qb->getParameter('alias1_field')->getValue()); + self::assertSame('value2', $qb->getParameter('alias2_field')->getValue()); + self::assertSame('value3', $qb->getParameter('alias2_field_2')->getValue()); } /** @@ -958,9 +958,9 @@ public function testParametersAreCloned(): void $copy = clone $originalQb; $copy->setParameter('parameter2', 'value2'); - $this->assertCount(1, $originalQb->getParameters()); - $this->assertSame('value1', $copy->getParameter('parameter1')->getValue()); - $this->assertSame('value2', $copy->getParameter('parameter2')->getValue()); + self::assertCount(1, $originalQb->getParameters()); + self::assertSame('value1', $copy->getParameter('parameter1')->getValue()); + self::assertSame('value2', $copy->getParameter('parameter2')->getValue()); } public function testGetRootAlias(): void @@ -969,7 +969,7 @@ public function testGetRootAlias(): void ->select('u') ->from(CmsUser::class, 'u'); - $this->assertEquals('u', $qb->getRootAlias()); + self::assertEquals('u', $qb->getRootAlias()); } public function testGetRootAliases(): void @@ -978,7 +978,7 @@ public function testGetRootAliases(): void ->select('u') ->from(CmsUser::class, 'u'); - $this->assertEquals(['u'], $qb->getRootAliases()); + self::assertEquals(['u'], $qb->getRootAliases()); } public function testGetRootEntities(): void @@ -987,7 +987,7 @@ public function testGetRootEntities(): void ->select('u') ->from(CmsUser::class, 'u'); - $this->assertEquals([CmsUser::class], $qb->getRootEntities()); + self::assertEquals([CmsUser::class], $qb->getRootEntities()); } public function testGetSeveralRootAliases(): void @@ -997,8 +997,8 @@ public function testGetSeveralRootAliases(): void ->from(CmsUser::class, 'u') ->from(CmsUser::class, 'u2'); - $this->assertEquals(['u', 'u2'], $qb->getRootAliases()); - $this->assertEquals('u', $qb->getRootAlias()); + self::assertEquals(['u', 'u2'], $qb->getRootAliases()); + self::assertEquals('u', $qb->getRootAlias()); } public function testBCAddJoinWithoutRootAlias(): void @@ -1008,7 +1008,7 @@ public function testBCAddJoinWithoutRootAlias(): void ->from(CmsUser::class, 'u') ->add('join', ['INNER JOIN u.groups g'], true); - $this->assertEquals('SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u INNER JOIN u.groups g', $qb->getDQL()); + self::assertEquals('SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u INNER JOIN u.groups g', $qb->getDQL()); } /** @@ -1022,7 +1022,7 @@ public function testEmptyStringLiteral(): void ->from(CmsUser::class, 'u') ->where($expr->eq('u.username', $expr->literal(''))); - $this->assertEquals("SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.username = ''", $qb->getDQL()); + self::assertEquals("SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.username = ''", $qb->getDQL()); } /** @@ -1036,7 +1036,7 @@ public function testEmptyNumericLiteral(): void ->from(CmsUser::class, 'u') ->where($expr->eq('u.username', $expr->literal(0))); - $this->assertEquals('SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.username = 0', $qb->getDQL()); + self::assertEquals('SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.username = 0', $qb->getDQL()); } /** @@ -1048,7 +1048,7 @@ public function testAddFromString(): void ->add('select', 'u') ->add('from', CmsUser::class . ' u'); - $this->assertEquals('SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u', $qb->getDQL()); + self::assertEquals('SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u', $qb->getDQL()); } /** @@ -1061,7 +1061,7 @@ public function testAddDistinct(): void ->distinct() ->from(CmsUser::class, 'u'); - $this->assertEquals('SELECT DISTINCT u FROM Doctrine\Tests\Models\CMS\CmsUser u', $qb->getDQL()); + self::assertEquals('SELECT DISTINCT u FROM Doctrine\Tests\Models\CMS\CmsUser u', $qb->getDQL()); } /** @@ -1083,17 +1083,17 @@ public function testSecondLevelCacheQueryBuilderOptions(): void ->select('s') ->from(State::class, 's'); - $this->assertFalse($defaultQueryBuilder->isCacheable()); - $this->assertEquals(0, $defaultQueryBuilder->getLifetime()); - $this->assertNull($defaultQueryBuilder->getCacheRegion()); - $this->assertNull($defaultQueryBuilder->getCacheMode()); + self::assertFalse($defaultQueryBuilder->isCacheable()); + self::assertEquals(0, $defaultQueryBuilder->getLifetime()); + self::assertNull($defaultQueryBuilder->getCacheRegion()); + self::assertNull($defaultQueryBuilder->getCacheMode()); $defaultQuery = $defaultQueryBuilder->getQuery(); - $this->assertFalse($defaultQuery->isCacheable()); - $this->assertEquals(0, $defaultQuery->getLifetime()); - $this->assertNull($defaultQuery->getCacheRegion()); - $this->assertNull($defaultQuery->getCacheMode()); + self::assertFalse($defaultQuery->isCacheable()); + self::assertEquals(0, $defaultQuery->getLifetime()); + self::assertNull($defaultQuery->getCacheRegion()); + self::assertNull($defaultQuery->getCacheMode()); $builder = $this->entityManager->createQueryBuilder() ->select('s') @@ -1103,17 +1103,17 @@ public function testSecondLevelCacheQueryBuilderOptions(): void ->setCacheMode(Cache::MODE_REFRESH) ->from(State::class, 's'); - $this->assertTrue($builder->isCacheable()); - $this->assertEquals(123, $builder->getLifetime()); - $this->assertEquals('foo_reg', $builder->getCacheRegion()); - $this->assertEquals(Cache::MODE_REFRESH, $builder->getCacheMode()); + self::assertTrue($builder->isCacheable()); + self::assertEquals(123, $builder->getLifetime()); + self::assertEquals('foo_reg', $builder->getCacheRegion()); + self::assertEquals(Cache::MODE_REFRESH, $builder->getCacheMode()); $query = $builder->getQuery(); - $this->assertTrue($query->isCacheable()); - $this->assertEquals(123, $query->getLifetime()); - $this->assertEquals('foo_reg', $query->getCacheRegion()); - $this->assertEquals(Cache::MODE_REFRESH, $query->getCacheMode()); + self::assertTrue($query->isCacheable()); + self::assertEquals(123, $query->getLifetime()); + self::assertEquals('foo_reg', $query->getCacheRegion()); + self::assertEquals(Cache::MODE_REFRESH, $query->getCacheMode()); } /** @@ -1136,7 +1136,7 @@ public function testRebuildsFromParts(): void $dql2 = $qb2->getDQL(); - $this->assertEquals($dql, $dql2); + self::assertEquals($dql, $dql2); } public function testGetAllAliasesWithNoJoins(): void @@ -1146,7 +1146,7 @@ public function testGetAllAliasesWithNoJoins(): void $aliases = $qb->getAllAliases(); - $this->assertEquals(['u'], $aliases); + self::assertEquals(['u'], $aliases); } public function testGetAllAliasesWithJoins(): void @@ -1158,7 +1158,7 @@ public function testGetAllAliasesWithJoins(): void $aliases = $qb->getAllAliases(); - $this->assertEquals(['u', 'g'], $aliases); + self::assertEquals(['u', 'g'], $aliases); } /** diff --git a/tests/Doctrine/Tests/ORM/Repository/DefaultRepositoryFactoryTest.php b/tests/Doctrine/Tests/ORM/Repository/DefaultRepositoryFactoryTest.php index 520dc40f755..649433e129e 100644 --- a/tests/Doctrine/Tests/ORM/Repository/DefaultRepositoryFactoryTest.php +++ b/tests/Doctrine/Tests/ORM/Repository/DefaultRepositoryFactoryTest.php @@ -38,19 +38,19 @@ protected function setUp(): void $this->repositoryFactory = new DefaultRepositoryFactory(); $this->configuration - ->expects($this->any()) + ->expects(self::any()) ->method('getDefaultRepositoryClassName') - ->will($this->returnValue(DDC869PaymentRepository::class)); + ->will(self::returnValue(DDC869PaymentRepository::class)); } public function testCreatesRepositoryFromDefaultRepositoryClass(): void { $this->entityManager - ->expects($this->any()) + ->expects(self::any()) ->method('getClassMetadata') - ->will($this->returnCallback([$this, 'buildClassMetadata'])); + ->will(self::returnCallback([$this, 'buildClassMetadata'])); - $this->assertInstanceOf( + self::assertInstanceOf( DDC869PaymentRepository::class, $this->repositoryFactory->getRepository($this->entityManager, self::class) ); @@ -59,11 +59,11 @@ public function testCreatesRepositoryFromDefaultRepositoryClass(): void public function testCreatedRepositoriesAreCached(): void { $this->entityManager - ->expects($this->any()) + ->expects(self::any()) ->method('getClassMetadata') - ->will($this->returnCallback([$this, 'buildClassMetadata'])); + ->will(self::returnCallback([$this, 'buildClassMetadata'])); - $this->assertSame( + self::assertSame( $this->repositoryFactory->getRepository($this->entityManager, self::class), $this->repositoryFactory->getRepository($this->entityManager, self::class) ); @@ -75,11 +75,11 @@ public function testCreatesRepositoryFromCustomClassMetadata(): void $customMetadata->customRepositoryClassName = DDC753DefaultRepository::class; $this->entityManager - ->expects($this->any()) + ->expects(self::any()) ->method('getClassMetadata') - ->will($this->returnValue($customMetadata)); + ->will(self::returnValue($customMetadata)); - $this->assertInstanceOf( + self::assertInstanceOf( DDC753DefaultRepository::class, $this->repositoryFactory->getRepository($this->entityManager, self::class) ); @@ -90,21 +90,21 @@ public function testCachesDistinctRepositoriesPerDistinctEntityManager(): void $em1 = $this->createEntityManager(); $em2 = $this->createEntityManager(); - $em1->expects($this->any()) + $em1->expects(self::any()) ->method('getClassMetadata') - ->will($this->returnCallback([$this, 'buildClassMetadata'])); + ->will(self::returnCallback([$this, 'buildClassMetadata'])); - $em2->expects($this->any()) + $em2->expects(self::any()) ->method('getClassMetadata') - ->will($this->returnCallback([$this, 'buildClassMetadata'])); + ->will(self::returnCallback([$this, 'buildClassMetadata'])); $repo1 = $this->repositoryFactory->getRepository($em1, self::class); $repo2 = $this->repositoryFactory->getRepository($em2, self::class); - $this->assertSame($repo1, $this->repositoryFactory->getRepository($em1, self::class)); - $this->assertSame($repo2, $this->repositoryFactory->getRepository($em2, self::class)); + self::assertSame($repo1, $this->repositoryFactory->getRepository($em1, self::class)); + self::assertSame($repo2, $this->repositoryFactory->getRepository($em2, self::class)); - $this->assertNotSame($repo1, $repo2); + self::assertNotSame($repo1, $repo2); } /** @@ -117,7 +117,7 @@ public function buildClassMetadata(string $className) $metadata = $this->createMock(ClassMetadata::class); assert($metadata instanceof ClassMetadata || $metadata instanceof MockObject); - $metadata->expects($this->any())->method('getName')->will($this->returnValue($className)); + $metadata->expects(self::any())->method('getName')->will(self::returnValue($className)); $metadata->customRepositoryClassName = null; @@ -131,9 +131,9 @@ private function createEntityManager(): EntityManagerInterface { $entityManager = $this->createMock(EntityManagerInterface::class); - $entityManager->expects($this->any()) + $entityManager->expects(self::any()) ->method('getConfiguration') - ->will($this->returnValue($this->configuration)); + ->will(self::returnValue($this->configuration)); return $entityManager; } diff --git a/tests/Doctrine/Tests/ORM/Tools/AttachEntityListenersListenerTest.php b/tests/Doctrine/Tests/ORM/Tools/AttachEntityListenersListenerTest.php index 0c68b556f3c..b5430ef7a67 100644 --- a/tests/Doctrine/Tests/ORM/Tools/AttachEntityListenersListenerTest.php +++ b/tests/Doctrine/Tests/ORM/Tools/AttachEntityListenersListenerTest.php @@ -52,10 +52,10 @@ public function testAttachEntityListeners(): void $metadata = $this->factory->getMetadataFor(AttachEntityListenersListenerTestFooEntity::class); - $this->assertArrayHasKey('postLoad', $metadata->entityListeners); - $this->assertCount(1, $metadata->entityListeners['postLoad']); - $this->assertEquals('postLoadHandler', $metadata->entityListeners['postLoad'][0]['method']); - $this->assertEquals(AttachEntityListenersListenerTestListener::class, $metadata->entityListeners['postLoad'][0]['class']); + self::assertArrayHasKey('postLoad', $metadata->entityListeners); + self::assertCount(1, $metadata->entityListeners['postLoad']); + self::assertEquals('postLoadHandler', $metadata->entityListeners['postLoad'][0]['method']); + self::assertEquals(AttachEntityListenersListenerTestListener::class, $metadata->entityListeners['postLoad'][0]['class']); } public function testAttachToExistingEntityListeners(): void @@ -75,23 +75,23 @@ public function testAttachToExistingEntityListeners(): void $metadata = $this->factory->getMetadataFor(AttachEntityListenersListenerTestBarEntity::class); - $this->assertArrayHasKey('postPersist', $metadata->entityListeners); - $this->assertArrayHasKey('prePersist', $metadata->entityListeners); + self::assertArrayHasKey('postPersist', $metadata->entityListeners); + self::assertArrayHasKey('prePersist', $metadata->entityListeners); - $this->assertCount(2, $metadata->entityListeners['prePersist']); - $this->assertCount(2, $metadata->entityListeners['postPersist']); + self::assertCount(2, $metadata->entityListeners['prePersist']); + self::assertCount(2, $metadata->entityListeners['postPersist']); - $this->assertEquals('prePersist', $metadata->entityListeners['prePersist'][0]['method']); - $this->assertEquals(AttachEntityListenersListenerTestListener::class, $metadata->entityListeners['prePersist'][0]['class']); + self::assertEquals('prePersist', $metadata->entityListeners['prePersist'][0]['method']); + self::assertEquals(AttachEntityListenersListenerTestListener::class, $metadata->entityListeners['prePersist'][0]['class']); - $this->assertEquals('prePersist', $metadata->entityListeners['prePersist'][1]['method']); - $this->assertEquals(AttachEntityListenersListenerTestListener2::class, $metadata->entityListeners['prePersist'][1]['class']); + self::assertEquals('prePersist', $metadata->entityListeners['prePersist'][1]['method']); + self::assertEquals(AttachEntityListenersListenerTestListener2::class, $metadata->entityListeners['prePersist'][1]['class']); - $this->assertEquals('postPersist', $metadata->entityListeners['postPersist'][0]['method']); - $this->assertEquals(AttachEntityListenersListenerTestListener::class, $metadata->entityListeners['postPersist'][0]['class']); + self::assertEquals('postPersist', $metadata->entityListeners['postPersist'][0]['method']); + self::assertEquals(AttachEntityListenersListenerTestListener::class, $metadata->entityListeners['postPersist'][0]['class']); - $this->assertEquals('postPersistHandler', $metadata->entityListeners['postPersist'][1]['method']); - $this->assertEquals(AttachEntityListenersListenerTestListener2::class, $metadata->entityListeners['postPersist'][1]['class']); + self::assertEquals('postPersistHandler', $metadata->entityListeners['postPersist'][1]['method']); + self::assertEquals(AttachEntityListenersListenerTestListener2::class, $metadata->entityListeners['postPersist'][1]['class']); } public function testDuplicateEntityListenerException(): void diff --git a/tests/Doctrine/Tests/ORM/Tools/Console/Command/ConvertDoctrine1SchemaCommandTest.php b/tests/Doctrine/Tests/ORM/Tools/Console/Command/ConvertDoctrine1SchemaCommandTest.php index ce05e3bb61e..5e2b96a6543 100644 --- a/tests/Doctrine/Tests/ORM/Tools/Console/Command/ConvertDoctrine1SchemaCommandTest.php +++ b/tests/Doctrine/Tests/ORM/Tools/Console/Command/ConvertDoctrine1SchemaCommandTest.php @@ -20,9 +20,9 @@ public function testExecution(): void $command->setEntityGenerator($entityGenerator); $output = $this->createMock(OutputInterface::class); - $output->expects($this->once()) + $output->expects(self::once()) ->method('writeln') - ->with($this->equalTo('No Metadata Classes to process.')); + ->with(self::equalTo('No Metadata Classes to process.')); $command->convertDoctrine1Schema([], sys_get_temp_dir(), 'annotation', 4, null, $output); } diff --git a/tests/Doctrine/Tests/ORM/Tools/Console/Command/EnsureProductionSettingsCommandTest.php b/tests/Doctrine/Tests/ORM/Tools/Console/Command/EnsureProductionSettingsCommandTest.php index d61386c2b92..d11f0831df7 100644 --- a/tests/Doctrine/Tests/ORM/Tools/Console/Command/EnsureProductionSettingsCommandTest.php +++ b/tests/Doctrine/Tests/ORM/Tools/Console/Command/EnsureProductionSettingsCommandTest.php @@ -23,16 +23,16 @@ public function testExecute(): void $em = $this->createMock(EntityManagerInterface::class); $configuration = $this->createMock(Configuration::class); - $configuration->expects($this->once()) + $configuration->expects(self::once()) ->method('ensureProductionSettings'); $em->method('getConfiguration') ->willReturn($configuration); - $em->expects($this->never()) + $em->expects(self::never()) ->method('getConnection'); - $this->assertSame(0, $this->executeCommand($em)); + self::assertSame(0, $this->executeCommand($em)); } public function testExecuteFailed(): void @@ -40,17 +40,17 @@ public function testExecuteFailed(): void $em = $this->createMock(EntityManagerInterface::class); $configuration = $this->createMock(Configuration::class); - $configuration->expects($this->once()) + $configuration->expects(self::once()) ->method('ensureProductionSettings') ->willThrowException(new RuntimeException()); $em->method('getConfiguration') ->willReturn($configuration); - $em->expects($this->never()) + $em->expects(self::never()) ->method('getConnection'); - $this->assertSame(1, $this->executeCommand($em)); + self::assertSame(1, $this->executeCommand($em)); } public function testExecuteWithComplete(): void @@ -58,7 +58,7 @@ public function testExecuteWithComplete(): void $em = $this->createMock(EntityManagerInterface::class); $configuration = $this->createMock(Configuration::class); - $configuration->expects($this->once()) + $configuration->expects(self::once()) ->method('ensureProductionSettings'); $em->method('getConfiguration') @@ -66,13 +66,13 @@ public function testExecuteWithComplete(): void $connection = $this->createMock(Connection::class); - $connection->expects($this->once()) + $connection->expects(self::once()) ->method('connect'); $em->method('getConnection') ->willReturn($connection); - $this->assertSame(0, $this->executeCommand($em, ['--complete' => true])); + self::assertSame(0, $this->executeCommand($em, ['--complete' => true])); } public function testExecuteWithCompleteFailed(): void @@ -80,7 +80,7 @@ public function testExecuteWithCompleteFailed(): void $em = $this->createMock(EntityManagerInterface::class); $configuration = $this->createMock(Configuration::class); - $configuration->expects($this->once()) + $configuration->expects(self::once()) ->method('ensureProductionSettings'); $em->method('getConfiguration') @@ -88,14 +88,14 @@ public function testExecuteWithCompleteFailed(): void $connection = $this->createMock(Connection::class); - $connection->expects($this->once()) + $connection->expects(self::once()) ->method('connect') ->willThrowException(new RuntimeException()); $em->method('getConnection') ->willReturn($connection); - $this->assertSame(1, $this->executeCommand($em, ['--complete' => true])); + self::assertSame(1, $this->executeCommand($em, ['--complete' => true])); } private function executeCommand( diff --git a/tests/Doctrine/Tests/ORM/Tools/Console/MetadataFilterTest.php b/tests/Doctrine/Tests/ORM/Tools/Console/MetadataFilterTest.php index a390610b52b..19f40eb34f6 100644 --- a/tests/Doctrine/Tests/ORM/Tools/Console/MetadataFilterTest.php +++ b/tests/Doctrine/Tests/ORM/Tools/Console/MetadataFilterTest.php @@ -46,9 +46,9 @@ public function testFilterWithEmptyArray(): void $metadatas = $originalMetadatas; $metadatas = MetadataFilter::filter($metadatas, []); - $this->assertContains($metadataAaa, $metadatas); - $this->assertContains($metadataBbb, $metadatas); - $this->assertCount(count($originalMetadatas), $metadatas); + self::assertContains($metadataAaa, $metadatas); + self::assertContains($metadataBbb, $metadatas); + self::assertCount(count($originalMetadatas), $metadatas); } public function testFilterWithString(): void @@ -62,26 +62,26 @@ public function testFilterWithString(): void $metadatas = $originalMetadatas; $metadatas = MetadataFilter::filter($metadatas, 'MetadataFilterTestEntityAaa'); - $this->assertContains($metadataAaa, $metadatas); - $this->assertNotContains($metadataBbb, $metadatas); - $this->assertNotContains($metadataCcc, $metadatas); - $this->assertCount(1, $metadatas); + self::assertContains($metadataAaa, $metadatas); + self::assertNotContains($metadataBbb, $metadatas); + self::assertNotContains($metadataCcc, $metadatas); + self::assertCount(1, $metadatas); $metadatas = $originalMetadatas; $metadatas = MetadataFilter::filter($metadatas, 'MetadataFilterTestEntityBbb'); - $this->assertNotContains($metadataAaa, $metadatas); - $this->assertContains($metadataBbb, $metadatas); - $this->assertNotContains($metadataCcc, $metadatas); - $this->assertCount(1, $metadatas); + self::assertNotContains($metadataAaa, $metadatas); + self::assertContains($metadataBbb, $metadatas); + self::assertNotContains($metadataCcc, $metadatas); + self::assertCount(1, $metadatas); $metadatas = $originalMetadatas; $metadatas = MetadataFilter::filter($metadatas, 'MetadataFilterTestEntityCcc'); - $this->assertNotContains($metadataAaa, $metadatas); - $this->assertNotContains($metadataBbb, $metadatas); - $this->assertContains($metadataCcc, $metadatas); - $this->assertCount(1, $metadatas); + self::assertNotContains($metadataAaa, $metadatas); + self::assertNotContains($metadataBbb, $metadatas); + self::assertContains($metadataCcc, $metadatas); + self::assertCount(1, $metadatas); } public function testFilterWithString2(): void @@ -95,10 +95,10 @@ public function testFilterWithString2(): void $metadatas = $originalMetadatas; $metadatas = MetadataFilter::filter($metadatas, 'MetadataFilterTestEntityFoo'); - $this->assertContains($metadataFoo, $metadatas); - $this->assertContains($metadataFooBar, $metadatas); - $this->assertNotContains($metadataBar, $metadatas); - $this->assertCount(2, $metadatas); + self::assertContains($metadataFoo, $metadatas); + self::assertContains($metadataFooBar, $metadatas); + self::assertNotContains($metadataBar, $metadatas); + self::assertCount(2, $metadatas); } public function testFilterWithArray(): void @@ -115,10 +115,10 @@ public function testFilterWithArray(): void 'MetadataFilterTestEntityCcc', ]); - $this->assertContains($metadataAaa, $metadatas); - $this->assertNotContains($metadataBbb, $metadatas); - $this->assertContains($metadataCcc, $metadatas); - $this->assertCount(2, $metadatas); + self::assertContains($metadataAaa, $metadatas); + self::assertNotContains($metadataBbb, $metadatas); + self::assertContains($metadataCcc, $metadatas); + self::assertCount(2, $metadatas); } public function testFilterWithRegex(): void @@ -132,18 +132,18 @@ public function testFilterWithRegex(): void $metadatas = $originalMetadatas; $metadatas = MetadataFilter::filter($metadatas, 'Foo$'); - $this->assertContains($metadataFoo, $metadatas); - $this->assertNotContains($metadataFooBar, $metadatas); - $this->assertNotContains($metadataBar, $metadatas); - $this->assertCount(1, $metadatas); + self::assertContains($metadataFoo, $metadatas); + self::assertNotContains($metadataFooBar, $metadatas); + self::assertNotContains($metadataBar, $metadatas); + self::assertCount(1, $metadatas); $metadatas = $originalMetadatas; $metadatas = MetadataFilter::filter($metadatas, 'Bar$'); - $this->assertNotContains($metadataFoo, $metadatas); - $this->assertContains($metadataFooBar, $metadatas); - $this->assertContains($metadataBar, $metadatas); - $this->assertCount(2, $metadatas); + self::assertNotContains($metadataFoo, $metadatas); + self::assertContains($metadataFooBar, $metadatas); + self::assertContains($metadataBar, $metadatas); + self::assertCount(2, $metadatas); } } diff --git a/tests/Doctrine/Tests/ORM/Tools/ConvertDoctrine1SchemaTest.php b/tests/Doctrine/Tests/ORM/Tools/ConvertDoctrine1SchemaTest.php index 621fbc2a2cd..41a44b651af 100644 --- a/tests/Doctrine/Tests/ORM/Tools/ConvertDoctrine1SchemaTest.php +++ b/tests/Doctrine/Tests/ORM/Tools/ConvertDoctrine1SchemaTest.php @@ -45,7 +45,7 @@ protected function createEntityManager(MappingDriver $metadataDriver): EntityMan public function testTest(): void { if (! class_exists('Symfony\Component\Yaml\Yaml', true)) { - $this->markTestSkipped('Please install Symfony YAML Component into the include path of your PHP installation.'); + self::markTestSkipped('Please install Symfony YAML Component into the include path of your PHP installation.'); } $cme = new ClassMetadataExporter(); @@ -56,8 +56,8 @@ public function testTest(): void $exporter->setMetadata($converter->getMetadata()); $exporter->export(); - $this->assertTrue(file_exists(__DIR__ . '/convert/User.dcm.yml')); - $this->assertTrue(file_exists(__DIR__ . '/convert/Profile.dcm.yml')); + self::assertTrue(file_exists(__DIR__ . '/convert/User.dcm.yml')); + self::assertTrue(file_exists(__DIR__ . '/convert/Profile.dcm.yml')); $metadataDriver = new YamlDriver(__DIR__ . '/convert'); $em = $this->createEntityManager($metadataDriver); @@ -67,19 +67,19 @@ public function testTest(): void $profileClass = $cmf->getMetadataFor('Profile'); $userClass = $cmf->getMetadataFor('User'); - $this->assertEquals(2, count($metadata)); - $this->assertEquals('Profile', $profileClass->name); - $this->assertEquals('User', $userClass->name); - $this->assertEquals(4, count($profileClass->fieldMappings)); - $this->assertEquals(5, count($userClass->fieldMappings)); - $this->assertEquals('text', $userClass->fieldMappings['clob']['type']); - $this->assertEquals('test_alias', $userClass->fieldMappings['theAlias']['columnName']); - $this->assertEquals('theAlias', $userClass->fieldMappings['theAlias']['fieldName']); + self::assertEquals(2, count($metadata)); + self::assertEquals('Profile', $profileClass->name); + self::assertEquals('User', $userClass->name); + self::assertEquals(4, count($profileClass->fieldMappings)); + self::assertEquals(5, count($userClass->fieldMappings)); + self::assertEquals('text', $userClass->fieldMappings['clob']['type']); + self::assertEquals('test_alias', $userClass->fieldMappings['theAlias']['columnName']); + self::assertEquals('theAlias', $userClass->fieldMappings['theAlias']['fieldName']); - $this->assertEquals('Profile', $profileClass->associationMappings['User']['sourceEntity']); - $this->assertEquals('User', $profileClass->associationMappings['User']['targetEntity']); + self::assertEquals('Profile', $profileClass->associationMappings['User']['sourceEntity']); + self::assertEquals('User', $profileClass->associationMappings['User']['targetEntity']); - $this->assertEquals('username', $userClass->table['uniqueConstraints']['username']['columns'][0]); + self::assertEquals('username', $userClass->table['uniqueConstraints']['username']['columns'][0]); } public function tearDown(): void diff --git a/tests/Doctrine/Tests/ORM/Tools/EntityGeneratorTest.php b/tests/Doctrine/Tests/ORM/Tools/EntityGeneratorTest.php index 9242ee82893..de1c2415bff 100644 --- a/tests/Doctrine/Tests/ORM/Tools/EntityGeneratorTest.php +++ b/tests/Doctrine/Tests/ORM/Tools/EntityGeneratorTest.php @@ -223,7 +223,7 @@ private function loadEntityClass(ClassMetadataInfo $metadata): void $className = basename(str_replace('\\', '/', $metadata->name)); $path = $this->tmpDir . '/' . $this->namespace . '/' . $className . '.php'; - $this->assertFileExists($path); + self::assertFileExists($path); require_once $path; } @@ -278,59 +278,59 @@ public function testGeneratedEntityClass(): void $metadata = $this->generateBookEntityFixture(['isbn' => $isbnMetadata]); $book = $this->newInstance($metadata); - $this->assertTrue(class_exists($metadata->name), 'Class does not exist.'); - $this->assertTrue(method_exists($metadata->namespace . '\EntityGeneratorBook', '__construct'), 'EntityGeneratorBook::__construct() missing.'); - $this->assertTrue(method_exists($metadata->namespace . '\EntityGeneratorBook', 'getId'), 'EntityGeneratorBook::getId() missing.'); - $this->assertTrue(method_exists($metadata->namespace . '\EntityGeneratorBook', 'setName'), 'EntityGeneratorBook::setName() missing.'); - $this->assertTrue(method_exists($metadata->namespace . '\EntityGeneratorBook', 'getName'), 'EntityGeneratorBook::getName() missing.'); - $this->assertTrue(method_exists($metadata->namespace . '\EntityGeneratorBook', 'setStatus'), 'EntityGeneratorBook::setStatus() missing.'); - $this->assertTrue(method_exists($metadata->namespace . '\EntityGeneratorBook', 'getStatus'), 'EntityGeneratorBook::getStatus() missing.'); - $this->assertTrue(method_exists($metadata->namespace . '\EntityGeneratorBook', 'setAuthor'), 'EntityGeneratorBook::setAuthor() missing.'); - $this->assertTrue(method_exists($metadata->namespace . '\EntityGeneratorBook', 'getAuthor'), 'EntityGeneratorBook::getAuthor() missing.'); - $this->assertTrue(method_exists($metadata->namespace . '\EntityGeneratorBook', 'getComments'), 'EntityGeneratorBook::getComments() missing.'); - $this->assertTrue(method_exists($metadata->namespace . '\EntityGeneratorBook', 'addComment'), 'EntityGeneratorBook::addComment() missing.'); - $this->assertTrue(method_exists($metadata->namespace . '\EntityGeneratorBook', 'removeComment'), 'EntityGeneratorBook::removeComment() missing.'); - $this->assertTrue(method_exists($metadata->namespace . '\EntityGeneratorBook', 'setIsbn'), 'EntityGeneratorBook::setIsbn() missing.'); - $this->assertTrue(method_exists($metadata->namespace . '\EntityGeneratorBook', 'getIsbn'), 'EntityGeneratorBook::getIsbn() missing.'); + self::assertTrue(class_exists($metadata->name), 'Class does not exist.'); + self::assertTrue(method_exists($metadata->namespace . '\EntityGeneratorBook', '__construct'), 'EntityGeneratorBook::__construct() missing.'); + self::assertTrue(method_exists($metadata->namespace . '\EntityGeneratorBook', 'getId'), 'EntityGeneratorBook::getId() missing.'); + self::assertTrue(method_exists($metadata->namespace . '\EntityGeneratorBook', 'setName'), 'EntityGeneratorBook::setName() missing.'); + self::assertTrue(method_exists($metadata->namespace . '\EntityGeneratorBook', 'getName'), 'EntityGeneratorBook::getName() missing.'); + self::assertTrue(method_exists($metadata->namespace . '\EntityGeneratorBook', 'setStatus'), 'EntityGeneratorBook::setStatus() missing.'); + self::assertTrue(method_exists($metadata->namespace . '\EntityGeneratorBook', 'getStatus'), 'EntityGeneratorBook::getStatus() missing.'); + self::assertTrue(method_exists($metadata->namespace . '\EntityGeneratorBook', 'setAuthor'), 'EntityGeneratorBook::setAuthor() missing.'); + self::assertTrue(method_exists($metadata->namespace . '\EntityGeneratorBook', 'getAuthor'), 'EntityGeneratorBook::getAuthor() missing.'); + self::assertTrue(method_exists($metadata->namespace . '\EntityGeneratorBook', 'getComments'), 'EntityGeneratorBook::getComments() missing.'); + self::assertTrue(method_exists($metadata->namespace . '\EntityGeneratorBook', 'addComment'), 'EntityGeneratorBook::addComment() missing.'); + self::assertTrue(method_exists($metadata->namespace . '\EntityGeneratorBook', 'removeComment'), 'EntityGeneratorBook::removeComment() missing.'); + self::assertTrue(method_exists($metadata->namespace . '\EntityGeneratorBook', 'setIsbn'), 'EntityGeneratorBook::setIsbn() missing.'); + self::assertTrue(method_exists($metadata->namespace . '\EntityGeneratorBook', 'getIsbn'), 'EntityGeneratorBook::getIsbn() missing.'); $reflClass = new ReflectionClass($metadata->name); - $this->assertCount(6, $reflClass->getProperties()); - $this->assertCount(15, $reflClass->getMethods()); + self::assertCount(6, $reflClass->getProperties()); + self::assertCount(15, $reflClass->getMethods()); - $this->assertEquals('published', $book->getStatus()); + self::assertEquals('published', $book->getStatus()); $book->setName('Jonathan H. Wage'); - $this->assertEquals('Jonathan H. Wage', $book->getName()); + self::assertEquals('Jonathan H. Wage', $book->getName()); $reflMethod = new ReflectionMethod($metadata->name, 'addComment'); $addCommentParameters = $reflMethod->getParameters(); - $this->assertEquals('comment', $addCommentParameters[0]->getName()); + self::assertEquals('comment', $addCommentParameters[0]->getName()); $reflMethod = new ReflectionMethod($metadata->name, 'removeComment'); $removeCommentParameters = $reflMethod->getParameters(); - $this->assertEquals('comment', $removeCommentParameters[0]->getName()); + self::assertEquals('comment', $removeCommentParameters[0]->getName()); $author = new EntityGeneratorAuthor(); $book->setAuthor($author); - $this->assertEquals($author, $book->getAuthor()); + self::assertEquals($author, $book->getAuthor()); $comment = new EntityGeneratorComment(); - $this->assertInstanceOf($metadata->name, $book->addComment($comment)); - $this->assertInstanceOf(ArrayCollection::class, $book->getComments()); - $this->assertEquals(new ArrayCollection([$comment]), $book->getComments()); - $this->assertIsBool($book->removeComment($comment)); - $this->assertEquals(new ArrayCollection([]), $book->getComments()); + self::assertInstanceOf($metadata->name, $book->addComment($comment)); + self::assertInstanceOf(ArrayCollection::class, $book->getComments()); + self::assertEquals(new ArrayCollection([$comment]), $book->getComments()); + self::assertIsBool($book->removeComment($comment)); + self::assertEquals(new ArrayCollection([]), $book->getComments()); $this->newInstance($isbnMetadata); $isbn = new $isbnMetadata->name(); $book->setIsbn($isbn); - $this->assertSame($isbn, $book->getIsbn()); + self::assertSame($isbn, $book->getIsbn()); $reflMethod = new ReflectionMethod($metadata->name, 'setIsbn'); $reflParameters = $reflMethod->getParameters(); - $this->assertEquals($isbnMetadata->name, $reflParameters[0]->getType()->getName()); + self::assertEquals($isbnMetadata->name, $reflParameters[0]->getType()->getName()); } public function testBooleanDefaultValue(): void @@ -344,12 +344,12 @@ public function testBooleanDefaultValue(): void $this->generator->writeEntityClass($metadata, $this->tmpDir); - $this->assertFileExists($this->tmpDir . '/' . $this->namespace . '/EntityGeneratorBook.php~'); + self::assertFileExists($this->tmpDir . '/' . $this->namespace . '/EntityGeneratorBook.php~'); $book = $this->newInstance($metadata); $reflClass = new ReflectionClass($metadata->name); - $this->assertTrue($book->getfoo()); + self::assertTrue($book->getfoo()); } public function testEntityUpdatingWorks(): void @@ -363,31 +363,31 @@ public function testEntityUpdatingWorks(): void $this->generator->writeEntityClass($metadata, $this->tmpDir); - $this->assertFileExists($this->tmpDir . '/' . $this->namespace . '/EntityGeneratorBook.php~'); + self::assertFileExists($this->tmpDir . '/' . $this->namespace . '/EntityGeneratorBook.php~'); $book = $this->newInstance($metadata); $reflClass = new ReflectionClass($metadata->name); - $this->assertTrue($reflClass->hasProperty('name'), "Regenerating keeps property 'name'."); - $this->assertTrue($reflClass->hasProperty('status'), "Regenerating keeps property 'status'."); - $this->assertTrue($reflClass->hasProperty('id'), "Regenerating keeps property 'id'."); - $this->assertTrue($reflClass->hasProperty('isbn'), "Regenerating keeps property 'isbn'."); - - $this->assertTrue($reflClass->hasProperty('test'), 'Check for property test failed.'); - $this->assertTrue($reflClass->getProperty('test')->isProtected(), 'Check for protected property test failed.'); - $this->assertTrue($reflClass->hasProperty('testEmbedded'), 'Check for property testEmbedded failed.'); - $this->assertTrue($reflClass->getProperty('testEmbedded')->isProtected(), 'Check for protected property testEmbedded failed.'); - $this->assertTrue($reflClass->hasMethod('getTest'), "Check for method 'getTest' failed."); - $this->assertTrue($reflClass->getMethod('getTest')->isPublic(), "Check for public visibility of method 'getTest' failed."); - $this->assertTrue($reflClass->hasMethod('setTest'), "Check for method 'setTest' failed."); - $this->assertTrue($reflClass->getMethod('setTest')->isPublic(), "Check for public visibility of method 'setTest' failed."); - $this->assertTrue($reflClass->hasMethod('getTestEmbedded'), "Check for method 'getTestEmbedded' failed."); - $this->assertTrue( + self::assertTrue($reflClass->hasProperty('name'), "Regenerating keeps property 'name'."); + self::assertTrue($reflClass->hasProperty('status'), "Regenerating keeps property 'status'."); + self::assertTrue($reflClass->hasProperty('id'), "Regenerating keeps property 'id'."); + self::assertTrue($reflClass->hasProperty('isbn'), "Regenerating keeps property 'isbn'."); + + self::assertTrue($reflClass->hasProperty('test'), 'Check for property test failed.'); + self::assertTrue($reflClass->getProperty('test')->isProtected(), 'Check for protected property test failed.'); + self::assertTrue($reflClass->hasProperty('testEmbedded'), 'Check for property testEmbedded failed.'); + self::assertTrue($reflClass->getProperty('testEmbedded')->isProtected(), 'Check for protected property testEmbedded failed.'); + self::assertTrue($reflClass->hasMethod('getTest'), "Check for method 'getTest' failed."); + self::assertTrue($reflClass->getMethod('getTest')->isPublic(), "Check for public visibility of method 'getTest' failed."); + self::assertTrue($reflClass->hasMethod('setTest'), "Check for method 'setTest' failed."); + self::assertTrue($reflClass->getMethod('setTest')->isPublic(), "Check for public visibility of method 'setTest' failed."); + self::assertTrue($reflClass->hasMethod('getTestEmbedded'), "Check for method 'getTestEmbedded' failed."); + self::assertTrue( $reflClass->getMethod('getTestEmbedded')->isPublic(), "Check for public visibility of method 'getTestEmbedded' failed." ); - $this->assertTrue($reflClass->hasMethod('setTestEmbedded'), "Check for method 'setTestEmbedded' failed."); - $this->assertTrue( + self::assertTrue($reflClass->hasMethod('setTestEmbedded'), "Check for method 'setTestEmbedded' failed."); + self::assertTrue( $reflClass->getMethod('setTestEmbedded')->isPublic(), "Check for public visibility of method 'setTestEmbedded' failed." ); @@ -408,19 +408,19 @@ public function testDoesNotRegenerateExistingMethodsWithDifferentCase(): void // Should not throw a PHP fatal error $this->generator->writeEntityClass($metadata, $this->tmpDir); - $this->assertFileExists($this->tmpDir . '/' . $this->namespace . '/EntityGeneratorBook.php~'); + self::assertFileExists($this->tmpDir . '/' . $this->namespace . '/EntityGeneratorBook.php~'); $this->newInstance($metadata); $reflClass = new ReflectionClass($metadata->name); - $this->assertTrue($reflClass->hasProperty('status')); - $this->assertTrue($reflClass->hasProperty('STATUS')); - $this->assertTrue($reflClass->hasProperty('isbn')); - $this->assertTrue($reflClass->hasProperty('ISBN')); - $this->assertTrue($reflClass->hasMethod('getStatus')); - $this->assertTrue($reflClass->hasMethod('setStatus')); - $this->assertTrue($reflClass->hasMethod('getIsbn')); - $this->assertTrue($reflClass->hasMethod('setIsbn')); + self::assertTrue($reflClass->hasProperty('status')); + self::assertTrue($reflClass->hasProperty('STATUS')); + self::assertTrue($reflClass->hasProperty('isbn')); + self::assertTrue($reflClass->hasProperty('ISBN')); + self::assertTrue($reflClass->hasMethod('getStatus')); + self::assertTrue($reflClass->hasMethod('setStatus')); + self::assertTrue($reflClass->hasMethod('getIsbn')); + self::assertTrue($reflClass->hasMethod('setIsbn')); } /** @@ -455,11 +455,11 @@ public function testEntityExtendsStdClass(): void $metadata = $this->generateBookEntityFixture(); $book = $this->newInstance($metadata); - $this->assertInstanceOf('stdClass', $book); + self::assertInstanceOf('stdClass', $book); $metadata = $this->generateIsbnEmbeddableFixture(); $isbn = $this->newInstance($metadata); - $this->assertInstanceOf('stdClass', $isbn); + self::assertInstanceOf('stdClass', $isbn); } public function testLifecycleCallbacks(): void @@ -469,8 +469,8 @@ public function testLifecycleCallbacks(): void $book = $this->newInstance($metadata); $reflClass = new ReflectionClass($metadata->name); - $this->assertTrue($reflClass->hasMethod('loading'), 'Check for postLoad lifecycle callback.'); - $this->assertTrue($reflClass->hasMethod('willBeRemoved'), 'Check for preRemove lifecycle callback.'); + self::assertTrue($reflClass->hasMethod('loading'), 'Check for postLoad lifecycle callback.'); + self::assertTrue($reflClass->hasMethod('willBeRemoved'), 'Check for preRemove lifecycle callback.'); } public function testLoadMetadata(): void @@ -488,16 +488,16 @@ public function testLoadMetadata(): void $driver = $this->createAnnotationDriver(); $driver->loadMetadataForClass($cm->name, $cm); - $this->assertEquals($cm->columnNames, $metadata->columnNames); - $this->assertEquals($cm->getTableName(), $metadata->getTableName()); - $this->assertEquals($cm->lifecycleCallbacks, $metadata->lifecycleCallbacks); - $this->assertEquals($cm->identifier, $metadata->identifier); - $this->assertEquals($cm->idGenerator, $metadata->idGenerator); - $this->assertEquals($cm->customRepositoryClassName, $metadata->customRepositoryClassName); - $this->assertEquals($cm->embeddedClasses, $metadata->embeddedClasses); - $this->assertEquals($cm->isEmbeddedClass, $metadata->isEmbeddedClass); + self::assertEquals($cm->columnNames, $metadata->columnNames); + self::assertEquals($cm->getTableName(), $metadata->getTableName()); + self::assertEquals($cm->lifecycleCallbacks, $metadata->lifecycleCallbacks); + self::assertEquals($cm->identifier, $metadata->identifier); + self::assertEquals($cm->idGenerator, $metadata->idGenerator); + self::assertEquals($cm->customRepositoryClassName, $metadata->customRepositoryClassName); + self::assertEquals($cm->embeddedClasses, $metadata->embeddedClasses); + self::assertEquals($cm->isEmbeddedClass, $metadata->isEmbeddedClass); - $this->assertEquals(ClassMetadataInfo::FETCH_EXTRA_LAZY, $cm->associationMappings['comments']['fetch']); + self::assertEquals(ClassMetadataInfo::FETCH_EXTRA_LAZY, $cm->associationMappings['comments']['fetch']); $isbn = $this->newInstance($embeddedMetadata); @@ -506,9 +506,9 @@ public function testLoadMetadata(): void $driver->loadMetadataForClass($cm->name, $cm); - $this->assertEquals($cm->columnNames, $embeddedMetadata->columnNames); - $this->assertEquals($cm->embeddedClasses, $embeddedMetadata->embeddedClasses); - $this->assertEquals($cm->isEmbeddedClass, $embeddedMetadata->isEmbeddedClass); + self::assertEquals($cm->columnNames, $embeddedMetadata->columnNames); + self::assertEquals($cm->embeddedClasses, $embeddedMetadata->embeddedClasses); + self::assertEquals($cm->isEmbeddedClass, $embeddedMetadata->isEmbeddedClass); } public function testLoadPrefixedMetadata(): void @@ -529,12 +529,12 @@ public function testLoadPrefixedMetadata(): void $driver->loadMetadataForClass($cm->name, $cm); - $this->assertEquals($cm->columnNames, $metadata->columnNames); - $this->assertEquals($cm->getTableName(), $metadata->getTableName()); - $this->assertEquals($cm->lifecycleCallbacks, $metadata->lifecycleCallbacks); - $this->assertEquals($cm->identifier, $metadata->identifier); - $this->assertEquals($cm->idGenerator, $metadata->idGenerator); - $this->assertEquals($cm->customRepositoryClassName, $metadata->customRepositoryClassName); + self::assertEquals($cm->columnNames, $metadata->columnNames); + self::assertEquals($cm->getTableName(), $metadata->getTableName()); + self::assertEquals($cm->lifecycleCallbacks, $metadata->lifecycleCallbacks); + self::assertEquals($cm->identifier, $metadata->identifier); + self::assertEquals($cm->idGenerator, $metadata->idGenerator); + self::assertEquals($cm->customRepositoryClassName, $metadata->customRepositoryClassName); $isbn = $this->newInstance($embeddedMetadata); @@ -543,9 +543,9 @@ public function testLoadPrefixedMetadata(): void $driver->loadMetadataForClass($cm->name, $cm); - $this->assertEquals($cm->columnNames, $embeddedMetadata->columnNames); - $this->assertEquals($cm->embeddedClasses, $embeddedMetadata->embeddedClasses); - $this->assertEquals($cm->isEmbeddedClass, $embeddedMetadata->isEmbeddedClass); + self::assertEquals($cm->columnNames, $embeddedMetadata->columnNames); + self::assertEquals($cm->embeddedClasses, $embeddedMetadata->embeddedClasses); + self::assertEquals($cm->isEmbeddedClass, $embeddedMetadata->isEmbeddedClass); } /** @@ -567,7 +567,7 @@ public function testMappedSuperclassAnnotationGeneration(): void $cm->initializeReflection(new RuntimeReflectionService()); $driver->loadMetadataForClass($cm->name, $cm); - $this->assertTrue($cm->isMappedSuperclass); + self::assertTrue($cm->isMappedSuperclass); } /** @@ -583,7 +583,7 @@ public function testParseTokensInEntityFile($php, $classes): void $p->setAccessible(true); $ret = $m->invoke($this->generator, $php); - $this->assertEquals($classes, array_keys($p->getValue($this->generator))); + self::assertEquals($classes, array_keys($p->getValue($this->generator))); } /** @@ -607,16 +607,16 @@ public function testGenerateEntityWithSequenceGenerator(): void $filename = $this->tmpDir . DIRECTORY_SEPARATOR . $this->namespace . DIRECTORY_SEPARATOR . 'DDC1784Entity.php'; - $this->assertFileExists($filename); + self::assertFileExists($filename); require_once $filename; $reflection = new ReflectionProperty($metadata->name, 'id'); $docComment = $reflection->getDocComment(); - $this->assertStringContainsString('@ORM\Id', $docComment); - $this->assertStringContainsString('@ORM\Column(name="id", type="integer")', $docComment); - $this->assertStringContainsString('@ORM\GeneratedValue(strategy="SEQUENCE")', $docComment); - $this->assertStringContainsString( + self::assertStringContainsString('@ORM\Id', $docComment); + self::assertStringContainsString('@ORM\Column(name="id", type="integer")', $docComment); + self::assertStringContainsString('@ORM\GeneratedValue(strategy="SEQUENCE")', $docComment); + self::assertStringContainsString( '@ORM\SequenceGenerator(sequenceName="DDC1784_ID_SEQ", allocationSize=1, initialValue=2)', $docComment ); @@ -653,27 +653,27 @@ public function testGenerateEntityWithMultipleInverseJoinColumns(): void $filename = $this->tmpDir . DIRECTORY_SEPARATOR . $this->namespace . DIRECTORY_SEPARATOR . 'DDC2079Entity.php'; - $this->assertFileExists($filename); + self::assertFileExists($filename); require_once $filename; $property = new ReflectionProperty($metadata->name, 'centroCustos'); $docComment = $property->getDocComment(); //joinColumns - $this->assertStringContainsString( + self::assertStringContainsString( '@ORM\JoinColumn(name="idorcamento", referencedColumnName="idorcamento"),', $docComment ); - $this->assertStringContainsString( + self::assertStringContainsString( '@ORM\JoinColumn(name="idunidade", referencedColumnName="idunidade")', $docComment ); //inverseJoinColumns - $this->assertStringContainsString( + self::assertStringContainsString( '@ORM\JoinColumn(name="idcentrocusto", referencedColumnName="idcentrocusto"),', $docComment ); - $this->assertStringContainsString( + self::assertStringContainsString( '@ORM\JoinColumn(name="idpais", referencedColumnName="idpais")', $docComment ); @@ -699,7 +699,7 @@ public function testGetInheritanceTypeString(): void $expected = preg_replace($pattern, '', $name); $actual = $method->invoke($this->generator, $value); - $this->assertEquals($expected, $actual); + self::assertEquals($expected, $actual); } $this->expectException(InvalidArgumentException::class); @@ -728,7 +728,7 @@ public function testGetChangeTrackingPolicyString(): void $expected = preg_replace($pattern, '', $name); $actual = $method->invoke($this->generator, $value); - $this->assertEquals($expected, $actual); + self::assertEquals($expected, $actual); } $this->expectException(InvalidArgumentException::class); @@ -757,7 +757,7 @@ public function testGetIdGeneratorTypeString(): void $expected = preg_replace($pattern, '', $name); $actual = $method->invoke($this->generator, $value); - $this->assertEquals($expected, $actual); + self::assertEquals($expected, $actual); } $this->expectException(InvalidArgumentException::class); @@ -775,7 +775,7 @@ public function testEntityTypeAlias(array $field): void $metadata = $this->generateEntityTypeFixture($field); $path = $this->tmpDir . '/' . $this->namespace . '/EntityType.php'; - $this->assertFileExists($path); + self::assertFileExists($path); require_once $path; $entity = new $metadata->name(); @@ -791,8 +791,8 @@ public function testEntityTypeAlias(array $field): void $this->assertPhpDocParamType($type, $reflClass->getMethod($setter)); $this->assertPhpDocReturnType($type, $reflClass->getMethod($getter)); - $this->assertSame($entity, $entity->{$setter}($value)); - $this->assertEquals($value, $entity->{$getter}()); + self::assertSame($entity, $entity->{$setter}($value)); + self::assertEquals($value, $entity->{$getter}()); } /** @@ -811,14 +811,14 @@ public function testTraitPropertiesAndMethodsAreNotDuplicated(): void $this->generator->writeEntityClass($metadata, $this->tmpDir); - $this->assertFileExists($this->tmpDir . '/' . $this->namespace . '/DDC2372User.php'); + self::assertFileExists($this->tmpDir . '/' . $this->namespace . '/DDC2372User.php'); require $this->tmpDir . '/' . $this->namespace . '/DDC2372User.php'; $reflClass = new ReflectionClass($metadata->name); - $this->assertSame($reflClass->hasProperty('address'), false); - $this->assertSame($reflClass->hasMethod('setAddress'), false); - $this->assertSame($reflClass->hasMethod('getAddress'), false); + self::assertSame($reflClass->hasProperty('address'), false); + self::assertSame($reflClass->hasMethod('setAddress'), false); + self::assertSame($reflClass->hasMethod('getAddress'), false); } /** @@ -837,14 +837,14 @@ public function testTraitPropertiesAndMethodsAreNotDuplicatedInChildClasses(): v $this->generator->writeEntityClass($metadata, $this->tmpDir); - $this->assertFileExists($this->tmpDir . '/' . $this->namespace . '/DDC2372Admin.php'); + self::assertFileExists($this->tmpDir . '/' . $this->namespace . '/DDC2372Admin.php'); require $this->tmpDir . '/' . $this->namespace . '/DDC2372Admin.php'; $reflClass = new ReflectionClass($metadata->name); - $this->assertSame($reflClass->hasProperty('address'), false); - $this->assertSame($reflClass->hasMethod('setAddress'), false); - $this->assertSame($reflClass->hasMethod('getAddress'), false); + self::assertSame($reflClass->hasProperty('address'), false); + self::assertSame($reflClass->hasMethod('setAddress'), false); + self::assertSame($reflClass->hasMethod('getAddress'), false); } /** @@ -891,30 +891,30 @@ public function testMethodsAndPropertiesAreNotDuplicatedInChildClasses(): void // class _DDC1590User extends DDC1590Entity { ... } $rc2 = new ReflectionClass($ns . '\_DDC1590User'); - $this->assertTrue($rc2->hasProperty('name')); - $this->assertTrue($rc2->hasProperty('id')); - $this->assertTrue($rc2->hasProperty('createdAt')); + self::assertTrue($rc2->hasProperty('name')); + self::assertTrue($rc2->hasProperty('id')); + self::assertTrue($rc2->hasProperty('createdAt')); - $this->assertTrue($rc2->hasMethod('getName')); - $this->assertTrue($rc2->hasMethod('setName')); - $this->assertTrue($rc2->hasMethod('getId')); - $this->assertFalse($rc2->hasMethod('setId')); - $this->assertTrue($rc2->hasMethod('getCreatedAt')); - $this->assertTrue($rc2->hasMethod('setCreatedAt')); + self::assertTrue($rc2->hasMethod('getName')); + self::assertTrue($rc2->hasMethod('setName')); + self::assertTrue($rc2->hasMethod('getId')); + self::assertFalse($rc2->hasMethod('setId')); + self::assertTrue($rc2->hasMethod('getCreatedAt')); + self::assertTrue($rc2->hasMethod('setCreatedAt')); // class __DDC1590User { ... } $rc3 = new ReflectionClass($ns . '\__DDC1590User'); - $this->assertTrue($rc3->hasProperty('name')); - $this->assertFalse($rc3->hasProperty('id')); - $this->assertFalse($rc3->hasProperty('createdAt')); + self::assertTrue($rc3->hasProperty('name')); + self::assertFalse($rc3->hasProperty('id')); + self::assertFalse($rc3->hasProperty('createdAt')); - $this->assertTrue($rc3->hasMethod('getName')); - $this->assertTrue($rc3->hasMethod('setName')); - $this->assertFalse($rc3->hasMethod('getId')); - $this->assertFalse($rc3->hasMethod('setId')); - $this->assertFalse($rc3->hasMethod('getCreatedAt')); - $this->assertFalse($rc3->hasMethod('setCreatedAt')); + self::assertTrue($rc3->hasMethod('getName')); + self::assertTrue($rc3->hasMethod('setName')); + self::assertFalse($rc3->hasMethod('getId')); + self::assertFalse($rc3->hasMethod('setId')); + self::assertFalse($rc3->hasMethod('getCreatedAt')); + self::assertFalse($rc3->hasMethod('setCreatedAt')); } /** @@ -927,33 +927,33 @@ public function testGeneratedMutableEmbeddablesClass(): void $isbn = $this->newInstance($metadata); - $this->assertTrue(class_exists($metadata->name), 'Class does not exist.'); - $this->assertFalse(method_exists($metadata->name, '__construct'), 'EntityGeneratorIsbn::__construct present.'); - $this->assertTrue(method_exists($metadata->name, 'getPrefix'), 'EntityGeneratorIsbn::getPrefix() missing.'); - $this->assertTrue(method_exists($metadata->name, 'setPrefix'), 'EntityGeneratorIsbn::setPrefix() missing.'); - $this->assertTrue(method_exists($metadata->name, 'getGroupNumber'), 'EntityGeneratorIsbn::getGroupNumber() missing.'); - $this->assertTrue(method_exists($metadata->name, 'setGroupNumber'), 'EntityGeneratorIsbn::setGroupNumber() missing.'); - $this->assertTrue(method_exists($metadata->name, 'getPublisherNumber'), 'EntityGeneratorIsbn::getPublisherNumber() missing.'); - $this->assertTrue(method_exists($metadata->name, 'setPublisherNumber'), 'EntityGeneratorIsbn::setPublisherNumber() missing.'); - $this->assertTrue(method_exists($metadata->name, 'getTitleNumber'), 'EntityGeneratorIsbn::getTitleNumber() missing.'); - $this->assertTrue(method_exists($metadata->name, 'setTitleNumber'), 'EntityGeneratorIsbn::setTitleNumber() missing.'); - $this->assertTrue(method_exists($metadata->name, 'getCheckDigit'), 'EntityGeneratorIsbn::getCheckDigit() missing.'); - $this->assertTrue(method_exists($metadata->name, 'setCheckDigit'), 'EntityGeneratorIsbn::setCheckDigit() missing.'); - $this->assertTrue(method_exists($metadata->name, 'getTest'), 'EntityGeneratorIsbn::getTest() missing.'); - $this->assertTrue(method_exists($metadata->name, 'setTest'), 'EntityGeneratorIsbn::setTest() missing.'); + self::assertTrue(class_exists($metadata->name), 'Class does not exist.'); + self::assertFalse(method_exists($metadata->name, '__construct'), 'EntityGeneratorIsbn::__construct present.'); + self::assertTrue(method_exists($metadata->name, 'getPrefix'), 'EntityGeneratorIsbn::getPrefix() missing.'); + self::assertTrue(method_exists($metadata->name, 'setPrefix'), 'EntityGeneratorIsbn::setPrefix() missing.'); + self::assertTrue(method_exists($metadata->name, 'getGroupNumber'), 'EntityGeneratorIsbn::getGroupNumber() missing.'); + self::assertTrue(method_exists($metadata->name, 'setGroupNumber'), 'EntityGeneratorIsbn::setGroupNumber() missing.'); + self::assertTrue(method_exists($metadata->name, 'getPublisherNumber'), 'EntityGeneratorIsbn::getPublisherNumber() missing.'); + self::assertTrue(method_exists($metadata->name, 'setPublisherNumber'), 'EntityGeneratorIsbn::setPublisherNumber() missing.'); + self::assertTrue(method_exists($metadata->name, 'getTitleNumber'), 'EntityGeneratorIsbn::getTitleNumber() missing.'); + self::assertTrue(method_exists($metadata->name, 'setTitleNumber'), 'EntityGeneratorIsbn::setTitleNumber() missing.'); + self::assertTrue(method_exists($metadata->name, 'getCheckDigit'), 'EntityGeneratorIsbn::getCheckDigit() missing.'); + self::assertTrue(method_exists($metadata->name, 'setCheckDigit'), 'EntityGeneratorIsbn::setCheckDigit() missing.'); + self::assertTrue(method_exists($metadata->name, 'getTest'), 'EntityGeneratorIsbn::getTest() missing.'); + self::assertTrue(method_exists($metadata->name, 'setTest'), 'EntityGeneratorIsbn::setTest() missing.'); $isbn->setPrefix(978); - $this->assertSame(978, $isbn->getPrefix()); + self::assertSame(978, $isbn->getPrefix()); $this->newInstance($embeddedMetadata); $test = new $embeddedMetadata->name(); $isbn->setTest($test); - $this->assertSame($test, $isbn->getTest()); + self::assertSame($test, $isbn->getTest()); $reflMethod = new ReflectionMethod($metadata->name, 'setTest'); $reflParameters = $reflMethod->getParameters(); - $this->assertEquals($embeddedMetadata->name, $reflParameters[0]->getType()->getName()); + self::assertEquals($embeddedMetadata->name, $reflParameters[0]->getType()->getName()); } /** @@ -968,20 +968,20 @@ public function testGeneratedImmutableEmbeddablesClass(): void $this->loadEntityClass($embeddedMetadata); $this->loadEntityClass($metadata); - $this->assertTrue(class_exists($metadata->name), 'Class does not exist.'); - $this->assertTrue(method_exists($metadata->name, '__construct'), 'EntityGeneratorIsbn::__construct missing.'); - $this->assertTrue(method_exists($metadata->name, 'getPrefix'), 'EntityGeneratorIsbn::getPrefix() missing.'); - $this->assertFalse(method_exists($metadata->name, 'setPrefix'), 'EntityGeneratorIsbn::setPrefix() present.'); - $this->assertTrue(method_exists($metadata->name, 'getGroupNumber'), 'EntityGeneratorIsbn::getGroupNumber() missing.'); - $this->assertFalse(method_exists($metadata->name, 'setGroupNumber'), 'EntityGeneratorIsbn::setGroupNumber() present.'); - $this->assertTrue(method_exists($metadata->name, 'getPublisherNumber'), 'EntityGeneratorIsbn::getPublisherNumber() missing.'); - $this->assertFalse(method_exists($metadata->name, 'setPublisherNumber'), 'EntityGeneratorIsbn::setPublisherNumber() present.'); - $this->assertTrue(method_exists($metadata->name, 'getTitleNumber'), 'EntityGeneratorIsbn::getTitleNumber() missing.'); - $this->assertFalse(method_exists($metadata->name, 'setTitleNumber'), 'EntityGeneratorIsbn::setTitleNumber() present.'); - $this->assertTrue(method_exists($metadata->name, 'getCheckDigit'), 'EntityGeneratorIsbn::getCheckDigit() missing.'); - $this->assertFalse(method_exists($metadata->name, 'setCheckDigit'), 'EntityGeneratorIsbn::setCheckDigit() present.'); - $this->assertTrue(method_exists($metadata->name, 'getTest'), 'EntityGeneratorIsbn::getTest() missing.'); - $this->assertFalse(method_exists($metadata->name, 'setTest'), 'EntityGeneratorIsbn::setTest() present.'); + self::assertTrue(class_exists($metadata->name), 'Class does not exist.'); + self::assertTrue(method_exists($metadata->name, '__construct'), 'EntityGeneratorIsbn::__construct missing.'); + self::assertTrue(method_exists($metadata->name, 'getPrefix'), 'EntityGeneratorIsbn::getPrefix() missing.'); + self::assertFalse(method_exists($metadata->name, 'setPrefix'), 'EntityGeneratorIsbn::setPrefix() present.'); + self::assertTrue(method_exists($metadata->name, 'getGroupNumber'), 'EntityGeneratorIsbn::getGroupNumber() missing.'); + self::assertFalse(method_exists($metadata->name, 'setGroupNumber'), 'EntityGeneratorIsbn::setGroupNumber() present.'); + self::assertTrue(method_exists($metadata->name, 'getPublisherNumber'), 'EntityGeneratorIsbn::getPublisherNumber() missing.'); + self::assertFalse(method_exists($metadata->name, 'setPublisherNumber'), 'EntityGeneratorIsbn::setPublisherNumber() present.'); + self::assertTrue(method_exists($metadata->name, 'getTitleNumber'), 'EntityGeneratorIsbn::getTitleNumber() missing.'); + self::assertFalse(method_exists($metadata->name, 'setTitleNumber'), 'EntityGeneratorIsbn::setTitleNumber() present.'); + self::assertTrue(method_exists($metadata->name, 'getCheckDigit'), 'EntityGeneratorIsbn::getCheckDigit() missing.'); + self::assertFalse(method_exists($metadata->name, 'setCheckDigit'), 'EntityGeneratorIsbn::setCheckDigit() present.'); + self::assertTrue(method_exists($metadata->name, 'getTest'), 'EntityGeneratorIsbn::getTest() missing.'); + self::assertFalse(method_exists($metadata->name, 'setTest'), 'EntityGeneratorIsbn::setTest() present.'); $test = new $embeddedMetadata->name(1, new DateTime()); $isbn = new $metadata->name($test, 978, 3, 12, 732320, 83); @@ -989,45 +989,45 @@ public function testGeneratedImmutableEmbeddablesClass(): void $reflMethod = new ReflectionMethod($isbn, '__construct'); $reflParameters = $reflMethod->getParameters(); - $this->assertCount(6, $reflParameters); + self::assertCount(6, $reflParameters); - $this->assertSame($embeddedMetadata->name, $reflParameters[0]->getType()->getName()); - $this->assertSame('test', $reflParameters[0]->getName()); - $this->assertFalse($reflParameters[0]->isOptional()); + self::assertSame($embeddedMetadata->name, $reflParameters[0]->getType()->getName()); + self::assertSame('test', $reflParameters[0]->getName()); + self::assertFalse($reflParameters[0]->isOptional()); - $this->assertSame('prefix', $reflParameters[1]->getName()); - $this->assertFalse($reflParameters[1]->isOptional()); + self::assertSame('prefix', $reflParameters[1]->getName()); + self::assertFalse($reflParameters[1]->isOptional()); - $this->assertSame('groupNumber', $reflParameters[2]->getName()); - $this->assertFalse($reflParameters[2]->isOptional()); + self::assertSame('groupNumber', $reflParameters[2]->getName()); + self::assertFalse($reflParameters[2]->isOptional()); - $this->assertSame('publisherNumber', $reflParameters[3]->getName()); - $this->assertFalse($reflParameters[3]->isOptional()); + self::assertSame('publisherNumber', $reflParameters[3]->getName()); + self::assertFalse($reflParameters[3]->isOptional()); - $this->assertSame('titleNumber', $reflParameters[4]->getName()); - $this->assertFalse($reflParameters[4]->isOptional()); + self::assertSame('titleNumber', $reflParameters[4]->getName()); + self::assertFalse($reflParameters[4]->isOptional()); - $this->assertSame('checkDigit', $reflParameters[5]->getName()); - $this->assertFalse($reflParameters[5]->isOptional()); + self::assertSame('checkDigit', $reflParameters[5]->getName()); + self::assertFalse($reflParameters[5]->isOptional()); $reflMethod = new ReflectionMethod($test, '__construct'); $reflParameters = $reflMethod->getParameters(); - $this->assertCount(4, $reflParameters); + self::assertCount(4, $reflParameters); - $this->assertSame('field1', $reflParameters[0]->getName()); - $this->assertFalse($reflParameters[0]->isOptional()); + self::assertSame('field1', $reflParameters[0]->getName()); + self::assertFalse($reflParameters[0]->isOptional()); - $this->assertSame('DateTime', $reflParameters[1]->getType()->getName()); - $this->assertSame('field3', $reflParameters[1]->getName()); - $this->assertFalse($reflParameters[1]->isOptional()); + self::assertSame('DateTime', $reflParameters[1]->getType()->getName()); + self::assertSame('field3', $reflParameters[1]->getName()); + self::assertFalse($reflParameters[1]->isOptional()); - $this->assertSame('field2', $reflParameters[2]->getName()); - $this->assertTrue($reflParameters[2]->isOptional()); + self::assertSame('field2', $reflParameters[2]->getName()); + self::assertTrue($reflParameters[2]->isOptional()); - $this->assertSame('DateTime', $reflParameters[3]->getType()->getName()); - $this->assertSame('field4', $reflParameters[3]->getName()); - $this->assertTrue($reflParameters[3]->isOptional()); + self::assertSame('DateTime', $reflParameters[3]->getType()->getName()); + self::assertSame('field4', $reflParameters[3]->getName()); + self::assertTrue($reflParameters[3]->isOptional()); } public function testRegenerateEntityClass(): void @@ -1045,7 +1045,7 @@ public function testRegenerateEntityClass(): void $this->generator->writeEntityClass($metadata, $this->tmpDir); $classNew = file_get_contents($path); - $this->assertSame($classTest, $classNew); + self::assertSame($classTest, $classNew); } /** @@ -1201,9 +1201,9 @@ private function assertPhpDocVarType(string $type, ReflectionProperty $property) $docComment = $property->getDocComment(); $regex = '/@var\s+([\S]+)$/m'; - $this->assertMatchesRegularExpression($regex, $docComment); - $this->assertEquals(1, preg_match($regex, $docComment, $matches)); - $this->assertEquals($type, $matches[1]); + self::assertMatchesRegularExpression($regex, $docComment); + self::assertEquals(1, preg_match($regex, $docComment, $matches)); + self::assertEquals($type, $matches[1]); } private function assertPhpDocReturnType(string $type, ReflectionMethod $method): void @@ -1211,15 +1211,15 @@ private function assertPhpDocReturnType(string $type, ReflectionMethod $method): $docComment = $method->getDocComment(); $regex = '/@return\s+([\S]+)(\s+.*)$/m'; - $this->assertMatchesRegularExpression($regex, $docComment); - $this->assertEquals(1, preg_match($regex, $docComment, $matches)); - $this->assertEquals($type, $matches[1]); + self::assertMatchesRegularExpression($regex, $docComment); + self::assertEquals(1, preg_match($regex, $docComment, $matches)); + self::assertEquals($type, $matches[1]); } private function assertPhpDocParamType(string $type, ReflectionMethod $method): void { - $this->assertEquals(1, preg_match('/@param\s+([^\s]+)/', $method->getDocComment(), $matches)); - $this->assertEquals($type, $matches[1]); + self::assertEquals(1, preg_match('/@param\s+([^\s]+)/', $method->getDocComment(), $matches)); + self::assertEquals($type, $matches[1]); } /** diff --git a/tests/Doctrine/Tests/ORM/Tools/EntityRepositoryGeneratorTest.php b/tests/Doctrine/Tests/ORM/Tools/EntityRepositoryGeneratorTest.php index f249416c7e8..a4ef2f1edf2 100644 --- a/tests/Doctrine/Tests/ORM/Tools/EntityRepositoryGeneratorTest.php +++ b/tests/Doctrine/Tests/ORM/Tools/EntityRepositoryGeneratorTest.php @@ -94,15 +94,15 @@ public function testGeneratedEntityRepositoryClass(): void $rpath = $this->writeRepositoryClass($className); - $this->assertFileExists($rpath); + self::assertFileExists($rpath); require $rpath; $repo = new ReflectionClass($em->getRepository($className)); - $this->assertTrue($repo->inNamespace()); - $this->assertSame($className . 'Repository', $repo->getName()); - $this->assertSame(EntityRepository::class, $repo->getParentClass()->getName()); + self::assertTrue($repo->inNamespace()); + self::assertSame($className . 'Repository', $repo->getName()); + self::assertSame(EntityRepository::class, $repo->getParentClass()->getName()); require_once __DIR__ . '/../../Models/DDC3231/DDC3231User1NoNamespace.php'; @@ -111,15 +111,15 @@ public function testGeneratedEntityRepositoryClass(): void $rpath2 = $this->writeRepositoryClass($className2); - $this->assertFileExists($rpath2); + self::assertFileExists($rpath2); require $rpath2; $repo2 = new ReflectionClass($em->getRepository($className2)); - $this->assertFalse($repo2->inNamespace()); - $this->assertSame($className2 . 'Repository', $repo2->getName()); - $this->assertSame(EntityRepository::class, $repo2->getParentClass()->getName()); + self::assertFalse($repo2->inNamespace()); + self::assertSame($className2 . 'Repository', $repo2->getName()); + self::assertSame(EntityRepository::class, $repo2->getParentClass()->getName()); } /** @@ -135,16 +135,16 @@ public function testGeneratedEntityRepositoryClassCustomDefaultRepository(): voi $rpath = $this->writeRepositoryClass($className, DDC3231EntityRepository::class); - $this->assertNotNull($rpath); - $this->assertFileExists($rpath); + self::assertNotNull($rpath); + self::assertFileExists($rpath); require $rpath; $repo = new ReflectionClass($em->getRepository($className)); - $this->assertTrue($repo->inNamespace()); - $this->assertSame($className . 'Repository', $repo->getName()); - $this->assertSame(DDC3231EntityRepository::class, $repo->getParentClass()->getName()); + self::assertTrue($repo->inNamespace()); + self::assertSame($className . 'Repository', $repo->getName()); + self::assertSame(DDC3231EntityRepository::class, $repo->getParentClass()->getName()); require_once __DIR__ . '/../../Models/DDC3231/DDC3231User2NoNamespace.php'; @@ -153,16 +153,16 @@ public function testGeneratedEntityRepositoryClassCustomDefaultRepository(): voi $rpath2 = $this->writeRepositoryClass($className2, DDC3231EntityRepository::class); - $this->assertNotNull($rpath2); - $this->assertFileExists($rpath2); + self::assertNotNull($rpath2); + self::assertFileExists($rpath2); require $rpath2; $repo2 = new ReflectionClass($em->getRepository($className2)); - $this->assertFalse($repo2->inNamespace()); - $this->assertSame($className2 . 'Repository', $repo2->getName()); - $this->assertSame(DDC3231EntityRepository::class, $repo2->getParentClass()->getName()); + self::assertFalse($repo2->inNamespace()); + self::assertSame($className2 . 'Repository', $repo2->getName()); + self::assertSame(DDC3231EntityRepository::class, $repo2->getParentClass()->getName()); } private function writeEntityClass(string $className, string $newClassName): void diff --git a/tests/Doctrine/Tests/ORM/Tools/Export/AbstractClassMetadataExporterTest.php b/tests/Doctrine/Tests/ORM/Tools/Export/AbstractClassMetadataExporterTest.php index c863464746a..a2bc8a77675 100644 --- a/tests/Doctrine/Tests/ORM/Tools/Export/AbstractClassMetadataExporterTest.php +++ b/tests/Doctrine/Tests/ORM/Tools/Export/AbstractClassMetadataExporterTest.php @@ -73,7 +73,7 @@ protected function createMetadataDriver(string $type, string $path): MappingDriv 'yaml' => YamlDriver::class, ]; - $this->assertArrayHasKey($type, $mappingDriver, "There is no metadata driver for the type '" . $type . "'."); + self::assertArrayHasKey($type, $mappingDriver, "There is no metadata driver for the type '" . $type . "'."); $class = $mappingDriver[$type]; @@ -105,7 +105,7 @@ public function testExportDirectoryAndFilesAreCreated(): void $metadata[0]->name = ExportedUser::class; - $this->assertEquals(ExportedUser::class, $metadata[0]->name); + self::assertEquals(ExportedUser::class, $metadata[0]->name); $type = $this->getType(); $cme = new ClassMetadataExporter(); @@ -123,9 +123,9 @@ public function testExportDirectoryAndFilesAreCreated(): void $exporter->export(); if ($type === 'annotation') { - $this->assertTrue(file_exists(__DIR__ . '/export/' . $type . '/' . str_replace('\\', '/', ExportedUser::class) . $this->extension)); + self::assertTrue(file_exists(__DIR__ . '/export/' . $type . '/' . str_replace('\\', '/', ExportedUser::class) . $this->extension)); } else { - $this->assertTrue(file_exists(__DIR__ . '/export/' . $type . '/Doctrine.Tests.ORM.Tools.Export.ExportedUser' . $this->extension)); + self::assertTrue(file_exists(__DIR__ . '/export/' . $type . '/Doctrine.Tests.ORM.Tools.Export.ExportedUser' . $this->extension)); } } @@ -141,11 +141,11 @@ public function testExportedMetadataCanBeReadBackIn(): ClassMetadataInfo $cmf = $this->createClassMetadataFactory($em, $type); $metadata = $cmf->getAllMetadata(); - $this->assertEquals(1, count($metadata)); + self::assertEquals(1, count($metadata)); $class = current($metadata); - $this->assertEquals(ExportedUser::class, $class->name); + self::assertEquals(ExportedUser::class, $class->name); return $class; } @@ -155,8 +155,8 @@ public function testExportedMetadataCanBeReadBackIn(): ClassMetadataInfo */ public function testTableIsExported(ClassMetadataInfo $class): ClassMetadataInfo { - $this->assertEquals('cms_users', $class->table['name']); - $this->assertEquals( + self::assertEquals('cms_users', $class->table['name']); + self::assertEquals( ['engine' => 'MyISAM', 'foo' => ['bar' => 'baz']], $class->table['options'] ); @@ -169,7 +169,7 @@ public function testTableIsExported(ClassMetadataInfo $class): ClassMetadataInfo */ public function testTypeIsExported(ClassMetadataInfo $class): ClassMetadataInfo { - $this->assertFalse($class->isMappedSuperclass); + self::assertFalse($class->isMappedSuperclass); return $class; } @@ -179,9 +179,9 @@ public function testTypeIsExported(ClassMetadataInfo $class): ClassMetadataInfo */ public function testIdentifierIsExported(ClassMetadataInfo $class): ClassMetadataInfo { - $this->assertEquals(ClassMetadataInfo::GENERATOR_TYPE_IDENTITY, $class->generatorType, 'Generator Type wrong'); - $this->assertEquals(['id'], $class->identifier); - $this->assertTrue(isset($class->fieldMappings['id']['id']) && $class->fieldMappings['id']['id'] === true); + self::assertEquals(ClassMetadataInfo::GENERATOR_TYPE_IDENTITY, $class->generatorType, 'Generator Type wrong'); + self::assertEquals(['id'], $class->identifier); + self::assertTrue(isset($class->fieldMappings['id']['id']) && $class->fieldMappings['id']['id'] === true); return $class; } @@ -191,22 +191,22 @@ public function testIdentifierIsExported(ClassMetadataInfo $class): ClassMetadat */ public function testFieldsAreExported(ClassMetadataInfo $class): ClassMetadataInfo { - $this->assertTrue(isset($class->fieldMappings['id']['id']) && $class->fieldMappings['id']['id'] === true); - $this->assertEquals('id', $class->fieldMappings['id']['fieldName']); - $this->assertEquals('integer', $class->fieldMappings['id']['type']); - $this->assertEquals('id', $class->fieldMappings['id']['columnName']); + self::assertTrue(isset($class->fieldMappings['id']['id']) && $class->fieldMappings['id']['id'] === true); + self::assertEquals('id', $class->fieldMappings['id']['fieldName']); + self::assertEquals('integer', $class->fieldMappings['id']['type']); + self::assertEquals('id', $class->fieldMappings['id']['columnName']); - $this->assertEquals('name', $class->fieldMappings['name']['fieldName']); - $this->assertEquals('string', $class->fieldMappings['name']['type']); - $this->assertEquals(50, $class->fieldMappings['name']['length']); - $this->assertEquals('name', $class->fieldMappings['name']['columnName']); + self::assertEquals('name', $class->fieldMappings['name']['fieldName']); + self::assertEquals('string', $class->fieldMappings['name']['type']); + self::assertEquals(50, $class->fieldMappings['name']['length']); + self::assertEquals('name', $class->fieldMappings['name']['columnName']); - $this->assertEquals('email', $class->fieldMappings['email']['fieldName']); - $this->assertEquals('string', $class->fieldMappings['email']['type']); - $this->assertEquals('user_email', $class->fieldMappings['email']['columnName']); - $this->assertEquals('CHAR(32) NOT NULL', $class->fieldMappings['email']['columnDefinition']); + self::assertEquals('email', $class->fieldMappings['email']['fieldName']); + self::assertEquals('string', $class->fieldMappings['email']['type']); + self::assertEquals('user_email', $class->fieldMappings['email']['columnName']); + self::assertEquals('CHAR(32) NOT NULL', $class->fieldMappings['email']['columnDefinition']); - $this->assertEquals(true, $class->fieldMappings['age']['options']['unsigned']); + self::assertEquals(true, $class->fieldMappings['age']['options']['unsigned']); return $class; } @@ -223,12 +223,12 @@ public function testFieldsAreProperlySerialized(): void $xml->registerXPathNamespace('d', 'http://doctrine-project.org/schemas/orm/doctrine-mapping'); $nodes = $xml->xpath("/d:doctrine-mapping/d:entity/d:field[@name='name' and @type='string' and @nullable='true']"); - $this->assertEquals(1, count($nodes)); + self::assertEquals(1, count($nodes)); $nodes = $xml->xpath("/d:doctrine-mapping/d:entity/d:field[@name='name' and @type='string' and @unique='true']"); - $this->assertEquals(1, count($nodes)); + self::assertEquals(1, count($nodes)); } else { - $this->markTestSkipped('Test not available for ' . $type . ' driver'); + self::markTestSkipped('Test not available for ' . $type . ' driver'); } } @@ -237,19 +237,19 @@ public function testFieldsAreProperlySerialized(): void */ public function testOneToOneAssociationsAreExported(ClassMetadataInfo $class): ClassMetadataInfo { - $this->assertTrue(isset($class->associationMappings['address'])); - $this->assertEquals(Address::class, $class->associationMappings['address']['targetEntity']); - $this->assertEquals('address_id', $class->associationMappings['address']['joinColumns'][0]['name']); - $this->assertEquals('id', $class->associationMappings['address']['joinColumns'][0]['referencedColumnName']); - $this->assertEquals('CASCADE', $class->associationMappings['address']['joinColumns'][0]['onDelete']); - - $this->assertTrue($class->associationMappings['address']['isCascadeRemove']); - $this->assertTrue($class->associationMappings['address']['isCascadePersist']); - $this->assertFalse($class->associationMappings['address']['isCascadeRefresh']); - $this->assertFalse($class->associationMappings['address']['isCascadeMerge']); - $this->assertFalse($class->associationMappings['address']['isCascadeDetach']); - $this->assertTrue($class->associationMappings['address']['orphanRemoval']); - $this->assertEquals(ClassMetadataInfo::FETCH_EAGER, $class->associationMappings['address']['fetch']); + self::assertTrue(isset($class->associationMappings['address'])); + self::assertEquals(Address::class, $class->associationMappings['address']['targetEntity']); + self::assertEquals('address_id', $class->associationMappings['address']['joinColumns'][0]['name']); + self::assertEquals('id', $class->associationMappings['address']['joinColumns'][0]['referencedColumnName']); + self::assertEquals('CASCADE', $class->associationMappings['address']['joinColumns'][0]['onDelete']); + + self::assertTrue($class->associationMappings['address']['isCascadeRemove']); + self::assertTrue($class->associationMappings['address']['isCascadePersist']); + self::assertFalse($class->associationMappings['address']['isCascadeRefresh']); + self::assertFalse($class->associationMappings['address']['isCascadeMerge']); + self::assertFalse($class->associationMappings['address']['isCascadeDetach']); + self::assertTrue($class->associationMappings['address']['orphanRemoval']); + self::assertEquals(ClassMetadataInfo::FETCH_EAGER, $class->associationMappings['address']['fetch']); return $class; } @@ -259,8 +259,8 @@ public function testOneToOneAssociationsAreExported(ClassMetadataInfo $class): C */ public function testManyToOneAssociationsAreExported($class): void { - $this->assertTrue(isset($class->associationMappings['mainGroup'])); - $this->assertEquals(Group::class, $class->associationMappings['mainGroup']['targetEntity']); + self::assertTrue(isset($class->associationMappings['mainGroup'])); + self::assertEquals(Group::class, $class->associationMappings['mainGroup']['targetEntity']); } /** @@ -268,18 +268,18 @@ public function testManyToOneAssociationsAreExported($class): void */ public function testOneToManyAssociationsAreExported(ClassMetadataInfo $class): ClassMetadataInfo { - $this->assertTrue(isset($class->associationMappings['phonenumbers'])); - $this->assertEquals(Phonenumber::class, $class->associationMappings['phonenumbers']['targetEntity']); - $this->assertEquals('user', $class->associationMappings['phonenumbers']['mappedBy']); - $this->assertEquals(['number' => 'ASC'], $class->associationMappings['phonenumbers']['orderBy']); - - $this->assertTrue($class->associationMappings['phonenumbers']['isCascadeRemove']); - $this->assertTrue($class->associationMappings['phonenumbers']['isCascadePersist']); - $this->assertFalse($class->associationMappings['phonenumbers']['isCascadeRefresh']); - $this->assertTrue($class->associationMappings['phonenumbers']['isCascadeMerge']); - $this->assertFalse($class->associationMappings['phonenumbers']['isCascadeDetach']); - $this->assertTrue($class->associationMappings['phonenumbers']['orphanRemoval']); - $this->assertEquals(ClassMetadataInfo::FETCH_LAZY, $class->associationMappings['phonenumbers']['fetch']); + self::assertTrue(isset($class->associationMappings['phonenumbers'])); + self::assertEquals(Phonenumber::class, $class->associationMappings['phonenumbers']['targetEntity']); + self::assertEquals('user', $class->associationMappings['phonenumbers']['mappedBy']); + self::assertEquals(['number' => 'ASC'], $class->associationMappings['phonenumbers']['orderBy']); + + self::assertTrue($class->associationMappings['phonenumbers']['isCascadeRemove']); + self::assertTrue($class->associationMappings['phonenumbers']['isCascadePersist']); + self::assertFalse($class->associationMappings['phonenumbers']['isCascadeRefresh']); + self::assertTrue($class->associationMappings['phonenumbers']['isCascadeMerge']); + self::assertFalse($class->associationMappings['phonenumbers']['isCascadeDetach']); + self::assertTrue($class->associationMappings['phonenumbers']['orphanRemoval']); + self::assertEquals(ClassMetadataInfo::FETCH_LAZY, $class->associationMappings['phonenumbers']['fetch']); return $class; } @@ -289,23 +289,23 @@ public function testOneToManyAssociationsAreExported(ClassMetadataInfo $class): */ public function testManyToManyAssociationsAreExported(ClassMetadataInfo $class): ClassMetadataInfo { - $this->assertTrue(isset($class->associationMappings['groups'])); - $this->assertEquals(Group::class, $class->associationMappings['groups']['targetEntity']); - $this->assertEquals('cms_users_groups', $class->associationMappings['groups']['joinTable']['name']); + self::assertTrue(isset($class->associationMappings['groups'])); + self::assertEquals(Group::class, $class->associationMappings['groups']['targetEntity']); + self::assertEquals('cms_users_groups', $class->associationMappings['groups']['joinTable']['name']); - $this->assertEquals('user_id', $class->associationMappings['groups']['joinTable']['joinColumns'][0]['name']); - $this->assertEquals('id', $class->associationMappings['groups']['joinTable']['joinColumns'][0]['referencedColumnName']); + self::assertEquals('user_id', $class->associationMappings['groups']['joinTable']['joinColumns'][0]['name']); + self::assertEquals('id', $class->associationMappings['groups']['joinTable']['joinColumns'][0]['referencedColumnName']); - $this->assertEquals('group_id', $class->associationMappings['groups']['joinTable']['inverseJoinColumns'][0]['name']); - $this->assertEquals('id', $class->associationMappings['groups']['joinTable']['inverseJoinColumns'][0]['referencedColumnName']); - $this->assertEquals('INT NULL', $class->associationMappings['groups']['joinTable']['inverseJoinColumns'][0]['columnDefinition']); + self::assertEquals('group_id', $class->associationMappings['groups']['joinTable']['inverseJoinColumns'][0]['name']); + self::assertEquals('id', $class->associationMappings['groups']['joinTable']['inverseJoinColumns'][0]['referencedColumnName']); + self::assertEquals('INT NULL', $class->associationMappings['groups']['joinTable']['inverseJoinColumns'][0]['columnDefinition']); - $this->assertTrue($class->associationMappings['groups']['isCascadeRemove']); - $this->assertTrue($class->associationMappings['groups']['isCascadePersist']); - $this->assertTrue($class->associationMappings['groups']['isCascadeRefresh']); - $this->assertTrue($class->associationMappings['groups']['isCascadeMerge']); - $this->assertTrue($class->associationMappings['groups']['isCascadeDetach']); - $this->assertEquals(ClassMetadataInfo::FETCH_EXTRA_LAZY, $class->associationMappings['groups']['fetch']); + self::assertTrue($class->associationMappings['groups']['isCascadeRemove']); + self::assertTrue($class->associationMappings['groups']['isCascadePersist']); + self::assertTrue($class->associationMappings['groups']['isCascadeRefresh']); + self::assertTrue($class->associationMappings['groups']['isCascadeMerge']); + self::assertTrue($class->associationMappings['groups']['isCascadeDetach']); + self::assertEquals(ClassMetadataInfo::FETCH_EXTRA_LAZY, $class->associationMappings['groups']['fetch']); return $class; } @@ -315,14 +315,14 @@ public function testManyToManyAssociationsAreExported(ClassMetadataInfo $class): */ public function testLifecycleCallbacksAreExported(ClassMetadataInfo $class): ClassMetadataInfo { - $this->assertTrue(isset($class->lifecycleCallbacks['prePersist'])); - $this->assertEquals(2, count($class->lifecycleCallbacks['prePersist'])); - $this->assertEquals('doStuffOnPrePersist', $class->lifecycleCallbacks['prePersist'][0]); - $this->assertEquals('doOtherStuffOnPrePersistToo', $class->lifecycleCallbacks['prePersist'][1]); + self::assertTrue(isset($class->lifecycleCallbacks['prePersist'])); + self::assertEquals(2, count($class->lifecycleCallbacks['prePersist'])); + self::assertEquals('doStuffOnPrePersist', $class->lifecycleCallbacks['prePersist'][0]); + self::assertEquals('doOtherStuffOnPrePersistToo', $class->lifecycleCallbacks['prePersist'][1]); - $this->assertTrue(isset($class->lifecycleCallbacks['postPersist'])); - $this->assertEquals(1, count($class->lifecycleCallbacks['postPersist'])); - $this->assertEquals('doStuffOnPostPersist', $class->lifecycleCallbacks['postPersist'][0]); + self::assertTrue(isset($class->lifecycleCallbacks['postPersist'])); + self::assertEquals(1, count($class->lifecycleCallbacks['postPersist'])); + self::assertEquals('doStuffOnPostPersist', $class->lifecycleCallbacks['postPersist'][0]); return $class; } @@ -332,12 +332,12 @@ public function testLifecycleCallbacksAreExported(ClassMetadataInfo $class): Cla */ public function testCascadeIsExported(ClassMetadataInfo $class): ClassMetadataInfo { - $this->assertTrue($class->associationMappings['phonenumbers']['isCascadePersist']); - $this->assertTrue($class->associationMappings['phonenumbers']['isCascadeMerge']); - $this->assertTrue($class->associationMappings['phonenumbers']['isCascadeRemove']); - $this->assertFalse($class->associationMappings['phonenumbers']['isCascadeRefresh']); - $this->assertFalse($class->associationMappings['phonenumbers']['isCascadeDetach']); - $this->assertTrue($class->associationMappings['phonenumbers']['orphanRemoval']); + self::assertTrue($class->associationMappings['phonenumbers']['isCascadePersist']); + self::assertTrue($class->associationMappings['phonenumbers']['isCascadeMerge']); + self::assertTrue($class->associationMappings['phonenumbers']['isCascadeRemove']); + self::assertFalse($class->associationMappings['phonenumbers']['isCascadeRefresh']); + self::assertFalse($class->associationMappings['phonenumbers']['isCascadeDetach']); + self::assertTrue($class->associationMappings['phonenumbers']['orphanRemoval']); return $class; } @@ -347,7 +347,7 @@ public function testCascadeIsExported(ClassMetadataInfo $class): ClassMetadataIn */ public function testInversedByIsExported(ClassMetadataInfo $class): void { - $this->assertEquals('user', $class->associationMappings['address']['inversedBy']); + self::assertEquals('user', $class->associationMappings['address']['inversedBy']); } /** @@ -362,18 +362,18 @@ public function testCascadeAllCollapsed(): void $xml->registerXPathNamespace('d', 'http://doctrine-project.org/schemas/orm/doctrine-mapping'); $nodes = $xml->xpath("/d:doctrine-mapping/d:entity/d:one-to-many[@field='interests']/d:cascade/d:*"); - $this->assertEquals(1, count($nodes)); + self::assertEquals(1, count($nodes)); - $this->assertEquals('cascade-all', $nodes[0]->getName()); + self::assertEquals('cascade-all', $nodes[0]->getName()); } elseif ($type === 'yaml') { $yaml = new Parser(); $value = $yaml->parse(file_get_contents(__DIR__ . '/export/' . $type . '/Doctrine.Tests.ORM.Tools.Export.ExportedUser.dcm.yml')); - $this->assertTrue(isset($value[ExportedUser::class]['oneToMany']['interests']['cascade'])); - $this->assertEquals(1, count($value[ExportedUser::class]['oneToMany']['interests']['cascade'])); - $this->assertEquals('all', $value[ExportedUser::class]['oneToMany']['interests']['cascade'][0]); + self::assertTrue(isset($value[ExportedUser::class]['oneToMany']['interests']['cascade'])); + self::assertEquals(1, count($value[ExportedUser::class]['oneToMany']['interests']['cascade'])); + self::assertEquals('all', $value[ExportedUser::class]['oneToMany']['interests']['cascade'][0]); } else { - $this->markTestSkipped('Test not available for ' . $type . ' driver'); + self::markTestSkipped('Test not available for ' . $type . ' driver'); } } @@ -382,17 +382,17 @@ public function testCascadeAllCollapsed(): void */ public function testEntityListenersAreExported(ClassMetadata $class): void { - $this->assertNotEmpty($class->entityListeners); - $this->assertCount(2, $class->entityListeners[Events::prePersist]); - $this->assertCount(2, $class->entityListeners[Events::postPersist]); - $this->assertEquals(UserListener::class, $class->entityListeners[Events::prePersist][0]['class']); - $this->assertEquals('customPrePersist', $class->entityListeners[Events::prePersist][0]['method']); - $this->assertEquals(GroupListener::class, $class->entityListeners[Events::prePersist][1]['class']); - $this->assertEquals('prePersist', $class->entityListeners[Events::prePersist][1]['method']); - $this->assertEquals(UserListener::class, $class->entityListeners[Events::postPersist][0]['class']); - $this->assertEquals('customPostPersist', $class->entityListeners[Events::postPersist][0]['method']); - $this->assertEquals(AddressListener::class, $class->entityListeners[Events::postPersist][1]['class']); - $this->assertEquals('customPostPersist', $class->entityListeners[Events::postPersist][1]['method']); + self::assertNotEmpty($class->entityListeners); + self::assertCount(2, $class->entityListeners[Events::prePersist]); + self::assertCount(2, $class->entityListeners[Events::postPersist]); + self::assertEquals(UserListener::class, $class->entityListeners[Events::prePersist][0]['class']); + self::assertEquals('customPrePersist', $class->entityListeners[Events::prePersist][0]['method']); + self::assertEquals(GroupListener::class, $class->entityListeners[Events::prePersist][1]['class']); + self::assertEquals('prePersist', $class->entityListeners[Events::prePersist][1]['method']); + self::assertEquals(UserListener::class, $class->entityListeners[Events::postPersist][0]['class']); + self::assertEquals('customPostPersist', $class->entityListeners[Events::postPersist][0]['method']); + self::assertEquals(AddressListener::class, $class->entityListeners[Events::postPersist][1]['class']); + self::assertEquals('customPostPersist', $class->entityListeners[Events::postPersist][1]['method']); } protected function deleteDirectory(string $path): void diff --git a/tests/Doctrine/Tests/ORM/Tools/Export/XmlClassMetadataExporterTest.php b/tests/Doctrine/Tests/ORM/Tools/Export/XmlClassMetadataExporterTest.php index 5586284fcdf..7d23defc749 100644 --- a/tests/Doctrine/Tests/ORM/Tools/Export/XmlClassMetadataExporterTest.php +++ b/tests/Doctrine/Tests/ORM/Tools/Export/XmlClassMetadataExporterTest.php @@ -62,7 +62,7 @@ public function testSequenceGenerator(): void XML; - $this->assertXmlStringEqualsXmlString($expectedFileContent, $exporter->exportClassMetadata($metadata)); + self::assertXmlStringEqualsXmlString($expectedFileContent, $exporter->exportClassMetadata($metadata)); } /** @@ -101,6 +101,6 @@ public function testFieldOptionsExport(): void XML; - $this->assertXmlStringEqualsXmlString($expectedFileContent, $exporter->exportClassMetadata($metadata)); + self::assertXmlStringEqualsXmlString($expectedFileContent, $exporter->exportClassMetadata($metadata)); } } diff --git a/tests/Doctrine/Tests/ORM/Tools/Export/YamlClassMetadataExporterTest.php b/tests/Doctrine/Tests/ORM/Tools/Export/YamlClassMetadataExporterTest.php index a031a3ea99f..c927ceca30b 100644 --- a/tests/Doctrine/Tests/ORM/Tools/Export/YamlClassMetadataExporterTest.php +++ b/tests/Doctrine/Tests/ORM/Tools/Export/YamlClassMetadataExporterTest.php @@ -16,7 +16,7 @@ class YamlClassMetadataExporterTest extends AbstractClassMetadataExporterTest protected function getType(): string { if (! class_exists('Symfony\Component\Yaml\Yaml', true)) { - $this->markTestSkipped('Please install Symfony YAML Component into the include path of your PHP installation.'); + self::markTestSkipped('Please install Symfony YAML Component into the include path of your PHP installation.'); } return 'yaml'; diff --git a/tests/Doctrine/Tests/ORM/Tools/Pagination/CountOutputWalkerTest.php b/tests/Doctrine/Tests/ORM/Tools/Pagination/CountOutputWalkerTest.php index e6a8d9a218c..9c714174aaa 100644 --- a/tests/Doctrine/Tests/ORM/Tools/Pagination/CountOutputWalkerTest.php +++ b/tests/Doctrine/Tests/ORM/Tools/Pagination/CountOutputWalkerTest.php @@ -17,7 +17,7 @@ public function testCountQuery(): void $query->setHint(Query::HINT_CUSTOM_OUTPUT_WALKER, CountOutputWalker::class); $query->setFirstResult(null)->setMaxResults(null); - $this->assertEquals( + self::assertEquals( 'SELECT COUNT(*) AS dctrn_count FROM (SELECT DISTINCT id_0 FROM (SELECT b0_.id AS id_0, c1_.id AS id_1, a2_.id AS id_2, a2_.name AS name_3, b0_.author_id AS author_id_4, b0_.category_id AS category_id_5 FROM BlogPost b0_ INNER JOIN Category c1_ ON b0_.category_id = c1_.id INNER JOIN Author a2_ ON b0_.author_id = a2_.id) dctrn_result) dctrn_table', $query->getSQL() ); @@ -31,7 +31,7 @@ public function testCountQueryMixedResultsWithName(): void $query->setHint(Query::HINT_CUSTOM_OUTPUT_WALKER, CountOutputWalker::class); $query->setFirstResult(null)->setMaxResults(null); - $this->assertEquals( + self::assertEquals( 'SELECT COUNT(*) AS dctrn_count FROM (SELECT DISTINCT id_0 FROM (SELECT a0_.id AS id_0, a0_.name AS name_1, sum(a0_.name) AS sclr_2 FROM Author a0_) dctrn_result) dctrn_table', $query->getSQL() ); @@ -45,7 +45,7 @@ public function testCountQueryGroupBy(): void $query->setHint(Query::HINT_CUSTOM_OUTPUT_WALKER, CountOutputWalker::class); $query->setFirstResult(null)->setMaxResults(null); - $this->assertSame( + self::assertSame( 'SELECT COUNT(*) AS dctrn_count FROM (SELECT p0_.name AS name_0 FROM Person p0_ GROUP BY p0_.name) dctrn_table', $query->getSQL() ); @@ -59,7 +59,7 @@ public function testCountQueryHaving(): void $query->setHint(Query::HINT_CUSTOM_OUTPUT_WALKER, CountOutputWalker::class); $query->setFirstResult(null)->setMaxResults(null); - $this->assertSame( + self::assertSame( 'SELECT COUNT(*) AS dctrn_count FROM (SELECT count(u0_.id) AS sclr_0, g1_.id AS id_1, u0_.id AS id_2 FROM groups g1_ LEFT JOIN user_group u2_ ON g1_.id = u2_.group_id LEFT JOIN User u0_ ON u0_.id = u2_.user_id GROUP BY g1_.id HAVING sclr_0 > 0) dctrn_table', $query->getSQL() ); @@ -68,7 +68,7 @@ public function testCountQueryHaving(): void public function testCountQueryOrderBySqlServer(): void { if ($this->entityManager->getConnection()->getDatabasePlatform()->getName() !== 'mssql') { - $this->markTestSkipped('SQLServer only test.'); + self::markTestSkipped('SQLServer only test.'); } $query = $this->entityManager->createQuery( @@ -77,7 +77,7 @@ public function testCountQueryOrderBySqlServer(): void $query->setHint(Query::HINT_CUSTOM_OUTPUT_WALKER, CountOutputWalker::class); $query->setFirstResult(null)->setMaxResults(null); - $this->assertEquals( + self::assertEquals( 'SELECT COUNT(*) AS dctrn_count FROM (SELECT DISTINCT id_0 FROM (SELECT b0_.id AS id_0, b0_.author_id AS author_id_1, b0_.category_id AS category_id_2 FROM BlogPost b0_) dctrn_result) dctrn_table', $query->getSQL() ); diff --git a/tests/Doctrine/Tests/ORM/Tools/Pagination/CountWalkerTest.php b/tests/Doctrine/Tests/ORM/Tools/Pagination/CountWalkerTest.php index 466ccafd05b..d384f6122a9 100644 --- a/tests/Doctrine/Tests/ORM/Tools/Pagination/CountWalkerTest.php +++ b/tests/Doctrine/Tests/ORM/Tools/Pagination/CountWalkerTest.php @@ -22,7 +22,7 @@ public function testCountQuery(): void $query->setHint(CountWalker::HINT_DISTINCT, true); $query->setFirstResult(null)->setMaxResults(null); - $this->assertEquals( + self::assertEquals( 'SELECT count(DISTINCT b0_.id) AS sclr_0 FROM BlogPost b0_ INNER JOIN Category c1_ ON b0_.category_id = c1_.id INNER JOIN Author a2_ ON b0_.author_id = a2_.id', $query->getSQL() ); @@ -37,7 +37,7 @@ public function testCountQueryMixedResultsWithName(): void $query->setHint(CountWalker::HINT_DISTINCT, true); $query->setFirstResult(null)->setMaxResults(null); - $this->assertEquals( + self::assertEquals( 'SELECT count(DISTINCT a0_.id) AS sclr_0 FROM Author a0_', $query->getSQL() ); @@ -52,7 +52,7 @@ public function testCountQueryKeepsGroupBy(): void $query->setHint(CountWalker::HINT_DISTINCT, true); $query->setFirstResult(null)->setMaxResults(null); - $this->assertEquals( + self::assertEquals( 'SELECT count(DISTINCT b0_.id) AS sclr_0 FROM BlogPost b0_ GROUP BY b0_.id', $query->getSQL() ); @@ -67,7 +67,7 @@ public function testCountQueryRemovesOrderBy(): void $query->setHint(CountWalker::HINT_DISTINCT, true); $query->setFirstResult(null)->setMaxResults(null); - $this->assertEquals( + self::assertEquals( 'SELECT count(DISTINCT b0_.id) AS sclr_0 FROM BlogPost b0_ INNER JOIN Category c1_ ON b0_.category_id = c1_.id INNER JOIN Author a2_ ON b0_.author_id = a2_.id', $query->getSQL() ); @@ -82,7 +82,7 @@ public function testCountQueryRemovesLimits(): void $query->setHint(CountWalker::HINT_DISTINCT, true); $query->setFirstResult(null)->setMaxResults(null); - $this->assertEquals( + self::assertEquals( 'SELECT count(DISTINCT b0_.id) AS sclr_0 FROM BlogPost b0_ INNER JOIN Category c1_ ON b0_.category_id = c1_.id INNER JOIN Author a2_ ON b0_.author_id = a2_.id', $query->getSQL() ); @@ -114,7 +114,7 @@ public function testCountQueryWithArbitraryJoin(): void $query->setHint(CountWalker::HINT_DISTINCT, true); $query->setFirstResult(null)->setMaxResults(null); - $this->assertEquals( + self::assertEquals( 'SELECT count(DISTINCT b0_.id) AS sclr_0 FROM BlogPost b0_ LEFT JOIN Category c1_ ON (b0_.category_id = c1_.id)', $query->getSQL() ); diff --git a/tests/Doctrine/Tests/ORM/Tools/Pagination/LimitSubqueryOutputWalkerTest.php b/tests/Doctrine/Tests/ORM/Tools/Pagination/LimitSubqueryOutputWalkerTest.php index 061d6c99f2d..696c2a92bd9 100644 --- a/tests/Doctrine/Tests/ORM/Tools/Pagination/LimitSubqueryOutputWalkerTest.php +++ b/tests/Doctrine/Tests/ORM/Tools/Pagination/LimitSubqueryOutputWalkerTest.php @@ -219,7 +219,7 @@ public function testCountQueryWithArithmeticOrderByCondition(): void $query->setHint(Query::HINT_CUSTOM_OUTPUT_WALKER, LimitSubqueryOutputWalker::class); - $this->assertSame( + self::assertSame( 'SELECT DISTINCT id_0 FROM (SELECT DISTINCT id_0, (1 - 1000) * 1 FROM (SELECT a0_.id AS id_0, a0_.name AS name_1 FROM Author a0_) dctrn_result_inner ORDER BY (1 - 1000) * 1 DESC) dctrn_result', $query->getSQL() ); @@ -234,7 +234,7 @@ public function testCountQueryWithComplexScalarOrderByItem(): void $query->setHint(Query::HINT_CUSTOM_OUTPUT_WALKER, LimitSubqueryOutputWalker::class); - $this->assertSame( + self::assertSame( 'SELECT DISTINCT id_0 FROM (SELECT DISTINCT id_0, imageHeight_2 * imageWidth_3 FROM (SELECT a0_.id AS id_0, a0_.image AS image_1, a0_.imageHeight AS imageHeight_2, a0_.imageWidth AS imageWidth_3, a0_.imageAltDesc AS imageAltDesc_4, a0_.user_id AS user_id_5 FROM Avatar a0_) dctrn_result_inner ORDER BY imageHeight_2 * imageWidth_3 DESC) dctrn_result', $query->getSQL() ); @@ -249,7 +249,7 @@ public function testCountQueryWithComplexScalarOrderByItemJoined(): void $query->setHint(Query::HINT_CUSTOM_OUTPUT_WALKER, LimitSubqueryOutputWalker::class); - $this->assertSame( + self::assertSame( 'SELECT DISTINCT id_0 FROM (SELECT DISTINCT id_0, imageHeight_1 * imageWidth_2 FROM (SELECT u0_.id AS id_0, a1_.imageHeight AS imageHeight_1, a1_.imageWidth AS imageWidth_2, a1_.user_id AS user_id_3 FROM User u0_ INNER JOIN Avatar a1_ ON u0_.id = a1_.user_id) dctrn_result_inner ORDER BY imageHeight_1 * imageWidth_2 DESC) dctrn_result', $query->getSQL() ); @@ -264,7 +264,7 @@ public function testCountQueryWithComplexScalarOrderByItemJoinedWithPartial(): v $query->setHint(Query::HINT_CUSTOM_OUTPUT_WALKER, LimitSubqueryOutputWalker::class); - $this->assertSame( + self::assertSame( 'SELECT DISTINCT id_0 FROM (SELECT DISTINCT id_0, imageHeight_3 * imageWidth_4 FROM (SELECT u0_.id AS id_0, a1_.id AS id_1, a1_.imageAltDesc AS imageAltDesc_2, a1_.imageHeight AS imageHeight_3, a1_.imageWidth AS imageWidth_4, a1_.user_id AS user_id_5 FROM User u0_ INNER JOIN Avatar a1_ ON u0_.id = a1_.user_id) dctrn_result_inner ORDER BY imageHeight_3 * imageWidth_4 DESC) dctrn_result', $query->getSQL() ); @@ -279,7 +279,7 @@ public function testCountQueryWithComplexScalarOrderByItemOracle(): void $query->setHint(Query::HINT_CUSTOM_OUTPUT_WALKER, LimitSubqueryOutputWalker::class); - $this->assertSame( + self::assertSame( 'SELECT DISTINCT ID_0, MIN(SCLR_5) AS dctrn_minrownum FROM (SELECT a0_.id AS ID_0, a0_.image AS IMAGE_1, a0_.imageHeight AS IMAGEHEIGHT_2, a0_.imageWidth AS IMAGEWIDTH_3, a0_.imageAltDesc AS IMAGEALTDESC_4, ROW_NUMBER() OVER(ORDER BY a0_.imageHeight * a0_.imageWidth DESC) AS SCLR_5, a0_.user_id AS USER_ID_6 FROM Avatar a0_) dctrn_result GROUP BY ID_0 ORDER BY dctrn_minrownum ASC', $query->getSQL() ); @@ -311,7 +311,7 @@ public function testLimitSubqueryWithColumnWithSortDirectionInName(): void $query->setHint(Query::HINT_CUSTOM_OUTPUT_WALKER, LimitSubqueryOutputWalker::class); - $this->assertSame( + self::assertSame( 'SELECT DISTINCT id_0 FROM (SELECT DISTINCT id_0, imageAltDesc_4 FROM (SELECT a0_.id AS id_0, a0_.image AS image_1, a0_.imageHeight AS imageHeight_2, a0_.imageWidth AS imageWidth_3, a0_.imageAltDesc AS imageAltDesc_4, a0_.user_id AS user_id_5 FROM Avatar a0_) dctrn_result_inner ORDER BY imageAltDesc_4 DESC) dctrn_result', $query->getSQL() ); diff --git a/tests/Doctrine/Tests/ORM/Tools/Pagination/LimitSubqueryWalkerTest.php b/tests/Doctrine/Tests/ORM/Tools/Pagination/LimitSubqueryWalkerTest.php index e8c1e91b3e0..5893e01d258 100644 --- a/tests/Doctrine/Tests/ORM/Tools/Pagination/LimitSubqueryWalkerTest.php +++ b/tests/Doctrine/Tests/ORM/Tools/Pagination/LimitSubqueryWalkerTest.php @@ -20,7 +20,7 @@ public function testLimitSubquery(): void $limitQuery->setHint(Query::HINT_CUSTOM_TREE_WALKERS, [LimitSubqueryWalker::class]); - $this->assertEquals( + self::assertEquals( 'SELECT DISTINCT m0_.id AS id_0 FROM MyBlogPost m0_ INNER JOIN Category c1_ ON m0_.category_id = c1_.id INNER JOIN Author a2_ ON m0_.author_id = a2_.id', $limitQuery->getSQL() ); @@ -34,7 +34,7 @@ public function testLimitSubqueryWithSort(): void $limitQuery->setHint(Query::HINT_CUSTOM_TREE_WALKERS, [LimitSubqueryWalker::class]); - $this->assertEquals( + self::assertEquals( 'SELECT DISTINCT m0_.id AS id_0, m0_.title AS title_1 FROM MyBlogPost m0_ INNER JOIN Category c1_ ON m0_.category_id = c1_.id INNER JOIN Author a2_ ON m0_.author_id = a2_.id ORDER BY m0_.title ASC', $limitQuery->getSQL() ); @@ -62,7 +62,7 @@ public function testCountQueryMixedResultsWithName(): void $limitQuery->setHint(Query::HINT_CUSTOM_TREE_WALKERS, [LimitSubqueryWalker::class]); - $this->assertEquals( + self::assertEquals( 'SELECT DISTINCT a0_.id AS id_0 FROM Author a0_', $limitQuery->getSQL() ); @@ -107,7 +107,7 @@ public function testLimitSubqueryWithSortOnAssociation(): void $limitQuery->setHint(Query::HINT_CUSTOM_TREE_WALKERS, [LimitSubqueryWalker::class]); - $this->assertEquals( + self::assertEquals( 'SELECT DISTINCT m0_.id AS id_0, m0_.author_id AS sclr_1 FROM MyBlogPost m0_ ORDER BY m0_.author_id ASC', $limitQuery->getSQL() ); @@ -124,7 +124,7 @@ public function testLimitSubqueryWithArbitraryJoin(): void $limitQuery->setHint(Query::HINT_CUSTOM_TREE_WALKERS, [LimitSubqueryWalker::class]); - $this->assertEquals( + self::assertEquals( 'SELECT DISTINCT m0_.id AS id_0 FROM MyBlogPost m0_ INNER JOIN Category c1_ ON (m0_.category_id = c1_.id)', $limitQuery->getSQL() ); @@ -138,7 +138,7 @@ public function testLimitSubqueryWithSortWithArbitraryJoin(): void $limitQuery->setHint(Query::HINT_CUSTOM_TREE_WALKERS, [LimitSubqueryWalker::class]); - $this->assertEquals( + self::assertEquals( 'SELECT DISTINCT m0_.id AS id_0, m0_.title AS title_1 FROM MyBlogPost m0_ INNER JOIN Category c1_ ON (m0_.category_id = c1_.id) ORDER BY m0_.title ASC', $limitQuery->getSQL() ); diff --git a/tests/Doctrine/Tests/ORM/Tools/Pagination/PaginatorTest.php b/tests/Doctrine/Tests/ORM/Tools/Pagination/PaginatorTest.php index 786839dda9f..2ce23abdd02 100644 --- a/tests/Doctrine/Tests/ORM/Tools/Pagination/PaginatorTest.php +++ b/tests/Doctrine/Tests/ORM/Tools/Pagination/PaginatorTest.php @@ -63,12 +63,12 @@ public function testExtraParametersAreStrippedWhenWalkerRemovingOriginalSelectEl $paginator = (new Paginator($query, true))->setUseOutputWalkers(false); $this->connection - ->expects($this->exactly(3)) + ->expects(self::exactly(3)) ->method('executeQuery') ->withConsecutive( - [$this->anything(), [$paramInWhere]], - [$this->anything(), [$paramInWhere]], - [$this->anything(), [$paramInSubSelect, $paramInWhere, $returnedIds]] + [self::anything(), [$paramInWhere]], + [self::anything(), [$paramInWhere]], + [self::anything(), [$paramInSubSelect, $paramInWhere, $returnedIds]] ); $paginator->count(); @@ -77,7 +77,7 @@ public function testExtraParametersAreStrippedWhenWalkerRemovingOriginalSelectEl public function testPaginatorNotCaringAboutExtraParametersWithoutOutputWalkers(): void { - $this->connection->expects($this->exactly(3))->method('executeQuery'); + $this->connection->expects(self::exactly(3))->method('executeQuery'); $this->createPaginatorWithExtraParametersWithoutOutputWalkers([])->count(); $this->createPaginatorWithExtraParametersWithoutOutputWalkers([[10]])->count(); @@ -86,7 +86,7 @@ public function testPaginatorNotCaringAboutExtraParametersWithoutOutputWalkers() public function testgetIteratorDoesCareAboutExtraParametersWithoutOutputWalkersWhenResultIsNotEmpty(): void { - $this->connection->expects($this->exactly(1))->method('executeQuery'); + $this->connection->expects(self::exactly(1))->method('executeQuery'); $this->expectException(Query\QueryException::class); $this->expectExceptionMessage('Too many parameters: the query defines 1 parameters and you bound 2'); @@ -99,7 +99,7 @@ public function testgetIteratorDoesCareAboutExtraParametersWithoutOutputWalkersW private function createPaginatorWithExtraParametersWithoutOutputWalkers(array $willReturnRows): Paginator { $this->hydrator->method('hydrateAll')->willReturn($willReturnRows); - $this->connection->method('executeQuery')->with($this->anything(), []); + $this->connection->method('executeQuery')->with(self::anything(), []); $query = new Query($this->em); $query->setDQL('SELECT u FROM Doctrine\\Tests\\Models\\CMS\\CmsUser u'); diff --git a/tests/Doctrine/Tests/ORM/Tools/Pagination/WhereInWalkerTest.php b/tests/Doctrine/Tests/ORM/Tools/Pagination/WhereInWalkerTest.php index c9a8cbaf32b..23e6d717607 100644 --- a/tests/Doctrine/Tests/ORM/Tools/Pagination/WhereInWalkerTest.php +++ b/tests/Doctrine/Tests/ORM/Tools/Pagination/WhereInWalkerTest.php @@ -35,7 +35,7 @@ public function testWhereInQueryNoWhere(): void $whereInQuery->setHint(WhereInWalker::HINT_PAGINATOR_ID_COUNT, 10); $whereInQuery->setParameter(WhereInWalker::PAGINATOR_ID_ALIAS, [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]); - $this->assertEquals( + self::assertEquals( 'SELECT u0_.id AS id_0, g1_.id AS id_1 FROM User u0_ INNER JOIN user_group u2_ ON u0_.id = u2_.user_id INNER JOIN groups g1_ ON g1_.id = u2_.group_id WHERE u0_.id IN (?)', $whereInQuery->getSQL() ); @@ -56,7 +56,7 @@ public function testCountQueryMixedResultsWithName(): void $whereInQuery->setHint(WhereInWalker::HINT_PAGINATOR_ID_COUNT, 10); $whereInQuery->setParameter(WhereInWalker::PAGINATOR_ID_ALIAS, [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]); - $this->assertEquals( + self::assertEquals( 'SELECT a0_.id AS id_0, a0_.name AS name_1, sum(a0_.name) AS sclr_2 FROM Author a0_ WHERE a0_.id IN (?)', $whereInQuery->getSQL() ); @@ -77,7 +77,7 @@ public function testWhereInQuerySingleWhere(): void $whereInQuery->setHint(WhereInWalker::HINT_PAGINATOR_ID_COUNT, 10); $whereInQuery->setParameter(WhereInWalker::PAGINATOR_ID_ALIAS, [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]); - $this->assertEquals( + self::assertEquals( 'SELECT u0_.id AS id_0, g1_.id AS id_1 FROM User u0_ INNER JOIN user_group u2_ ON u0_.id = u2_.user_id INNER JOIN groups g1_ ON g1_.id = u2_.group_id WHERE 1 = 1 AND u0_.id IN (?)', $whereInQuery->getSQL() ); @@ -98,7 +98,7 @@ public function testWhereInQueryMultipleWhereWithAnd(): void $whereInQuery->setHint(WhereInWalker::HINT_PAGINATOR_ID_COUNT, 10); $whereInQuery->setParameter(WhereInWalker::PAGINATOR_ID_ALIAS, [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]); - $this->assertEquals( + self::assertEquals( 'SELECT u0_.id AS id_0, g1_.id AS id_1 FROM User u0_ INNER JOIN user_group u2_ ON u0_.id = u2_.user_id INNER JOIN groups g1_ ON g1_.id = u2_.group_id WHERE 1 = 1 AND 2 = 2 AND u0_.id IN (?)', $whereInQuery->getSQL() ); @@ -119,7 +119,7 @@ public function testWhereInQueryMultipleWhereWithOr(): void $whereInQuery->setHint(WhereInWalker::HINT_PAGINATOR_ID_COUNT, 10); $whereInQuery->setParameter(WhereInWalker::PAGINATOR_ID_ALIAS, [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]); - $this->assertEquals( + self::assertEquals( 'SELECT u0_.id AS id_0, g1_.id AS id_1 FROM User u0_ INNER JOIN user_group u2_ ON u0_.id = u2_.user_id INNER JOIN groups g1_ ON g1_.id = u2_.group_id WHERE (1 = 1 OR 2 = 2) AND u0_.id IN (?)', $whereInQuery->getSQL() ); @@ -140,7 +140,7 @@ public function testWhereInQueryMultipleWhereWithMixed1(): void $whereInQuery->setHint(WhereInWalker::HINT_PAGINATOR_ID_COUNT, 10); $whereInQuery->setParameter(WhereInWalker::PAGINATOR_ID_ALIAS, [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]); - $this->assertEquals( + self::assertEquals( 'SELECT u0_.id AS id_0, g1_.id AS id_1 FROM User u0_ INNER JOIN user_group u2_ ON u0_.id = u2_.user_id INNER JOIN groups g1_ ON g1_.id = u2_.group_id WHERE (1 = 1 OR 2 = 2) AND 3 = 3 AND u0_.id IN (?)', $whereInQuery->getSQL() ); @@ -161,7 +161,7 @@ public function testWhereInQueryMultipleWhereWithMixed2(): void $whereInQuery->setHint(WhereInWalker::HINT_PAGINATOR_ID_COUNT, 10); $whereInQuery->setParameter(WhereInWalker::PAGINATOR_ID_ALIAS, [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]); - $this->assertEquals( + self::assertEquals( 'SELECT u0_.id AS id_0, g1_.id AS id_1 FROM User u0_ INNER JOIN user_group u2_ ON u0_.id = u2_.user_id INNER JOIN groups g1_ ON g1_.id = u2_.group_id WHERE (1 = 1 AND 2 = 2 OR 3 = 3) AND u0_.id IN (?)', $whereInQuery->getSQL() ); @@ -182,7 +182,7 @@ public function testWhereInQueryWhereNot(): void $whereInQuery->setHint(WhereInWalker::HINT_PAGINATOR_ID_COUNT, 10); $whereInQuery->setParameter(WhereInWalker::PAGINATOR_ID_ALIAS, [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]); - $this->assertEquals( + self::assertEquals( 'SELECT u0_.id AS id_0, g1_.id AS id_1 FROM User u0_ INNER JOIN user_group u2_ ON u0_.id = u2_.user_id INNER JOIN groups g1_ ON g1_.id = u2_.group_id WHERE (NOT 1 = 2) AND u0_.id IN (?)', $whereInQuery->getSQL() ); @@ -205,7 +205,7 @@ public function testWhereInQueryWithArbitraryJoinNoWhere(): void $whereInQuery->setHint(WhereInWalker::HINT_PAGINATOR_ID_COUNT, 10); $whereInQuery->setParameter(WhereInWalker::PAGINATOR_ID_ALIAS, [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]); - $this->assertEquals( + self::assertEquals( 'SELECT b0_.id AS id_0, b0_.author_id AS author_id_1, b0_.category_id AS category_id_2 FROM BlogPost b0_ INNER JOIN Category c1_ ON (b0_.category_id = c1_.id) WHERE b0_.id IN (?)', $whereInQuery->getSQL() ); @@ -225,7 +225,7 @@ public function testWhereInQueryWithArbitraryJoinSingleWhere(): void $whereInQuery->setHint(WhereInWalker::HINT_PAGINATOR_ID_COUNT, 10); $whereInQuery->setParameter(WhereInWalker::PAGINATOR_ID_ALIAS, [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]); - $this->assertEquals( + self::assertEquals( 'SELECT b0_.id AS id_0, b0_.author_id AS author_id_1, b0_.category_id AS category_id_2 FROM BlogPost b0_ INNER JOIN Category c1_ ON (b0_.category_id = c1_.id) WHERE 1 = 1 AND b0_.id IN (?)', $whereInQuery->getSQL() ); diff --git a/tests/Doctrine/Tests/ORM/Tools/ResolveTargetEntityListenerTest.php b/tests/Doctrine/Tests/ORM/Tools/ResolveTargetEntityListenerTest.php index d8b0333a396..80d0957761d 100644 --- a/tests/Doctrine/Tests/ORM/Tools/ResolveTargetEntityListenerTest.php +++ b/tests/Doctrine/Tests/ORM/Tools/ResolveTargetEntityListenerTest.php @@ -54,12 +54,12 @@ public function testResolveTargetEntityListenerCanResolveTargetEntity(): void $cm = $this->factory->getMetadataFor(ResolveTargetEntity::class); $meta = $cm->associationMappings; - $this->assertSame(TargetEntity::class, $meta['manyToMany']['targetEntity']); - $this->assertSame(ResolveTargetEntity::class, $meta['manyToOne']['targetEntity']); - $this->assertSame(ResolveTargetEntity::class, $meta['oneToMany']['targetEntity']); - $this->assertSame(TargetEntity::class, $meta['oneToOne']['targetEntity']); + self::assertSame(TargetEntity::class, $meta['manyToMany']['targetEntity']); + self::assertSame(ResolveTargetEntity::class, $meta['manyToOne']['targetEntity']); + self::assertSame(ResolveTargetEntity::class, $meta['oneToMany']['targetEntity']); + self::assertSame(TargetEntity::class, $meta['oneToOne']['targetEntity']); - $this->assertSame($cm, $this->factory->getMetadataFor(ResolveTarget::class)); + self::assertSame($cm, $this->factory->getMetadataFor(ResolveTarget::class)); } /** @@ -75,7 +75,7 @@ public function testResolveTargetEntityListenerCanRetrieveTargetEntityByInterfac $cm = $this->factory->getMetadataFor(ResolveTarget::class); - $this->assertSame($this->factory->getMetadataFor(ResolveTargetEntity::class), $cm); + self::assertSame($this->factory->getMetadataFor(ResolveTargetEntity::class), $cm); } /** @@ -91,8 +91,8 @@ public function testAssertTableColumnsAreNotAddedInManyToMany(): void $cm = $this->factory->getMetadataFor(ResolveTargetEntity::class); $meta = $cm->associationMappings['manyToMany']; - $this->assertSame(TargetEntity::class, $meta['targetEntity']); - $this->assertEquals(['resolvetargetentity_id', 'target_id'], $meta['joinTableColumns']); + self::assertSame(TargetEntity::class, $meta['targetEntity']); + self::assertEquals(['resolvetargetentity_id', 'target_id'], $meta['joinTableColumns']); } /** @@ -107,7 +107,7 @@ public function testDoesResolveTargetEntitiesInDQLAlsoWithInterfaces(): void $evm->addEventSubscriber($this->listener); - $this->assertStringMatchesFormat( + self::assertStringMatchesFormat( 'SELECT%AFROM ResolveTargetEntity%A', $this ->em diff --git a/tests/Doctrine/Tests/ORM/Tools/SchemaToolTest.php b/tests/Doctrine/Tests/ORM/Tools/SchemaToolTest.php index 0010d28817c..81968bfca5b 100644 --- a/tests/Doctrine/Tests/ORM/Tools/SchemaToolTest.php +++ b/tests/Doctrine/Tests/ORM/Tools/SchemaToolTest.php @@ -62,8 +62,8 @@ public function testAddUniqueIndexForUniqueFieldAnnotation(): void $schema = $schemaTool->getSchemaFromMetadata($classes); - $this->assertTrue($schema->hasTable('cms_users'), 'Table cms_users should exist.'); - $this->assertTrue($schema->getTable('cms_users')->columnsAreIndexed(['username']), 'username column should be indexed.'); + self::assertTrue($schema->hasTable('cms_users'), 'Table cms_users should exist.'); + self::assertTrue($schema->getTable('cms_users')->columnsAreIndexed(['username']), 'username column should be indexed.'); } public function testAnnotationOptionsAttribute(): void @@ -102,10 +102,10 @@ public function testPassColumnDefinitionToJoinColumn(): void $schema = $schemaTool->getSchemaFromMetadata($classes); - $this->assertTrue($schema->hasTable('forum_users')); + self::assertTrue($schema->hasTable('forum_users')); $table = $schema->getTable('forum_users'); - $this->assertTrue($table->hasColumn('avatar_id')); - $this->assertEquals($customColumnDef, $table->getColumn('avatar_id')->getColumnDefinition()); + self::assertTrue($table->hasColumn('avatar_id')); + self::assertEquals($customColumnDef, $table->getColumn('avatar_id')->getColumnDefinition()); } /** @@ -172,8 +172,8 @@ public function testPostGenerateEvents(): void $schema = $schemaTool->getSchemaFromMetadata($classes); - $this->assertEquals(count($classes), $listener->tableCalls); - $this->assertTrue($listener->schemaCalled); + self::assertEquals(count($classes), $listener->tableCalls); + self::assertTrue($listener->schemaCalled); } public function testNullDefaultNotAddedToCustomSchemaOptions(): void @@ -186,7 +186,7 @@ public function testNullDefaultNotAddedToCustomSchemaOptions(): void ->getColumn('nullDefault') ->getCustomSchemaOptions(); - $this->assertSame([], $customSchemaOptions); + self::assertSame([], $customSchemaOptions); } /** @@ -202,12 +202,12 @@ public function testSchemaHasProperIndexesFromUniqueConstraintAnnotation(): void $schema = $schemaTool->getSchemaFromMetadata($classes); - $this->assertTrue($schema->hasTable('unique_constraint_annotation_table')); + self::assertTrue($schema->hasTable('unique_constraint_annotation_table')); $table = $schema->getTable('unique_constraint_annotation_table'); - $this->assertEquals(2, count($table->getIndexes())); - $this->assertTrue($table->hasIndex('primary')); - $this->assertTrue($table->hasIndex('uniq_hash')); + self::assertEquals(2, count($table->getIndexes())); + self::assertTrue($table->hasIndex('primary')); + self::assertTrue($table->hasIndex('uniq_hash')); } public function testRemoveUniqueIndexOverruledByPrimaryKey(): void @@ -221,12 +221,12 @@ public function testRemoveUniqueIndexOverruledByPrimaryKey(): void $schema = $schemaTool->getSchemaFromMetadata($classes); - $this->assertTrue($schema->hasTable('first_entity'), 'Table first_entity should exist.'); + self::assertTrue($schema->hasTable('first_entity'), 'Table first_entity should exist.'); $indexes = $schema->getTable('first_entity')->getIndexes(); - $this->assertCount(1, $indexes, 'there should be only one index'); - $this->assertTrue(current($indexes)->isPrimary(), 'index should be primary'); + self::assertCount(1, $indexes, 'there should be only one index'); + self::assertTrue(current($indexes)->isPrimary(), 'index should be primary'); } public function testSetDiscriminatorColumnWithoutLength(): void @@ -240,13 +240,13 @@ public function testSetDiscriminatorColumnWithoutLength(): void $schema = $schemaTool->getSchemaFromMetadata([$metadata]); - $this->assertTrue($schema->hasTable('first_entity')); + self::assertTrue($schema->hasTable('first_entity')); $table = $schema->getTable('first_entity'); - $this->assertTrue($table->hasColumn('discriminator')); + self::assertTrue($table->hasColumn('discriminator')); $column = $table->getColumn('discriminator'); - $this->assertEquals(255, $column->getLength()); + self::assertEquals(255, $column->getLength()); } public function testDerivedCompositeKey(): void diff --git a/tests/Doctrine/Tests/ORM/Tools/SchemaValidatorTest.php b/tests/Doctrine/Tests/ORM/Tools/SchemaValidatorTest.php index c7415396654..da32bee58e3 100644 --- a/tests/Doctrine/Tests/ORM/Tools/SchemaValidatorTest.php +++ b/tests/Doctrine/Tests/ORM/Tools/SchemaValidatorTest.php @@ -71,7 +71,7 @@ public function testInvalidManyToManyJoinColumnSchema(): void $ce = $this->validator->validateClass($class1); - $this->assertEquals( + self::assertEquals( [ "The inverse join columns of the many-to-many table 'Entity1Entity2' have to contain to ALL identifier columns of the target entity 'Doctrine\Tests\ORM\Tools\InvalidEntity2', however 'key4' are missing.", "The join columns of the many-to-many table 'Entity1Entity2' have to contain to ALL identifier columns of the source entity 'Doctrine\Tests\ORM\Tools\InvalidEntity1', however 'key2' are missing.", @@ -90,7 +90,7 @@ public function testInvalidToOneJoinColumnSchema(): void $ce = $this->validator->validateClass($class2); - $this->assertEquals( + self::assertEquals( [ "The referenced column name 'id' has to be a primary key column on the target entity class 'Doctrine\Tests\ORM\Tools\InvalidEntity1'.", "The join columns of the association 'assoc' have to match to ALL identifier columns of the target entity 'Doctrine\Tests\ORM\Tools\InvalidEntity1', however 'key1, key2' are missing.", @@ -109,7 +109,7 @@ public function testValidOneToOneAsIdentifierSchema(): void $ce = $this->validator->validateClass($class1); - $this->assertEquals([], $ce); + self::assertEquals([], $ce); } /** @@ -120,7 +120,7 @@ public function testInvalidTripleAssociationAsKeyMapping(): void $classThree = $this->em->getClassMetadata(DDC1649Three::class); $ce = $this->validator->validateClass($classThree); - $this->assertEquals( + self::assertEquals( [ "Cannot map association 'Doctrine\Tests\ORM\Tools\DDC1649Three#two as identifier, because the target entity 'Doctrine\Tests\ORM\Tools\DDC1649Two' also maps an association as identifier.", "The referenced column name 'id' has to be a primary key column on the target entity class 'Doctrine\Tests\ORM\Tools\DDC1649Two'.", @@ -137,7 +137,7 @@ public function testInvalidBiDirectionalRelationMappingMissingInversedByAttribut $class = $this->em->getClassMetadata(DDC3274One::class); $ce = $this->validator->validateClass($class); - $this->assertEquals( + self::assertEquals( [ 'The field Doctrine\Tests\ORM\Tools\DDC3274One#two is on the inverse side of a bi-directional ' . 'relationship, but the specified mappedBy association on the target-entity ' . @@ -155,7 +155,7 @@ public function testInvalidOrderByInvalidField(): void $class = $this->em->getClassMetadata(DDC3322One::class); $ce = $this->validator->validateClass($class); - $this->assertEquals( + self::assertEquals( [ 'The association Doctrine\Tests\ORM\Tools\DDC3322One#invalidAssoc is ordered by a foreign field ' . 'invalidField that is not a field on the target entity Doctrine\Tests\ORM\Tools\DDC3322ValidEntity1.', @@ -172,7 +172,7 @@ public function testInvalidOrderByCollectionValuedAssociation(): void $class = $this->em->getClassMetadata(DDC3322Two::class); $ce = $this->validator->validateClass($class); - $this->assertEquals( + self::assertEquals( [ 'The association Doctrine\Tests\ORM\Tools\DDC3322Two#invalidAssoc is ordered by a field oneToMany ' . 'on Doctrine\Tests\ORM\Tools\DDC3322ValidEntity1 that is a collection-valued association.', @@ -189,7 +189,7 @@ public function testInvalidOrderByAssociationInverseSide(): void $class = $this->em->getClassMetadata(DDC3322Three::class); $ce = $this->validator->validateClass($class); - $this->assertEquals( + self::assertEquals( [ 'The association Doctrine\Tests\ORM\Tools\DDC3322Three#invalidAssoc is ordered by a field oneToOneInverse ' . 'on Doctrine\Tests\ORM\Tools\DDC3322ValidEntity1 that is the inverse side of an association.', @@ -206,7 +206,7 @@ public function testInvalidAssociationInsideEmbeddable(): void $class = $this->em->getClassMetadata(EmbeddableWithAssociation::class); $ce = $this->validator->validateClass($class); - $this->assertEquals( + self::assertEquals( ["Embeddable 'Doctrine\Tests\ORM\Tools\EmbeddableWithAssociation' does not support associations"], $ce ); diff --git a/tests/Doctrine/Tests/ORM/Tools/SetupTest.php b/tests/Doctrine/Tests/ORM/Tools/SetupTest.php index adc4d7d5d25..6e5022e54fd 100644 --- a/tests/Doctrine/Tests/ORM/Tools/SetupTest.php +++ b/tests/Doctrine/Tests/ORM/Tools/SetupTest.php @@ -59,33 +59,33 @@ public function testDirectoryAutoload(): void { Setup::registerAutoloadDirectory(__DIR__ . '/../../../../../vendor/doctrine/common/lib'); - $this->assertEquals($this->originalAutoloaderCount + 2, count(spl_autoload_functions())); + self::assertEquals($this->originalAutoloaderCount + 2, count(spl_autoload_functions())); } public function testAnnotationConfiguration(): void { $config = Setup::createAnnotationMetadataConfiguration([], true); - $this->assertInstanceOf(Configuration::class, $config); - $this->assertEquals(sys_get_temp_dir(), $config->getProxyDir()); - $this->assertEquals('DoctrineProxies', $config->getProxyNamespace()); - $this->assertInstanceOf(AnnotationDriver::class, $config->getMetadataDriverImpl()); + self::assertInstanceOf(Configuration::class, $config); + self::assertEquals(sys_get_temp_dir(), $config->getProxyDir()); + self::assertEquals('DoctrineProxies', $config->getProxyNamespace()); + self::assertInstanceOf(AnnotationDriver::class, $config->getMetadataDriverImpl()); } public function testXMLConfiguration(): void { $config = Setup::createXMLMetadataConfiguration([], true); - $this->assertInstanceOf(Configuration::class, $config); - $this->assertInstanceOf(XmlDriver::class, $config->getMetadataDriverImpl()); + self::assertInstanceOf(Configuration::class, $config); + self::assertInstanceOf(XmlDriver::class, $config->getMetadataDriverImpl()); } public function testYAMLConfiguration(): void { $config = Setup::createYAMLMetadataConfiguration([], true); - $this->assertInstanceOf(Configuration::class, $config); - $this->assertInstanceOf(YamlDriver::class, $config->getMetadataDriverImpl()); + self::assertInstanceOf(Configuration::class, $config); + self::assertInstanceOf(YamlDriver::class, $config->getMetadataDriverImpl()); } /** @@ -94,7 +94,7 @@ public function testYAMLConfiguration(): void public function testCacheNamespaceShouldBeGeneratedWhenCacheIsGivenButHasNoNamespace(): void { if (! class_exists(ArrayCache::class)) { - $this->markTestSkipped('Only applies when using doctrine/cache directly'); + self::markTestSkipped('Only applies when using doctrine/cache directly'); } $config = Setup::createConfiguration(false, '/foo', new ArrayCache()); @@ -109,7 +109,7 @@ public function testCacheNamespaceShouldBeGeneratedWhenCacheIsGivenButHasNoNames public function testConfiguredCacheNamespaceShouldBeUsedAsPrefixOfGeneratedNamespace(): void { if (! class_exists(ArrayCache::class)) { - $this->markTestSkipped('Only applies when using doctrine/cache directly'); + self::markTestSkipped('Only applies when using doctrine/cache directly'); } $originalCache = new ArrayCache(); @@ -127,7 +127,7 @@ public function testConfiguredCacheNamespaceShouldBeUsedAsPrefixOfGeneratedNames public function testConfigureProxyDir(): void { $config = Setup::createAnnotationMetadataConfiguration([], true, '/foo'); - $this->assertEquals('/foo', $config->getProxyDir()); + self::assertEquals('/foo', $config->getProxyDir()); } /** @@ -139,13 +139,13 @@ public function testConfigureCache(): void $cache = DoctrineProvider::wrap($adapter); $config = Setup::createAnnotationMetadataConfiguration([], true, null, $cache); - $this->assertSame($cache, $config->getResultCacheImpl()); - $this->assertSame($cache, $config->getQueryCacheImpl()); + self::assertSame($cache, $config->getResultCacheImpl()); + self::assertSame($cache, $config->getQueryCacheImpl()); if (method_exists(Configuration::class, 'getMetadataCache')) { - $this->assertSame($adapter, $config->getMetadataCache()->getCache()->getPool()); + self::assertSame($adapter, $config->getMetadataCache()->getCache()->getPool()); } else { - $this->assertSame($cache, $config->getMetadataCacheImpl()); + self::assertSame($cache, $config->getMetadataCacheImpl()); } } @@ -157,14 +157,14 @@ public function testConfigureCacheCustomInstance(): void $cache = $this->createMock(Cache::class); $config = Setup::createConfiguration(true, null, $cache); - $this->assertSame($cache, $config->getResultCacheImpl()); - $this->assertSame($cache, $config->getQueryCacheImpl()); + self::assertSame($cache, $config->getResultCacheImpl()); + self::assertSame($cache, $config->getQueryCacheImpl()); if (method_exists(Configuration::class, 'getMetadataCache')) { - $this->assertInstanceOf(CacheAdapter::class, $config->getMetadataCache()); - $this->assertSame($cache, $config->getMetadataCache()->getCache()); + self::assertInstanceOf(CacheAdapter::class, $config->getMetadataCache()); + self::assertSame($cache, $config->getMetadataCache()->getCache()); } else { - $this->assertSame($cache, $config->getMetadataCacheImpl()); + self::assertSame($cache, $config->getMetadataCacheImpl()); } } } diff --git a/tests/Doctrine/Tests/ORM/UnitOfWorkTest.php b/tests/Doctrine/Tests/ORM/UnitOfWorkTest.php index 1d236a1745d..bddaec9bbae 100644 --- a/tests/Doctrine/Tests/ORM/UnitOfWorkTest.php +++ b/tests/Doctrine/Tests/ORM/UnitOfWorkTest.php @@ -89,9 +89,9 @@ public function testRegisterRemovedOnNewEntityIsIgnored(): void { $user = new ForumUser(); $user->username = 'romanb'; - $this->assertFalse($this->_unitOfWork->isScheduledForDelete($user)); + self::assertFalse($this->_unitOfWork->isScheduledForDelete($user)); $this->_unitOfWork->scheduleForDelete($user); - $this->assertFalse($this->_unitOfWork->isScheduledForDelete($user)); + self::assertFalse($this->_unitOfWork->isScheduledForDelete($user)); } /* Operational tests */ @@ -109,12 +109,12 @@ public function testSavingSingleEntityWithIdentityColumnForcesInsert(): void $this->_unitOfWork->persist($user); // Check - $this->assertEquals(0, count($userPersister->getInserts())); - $this->assertEquals(0, count($userPersister->getUpdates())); - $this->assertEquals(0, count($userPersister->getDeletes())); - $this->assertFalse($this->_unitOfWork->isInIdentityMap($user)); + self::assertEquals(0, count($userPersister->getInserts())); + self::assertEquals(0, count($userPersister->getUpdates())); + self::assertEquals(0, count($userPersister->getDeletes())); + self::assertFalse($this->_unitOfWork->isInIdentityMap($user)); // should no longer be scheduled for insert - $this->assertTrue($this->_unitOfWork->isScheduledForInsert($user)); + self::assertTrue($this->_unitOfWork->isScheduledForInsert($user)); // Now lets check whether a subsequent commit() does anything $userPersister->reset(); @@ -123,12 +123,12 @@ public function testSavingSingleEntityWithIdentityColumnForcesInsert(): void $this->_unitOfWork->commit(); // Check. - $this->assertEquals(1, count($userPersister->getInserts())); - $this->assertEquals(0, count($userPersister->getUpdates())); - $this->assertEquals(0, count($userPersister->getDeletes())); + self::assertEquals(1, count($userPersister->getInserts())); + self::assertEquals(0, count($userPersister->getUpdates())); + self::assertEquals(0, count($userPersister->getDeletes())); // should have an id - $this->assertTrue(is_numeric($user->id)); + self::assertTrue(is_numeric($user->id)); } /** @@ -156,16 +156,16 @@ public function testCascadedIdentityColumnInsert(): void $this->_unitOfWork->commit(); - $this->assertTrue(is_numeric($user->id)); - $this->assertTrue(is_numeric($avatar->id)); + self::assertTrue(is_numeric($user->id)); + self::assertTrue(is_numeric($avatar->id)); - $this->assertEquals(1, count($userPersister->getInserts())); - $this->assertEquals(0, count($userPersister->getUpdates())); - $this->assertEquals(0, count($userPersister->getDeletes())); + self::assertEquals(1, count($userPersister->getInserts())); + self::assertEquals(0, count($userPersister->getUpdates())); + self::assertEquals(0, count($userPersister->getDeletes())); - $this->assertEquals(1, count($avatarPersister->getInserts())); - $this->assertEquals(0, count($avatarPersister->getUpdates())); - $this->assertEquals(0, count($avatarPersister->getDeletes())); + self::assertEquals(1, count($avatarPersister->getInserts())); + self::assertEquals(0, count($avatarPersister->getUpdates())); + self::assertEquals(0, count($avatarPersister->getDeletes())); } public function testChangeTrackingNotify(): void @@ -180,18 +180,18 @@ public function testChangeTrackingNotify(): void $this->_unitOfWork->persist($entity); $this->_unitOfWork->commit(); - $this->assertCount(1, $persister->getInserts()); + self::assertCount(1, $persister->getInserts()); $persister->reset(); - $this->assertTrue($this->_unitOfWork->isInIdentityMap($entity)); + self::assertTrue($this->_unitOfWork->isInIdentityMap($entity)); $entity->setData('newdata'); $entity->setTransient('newtransientvalue'); - $this->assertTrue($this->_unitOfWork->isScheduledForDirtyCheck($entity)); + self::assertTrue($this->_unitOfWork->isScheduledForDirtyCheck($entity)); - $this->assertEquals(['data' => ['thedata', 'newdata']], $this->_unitOfWork->getEntityChangeSet($entity)); + self::assertEquals(['data' => ['thedata', 'newdata']], $this->_unitOfWork->getEntityChangeSet($entity)); $item = new NotifyChangedRelatedItem(); $entity->getItems()->add($item); @@ -199,17 +199,17 @@ public function testChangeTrackingNotify(): void $this->_unitOfWork->persist($item); $this->_unitOfWork->commit(); - $this->assertEquals(1, count($itemPersister->getInserts())); + self::assertEquals(1, count($itemPersister->getInserts())); $persister->reset(); $itemPersister->reset(); $entity->getItems()->removeElement($item); $item->setOwner(null); - $this->assertTrue($entity->getItems()->isDirty()); + self::assertTrue($entity->getItems()->isDirty()); $this->_unitOfWork->commit(); $updates = $itemPersister->getUpdates(); - $this->assertEquals(1, count($updates)); - $this->assertTrue($updates[0] === $item); + self::assertEquals(1, count($updates)); + self::assertTrue($updates[0] === $item); } public function testChangeTrackingNotifyIndividualCommit(): void @@ -230,21 +230,21 @@ public function testChangeTrackingNotifyIndividualCommit(): void $this->_unitOfWork->commit($entity); $this->_unitOfWork->commit(); - $this->assertEquals(2, count($persister->getInserts())); + self::assertEquals(2, count($persister->getInserts())); $persister->reset(); - $this->assertTrue($this->_unitOfWork->isInIdentityMap($entity2)); + self::assertTrue($this->_unitOfWork->isInIdentityMap($entity2)); $entity->setData('newdata'); $entity2->setData('newdata'); $this->_unitOfWork->commit($entity); - $this->assertTrue($this->_unitOfWork->isScheduledForDirtyCheck($entity2)); - $this->assertEquals(['data' => ['thedata', 'newdata']], $this->_unitOfWork->getEntityChangeSet($entity2)); - $this->assertFalse($this->_unitOfWork->isScheduledForDirtyCheck($entity)); - $this->assertEquals([], $this->_unitOfWork->getEntityChangeSet($entity)); + self::assertTrue($this->_unitOfWork->isScheduledForDirtyCheck($entity2)); + self::assertEquals(['data' => ['thedata', 'newdata']], $this->_unitOfWork->getEntityChangeSet($entity2)); + self::assertFalse($this->_unitOfWork->isScheduledForDirtyCheck($entity)); + self::assertEquals([], $this->_unitOfWork->getEntityChangeSet($entity)); } public function testGetEntityStateOnVersionedEntityWithAssignedIdentifier(): void @@ -254,8 +254,8 @@ public function testGetEntityStateOnVersionedEntityWithAssignedIdentifier(): voi $e = new VersionedAssignedIdentifierEntity(); $e->id = 42; - $this->assertEquals(UnitOfWork::STATE_NEW, $this->_unitOfWork->getEntityState($e)); - $this->assertFalse($persister->isExistsCalled()); + self::assertEquals(UnitOfWork::STATE_NEW, $this->_unitOfWork->getEntityState($e)); + self::assertFalse($persister->isExistsCalled()); } public function testGetEntityStateWithAssignedIdentity(): void @@ -266,19 +266,19 @@ public function testGetEntityStateWithAssignedIdentity(): void $ph = new CmsPhonenumber(); $ph->phonenumber = '12345'; - $this->assertEquals(UnitOfWork::STATE_NEW, $this->_unitOfWork->getEntityState($ph)); - $this->assertTrue($persister->isExistsCalled()); + self::assertEquals(UnitOfWork::STATE_NEW, $this->_unitOfWork->getEntityState($ph)); + self::assertTrue($persister->isExistsCalled()); $persister->reset(); // if the entity is already managed the exists() check should be skipped $this->_unitOfWork->registerManaged($ph, ['phonenumber' => '12345'], []); - $this->assertEquals(UnitOfWork::STATE_MANAGED, $this->_unitOfWork->getEntityState($ph)); - $this->assertFalse($persister->isExistsCalled()); + self::assertEquals(UnitOfWork::STATE_MANAGED, $this->_unitOfWork->getEntityState($ph)); + self::assertFalse($persister->isExistsCalled()); $ph2 = new CmsPhonenumber(); $ph2->phonenumber = '12345'; - $this->assertEquals(UnitOfWork::STATE_DETACHED, $this->_unitOfWork->getEntityState($ph2)); - $this->assertFalse($persister->isExistsCalled()); + self::assertEquals(UnitOfWork::STATE_DETACHED, $this->_unitOfWork->getEntityState($ph2)); + self::assertFalse($persister->isExistsCalled()); } /** @@ -370,13 +370,13 @@ public function testRemovedAndRePersistedEntitiesAreInTheIdentityMapAndAreNotGar $entity->id = 123; $this->_unitOfWork->registerManaged($entity, ['id' => 123], []); - $this->assertTrue($this->_unitOfWork->isInIdentityMap($entity)); + self::assertTrue($this->_unitOfWork->isInIdentityMap($entity)); $this->_unitOfWork->remove($entity); - $this->assertFalse($this->_unitOfWork->isInIdentityMap($entity)); + self::assertFalse($this->_unitOfWork->isInIdentityMap($entity)); $this->_unitOfWork->persist($entity); - $this->assertTrue($this->_unitOfWork->isInIdentityMap($entity)); + self::assertTrue($this->_unitOfWork->isInIdentityMap($entity)); } /** @@ -389,16 +389,16 @@ public function testPersistedEntityAndClearManager(): void $entity2 = new Country(456, 'United Kingdom'); $this->_unitOfWork->persist($entity1); - $this->assertTrue($this->_unitOfWork->isInIdentityMap($entity1)); + self::assertTrue($this->_unitOfWork->isInIdentityMap($entity1)); $this->_unitOfWork->persist($entity2); - $this->assertTrue($this->_unitOfWork->isInIdentityMap($entity2)); + self::assertTrue($this->_unitOfWork->isInIdentityMap($entity2)); $this->_unitOfWork->clear(Country::class); - $this->assertTrue($this->_unitOfWork->isInIdentityMap($entity1)); - $this->assertFalse($this->_unitOfWork->isInIdentityMap($entity2)); - $this->assertTrue($this->_unitOfWork->isScheduledForInsert($entity1)); - $this->assertFalse($this->_unitOfWork->isScheduledForInsert($entity2)); + self::assertTrue($this->_unitOfWork->isInIdentityMap($entity1)); + self::assertFalse($this->_unitOfWork->isInIdentityMap($entity2)); + self::assertTrue($this->_unitOfWork->isScheduledForInsert($entity1)); + self::assertFalse($this->_unitOfWork->isScheduledForInsert($entity2)); } /** @@ -697,9 +697,9 @@ public function testNewAssociatedEntityPersistenceOfNewEntitiesThroughCascadedAs $this->_unitOfWork->commit(); - $this->assertCount(1, $persister1->getInserts()); - $this->assertCount(1, $persister2->getInserts()); - $this->assertCount(1, $persister3->getInserts()); + self::assertCount(1, $persister1->getInserts()); + self::assertCount(1, $persister2->getInserts()); + self::assertCount(1, $persister3->getInserts()); } /** diff --git a/tests/Doctrine/Tests/ORM/Utility/HierarchyDiscriminatorResolverTest.php b/tests/Doctrine/Tests/ORM/Utility/HierarchyDiscriminatorResolverTest.php index fd9d68871db..be037861967 100644 --- a/tests/Doctrine/Tests/ORM/Utility/HierarchyDiscriminatorResolverTest.php +++ b/tests/Doctrine/Tests/ORM/Utility/HierarchyDiscriminatorResolverTest.php @@ -23,7 +23,7 @@ public function testResolveDiscriminatorsForClass(): void $classMetadata->discriminatorValue = 'discriminator'; $em = $this->createMock(EntityManagerInterface::class); - $em->expects($this->exactly(2)) + $em->expects(self::exactly(2)) ->method('getClassMetadata') ->willReturnMap( [ @@ -34,9 +34,9 @@ public function testResolveDiscriminatorsForClass(): void $discriminators = HierarchyDiscriminatorResolver::resolveDiscriminatorsForClass($classMetadata, $em); - $this->assertCount(2, $discriminators); - $this->assertArrayHasKey($classMetadata->discriminatorValue, $discriminators); - $this->assertArrayHasKey($childClassMetadata->discriminatorValue, $discriminators); + self::assertCount(2, $discriminators); + self::assertArrayHasKey($classMetadata->discriminatorValue, $discriminators); + self::assertArrayHasKey($childClassMetadata->discriminatorValue, $discriminators); } public function testResolveDiscriminatorsForClassWithNoSubclasses(): void @@ -47,14 +47,14 @@ public function testResolveDiscriminatorsForClassWithNoSubclasses(): void $classMetadata->discriminatorValue = 'discriminator'; $em = $this->createMock(EntityManagerInterface::class); - $em->expects($this->exactly(1)) + $em->expects(self::exactly(1)) ->method('getClassMetadata') ->with($classMetadata->name) ->willReturn($classMetadata); $discriminators = HierarchyDiscriminatorResolver::resolveDiscriminatorsForClass($classMetadata, $em); - $this->assertCount(1, $discriminators); - $this->assertArrayHasKey($classMetadata->discriminatorValue, $discriminators); + self::assertCount(1, $discriminators); + self::assertArrayHasKey($classMetadata->discriminatorValue, $discriminators); } } diff --git a/tests/Doctrine/Tests/ORM/Utility/IdentifierFlattenerTest.php b/tests/Doctrine/Tests/ORM/Utility/IdentifierFlattenerTest.php index 9c66ca12e9f..716b20f738a 100644 --- a/tests/Doctrine/Tests/ORM/Utility/IdentifierFlattenerTest.php +++ b/tests/Doctrine/Tests/ORM/Utility/IdentifierFlattenerTest.php @@ -73,11 +73,11 @@ public function testFlattenIdentifierWithOneToOneId(): void $id = $class->getIdentifierValues($firstEntity); - $this->assertCount(1, $id, 'We should have 1 identifier'); + self::assertCount(1, $id, 'We should have 1 identifier'); - $this->assertArrayHasKey('secondEntity', $id, 'It should be called secondEntity'); + self::assertArrayHasKey('secondEntity', $id, 'It should be called secondEntity'); - $this->assertInstanceOf( + self::assertInstanceOf( '\Doctrine\Tests\Models\VersionedOneToOne\SecondRelatedEntity', $id['secondEntity'], 'The entity should be an instance of SecondRelatedEntity' @@ -85,11 +85,11 @@ public function testFlattenIdentifierWithOneToOneId(): void $flatIds = $this->identifierFlattener->flattenIdentifier($class, $id); - $this->assertCount(1, $flatIds, 'We should have 1 flattened id'); + self::assertCount(1, $flatIds, 'We should have 1 flattened id'); - $this->assertArrayHasKey('secondEntity', $flatIds, 'It should be called secondEntity'); + self::assertArrayHasKey('secondEntity', $flatIds, 'It should be called secondEntity'); - $this->assertEquals($id['secondEntity']->id, $flatIds['secondEntity']); + self::assertEquals($id['secondEntity']->id, $flatIds['secondEntity']); } /** @@ -112,22 +112,22 @@ public function testFlattenIdentifierWithMutlipleIds(): void $class = $this->_em->getClassMetadata(Flight::class); $id = $class->getIdentifierValues($flight); - $this->assertCount(2, $id); + self::assertCount(2, $id); - $this->assertArrayHasKey('leavingFrom', $id); - $this->assertArrayHasKey('goingTo', $id); + self::assertArrayHasKey('leavingFrom', $id); + self::assertArrayHasKey('goingTo', $id); - $this->assertEquals($leeds, $id['leavingFrom']); - $this->assertEquals($london, $id['goingTo']); + self::assertEquals($leeds, $id['leavingFrom']); + self::assertEquals($london, $id['goingTo']); $flatIds = $this->identifierFlattener->flattenIdentifier($class, $id); - $this->assertCount(2, $flatIds); + self::assertCount(2, $flatIds); - $this->assertArrayHasKey('leavingFrom', $flatIds); - $this->assertArrayHasKey('goingTo', $flatIds); + self::assertArrayHasKey('leavingFrom', $flatIds); + self::assertArrayHasKey('goingTo', $flatIds); - $this->assertEquals($id['leavingFrom']->getId(), $flatIds['leavingFrom']); - $this->assertEquals($id['goingTo']->getId(), $flatIds['goingTo']); + self::assertEquals($id['leavingFrom']->getId(), $flatIds['leavingFrom']); + self::assertEquals($id['goingTo']->getId(), $flatIds['goingTo']); } } diff --git a/tests/Doctrine/Tests/OrmFunctionalTestCase.php b/tests/Doctrine/Tests/OrmFunctionalTestCase.php index efe99fad96a..6d3d892d5c6 100644 --- a/tests/Doctrine/Tests/OrmFunctionalTestCase.php +++ b/tests/Doctrine/Tests/OrmFunctionalTestCase.php @@ -839,7 +839,7 @@ protected function onNotSuccessfulTest(Throwable $e): void public function assertSQLEquals(string $expectedSql, string $actualSql): void { - $this->assertEquals( + self::assertEquals( strtolower($expectedSql), strtolower($actualSql), 'Lowercase comparison of SQL statements failed.' diff --git a/tests/Doctrine/Tests/OrmPerformanceTestCase.php b/tests/Doctrine/Tests/OrmPerformanceTestCase.php index e9e18c22456..c10fea12e4e 100644 --- a/tests/Doctrine/Tests/OrmPerformanceTestCase.php +++ b/tests/Doctrine/Tests/OrmPerformanceTestCase.php @@ -25,7 +25,7 @@ protected function runTest(): void $time = microtime(true) - $s; if ($this->maxRunningTime !== 0 && $time > $this->maxRunningTime) { - $this->fail( + self::fail( sprintf( 'expected running time: <= %s but was: %s', $this->maxRunningTime,