1
0
mirror of synced 2025-02-03 05:49:25 +03:00

Use "::class" syntax on "tests" directory

This commit is contained in:
Luís Cobucci 2016-12-08 18:01:04 +01:00
parent 512aa8a3c7
commit fda6fdd9fb
No known key found for this signature in database
GPG Key ID: 8042585A7DBC92E1
372 changed files with 4583 additions and 4529 deletions

View File

@ -172,7 +172,7 @@ class CmsAddress
[ [
'name' => 'find-by-id', 'name' => 'find-by-id',
'query' => 'SELECT * FROM cms_addresses WHERE id = ?', 'query' => 'SELECT * FROM cms_addresses WHERE id = ?',
'resultClass' => 'Doctrine\\Tests\\Models\\CMS\\CmsAddress', 'resultClass' => CmsAddress::class,
] ]
); );
@ -204,7 +204,7 @@ class CmsAddress
'column' => 'country', 'column' => 'country',
], ],
], ],
'entityClass' => 'Doctrine\Tests\Models\CMS\CmsAddress', 'entityClass' => CmsAddress::class,
], ],
], ],
] ]
@ -216,7 +216,7 @@ class CmsAddress
'columns' => [], 'columns' => [],
'entities' => [ 'entities' => [
[ [
'entityClass' => 'Doctrine\\Tests\\Models\\CMS\\CmsAddress', 'entityClass' => CmsAddress::class,
'fields' => [] 'fields' => []
] ]
] ]

View File

@ -281,7 +281,7 @@ class CmsUser
[ [
'name' => 'fetchIdAndUsernameWithResultClass', 'name' => 'fetchIdAndUsernameWithResultClass',
'query' => 'SELECT id, username FROM cms_users WHERE username = ?', 'query' => 'SELECT id, username FROM cms_users WHERE username = ?',
'resultClass' => 'Doctrine\\Tests\\Models\\CMS\\CmsUser', 'resultClass' => CmsUser::class,
] ]
); );
@ -289,7 +289,7 @@ class CmsUser
[ [
'name' => 'fetchAllColumns', 'name' => 'fetchAllColumns',
'query' => 'SELECT * FROM cms_users WHERE username = ?', 'query' => 'SELECT * FROM cms_users WHERE username = ?',
'resultClass' => 'Doctrine\\Tests\\Models\\CMS\\CmsUser', 'resultClass' => CmsUser::class,
] ]
); );
@ -361,7 +361,7 @@ class CmsUser
'column' => 'a_id', 'column' => 'a_id',
], ],
], ],
'entityClass' => 'Doctrine\Tests\Models\CMS\CmsUser', 'entityClass' => CmsUser::class,
'discriminatorColumn' => null 'discriminatorColumn' => null
], ],
], ],
@ -392,7 +392,7 @@ class CmsUser
'column' => 'number', 'column' => 'number',
], ],
], ],
'entityClass' => 'Doctrine\\Tests\\Models\\CMS\\CmsUser', 'entityClass' => CmsUser::class,
'discriminatorColumn' => null 'discriminatorColumn' => null
], ],
], ],
@ -419,7 +419,7 @@ class CmsUser
'column' => 'status', 'column' => 'status',
] ]
], ],
'entityClass' => 'Doctrine\Tests\Models\CMS\CmsUser', 'entityClass' => CmsUser::class,
'discriminatorColumn' => null 'discriminatorColumn' => null
] ]
], ],
@ -450,7 +450,7 @@ class CmsUser
'column' => 'u_status', 'column' => 'u_status',
] ]
], ],
'entityClass' => 'Doctrine\Tests\Models\CMS\CmsUser', 'entityClass' => CmsUser::class,
'discriminatorColumn' => null, 'discriminatorColumn' => null,
], ],
[ [
@ -468,7 +468,7 @@ class CmsUser
'column' => 'a_country', 'column' => 'a_country',
], ],
], ],
'entityClass' => 'Doctrine\Tests\Models\CMS\CmsAddress', 'entityClass' => CmsAddress::class,
'discriminatorColumn' => null, 'discriminatorColumn' => null,
], ],
], ],

View File

@ -130,7 +130,7 @@ class CompanyPerson
[ [
'name' => 'fetchAllWithResultClass', 'name' => 'fetchAllWithResultClass',
'query' => 'SELECT id, name, discr FROM company_persons ORDER BY name', 'query' => 'SELECT id, name, discr FROM company_persons ORDER BY name',
'resultClass' => 'Doctrine\\Tests\\Models\\Company\\CompanyPerson', 'resultClass' => CompanyPerson::class,
] ]
); );
@ -158,7 +158,7 @@ class CompanyPerson
'column' => 'name', 'column' => 'name',
], ],
], ],
'entityClass' => 'Doctrine\Tests\Models\Company\CompanyPerson', 'entityClass' => CompanyPerson::class,
'discriminatorColumn' => 'discriminator', 'discriminatorColumn' => 'discriminator',
], ],
], ],

View File

@ -36,7 +36,7 @@ class DDC869Payment
] ]
); );
$metadata->isMappedSuperclass = true; $metadata->isMappedSuperclass = true;
$metadata->setCustomRepositoryClass("Doctrine\Tests\Models\DDC869\DDC869PaymentRepository"); $metadata->setCustomRepositoryClass(DDC869PaymentRepository::class);
$metadata->setIdGeneratorType(\Doctrine\ORM\Mapping\ClassMetadataInfo::GENERATOR_TYPE_AUTO); $metadata->setIdGeneratorType(\Doctrine\ORM\Mapping\ClassMetadataInfo::GENERATOR_TYPE_AUTO);
} }

View File

@ -6,6 +6,7 @@ use Doctrine\ORM\Cache\CacheConfiguration;
use Doctrine\ORM\Cache\CacheFactory; use Doctrine\ORM\Cache\CacheFactory;
use Doctrine\ORM\Cache\QueryCacheValidator; use Doctrine\ORM\Cache\QueryCacheValidator;
use Doctrine\ORM\Cache\Logging\CacheLogger; use Doctrine\ORM\Cache\Logging\CacheLogger;
use Doctrine\ORM\Cache\TimestampQueryCacheValidator;
use Doctrine\ORM\Cache\TimestampRegion; use Doctrine\ORM\Cache\TimestampRegion;
use Doctrine\Tests\DoctrineTestCase; use Doctrine\Tests\DoctrineTestCase;
@ -75,7 +76,7 @@ class CacheConfigTest extends DoctrineTestCase
$validator = $this->createMock(QueryCacheValidator::class); $validator = $this->createMock(QueryCacheValidator::class);
$this->assertInstanceOf('Doctrine\ORM\Cache\TimestampQueryCacheValidator', $this->config->getQueryValidator()); $this->assertInstanceOf(TimestampQueryCacheValidator::class, $this->config->getQueryValidator());
$this->config->setQueryValidator($validator); $this->config->setQueryValidator($validator);

View File

@ -48,7 +48,7 @@ class CacheLoggerChainTest extends DoctrineTestCase
public function testEntityCacheChain() public function testEntityCacheChain()
{ {
$name = 'my_entity_region'; $name = 'my_entity_region';
$key = new EntityCacheKey(State::CLASSNAME, ['id' => 1]); $key = new EntityCacheKey(State::class, ['id' => 1]);
$this->logger->setLogger('mock', $this->mock); $this->logger->setLogger('mock', $this->mock);
@ -72,7 +72,7 @@ class CacheLoggerChainTest extends DoctrineTestCase
public function testCollectionCacheChain() public function testCollectionCacheChain()
{ {
$name = 'my_collection_region'; $name = 'my_collection_region';
$key = new CollectionCacheKey(State::CLASSNAME, 'cities', ['id' => 1]); $key = new CollectionCacheKey(State::class, 'cities', ['id' => 1]);
$this->logger->setLogger('mock', $this->mock); $this->logger->setLogger('mock', $this->mock);

View File

@ -4,14 +4,28 @@ namespace Doctrine\Tests\ORM\Cache;
use Doctrine\Common\Cache\Cache; use Doctrine\Common\Cache\Cache;
use Doctrine\Common\Cache\CacheProvider; use Doctrine\Common\Cache\CacheProvider;
use \Doctrine\Tests\OrmTestCase; use Doctrine\ORM\Cache\CacheFactory;
use Doctrine\ORM\Mapping\ClassMetadata;
use Doctrine\ORM\Cache\DefaultCacheFactory; use Doctrine\ORM\Cache\DefaultCacheFactory;
use Doctrine\ORM\Cache\Persister\Collection\CachedCollectionPersister;
use Doctrine\ORM\Cache\Persister\Collection\NonStrictReadWriteCachedCollectionPersister;
use Doctrine\ORM\Cache\Persister\Collection\ReadOnlyCachedCollectionPersister;
use Doctrine\ORM\Cache\Persister\Collection\ReadWriteCachedCollectionPersister;
use Doctrine\ORM\Cache\Persister\Entity\CachedEntityPersister;
use Doctrine\ORM\Cache\Persister\Entity\NonStrictReadWriteCachedEntityPersister;
use Doctrine\ORM\Cache\Persister\Entity\ReadOnlyCachedEntityPersister;
use Doctrine\ORM\Cache\Persister\Entity\ReadWriteCachedEntityPersister;
use Doctrine\ORM\Cache\Region\DefaultMultiGetRegion;
use Doctrine\ORM\Cache\Region\DefaultRegion; use Doctrine\ORM\Cache\Region\DefaultRegion;
use Doctrine\Tests\Mocks\ConcurrentRegionMock;
use Doctrine\ORM\Persisters\Entity\BasicEntityPersister;
use Doctrine\ORM\Persisters\Collection\OneToManyPersister;
use Doctrine\ORM\Cache\RegionsConfiguration; use Doctrine\ORM\Cache\RegionsConfiguration;
use Doctrine\ORM\Mapping\ClassMetadata;
use Doctrine\ORM\Persisters\Collection\OneToManyPersister;
use Doctrine\ORM\Persisters\Entity\BasicEntityPersister;
use Doctrine\Tests\Mocks\ConcurrentRegionMock;
use Doctrine\Tests\Models\Cache\AttractionContactInfo;
use Doctrine\Tests\Models\Cache\AttractionLocationInfo;
use Doctrine\Tests\Models\Cache\City;
use Doctrine\Tests\Models\Cache\State;
use Doctrine\Tests\OrmTestCase;
/** /**
* @group DDC-2183 * @group DDC-2183
@ -49,14 +63,13 @@ class DefaultCacheFactoryTest extends OrmTestCase
public function testImplementsCacheFactory() public function testImplementsCacheFactory()
{ {
$this->assertInstanceOf('Doctrine\ORM\Cache\CacheFactory', $this->factory); $this->assertInstanceOf(CacheFactory::class, $this->factory);
} }
public function testBuildCachedEntityPersisterReadOnly() public function testBuildCachedEntityPersisterReadOnly()
{ {
$em = $this->em; $em = $this->em;
$entityName = 'Doctrine\Tests\Models\Cache\State'; $metadata = clone $em->getClassMetadata(State::class);
$metadata = clone $em->getClassMetadata($entityName);
$persister = new BasicEntityPersister($em, $metadata); $persister = new BasicEntityPersister($em, $metadata);
$region = new ConcurrentRegionMock(new DefaultRegion('regionName', $this->getSharedSecondLevelCacheDriverImpl())); $region = new ConcurrentRegionMock(new DefaultRegion('regionName', $this->getSharedSecondLevelCacheDriverImpl()));
@ -69,15 +82,14 @@ class DefaultCacheFactoryTest extends OrmTestCase
$cachedPersister = $this->factory->buildCachedEntityPersister($em, $persister, $metadata); $cachedPersister = $this->factory->buildCachedEntityPersister($em, $persister, $metadata);
$this->assertInstanceOf('Doctrine\ORM\Cache\Persister\Entity\CachedEntityPersister', $cachedPersister); $this->assertInstanceOf(CachedEntityPersister::class, $cachedPersister);
$this->assertInstanceOf('Doctrine\ORM\Cache\Persister\Entity\ReadOnlyCachedEntityPersister', $cachedPersister); $this->assertInstanceOf(ReadOnlyCachedEntityPersister::class, $cachedPersister);
} }
public function testBuildCachedEntityPersisterReadWrite() public function testBuildCachedEntityPersisterReadWrite()
{ {
$em = $this->em; $em = $this->em;
$entityName = 'Doctrine\Tests\Models\Cache\State'; $metadata = clone $em->getClassMetadata(State::class);
$metadata = clone $em->getClassMetadata($entityName);
$persister = new BasicEntityPersister($em, $metadata); $persister = new BasicEntityPersister($em, $metadata);
$region = new ConcurrentRegionMock(new DefaultRegion('regionName', $this->getSharedSecondLevelCacheDriverImpl())); $region = new ConcurrentRegionMock(new DefaultRegion('regionName', $this->getSharedSecondLevelCacheDriverImpl()));
@ -90,15 +102,14 @@ class DefaultCacheFactoryTest extends OrmTestCase
$cachedPersister = $this->factory->buildCachedEntityPersister($em, $persister, $metadata); $cachedPersister = $this->factory->buildCachedEntityPersister($em, $persister, $metadata);
$this->assertInstanceOf('Doctrine\ORM\Cache\Persister\Entity\CachedEntityPersister', $cachedPersister); $this->assertInstanceOf(CachedEntityPersister::class, $cachedPersister);
$this->assertInstanceOf('Doctrine\ORM\Cache\Persister\Entity\ReadWriteCachedEntityPersister', $cachedPersister); $this->assertInstanceOf(ReadWriteCachedEntityPersister::class, $cachedPersister);
} }
public function testBuildCachedEntityPersisterNonStrictReadWrite() public function testBuildCachedEntityPersisterNonStrictReadWrite()
{ {
$em = $this->em; $em = $this->em;
$entityName = 'Doctrine\Tests\Models\Cache\State'; $metadata = clone $em->getClassMetadata(State::class);
$metadata = clone $em->getClassMetadata($entityName);
$persister = new BasicEntityPersister($em, $metadata); $persister = new BasicEntityPersister($em, $metadata);
$region = new ConcurrentRegionMock(new DefaultRegion('regionName', $this->getSharedSecondLevelCacheDriverImpl())); $region = new ConcurrentRegionMock(new DefaultRegion('regionName', $this->getSharedSecondLevelCacheDriverImpl()));
@ -111,15 +122,14 @@ class DefaultCacheFactoryTest extends OrmTestCase
$cachedPersister = $this->factory->buildCachedEntityPersister($em, $persister, $metadata); $cachedPersister = $this->factory->buildCachedEntityPersister($em, $persister, $metadata);
$this->assertInstanceOf('Doctrine\ORM\Cache\Persister\Entity\CachedEntityPersister', $cachedPersister); $this->assertInstanceOf(CachedEntityPersister::class, $cachedPersister);
$this->assertInstanceOf('Doctrine\ORM\Cache\Persister\Entity\NonStrictReadWriteCachedEntityPersister', $cachedPersister); $this->assertInstanceOf(NonStrictReadWriteCachedEntityPersister::class, $cachedPersister);
} }
public function testBuildCachedCollectionPersisterReadOnly() public function testBuildCachedCollectionPersisterReadOnly()
{ {
$em = $this->em; $em = $this->em;
$entityName = 'Doctrine\Tests\Models\Cache\State'; $metadata = $em->getClassMetadata(State::class);
$metadata = $em->getClassMetadata($entityName);
$mapping = $metadata->associationMappings['cities']; $mapping = $metadata->associationMappings['cities'];
$persister = new OneToManyPersister($em); $persister = new OneToManyPersister($em);
$region = new ConcurrentRegionMock(new DefaultRegion('regionName', $this->getSharedSecondLevelCacheDriverImpl())); $region = new ConcurrentRegionMock(new DefaultRegion('regionName', $this->getSharedSecondLevelCacheDriverImpl()));
@ -134,15 +144,14 @@ class DefaultCacheFactoryTest extends OrmTestCase
$cachedPersister = $this->factory->buildCachedCollectionPersister($em, $persister, $mapping); $cachedPersister = $this->factory->buildCachedCollectionPersister($em, $persister, $mapping);
$this->assertInstanceOf('Doctrine\ORM\Cache\Persister\Collection\CachedCollectionPersister', $cachedPersister); $this->assertInstanceOf(CachedCollectionPersister::class, $cachedPersister);
$this->assertInstanceOf('Doctrine\ORM\Cache\Persister\Collection\ReadOnlyCachedCollectionPersister', $cachedPersister); $this->assertInstanceOf(ReadOnlyCachedCollectionPersister::class, $cachedPersister);
} }
public function testBuildCachedCollectionPersisterReadWrite() public function testBuildCachedCollectionPersisterReadWrite()
{ {
$em = $this->em; $em = $this->em;
$entityName = 'Doctrine\Tests\Models\Cache\State'; $metadata = $em->getClassMetadata(State::class);
$metadata = $em->getClassMetadata($entityName);
$mapping = $metadata->associationMappings['cities']; $mapping = $metadata->associationMappings['cities'];
$persister = new OneToManyPersister($em); $persister = new OneToManyPersister($em);
$region = new ConcurrentRegionMock(new DefaultRegion('regionName', $this->getSharedSecondLevelCacheDriverImpl())); $region = new ConcurrentRegionMock(new DefaultRegion('regionName', $this->getSharedSecondLevelCacheDriverImpl()));
@ -156,15 +165,14 @@ class DefaultCacheFactoryTest extends OrmTestCase
$cachedPersister = $this->factory->buildCachedCollectionPersister($em, $persister, $mapping); $cachedPersister = $this->factory->buildCachedCollectionPersister($em, $persister, $mapping);
$this->assertInstanceOf('Doctrine\ORM\Cache\Persister\Collection\CachedCollectionPersister', $cachedPersister); $this->assertInstanceOf(CachedCollectionPersister::class, $cachedPersister);
$this->assertInstanceOf('Doctrine\ORM\Cache\Persister\Collection\ReadWriteCachedCollectionPersister', $cachedPersister); $this->assertInstanceOf(ReadWriteCachedCollectionPersister::class, $cachedPersister);
} }
public function testBuildCachedCollectionPersisterNonStrictReadWrite() public function testBuildCachedCollectionPersisterNonStrictReadWrite()
{ {
$em = $this->em; $em = $this->em;
$entityName = 'Doctrine\Tests\Models\Cache\State'; $metadata = $em->getClassMetadata(State::class);
$metadata = $em->getClassMetadata($entityName);
$mapping = $metadata->associationMappings['cities']; $mapping = $metadata->associationMappings['cities'];
$persister = new OneToManyPersister($em); $persister = new OneToManyPersister($em);
$region = new ConcurrentRegionMock(new DefaultRegion('regionName', $this->getSharedSecondLevelCacheDriverImpl())); $region = new ConcurrentRegionMock(new DefaultRegion('regionName', $this->getSharedSecondLevelCacheDriverImpl()));
@ -178,15 +186,15 @@ class DefaultCacheFactoryTest extends OrmTestCase
$cachedPersister = $this->factory->buildCachedCollectionPersister($em, $persister, $mapping); $cachedPersister = $this->factory->buildCachedCollectionPersister($em, $persister, $mapping);
$this->assertInstanceOf('Doctrine\ORM\Cache\Persister\Collection\CachedCollectionPersister', $cachedPersister); $this->assertInstanceOf(CachedCollectionPersister::class, $cachedPersister);
$this->assertInstanceOf('Doctrine\ORM\Cache\Persister\Collection\NonStrictReadWriteCachedCollectionPersister', $cachedPersister); $this->assertInstanceOf(NonStrictReadWriteCachedCollectionPersister::class, $cachedPersister);
} }
public function testInheritedEntityCacheRegion() public function testInheritedEntityCacheRegion()
{ {
$em = $this->em; $em = $this->em;
$metadata1 = clone $em->getClassMetadata('Doctrine\Tests\Models\Cache\AttractionContactInfo'); $metadata1 = clone $em->getClassMetadata(AttractionContactInfo::class);
$metadata2 = clone $em->getClassMetadata('Doctrine\Tests\Models\Cache\AttractionLocationInfo'); $metadata2 = clone $em->getClassMetadata(AttractionLocationInfo::class);
$persister1 = new BasicEntityPersister($em, $metadata1); $persister1 = new BasicEntityPersister($em, $metadata1);
$persister2 = new BasicEntityPersister($em, $metadata2); $persister2 = new BasicEntityPersister($em, $metadata2);
$factory = new DefaultCacheFactory($this->regionsConfig, $this->getSharedSecondLevelCacheDriverImpl()); $factory = new DefaultCacheFactory($this->regionsConfig, $this->getSharedSecondLevelCacheDriverImpl());
@ -194,8 +202,8 @@ class DefaultCacheFactoryTest extends OrmTestCase
$cachedPersister1 = $factory->buildCachedEntityPersister($em, $persister1, $metadata1); $cachedPersister1 = $factory->buildCachedEntityPersister($em, $persister1, $metadata1);
$cachedPersister2 = $factory->buildCachedEntityPersister($em, $persister2, $metadata2); $cachedPersister2 = $factory->buildCachedEntityPersister($em, $persister2, $metadata2);
$this->assertInstanceOf('Doctrine\ORM\Cache\Persister\Entity\CachedEntityPersister', $cachedPersister1); $this->assertInstanceOf(CachedEntityPersister::class, $cachedPersister1);
$this->assertInstanceOf('Doctrine\ORM\Cache\Persister\Entity\CachedEntityPersister', $cachedPersister2); $this->assertInstanceOf(CachedEntityPersister::class, $cachedPersister2);
$this->assertNotSame($cachedPersister1, $cachedPersister2); $this->assertNotSame($cachedPersister1, $cachedPersister2);
$this->assertSame($cachedPersister1->getCacheRegion(), $cachedPersister2->getCacheRegion()); $this->assertSame($cachedPersister1->getCacheRegion(), $cachedPersister2->getCacheRegion());
@ -204,8 +212,8 @@ class DefaultCacheFactoryTest extends OrmTestCase
public function testCreateNewCacheDriver() public function testCreateNewCacheDriver()
{ {
$em = $this->em; $em = $this->em;
$metadata1 = clone $em->getClassMetadata('Doctrine\Tests\Models\Cache\State'); $metadata1 = clone $em->getClassMetadata(State::class);
$metadata2 = clone $em->getClassMetadata('Doctrine\Tests\Models\Cache\City'); $metadata2 = clone $em->getClassMetadata(City::class);
$persister1 = new BasicEntityPersister($em, $metadata1); $persister1 = new BasicEntityPersister($em, $metadata1);
$persister2 = new BasicEntityPersister($em, $metadata2); $persister2 = new BasicEntityPersister($em, $metadata2);
$factory = new DefaultCacheFactory($this->regionsConfig, $this->getSharedSecondLevelCacheDriverImpl()); $factory = new DefaultCacheFactory($this->regionsConfig, $this->getSharedSecondLevelCacheDriverImpl());
@ -213,8 +221,8 @@ class DefaultCacheFactoryTest extends OrmTestCase
$cachedPersister1 = $factory->buildCachedEntityPersister($em, $persister1, $metadata1); $cachedPersister1 = $factory->buildCachedEntityPersister($em, $persister1, $metadata1);
$cachedPersister2 = $factory->buildCachedEntityPersister($em, $persister2, $metadata2); $cachedPersister2 = $factory->buildCachedEntityPersister($em, $persister2, $metadata2);
$this->assertInstanceOf('Doctrine\ORM\Cache\Persister\Entity\CachedEntityPersister', $cachedPersister1); $this->assertInstanceOf(CachedEntityPersister::class, $cachedPersister1);
$this->assertInstanceOf('Doctrine\ORM\Cache\Persister\Entity\CachedEntityPersister', $cachedPersister2); $this->assertInstanceOf(CachedEntityPersister::class, $cachedPersister2);
$this->assertNotSame($cachedPersister1, $cachedPersister2); $this->assertNotSame($cachedPersister1, $cachedPersister2);
$this->assertNotSame($cachedPersister1->getCacheRegion(), $cachedPersister2->getCacheRegion()); $this->assertNotSame($cachedPersister1->getCacheRegion(), $cachedPersister2->getCacheRegion());
@ -227,8 +235,7 @@ class DefaultCacheFactoryTest extends OrmTestCase
public function testBuildCachedEntityPersisterNonStrictException() public function testBuildCachedEntityPersisterNonStrictException()
{ {
$em = $this->em; $em = $this->em;
$entityName = 'Doctrine\Tests\Models\Cache\State'; $metadata = clone $em->getClassMetadata(State::class);
$metadata = clone $em->getClassMetadata($entityName);
$persister = new BasicEntityPersister($em, $metadata); $persister = new BasicEntityPersister($em, $metadata);
$metadata->cache['usage'] = -1; $metadata->cache['usage'] = -1;
@ -243,8 +250,7 @@ class DefaultCacheFactoryTest extends OrmTestCase
public function testBuildCachedCollectionPersisterException() public function testBuildCachedCollectionPersisterException()
{ {
$em = $this->em; $em = $this->em;
$entityName = 'Doctrine\Tests\Models\Cache\State'; $metadata = $em->getClassMetadata(State::class);
$metadata = $em->getClassMetadata($entityName);
$mapping = $metadata->associationMappings['cities']; $mapping = $metadata->associationMappings['cities'];
$persister = new OneToManyPersister($em); $persister = new OneToManyPersister($em);
@ -298,7 +304,7 @@ class DefaultCacheFactoryTest extends OrmTestCase
$factory = new DefaultCacheFactory($this->regionsConfig, $cache); $factory = new DefaultCacheFactory($this->regionsConfig, $cache);
$this->assertInstanceOf( $this->assertInstanceOf(
'Doctrine\ORM\Cache\Region\DefaultRegion', DefaultRegion::class,
$factory->getRegion( $factory->getRegion(
[ [
'region' => 'bar', 'region' => 'bar',
@ -316,7 +322,7 @@ class DefaultCacheFactoryTest extends OrmTestCase
$factory = new DefaultCacheFactory($this->regionsConfig, $cache); $factory = new DefaultCacheFactory($this->regionsConfig, $cache);
$this->assertInstanceOf( $this->assertInstanceOf(
'Doctrine\ORM\Cache\Region\DefaultMultiGetRegion', DefaultMultiGetRegion::class,
$factory->getRegion( $factory->getRegion(
[ [
'region' => 'bar', 'region' => 'bar',

View File

@ -2,6 +2,8 @@
namespace Doctrine\Tests\ORM\Cache; namespace Doctrine\Tests\ORM\Cache;
use Doctrine\ORM\Cache;
use Doctrine\Tests\Models\CMS\CmsUser;
use Doctrine\Tests\OrmTestCase; use Doctrine\Tests\OrmTestCase;
use Doctrine\ORM\Cache\DefaultCache; use Doctrine\ORM\Cache\DefaultCache;
use Doctrine\Tests\Models\Cache\State; use Doctrine\Tests\Models\Cache\State;
@ -26,8 +28,6 @@ class DefaultCacheTest extends OrmTestCase
*/ */
private $em; private $em;
const NON_CACHEABLE_ENTITY = 'Doctrine\Tests\Models\CMS\CmsUser';
protected function setUp() protected function setUp()
{ {
parent::enableSecondLevelCache(); parent::enableSecondLevelCache();
@ -70,104 +70,104 @@ class DefaultCacheTest extends OrmTestCase
public function testImplementsCache() public function testImplementsCache()
{ {
$this->assertInstanceOf('Doctrine\ORM\Cache', $this->cache); $this->assertInstanceOf(Cache::class, $this->cache);
} }
public function testGetEntityCacheRegionAccess() public function testGetEntityCacheRegionAccess()
{ {
$this->assertInstanceOf('Doctrine\ORM\Cache\Region', $this->cache->getEntityCacheRegion(State::CLASSNAME)); $this->assertInstanceOf(Cache\Region::class, $this->cache->getEntityCacheRegion(State::class));
$this->assertNull($this->cache->getEntityCacheRegion(self::NON_CACHEABLE_ENTITY)); $this->assertNull($this->cache->getEntityCacheRegion(CmsUser::class));
} }
public function testGetCollectionCacheRegionAccess() public function testGetCollectionCacheRegionAccess()
{ {
$this->assertInstanceOf('Doctrine\ORM\Cache\Region', $this->cache->getCollectionCacheRegion(State::CLASSNAME, 'cities')); $this->assertInstanceOf(Cache\Region::class, $this->cache->getCollectionCacheRegion(State::class, 'cities'));
$this->assertNull($this->cache->getCollectionCacheRegion(self::NON_CACHEABLE_ENTITY, 'phonenumbers')); $this->assertNull($this->cache->getCollectionCacheRegion(CmsUser::class, 'phonenumbers'));
} }
public function testContainsEntity() public function testContainsEntity()
{ {
$identifier = ['id'=>1]; $identifier = ['id'=>1];
$className = Country::CLASSNAME; $className = Country::class;
$cacheEntry = array_merge($identifier, ['name' => 'Brazil']); $cacheEntry = array_merge($identifier, ['name' => 'Brazil']);
$this->assertFalse($this->cache->containsEntity(Country::CLASSNAME, 1)); $this->assertFalse($this->cache->containsEntity(Country::class, 1));
$this->putEntityCacheEntry($className, $identifier, $cacheEntry); $this->putEntityCacheEntry($className, $identifier, $cacheEntry);
$this->assertTrue($this->cache->containsEntity(Country::CLASSNAME, 1)); $this->assertTrue($this->cache->containsEntity(Country::class, 1));
$this->assertFalse($this->cache->containsEntity(self::NON_CACHEABLE_ENTITY, 1)); $this->assertFalse($this->cache->containsEntity(CmsUser::class, 1));
} }
public function testEvictEntity() public function testEvictEntity()
{ {
$identifier = ['id'=>1]; $identifier = ['id'=>1];
$className = Country::CLASSNAME; $className = Country::class;
$cacheEntry = array_merge($identifier, ['name' => 'Brazil']); $cacheEntry = array_merge($identifier, ['name' => 'Brazil']);
$this->putEntityCacheEntry($className, $identifier, $cacheEntry); $this->putEntityCacheEntry($className, $identifier, $cacheEntry);
$this->assertTrue($this->cache->containsEntity(Country::CLASSNAME, 1)); $this->assertTrue($this->cache->containsEntity(Country::class, 1));
$this->cache->evictEntity(Country::CLASSNAME, 1); $this->cache->evictEntity(Country::class, 1);
$this->cache->evictEntity(self::NON_CACHEABLE_ENTITY, 1); $this->cache->evictEntity(CmsUser::class, 1);
$this->assertFalse($this->cache->containsEntity(Country::CLASSNAME, 1)); $this->assertFalse($this->cache->containsEntity(Country::class, 1));
} }
public function testEvictEntityRegion() public function testEvictEntityRegion()
{ {
$identifier = ['id'=>1]; $identifier = ['id'=>1];
$className = Country::CLASSNAME; $className = Country::class;
$cacheEntry = array_merge($identifier, ['name' => 'Brazil']); $cacheEntry = array_merge($identifier, ['name' => 'Brazil']);
$this->putEntityCacheEntry($className, $identifier, $cacheEntry); $this->putEntityCacheEntry($className, $identifier, $cacheEntry);
$this->assertTrue($this->cache->containsEntity(Country::CLASSNAME, 1)); $this->assertTrue($this->cache->containsEntity(Country::class, 1));
$this->cache->evictEntityRegion(Country::CLASSNAME); $this->cache->evictEntityRegion(Country::class);
$this->cache->evictEntityRegion(self::NON_CACHEABLE_ENTITY); $this->cache->evictEntityRegion(CmsUser::class);
$this->assertFalse($this->cache->containsEntity(Country::CLASSNAME, 1)); $this->assertFalse($this->cache->containsEntity(Country::class, 1));
} }
public function testEvictEntityRegions() public function testEvictEntityRegions()
{ {
$identifier = ['id'=>1]; $identifier = ['id'=>1];
$className = Country::CLASSNAME; $className = Country::class;
$cacheEntry = array_merge($identifier, ['name' => 'Brazil']); $cacheEntry = array_merge($identifier, ['name' => 'Brazil']);
$this->putEntityCacheEntry($className, $identifier, $cacheEntry); $this->putEntityCacheEntry($className, $identifier, $cacheEntry);
$this->assertTrue($this->cache->containsEntity(Country::CLASSNAME, 1)); $this->assertTrue($this->cache->containsEntity(Country::class, 1));
$this->cache->evictEntityRegions(); $this->cache->evictEntityRegions();
$this->assertFalse($this->cache->containsEntity(Country::CLASSNAME, 1)); $this->assertFalse($this->cache->containsEntity(Country::class, 1));
} }
public function testContainsCollection() public function testContainsCollection()
{ {
$ownerId = ['id'=>1]; $ownerId = ['id'=>1];
$className = State::CLASSNAME; $className = State::class;
$association = 'cities'; $association = 'cities';
$cacheEntry = [ $cacheEntry = [
['id' => 11], ['id' => 11],
['id' => 12], ['id' => 12],
]; ];
$this->assertFalse($this->cache->containsCollection(State::CLASSNAME, $association, 1)); $this->assertFalse($this->cache->containsCollection(State::class, $association, 1));
$this->putCollectionCacheEntry($className, $association, $ownerId, $cacheEntry); $this->putCollectionCacheEntry($className, $association, $ownerId, $cacheEntry);
$this->assertTrue($this->cache->containsCollection(State::CLASSNAME, $association, 1)); $this->assertTrue($this->cache->containsCollection(State::class, $association, 1));
$this->assertFalse($this->cache->containsCollection(self::NON_CACHEABLE_ENTITY, 'phonenumbers', 1)); $this->assertFalse($this->cache->containsCollection(CmsUser::class, 'phonenumbers', 1));
} }
public function testEvictCollection() public function testEvictCollection()
{ {
$ownerId = ['id'=>1]; $ownerId = ['id'=>1];
$className = State::CLASSNAME; $className = State::class;
$association = 'cities'; $association = 'cities';
$cacheEntry = [ $cacheEntry = [
['id' => 11], ['id' => 11],
@ -176,18 +176,18 @@ class DefaultCacheTest extends OrmTestCase
$this->putCollectionCacheEntry($className, $association, $ownerId, $cacheEntry); $this->putCollectionCacheEntry($className, $association, $ownerId, $cacheEntry);
$this->assertTrue($this->cache->containsCollection(State::CLASSNAME, $association, 1)); $this->assertTrue($this->cache->containsCollection(State::class, $association, 1));
$this->cache->evictCollection($className, $association, $ownerId); $this->cache->evictCollection($className, $association, $ownerId);
$this->cache->evictCollection(self::NON_CACHEABLE_ENTITY, 'phonenumbers', 1); $this->cache->evictCollection(CmsUser::class, 'phonenumbers', 1);
$this->assertFalse($this->cache->containsCollection(State::CLASSNAME, $association, 1)); $this->assertFalse($this->cache->containsCollection(State::class, $association, 1));
} }
public function testEvictCollectionRegion() public function testEvictCollectionRegion()
{ {
$ownerId = ['id'=>1]; $ownerId = ['id'=>1];
$className = State::CLASSNAME; $className = State::class;
$association = 'cities'; $association = 'cities';
$cacheEntry = [ $cacheEntry = [
['id' => 11], ['id' => 11],
@ -196,18 +196,18 @@ class DefaultCacheTest extends OrmTestCase
$this->putCollectionCacheEntry($className, $association, $ownerId, $cacheEntry); $this->putCollectionCacheEntry($className, $association, $ownerId, $cacheEntry);
$this->assertTrue($this->cache->containsCollection(State::CLASSNAME, $association, 1)); $this->assertTrue($this->cache->containsCollection(State::class, $association, 1));
$this->cache->evictCollectionRegion($className, $association); $this->cache->evictCollectionRegion($className, $association);
$this->cache->evictCollectionRegion(self::NON_CACHEABLE_ENTITY, 'phonenumbers'); $this->cache->evictCollectionRegion(CmsUser::class, 'phonenumbers');
$this->assertFalse($this->cache->containsCollection(State::CLASSNAME, $association, 1)); $this->assertFalse($this->cache->containsCollection(State::class, $association, 1));
} }
public function testEvictCollectionRegions() public function testEvictCollectionRegions()
{ {
$ownerId = ['id'=>1]; $ownerId = ['id'=>1];
$className = State::CLASSNAME; $className = State::class;
$association = 'cities'; $association = 'cities';
$cacheEntry = [ $cacheEntry = [
['id' => 11], ['id' => 11],
@ -216,11 +216,11 @@ class DefaultCacheTest extends OrmTestCase
$this->putCollectionCacheEntry($className, $association, $ownerId, $cacheEntry); $this->putCollectionCacheEntry($className, $association, $ownerId, $cacheEntry);
$this->assertTrue($this->cache->containsCollection(State::CLASSNAME, $association, 1)); $this->assertTrue($this->cache->containsCollection(State::class, $association, 1));
$this->cache->evictCollectionRegions(); $this->cache->evictCollectionRegions();
$this->assertFalse($this->cache->containsCollection(State::CLASSNAME, $association, 1)); $this->assertFalse($this->cache->containsCollection(State::class, $association, 1));
} }
public function testQueryCache() public function testQueryCache()
@ -230,8 +230,8 @@ class DefaultCacheTest extends OrmTestCase
$defaultQueryCache = $this->cache->getQueryCache(); $defaultQueryCache = $this->cache->getQueryCache();
$fooQueryCache = $this->cache->getQueryCache('foo'); $fooQueryCache = $this->cache->getQueryCache('foo');
$this->assertInstanceOf('Doctrine\ORM\Cache\QueryCache', $defaultQueryCache); $this->assertInstanceOf(Cache\QueryCache::class, $defaultQueryCache);
$this->assertInstanceOf('Doctrine\ORM\Cache\QueryCache', $fooQueryCache); $this->assertInstanceOf(Cache\QueryCache::class, $fooQueryCache);
$this->assertSame($defaultQueryCache, $this->cache->getQueryCache()); $this->assertSame($defaultQueryCache, $this->cache->getQueryCache());
$this->assertSame($fooQueryCache, $this->cache->getQueryCache('foo')); $this->assertSame($fooQueryCache, $this->cache->getQueryCache('foo'));
@ -249,7 +249,7 @@ class DefaultCacheTest extends OrmTestCase
{ {
$identifier = 123; $identifier = 123;
$entity = new Country('Foo'); $entity = new Country('Foo');
$metadata = $this->em->getClassMetadata(Country::CLASSNAME); $metadata = $this->em->getClassMetadata(Country::class);
$method = new \ReflectionMethod($this->cache, 'toIdentifierArray'); $method = new \ReflectionMethod($this->cache, 'toIdentifierArray');
$property = new \ReflectionProperty($entity, 'id'); $property = new \ReflectionProperty($entity, 'id');

View File

@ -2,17 +2,17 @@
namespace Doctrine\Tests\ORM\Cache; namespace Doctrine\Tests\ORM\Cache;
use Doctrine\ORM\UnitOfWork;
use Doctrine\ORM\PersistentCollection;
use Doctrine\Tests\Models\Cache\State;
use Doctrine\Tests\Models\Cache\City;
use Doctrine\Tests\OrmFunctionalTestCase;
use Doctrine\ORM\Cache\EntityCacheKey;
use Doctrine\ORM\Cache\EntityCacheEntry;
use Doctrine\ORM\Cache\CollectionCacheKey;
use Doctrine\ORM\Cache\CollectionCacheEntry;
use Doctrine\Common\Collections\ArrayCollection; use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\ORM\Cache\CollectionCacheEntry;
use Doctrine\ORM\Cache\CollectionCacheKey;
use Doctrine\ORM\Cache\DefaultCollectionHydrator; use Doctrine\ORM\Cache\DefaultCollectionHydrator;
use Doctrine\ORM\Cache\EntityCacheEntry;
use Doctrine\ORM\Cache\EntityCacheKey;
use Doctrine\ORM\PersistentCollection;
use Doctrine\ORM\UnitOfWork;
use Doctrine\Tests\Models\Cache\City;
use Doctrine\Tests\Models\Cache\State;
use Doctrine\Tests\OrmFunctionalTestCase;
/** /**
* @group DDC-2183 * @group DDC-2183
@ -29,32 +29,32 @@ class DefaultCollectionHydratorTest extends OrmFunctionalTestCase
$this->enableSecondLevelCache(); $this->enableSecondLevelCache();
parent::setUp(); parent::setUp();
$targetPersister = $this->_em->getUnitOfWork()->getEntityPersister(City::CLASSNAME); $targetPersister = $this->_em->getUnitOfWork()->getEntityPersister(City::class);
$this->structure = new DefaultCollectionHydrator($this->_em, $targetPersister); $this->structure = new DefaultCollectionHydrator($this->_em, $targetPersister);
} }
public function testImplementsCollectionEntryStructure() public function testImplementsCollectionEntryStructure()
{ {
$this->assertInstanceOf('Doctrine\ORM\Cache\DefaultCollectionHydrator', $this->structure); $this->assertInstanceOf(DefaultCollectionHydrator::class, $this->structure);
} }
public function testLoadCacheCollection() public function testLoadCacheCollection()
{ {
$targetRegion = $this->_em->getCache()->getEntityCacheRegion(City::CLASSNAME); $targetRegion = $this->_em->getCache()->getEntityCacheRegion(City::class);
$entry = new CollectionCacheEntry( $entry = new CollectionCacheEntry(
[ [
new EntityCacheKey(City::CLASSNAME, ['id'=>31]), new EntityCacheKey(City::class, ['id'=>31]),
new EntityCacheKey(City::CLASSNAME, ['id'=>32]), new EntityCacheKey(City::class, ['id'=>32]),
] ]
); );
$targetRegion->put(new EntityCacheKey(City::CLASSNAME, ['id'=>31]), new EntityCacheEntry(City::CLASSNAME, ['id'=>31, 'name'=>'Foo'] $targetRegion->put(new EntityCacheKey(City::class, ['id'=>31]), new EntityCacheEntry(City::class, ['id'=>31, 'name'=>'Foo']
)); ));
$targetRegion->put(new EntityCacheKey(City::CLASSNAME, ['id'=>32]), new EntityCacheEntry(City::CLASSNAME, ['id'=>32, 'name'=>'Bar'] $targetRegion->put(new EntityCacheKey(City::class, ['id'=>32]), new EntityCacheEntry(City::class, ['id'=>32, 'name'=>'Bar']
)); ));
$sourceClass = $this->_em->getClassMetadata(State::CLASSNAME); $sourceClass = $this->_em->getClassMetadata(State::class);
$targetClass = $this->_em->getClassMetadata(City::CLASSNAME); $targetClass = $this->_em->getClassMetadata(City::class);
$key = new CollectionCacheKey($sourceClass->name, 'cities', ['id'=>21]); $key = new CollectionCacheKey($sourceClass->name, 'cities', ['id'=>21]);
$collection = new PersistentCollection($this->_em, $targetClass, new ArrayCollection()); $collection = new PersistentCollection($this->_em, $targetClass, new ArrayCollection());
$list = $this->structure->loadCacheEntry($sourceClass, $key, $entry, $collection); $list = $this->structure->loadCacheEntry($sourceClass, $key, $entry, $collection);

View File

@ -2,15 +2,15 @@
namespace Doctrine\Tests\ORM\Cache; namespace Doctrine\Tests\ORM\Cache;
use Doctrine\Tests\OrmTestCase;
use Doctrine\Tests\Models\Cache\State;
use Doctrine\Tests\Models\Cache\Country;
use Doctrine\ORM\UnitOfWork;
use Doctrine\ORM\Cache\EntityCacheKey;
use Doctrine\ORM\Cache\EntityCacheEntry;
use Doctrine\ORM\Cache\DefaultEntityHydrator;
use Doctrine\ORM\Cache\AssociationCacheEntry; use Doctrine\ORM\Cache\AssociationCacheEntry;
use Doctrine\ORM\Cache\CacheEntry;
use Doctrine\ORM\Cache\DefaultEntityHydrator;
use Doctrine\ORM\Cache\EntityCacheEntry;
use Doctrine\ORM\Cache\EntityCacheKey;
use Doctrine\ORM\UnitOfWork;
use Doctrine\Tests\Models\Cache\Country;
use Doctrine\Tests\Models\Cache\State;
use Doctrine\Tests\OrmTestCase;
/** /**
* @group DDC-2183 * @group DDC-2183
@ -42,7 +42,7 @@ class DefaultEntityHydratorTest extends OrmTestCase
public function testCreateEntity() public function testCreateEntity()
{ {
$metadata = $this->em->getClassMetadata(Country::CLASSNAME); $metadata = $this->em->getClassMetadata(Country::class);
$key = new EntityCacheKey($metadata->name, ['id'=>1]); $key = new EntityCacheKey($metadata->name, ['id'=>1]);
$entry = new EntityCacheEntry($metadata->name, ['id'=>1, 'name'=>'Foo']); $entry = new EntityCacheEntry($metadata->name, ['id'=>1, 'name'=>'Foo']);
$entity = $this->structure->loadCacheEntry($metadata, $key, $entry); $entity = $this->structure->loadCacheEntry($metadata, $key, $entry);
@ -56,7 +56,7 @@ class DefaultEntityHydratorTest extends OrmTestCase
public function testLoadProxy() public function testLoadProxy()
{ {
$metadata = $this->em->getClassMetadata(Country::CLASSNAME); $metadata = $this->em->getClassMetadata(Country::class);
$key = new EntityCacheKey($metadata->name, ['id'=>1]); $key = new EntityCacheKey($metadata->name, ['id'=>1]);
$entry = new EntityCacheEntry($metadata->name, ['id'=>1, 'name'=>'Foo']); $entry = new EntityCacheEntry($metadata->name, ['id'=>1, 'name'=>'Foo']);
$proxy = $this->em->getReference($metadata->name, $key->identifier); $proxy = $this->em->getReference($metadata->name, $key->identifier);
@ -75,7 +75,7 @@ class DefaultEntityHydratorTest extends OrmTestCase
$entity = new Country('Foo'); $entity = new Country('Foo');
$uow = $this->em->getUnitOfWork(); $uow = $this->em->getUnitOfWork();
$data = ['id'=>1, 'name'=>'Foo']; $data = ['id'=>1, 'name'=>'Foo'];
$metadata = $this->em->getClassMetadata(Country::CLASSNAME); $metadata = $this->em->getClassMetadata(Country::class);
$key = new EntityCacheKey($metadata->name, ['id'=>1]); $key = new EntityCacheKey($metadata->name, ['id'=>1]);
$entity->setId(1); $entity->setId(1);
@ -83,8 +83,8 @@ class DefaultEntityHydratorTest extends OrmTestCase
$cache = $this->structure->buildCacheEntry($metadata, $key, $entity); $cache = $this->structure->buildCacheEntry($metadata, $key, $entity);
$this->assertInstanceOf('Doctrine\ORM\Cache\CacheEntry', $cache); $this->assertInstanceOf(CacheEntry::class, $cache);
$this->assertInstanceOf('Doctrine\ORM\Cache\EntityCacheEntry', $cache); $this->assertInstanceOf(EntityCacheEntry::class, $cache);
$this->assertArrayHasKey('id', $cache->data); $this->assertArrayHasKey('id', $cache->data);
$this->assertArrayHasKey('name', $cache->data); $this->assertArrayHasKey('name', $cache->data);
@ -102,7 +102,7 @@ class DefaultEntityHydratorTest extends OrmTestCase
$uow = $this->em->getUnitOfWork(); $uow = $this->em->getUnitOfWork();
$countryData = ['id'=>11, 'name'=>'Foo']; $countryData = ['id'=>11, 'name'=>'Foo'];
$stateData = ['id'=>12, 'name'=>'Bar', 'country' => $country]; $stateData = ['id'=>12, 'name'=>'Bar', 'country' => $country];
$metadata = $this->em->getClassMetadata(State::CLASSNAME); $metadata = $this->em->getClassMetadata(State::class);
$key = new EntityCacheKey($metadata->name, ['id'=>11]); $key = new EntityCacheKey($metadata->name, ['id'=>11]);
$country->setId(11); $country->setId(11);
@ -113,8 +113,8 @@ class DefaultEntityHydratorTest extends OrmTestCase
$cache = $this->structure->buildCacheEntry($metadata, $key, $state); $cache = $this->structure->buildCacheEntry($metadata, $key, $state);
$this->assertInstanceOf('Doctrine\ORM\Cache\CacheEntry', $cache); $this->assertInstanceOf(CacheEntry::class, $cache);
$this->assertInstanceOf('Doctrine\ORM\Cache\EntityCacheEntry', $cache); $this->assertInstanceOf(EntityCacheEntry::class, $cache);
$this->assertArrayHasKey('id', $cache->data); $this->assertArrayHasKey('id', $cache->data);
$this->assertArrayHasKey('name', $cache->data); $this->assertArrayHasKey('name', $cache->data);
@ -123,17 +123,17 @@ class DefaultEntityHydratorTest extends OrmTestCase
[ [
'id' => 12, 'id' => 12,
'name' => 'Bar', 'name' => 'Bar',
'country' => new AssociationCacheEntry(Country::CLASSNAME, ['id' => 11]), 'country' => new AssociationCacheEntry(Country::class, ['id' => 11]),
], $cache->data); ], $cache->data);
} }
public function testBuildCacheEntryNonInitializedAssocProxy() public function testBuildCacheEntryNonInitializedAssocProxy()
{ {
$proxy = $this->em->getReference(Country::CLASSNAME, 11); $proxy = $this->em->getReference(Country::class, 11);
$entity = new State('Bat', $proxy); $entity = new State('Bat', $proxy);
$uow = $this->em->getUnitOfWork(); $uow = $this->em->getUnitOfWork();
$entityData = ['id'=>12, 'name'=>'Bar', 'country' => $proxy]; $entityData = ['id'=>12, 'name'=>'Bar', 'country' => $proxy];
$metadata = $this->em->getClassMetadata(State::CLASSNAME); $metadata = $this->em->getClassMetadata(State::class);
$key = new EntityCacheKey($metadata->name, ['id'=>11]); $key = new EntityCacheKey($metadata->name, ['id'=>11]);
$entity->setId(12); $entity->setId(12);
@ -142,8 +142,8 @@ class DefaultEntityHydratorTest extends OrmTestCase
$cache = $this->structure->buildCacheEntry($metadata, $key, $entity); $cache = $this->structure->buildCacheEntry($metadata, $key, $entity);
$this->assertInstanceOf('Doctrine\ORM\Cache\CacheEntry', $cache); $this->assertInstanceOf(CacheEntry::class, $cache);
$this->assertInstanceOf('Doctrine\ORM\Cache\EntityCacheEntry', $cache); $this->assertInstanceOf(EntityCacheEntry::class, $cache);
$this->assertArrayHasKey('id', $cache->data); $this->assertArrayHasKey('id', $cache->data);
$this->assertArrayHasKey('name', $cache->data); $this->assertArrayHasKey('name', $cache->data);
@ -152,17 +152,17 @@ class DefaultEntityHydratorTest extends OrmTestCase
[ [
'id' => 12, 'id' => 12,
'name' => 'Bar', 'name' => 'Bar',
'country' => new AssociationCacheEntry(Country::CLASSNAME, ['id' => 11]), 'country' => new AssociationCacheEntry(Country::class, ['id' => 11]),
], $cache->data); ], $cache->data);
} }
public function testCacheEntryWithWrongIdentifierType() public function testCacheEntryWithWrongIdentifierType()
{ {
$proxy = $this->em->getReference(Country::CLASSNAME, 11); $proxy = $this->em->getReference(Country::class, 11);
$entity = new State('Bat', $proxy); $entity = new State('Bat', $proxy);
$uow = $this->em->getUnitOfWork(); $uow = $this->em->getUnitOfWork();
$entityData = ['id'=> 12, 'name'=>'Bar', 'country' => $proxy]; $entityData = ['id'=> 12, 'name'=>'Bar', 'country' => $proxy];
$metadata = $this->em->getClassMetadata(State::CLASSNAME); $metadata = $this->em->getClassMetadata(State::class);
$key = new EntityCacheKey($metadata->name, ['id'=>'12']); $key = new EntityCacheKey($metadata->name, ['id'=>'12']);
$entity->setId(12); $entity->setId(12);
@ -171,8 +171,8 @@ class DefaultEntityHydratorTest extends OrmTestCase
$cache = $this->structure->buildCacheEntry($metadata, $key, $entity); $cache = $this->structure->buildCacheEntry($metadata, $key, $entity);
$this->assertInstanceOf('Doctrine\ORM\Cache\CacheEntry', $cache); $this->assertInstanceOf(CacheEntry::class, $cache);
$this->assertInstanceOf('Doctrine\ORM\Cache\EntityCacheEntry', $cache); $this->assertInstanceOf(EntityCacheEntry::class, $cache);
$this->assertArrayHasKey('id', $cache->data); $this->assertArrayHasKey('id', $cache->data);
$this->assertArrayHasKey('name', $cache->data); $this->assertArrayHasKey('name', $cache->data);
@ -182,7 +182,7 @@ class DefaultEntityHydratorTest extends OrmTestCase
[ [
'id' => 12, 'id' => 12,
'name' => 'Bar', 'name' => 'Bar',
'country' => new AssociationCacheEntry(Country::CLASSNAME, ['id' => 11]), 'country' => new AssociationCacheEntry(Country::class, ['id' => 11]),
], $cache->data); ], $cache->data);
} }

View File

@ -2,6 +2,9 @@
namespace Doctrine\Tests\ORM\Cache; namespace Doctrine\Tests\ORM\Cache;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Cache\EntityCacheKey;
use Doctrine\ORM\Cache\QueryCache;
use Doctrine\Tests\Mocks\TimestampRegionMock; use Doctrine\Tests\Mocks\TimestampRegionMock;
use Doctrine\Tests\OrmTestCase; use Doctrine\Tests\OrmTestCase;
use Doctrine\Tests\Mocks\CacheRegionMock; use Doctrine\Tests\Mocks\CacheRegionMock;
@ -61,7 +64,7 @@ class DefaultQueryCacheTest extends OrmTestCase
public function testImplementQueryCache() public function testImplementQueryCache()
{ {
$this->assertInstanceOf('Doctrine\ORM\Cache\QueryCache', $this->queryCache); $this->assertInstanceOf(QueryCache::class, $this->queryCache);
} }
public function testGetRegion() public function testGetRegion()
@ -82,9 +85,9 @@ class DefaultQueryCacheTest extends OrmTestCase
$result = []; $result = [];
$key = new QueryCacheKey('query.key1', 0); $key = new QueryCacheKey('query.key1', 0);
$rsm = new ResultSetMappingBuilder($this->em); $rsm = new ResultSetMappingBuilder($this->em);
$metadata = $this->em->getClassMetadata(Country::CLASSNAME); $metadata = $this->em->getClassMetadata(Country::class);
$rsm->addRootEntityFromClassMetadata(Country::CLASSNAME, 'c'); $rsm->addRootEntityFromClassMetadata(Country::class, 'c');
for ($i = 0; $i < 4; $i++) { for ($i = 0; $i < 4; $i++) {
$name = "Country $i"; $name = "Country $i";
@ -99,17 +102,17 @@ class DefaultQueryCacheTest extends OrmTestCase
$this->assertArrayHasKey('put', $this->region->calls); $this->assertArrayHasKey('put', $this->region->calls);
$this->assertCount(5, $this->region->calls['put']); $this->assertCount(5, $this->region->calls['put']);
$this->assertInstanceOf('Doctrine\ORM\Cache\EntityCacheKey', $this->region->calls['put'][0]['key']); $this->assertInstanceOf(EntityCacheKey::class, $this->region->calls['put'][0]['key']);
$this->assertInstanceOf('Doctrine\ORM\Cache\EntityCacheKey', $this->region->calls['put'][1]['key']); $this->assertInstanceOf(EntityCacheKey::class, $this->region->calls['put'][1]['key']);
$this->assertInstanceOf('Doctrine\ORM\Cache\EntityCacheKey', $this->region->calls['put'][2]['key']); $this->assertInstanceOf(EntityCacheKey::class, $this->region->calls['put'][2]['key']);
$this->assertInstanceOf('Doctrine\ORM\Cache\EntityCacheKey', $this->region->calls['put'][3]['key']); $this->assertInstanceOf(EntityCacheKey::class, $this->region->calls['put'][3]['key']);
$this->assertInstanceOf('Doctrine\ORM\Cache\QueryCacheKey', $this->region->calls['put'][4]['key']); $this->assertInstanceOf(QueryCacheKey::class, $this->region->calls['put'][4]['key']);
$this->assertInstanceOf('Doctrine\ORM\Cache\EntityCacheEntry', $this->region->calls['put'][0]['entry']); $this->assertInstanceOf(EntityCacheEntry::class, $this->region->calls['put'][0]['entry']);
$this->assertInstanceOf('Doctrine\ORM\Cache\EntityCacheEntry', $this->region->calls['put'][1]['entry']); $this->assertInstanceOf(EntityCacheEntry::class, $this->region->calls['put'][1]['entry']);
$this->assertInstanceOf('Doctrine\ORM\Cache\EntityCacheEntry', $this->region->calls['put'][2]['entry']); $this->assertInstanceOf(EntityCacheEntry::class, $this->region->calls['put'][2]['entry']);
$this->assertInstanceOf('Doctrine\ORM\Cache\EntityCacheEntry', $this->region->calls['put'][3]['entry']); $this->assertInstanceOf(EntityCacheEntry::class, $this->region->calls['put'][3]['entry']);
$this->assertInstanceOf('Doctrine\ORM\Cache\QueryCacheEntry', $this->region->calls['put'][4]['entry']); $this->assertInstanceOf(QueryCacheEntry::class, $this->region->calls['put'][4]['entry']);
} }
public function testPutToOneAssociationQueryResult() public function testPutToOneAssociationQueryResult()
@ -118,11 +121,11 @@ class DefaultQueryCacheTest extends OrmTestCase
$uow = $this->em->getUnitOfWork(); $uow = $this->em->getUnitOfWork();
$key = new QueryCacheKey('query.key1', 0); $key = new QueryCacheKey('query.key1', 0);
$rsm = new ResultSetMappingBuilder($this->em); $rsm = new ResultSetMappingBuilder($this->em);
$cityClass = $this->em->getClassMetadata(City::CLASSNAME); $cityClass = $this->em->getClassMetadata(City::class);
$stateClass = $this->em->getClassMetadata(State::CLASSNAME); $stateClass = $this->em->getClassMetadata(State::class);
$rsm->addRootEntityFromClassMetadata(City::CLASSNAME, 'c'); $rsm->addRootEntityFromClassMetadata(City::class, 'c');
$rsm->addJoinedEntityFromClassMetadata(State::CLASSNAME, 's', 'c', 'state', ['id'=>'state_id', 'name'=>'state_name'] $rsm->addJoinedEntityFromClassMetadata(State::class, 's', 'c', 'state', ['id'=>'state_id', 'name'=>'state_name']
); );
for ($i = 0; $i < 4; $i++) { for ($i = 0; $i < 4; $i++) {
@ -141,15 +144,15 @@ class DefaultQueryCacheTest extends OrmTestCase
$this->assertArrayHasKey('put', $this->region->calls); $this->assertArrayHasKey('put', $this->region->calls);
$this->assertCount(9, $this->region->calls['put']); $this->assertCount(9, $this->region->calls['put']);
$this->assertInstanceOf('Doctrine\ORM\Cache\EntityCacheKey', $this->region->calls['put'][0]['key']); $this->assertInstanceOf(EntityCacheKey::class, $this->region->calls['put'][0]['key']);
$this->assertInstanceOf('Doctrine\ORM\Cache\EntityCacheKey', $this->region->calls['put'][1]['key']); $this->assertInstanceOf(EntityCacheKey::class, $this->region->calls['put'][1]['key']);
$this->assertInstanceOf('Doctrine\ORM\Cache\EntityCacheKey', $this->region->calls['put'][2]['key']); $this->assertInstanceOf(EntityCacheKey::class, $this->region->calls['put'][2]['key']);
$this->assertInstanceOf('Doctrine\ORM\Cache\EntityCacheKey', $this->region->calls['put'][3]['key']); $this->assertInstanceOf(EntityCacheKey::class, $this->region->calls['put'][3]['key']);
$this->assertInstanceOf('Doctrine\ORM\Cache\EntityCacheKey', $this->region->calls['put'][4]['key']); $this->assertInstanceOf(EntityCacheKey::class, $this->region->calls['put'][4]['key']);
$this->assertInstanceOf('Doctrine\ORM\Cache\EntityCacheKey', $this->region->calls['put'][5]['key']); $this->assertInstanceOf(EntityCacheKey::class, $this->region->calls['put'][5]['key']);
$this->assertInstanceOf('Doctrine\ORM\Cache\EntityCacheKey', $this->region->calls['put'][6]['key']); $this->assertInstanceOf(EntityCacheKey::class, $this->region->calls['put'][6]['key']);
$this->assertInstanceOf('Doctrine\ORM\Cache\EntityCacheKey', $this->region->calls['put'][7]['key']); $this->assertInstanceOf(EntityCacheKey::class, $this->region->calls['put'][7]['key']);
$this->assertInstanceOf('Doctrine\ORM\Cache\QueryCacheKey', $this->region->calls['put'][8]['key']); $this->assertInstanceOf(QueryCacheKey::class, $this->region->calls['put'][8]['key']);
} }
public function testPutToOneAssociation2LevelsQueryResult() public function testPutToOneAssociation2LevelsQueryResult()
@ -158,14 +161,14 @@ class DefaultQueryCacheTest extends OrmTestCase
$uow = $this->em->getUnitOfWork(); $uow = $this->em->getUnitOfWork();
$key = new QueryCacheKey('query.key1', 0); $key = new QueryCacheKey('query.key1', 0);
$rsm = new ResultSetMappingBuilder($this->em); $rsm = new ResultSetMappingBuilder($this->em);
$cityClass = $this->em->getClassMetadata(City::CLASSNAME); $cityClass = $this->em->getClassMetadata(City::class);
$stateClass = $this->em->getClassMetadata(State::CLASSNAME); $stateClass = $this->em->getClassMetadata(State::class);
$countryClass = $this->em->getClassMetadata(Country::CLASSNAME); $countryClass = $this->em->getClassMetadata(Country::class);
$rsm->addRootEntityFromClassMetadata(City::CLASSNAME, 'c'); $rsm->addRootEntityFromClassMetadata(City::class, 'c');
$rsm->addJoinedEntityFromClassMetadata(State::CLASSNAME, 's', 'c', 'state', ['id'=>'state_id', 'name'=>'state_name'] $rsm->addJoinedEntityFromClassMetadata(State::class, 's', 'c', 'state', ['id'=>'state_id', 'name'=>'state_name']
); );
$rsm->addJoinedEntityFromClassMetadata(Country::CLASSNAME, 'co', 's', 'country', ['id'=>'country_id', 'name'=>'country_name'] $rsm->addJoinedEntityFromClassMetadata(Country::class, 'co', 's', 'country', ['id'=>'country_id', 'name'=>'country_name']
); );
for ($i = 0; $i < 4; $i++) { for ($i = 0; $i < 4; $i++) {
@ -189,19 +192,19 @@ class DefaultQueryCacheTest extends OrmTestCase
$this->assertArrayHasKey('put', $this->region->calls); $this->assertArrayHasKey('put', $this->region->calls);
$this->assertCount(13, $this->region->calls['put']); $this->assertCount(13, $this->region->calls['put']);
$this->assertInstanceOf('Doctrine\ORM\Cache\EntityCacheKey', $this->region->calls['put'][0]['key']); $this->assertInstanceOf(EntityCacheKey::class, $this->region->calls['put'][0]['key']);
$this->assertInstanceOf('Doctrine\ORM\Cache\EntityCacheKey', $this->region->calls['put'][1]['key']); $this->assertInstanceOf(EntityCacheKey::class, $this->region->calls['put'][1]['key']);
$this->assertInstanceOf('Doctrine\ORM\Cache\EntityCacheKey', $this->region->calls['put'][2]['key']); $this->assertInstanceOf(EntityCacheKey::class, $this->region->calls['put'][2]['key']);
$this->assertInstanceOf('Doctrine\ORM\Cache\EntityCacheKey', $this->region->calls['put'][3]['key']); $this->assertInstanceOf(EntityCacheKey::class, $this->region->calls['put'][3]['key']);
$this->assertInstanceOf('Doctrine\ORM\Cache\EntityCacheKey', $this->region->calls['put'][4]['key']); $this->assertInstanceOf(EntityCacheKey::class, $this->region->calls['put'][4]['key']);
$this->assertInstanceOf('Doctrine\ORM\Cache\EntityCacheKey', $this->region->calls['put'][5]['key']); $this->assertInstanceOf(EntityCacheKey::class, $this->region->calls['put'][5]['key']);
$this->assertInstanceOf('Doctrine\ORM\Cache\EntityCacheKey', $this->region->calls['put'][6]['key']); $this->assertInstanceOf(EntityCacheKey::class, $this->region->calls['put'][6]['key']);
$this->assertInstanceOf('Doctrine\ORM\Cache\EntityCacheKey', $this->region->calls['put'][7]['key']); $this->assertInstanceOf(EntityCacheKey::class, $this->region->calls['put'][7]['key']);
$this->assertInstanceOf('Doctrine\ORM\Cache\EntityCacheKey', $this->region->calls['put'][8]['key']); $this->assertInstanceOf(EntityCacheKey::class, $this->region->calls['put'][8]['key']);
$this->assertInstanceOf('Doctrine\ORM\Cache\EntityCacheKey', $this->region->calls['put'][9]['key']); $this->assertInstanceOf(EntityCacheKey::class, $this->region->calls['put'][9]['key']);
$this->assertInstanceOf('Doctrine\ORM\Cache\EntityCacheKey', $this->region->calls['put'][10]['key']); $this->assertInstanceOf(EntityCacheKey::class, $this->region->calls['put'][10]['key']);
$this->assertInstanceOf('Doctrine\ORM\Cache\EntityCacheKey', $this->region->calls['put'][11]['key']); $this->assertInstanceOf(EntityCacheKey::class, $this->region->calls['put'][11]['key']);
$this->assertInstanceOf('Doctrine\ORM\Cache\QueryCacheKey', $this->region->calls['put'][12]['key']); $this->assertInstanceOf(QueryCacheKey::class, $this->region->calls['put'][12]['key']);
} }
public function testPutToOneAssociationNullQueryResult() public function testPutToOneAssociationNullQueryResult()
@ -210,10 +213,10 @@ class DefaultQueryCacheTest extends OrmTestCase
$uow = $this->em->getUnitOfWork(); $uow = $this->em->getUnitOfWork();
$key = new QueryCacheKey('query.key1', 0); $key = new QueryCacheKey('query.key1', 0);
$rsm = new ResultSetMappingBuilder($this->em); $rsm = new ResultSetMappingBuilder($this->em);
$cityClass = $this->em->getClassMetadata(City::CLASSNAME); $cityClass = $this->em->getClassMetadata(City::class);
$rsm->addRootEntityFromClassMetadata(City::CLASSNAME, 'c'); $rsm->addRootEntityFromClassMetadata(City::class, 'c');
$rsm->addJoinedEntityFromClassMetadata(State::CLASSNAME, 's', 'c', 'state', ['id'=>'state_id', 'name'=>'state_name'] $rsm->addJoinedEntityFromClassMetadata(State::class, 's', 'c', 'state', ['id'=>'state_id', 'name'=>'state_name']
); );
for ($i = 0; $i < 4; $i++) { for ($i = 0; $i < 4; $i++) {
@ -229,11 +232,11 @@ class DefaultQueryCacheTest extends OrmTestCase
$this->assertArrayHasKey('put', $this->region->calls); $this->assertArrayHasKey('put', $this->region->calls);
$this->assertCount(5, $this->region->calls['put']); $this->assertCount(5, $this->region->calls['put']);
$this->assertInstanceOf('Doctrine\ORM\Cache\EntityCacheKey', $this->region->calls['put'][0]['key']); $this->assertInstanceOf(EntityCacheKey::class, $this->region->calls['put'][0]['key']);
$this->assertInstanceOf('Doctrine\ORM\Cache\EntityCacheKey', $this->region->calls['put'][1]['key']); $this->assertInstanceOf(EntityCacheKey::class, $this->region->calls['put'][1]['key']);
$this->assertInstanceOf('Doctrine\ORM\Cache\EntityCacheKey', $this->region->calls['put'][2]['key']); $this->assertInstanceOf(EntityCacheKey::class, $this->region->calls['put'][2]['key']);
$this->assertInstanceOf('Doctrine\ORM\Cache\EntityCacheKey', $this->region->calls['put'][3]['key']); $this->assertInstanceOf(EntityCacheKey::class, $this->region->calls['put'][3]['key']);
$this->assertInstanceOf('Doctrine\ORM\Cache\QueryCacheKey', $this->region->calls['put'][4]['key']); $this->assertInstanceOf(QueryCacheKey::class, $this->region->calls['put'][4]['key']);
} }
public function testPutToManyAssociationQueryResult() public function testPutToManyAssociationQueryResult()
@ -242,11 +245,11 @@ class DefaultQueryCacheTest extends OrmTestCase
$uow = $this->em->getUnitOfWork(); $uow = $this->em->getUnitOfWork();
$key = new QueryCacheKey('query.key1', 0); $key = new QueryCacheKey('query.key1', 0);
$rsm = new ResultSetMappingBuilder($this->em); $rsm = new ResultSetMappingBuilder($this->em);
$cityClass = $this->em->getClassMetadata(City::CLASSNAME); $cityClass = $this->em->getClassMetadata(City::class);
$stateClass = $this->em->getClassMetadata(State::CLASSNAME); $stateClass = $this->em->getClassMetadata(State::class);
$rsm->addRootEntityFromClassMetadata(State::CLASSNAME, 's'); $rsm->addRootEntityFromClassMetadata(State::class, 's');
$rsm->addJoinedEntityFromClassMetadata(City::CLASSNAME, 'c', 's', 'cities', ['id'=>'c_id', 'name'=>'c_name']); $rsm->addJoinedEntityFromClassMetadata(City::class, 'c', 's', 'cities', ['id'=>'c_id', 'name'=>'c_name']);
for ($i = 0; $i < 4; $i++) { for ($i = 0; $i < 4; $i++) {
$state = new State("State $i"); $state = new State("State $i");
@ -291,16 +294,16 @@ class DefaultQueryCacheTest extends OrmTestCase
]; ];
$this->region->addReturn('get', $entry); $this->region->addReturn('get', $entry);
$this->region->addReturn('get', new EntityCacheEntry(Country::CLASSNAME, $data[0])); $this->region->addReturn('get', new EntityCacheEntry(Country::class, $data[0]));
$this->region->addReturn('get', new EntityCacheEntry(Country::CLASSNAME, $data[1])); $this->region->addReturn('get', new EntityCacheEntry(Country::class, $data[1]));
$rsm->addRootEntityFromClassMetadata(Country::CLASSNAME, 'c'); $rsm->addRootEntityFromClassMetadata(Country::class, 'c');
$result = $this->queryCache->get($key, $rsm); $result = $this->queryCache->get($key, $rsm);
$this->assertCount(2, $result); $this->assertCount(2, $result);
$this->assertInstanceOf(Country::CLASSNAME, $result[0]); $this->assertInstanceOf(Country::class, $result[0]);
$this->assertInstanceOf(Country::CLASSNAME, $result[1]); $this->assertInstanceOf(Country::class, $result[1]);
$this->assertEquals(1, $result[0]->getId()); $this->assertEquals(1, $result[0]->getId());
$this->assertEquals(2, $result[1]->getId()); $this->assertEquals(2, $result[1]->getId());
$this->assertEquals('Foo', $result[0]->getName()); $this->assertEquals('Foo', $result[0]->getName());
@ -312,9 +315,9 @@ class DefaultQueryCacheTest extends OrmTestCase
$result = []; $result = [];
$key = new QueryCacheKey('query.key1', 0); $key = new QueryCacheKey('query.key1', 0);
$rsm = new ResultSetMappingBuilder($this->em); $rsm = new ResultSetMappingBuilder($this->em);
$metadata = $this->em->getClassMetadata(Country::CLASSNAME); $metadata = $this->em->getClassMetadata(Country::class);
$rsm->addRootEntityFromClassMetadata(Country::CLASSNAME, 'c'); $rsm->addRootEntityFromClassMetadata(Country::class, 'c');
for ($i = 0; $i < 4; $i++) { for ($i = 0; $i < 4; $i++) {
$name = "Country $i"; $name = "Country $i";
@ -338,11 +341,11 @@ class DefaultQueryCacheTest extends OrmTestCase
$uow = $this->em->getUnitOfWork(); $uow = $this->em->getUnitOfWork();
$key = new QueryCacheKey('query.key1', 0); $key = new QueryCacheKey('query.key1', 0);
$rsm = new ResultSetMappingBuilder($this->em); $rsm = new ResultSetMappingBuilder($this->em);
$cityClass = $this->em->getClassMetadata(City::CLASSNAME); $cityClass = $this->em->getClassMetadata(City::class);
$stateClass = $this->em->getClassMetadata(State::CLASSNAME); $stateClass = $this->em->getClassMetadata(State::class);
$rsm->addRootEntityFromClassMetadata(City::CLASSNAME, 'c'); $rsm->addRootEntityFromClassMetadata(City::class, 'c');
$rsm->addJoinedEntityFromClassMetadata(State::CLASSNAME, 's', 'c', 'state', ['id'=>'state_id', 'name'=>'state_name'] $rsm->addJoinedEntityFromClassMetadata(State::class, 's', 'c', 'state', ['id'=>'state_id', 'name'=>'state_name']
); );
$state = new State("State 1"); $state = new State("State 1");
@ -367,11 +370,11 @@ class DefaultQueryCacheTest extends OrmTestCase
$uow = $this->em->getUnitOfWork(); $uow = $this->em->getUnitOfWork();
$key = new QueryCacheKey('query.key1', 0); $key = new QueryCacheKey('query.key1', 0);
$rsm = new ResultSetMappingBuilder($this->em); $rsm = new ResultSetMappingBuilder($this->em);
$cityClass = $this->em->getClassMetadata(City::CLASSNAME); $cityClass = $this->em->getClassMetadata(City::class);
$stateClass = $this->em->getClassMetadata(State::CLASSNAME); $stateClass = $this->em->getClassMetadata(State::class);
$rsm->addRootEntityFromClassMetadata(State::CLASSNAME, 's'); $rsm->addRootEntityFromClassMetadata(State::class, 's');
$rsm->addJoinedEntityFromClassMetadata(City::CLASSNAME, 'c', 's', 'cities', ['id'=>'c_id', 'name'=>'c_name']); $rsm->addJoinedEntityFromClassMetadata(City::class, 'c', 's', 'cities', ['id'=>'c_id', 'name'=>'c_name']);
$state = new State("State"); $state = new State("State");
$city1 = new City("City 1", $state); $city1 = new City("City 1", $state);
@ -409,7 +412,7 @@ class DefaultQueryCacheTest extends OrmTestCase
] ]
); );
$rsm->addRootEntityFromClassMetadata(Country::CLASSNAME, 'c'); $rsm->addRootEntityFromClassMetadata(Country::class, 'c');
$this->region->addReturn('get', $entry); $this->region->addReturn('get', $entry);
@ -420,10 +423,10 @@ class DefaultQueryCacheTest extends OrmTestCase
{ {
$result = []; $result = [];
$rsm = new ResultSetMappingBuilder($this->em); $rsm = new ResultSetMappingBuilder($this->em);
$metadata = $this->em->getClassMetadata(Country::CLASSNAME); $metadata = $this->em->getClassMetadata(Country::class);
$key = new QueryCacheKey('query.key1', 0, Cache::MODE_GET); $key = new QueryCacheKey('query.key1', 0, Cache::MODE_GET);
$rsm->addRootEntityFromClassMetadata(Country::CLASSNAME, 'c'); $rsm->addRootEntityFromClassMetadata(Country::class, 'c');
for ($i = 0; $i < 4; $i++) { for ($i = 0; $i < 4; $i++) {
$name = "Country $i"; $name = "Country $i";
@ -455,10 +458,10 @@ class DefaultQueryCacheTest extends OrmTestCase
$entry->time = microtime(true) - 100; $entry->time = microtime(true) - 100;
$this->region->addReturn('get', $entry); $this->region->addReturn('get', $entry);
$this->region->addReturn('get', new EntityCacheEntry(Country::CLASSNAME, $entities[0])); $this->region->addReturn('get', new EntityCacheEntry(Country::class, $entities[0]));
$this->region->addReturn('get', new EntityCacheEntry(Country::CLASSNAME, $entities[1])); $this->region->addReturn('get', new EntityCacheEntry(Country::class, $entities[1]));
$rsm->addRootEntityFromClassMetadata(Country::CLASSNAME, 'c'); $rsm->addRootEntityFromClassMetadata(Country::class, 'c');
$this->assertNull($this->queryCache->get($key, $rsm)); $this->assertNull($this->queryCache->get($key, $rsm));
} }
@ -480,10 +483,10 @@ class DefaultQueryCacheTest extends OrmTestCase
]; ];
$this->region->addReturn('get', $entry); $this->region->addReturn('get', $entry);
$this->region->addReturn('get', new EntityCacheEntry(Country::CLASSNAME, $data[0])); $this->region->addReturn('get', new EntityCacheEntry(Country::class, $data[0]));
$this->region->addReturn('get', new EntityCacheEntry(Country::CLASSNAME, $data[1])); $this->region->addReturn('get', new EntityCacheEntry(Country::class, $data[1]));
$rsm->addRootEntityFromClassMetadata(Country::CLASSNAME, 'c'); $rsm->addRootEntityFromClassMetadata(Country::class, 'c');
$this->assertNull($this->queryCache->get($key, $rsm)); $this->assertNull($this->queryCache->get($key, $rsm));
} }
@ -502,7 +505,7 @@ class DefaultQueryCacheTest extends OrmTestCase
$this->region->addReturn('get', $entry); $this->region->addReturn('get', $entry);
$this->region->addReturn('get', null); $this->region->addReturn('get', null);
$rsm->addRootEntityFromClassMetadata(Country::CLASSNAME, 'c'); $rsm->addRootEntityFromClassMetadata(Country::class, 'c');
$this->assertNull($this->queryCache->get($key, $rsm)); $this->assertNull($this->queryCache->get($key, $rsm));
} }
@ -527,13 +530,13 @@ class DefaultQueryCacheTest extends OrmTestCase
$munich->addAttraction(new Restaurant('Schneider Weisse', $munich)); $munich->addAttraction(new Restaurant('Schneider Weisse', $munich));
$wurzburg->addAttraction(new Restaurant('Fischers Fritz', $wurzburg)); $wurzburg->addAttraction(new Restaurant('Fischers Fritz', $wurzburg));
$rsm->addRootEntityFromClassMetadata(State::CLASSNAME, 's'); $rsm->addRootEntityFromClassMetadata(State::class, 's');
$rsm->addJoinedEntityFromClassMetadata(City::CLASSNAME, 'c', 's', 'cities', [ $rsm->addJoinedEntityFromClassMetadata(City::class, 'c', 's', 'cities', [
'id' => 'c_id', 'id' => 'c_id',
'name' => 'c_name' 'name' => 'c_name'
] ]
); );
$rsm->addJoinedEntityFromClassMetadata(Restaurant::CLASSNAME, 'a', 'c', 'attractions', [ $rsm->addJoinedEntityFromClassMetadata(Restaurant::class, 'a', 'c', 'attractions', [
'id' => 'a_id', 'id' => 'a_id',
'name' => 'a_name' 'name' => 'a_name'
] ]
@ -545,9 +548,9 @@ class DefaultQueryCacheTest extends OrmTestCase
$this->assertCount(2, $cities); $this->assertCount(2, $cities);
$this->assertCount(2, $attractions); $this->assertCount(2, $attractions);
$this->assertInstanceOf('Doctrine\Common\Collections\Collection', $cities); $this->assertInstanceOf(Collection::class, $cities);
$this->assertInstanceOf('Doctrine\Common\Collections\Collection', $attractions[0]); $this->assertInstanceOf(Collection::class, $attractions[0]);
$this->assertInstanceOf('Doctrine\Common\Collections\Collection', $attractions[1]); $this->assertInstanceOf(Collection::class, $attractions[1]);
$this->assertCount(2, $attractions[0]); $this->assertCount(2, $attractions[0]);
$this->assertCount(1, $attractions[1]); $this->assertCount(1, $attractions[1]);
@ -578,8 +581,8 @@ class DefaultQueryCacheTest extends OrmTestCase
$key = new QueryCacheKey('query.key1', 0); $key = new QueryCacheKey('query.key1', 0);
$rsm = new ResultSetMappingBuilder($this->em); $rsm = new ResultSetMappingBuilder($this->em);
$rsm->addEntityResult('Doctrine\Tests\Models\Cache\City', 'e1'); $rsm->addEntityResult(City::class, 'e1');
$rsm->addEntityResult('Doctrine\Tests\Models\Cache\State', 'e2'); $rsm->addEntityResult(State::class, 'e2');
$this->queryCache->put($key, $rsm, $result); $this->queryCache->put($key, $rsm, $result);
} }
@ -593,9 +596,7 @@ class DefaultQueryCacheTest extends OrmTestCase
$result = []; $result = [];
$key = new QueryCacheKey('query.key1', 0); $key = new QueryCacheKey('query.key1', 0);
$rsm = new ResultSetMappingBuilder($this->em); $rsm = new ResultSetMappingBuilder($this->em);
$className = 'Doctrine\Tests\Models\Generic\BooleanModel'; $rsm->addRootEntityFromClassMetadata(BooleanModel::class, 'c');
$rsm->addRootEntityFromClassMetadata($className, 'c');
for ($i = 0; $i < 4; $i++) { for ($i = 0; $i < 4; $i++) {
$entity = new BooleanModel(); $entity = new BooleanModel();

View File

@ -2,15 +2,15 @@
namespace Doctrine\Tests\ORM\Cache; namespace Doctrine\Tests\ORM\Cache;
use Doctrine\ORM\Cache\CacheKey;
use Doctrine\ORM\Cache\ConcurrentRegion;
use Doctrine\ORM\Cache\Lock;
use Doctrine\ORM\Cache\Region\DefaultRegion; use Doctrine\ORM\Cache\Region\DefaultRegion;
use Doctrine\ORM\Cache\Region\FileLockRegion; use Doctrine\ORM\Cache\Region\FileLockRegion;
use Doctrine\ORM\Cache\ConcurrentRegion;
use Doctrine\Tests\Mocks\CacheEntryMock; use Doctrine\Tests\Mocks\CacheEntryMock;
use Doctrine\Tests\Mocks\CacheKeyMock; use Doctrine\Tests\Mocks\CacheKeyMock;
use Doctrine\ORM\Cache\CacheKey;
use RecursiveIteratorIterator;
use RecursiveDirectoryIterator; use RecursiveDirectoryIterator;
use RecursiveIteratorIterator;
/** /**
* @group DDC-2183 * @group DDC-2183
@ -77,7 +77,7 @@ class FileLockRegionTest extends AbstractRegionTest
$lock = $this->region->lock($key); $lock = $this->region->lock($key);
$this->assertFileExists($file); $this->assertFileExists($file);
$this->assertInstanceOf('Doctrine\ORM\Cache\Lock', $lock); $this->assertInstanceOf(Lock::class, $lock);
$this->assertEquals($lock->value, file_get_contents($file)); $this->assertEquals($lock->value, file_get_contents($file));
// should be not available after lock // should be not available after lock
@ -121,7 +121,7 @@ class FileLockRegionTest extends AbstractRegionTest
$this->assertTrue($this->region->put($key, $entry)); $this->assertTrue($this->region->put($key, $entry));
$this->assertTrue($this->region->contains($key)); $this->assertTrue($this->region->contains($key));
$this->assertInstanceOf('Doctrine\ORM\Cache\Lock', $lock = $this->region->lock($key)); $this->assertInstanceOf(Lock::class, $lock = $this->region->lock($key));
$this->assertEquals($lock->value, file_get_contents($file)); $this->assertEquals($lock->value, file_get_contents($file));
$this->assertFileExists($file); $this->assertFileExists($file);
@ -173,7 +173,7 @@ class FileLockRegionTest extends AbstractRegionTest
$this->assertTrue($this->region->put($key, $entry)); $this->assertTrue($this->region->put($key, $entry));
$this->assertTrue($this->region->contains($key)); $this->assertTrue($this->region->contains($key));
$this->assertInstanceOf('Doctrine\ORM\Cache\Lock', $lock = $this->region->lock($key)); $this->assertInstanceOf(Lock::class, $lock = $this->region->lock($key));
$this->assertEquals($lock->value, file_get_contents($file)); $this->assertEquals($lock->value, file_get_contents($file));
$this->assertFileExists($file); $this->assertFileExists($file);
@ -201,8 +201,8 @@ class FileLockRegionTest extends AbstractRegionTest
$this->assertTrue($this->region->put($key2, $entry2)); $this->assertTrue($this->region->put($key2, $entry2));
$this->assertTrue($this->region->contains($key2)); $this->assertTrue($this->region->contains($key2));
$this->assertInstanceOf('Doctrine\ORM\Cache\Lock', $lock1 = $this->region->lock($key1)); $this->assertInstanceOf(Lock::class, $lock1 = $this->region->lock($key1));
$this->assertInstanceOf('Doctrine\ORM\Cache\Lock', $lock2 = $this->region->lock($key2)); $this->assertInstanceOf(Lock::class, $lock2 = $this->region->lock($key2));
$this->assertEquals($lock2->value, file_get_contents($file2)); $this->assertEquals($lock2->value, file_get_contents($file2));
$this->assertEquals($lock1->value, file_get_contents($file1)); $this->assertEquals($lock1->value, file_get_contents($file1));
@ -233,7 +233,7 @@ class FileLockRegionTest extends AbstractRegionTest
$this->assertTrue($this->region->put($key, $entry)); $this->assertTrue($this->region->put($key, $entry));
$this->assertTrue($this->region->contains($key)); $this->assertTrue($this->region->contains($key));
$this->assertInstanceOf('Doctrine\ORM\Cache\Lock', $lock = $this->region->lock($key)); $this->assertInstanceOf(Lock::class, $lock = $this->region->lock($key));
$this->assertEquals($lock->value, file_get_contents($file)); $this->assertEquals($lock->value, file_get_contents($file));
$this->assertFileExists($file); $this->assertFileExists($file);

View File

@ -2,6 +2,8 @@
namespace Doctrine\Tests\ORM\Cache\Persister\Collection; namespace Doctrine\Tests\ORM\Cache\Persister\Collection;
use Doctrine\ORM\Cache\Persister\CachedPersister;
use Doctrine\ORM\Cache\Persister\Collection\CachedCollectionPersister;
use Doctrine\ORM\PersistentCollection; use Doctrine\ORM\PersistentCollection;
use Doctrine\Tests\OrmTestCase; use Doctrine\Tests\OrmTestCase;
@ -101,7 +103,7 @@ abstract class AbstractCollectionPersisterTest extends OrmTestCase
protected function createCollection($owner, $assoc = null, $class = null, $elements = null) protected function createCollection($owner, $assoc = null, $class = null, $elements = null)
{ {
$em = $this->em; $em = $this->em;
$class = $class ?: $this->em->getClassMetadata('Doctrine\Tests\Models\Cache\State'); $class = $class ?: $this->em->getClassMetadata(State::class);
$assoc = $assoc ?: $class->associationMappings['cities']; $assoc = $assoc ?: $class->associationMappings['cities'];
$coll = new PersistentCollection($em, $class, $elements ?: new ArrayCollection); $coll = new PersistentCollection($em, $class, $elements ?: new ArrayCollection);
@ -113,7 +115,7 @@ abstract class AbstractCollectionPersisterTest extends OrmTestCase
protected function createPersisterDefault() protected function createPersisterDefault()
{ {
$assoc = $this->em->getClassMetadata('Doctrine\Tests\Models\Cache\State')->associationMappings['cities']; $assoc = $this->em->getClassMetadata(State::class)->associationMappings['cities'];
return $this->createPersister($this->em, $this->collectionPersister, $this->region, $assoc); return $this->createPersister($this->em, $this->collectionPersister, $this->region, $assoc);
} }
@ -122,9 +124,9 @@ abstract class AbstractCollectionPersisterTest extends OrmTestCase
{ {
$persister = $this->createPersisterDefault(); $persister = $this->createPersisterDefault();
$this->assertInstanceOf('Doctrine\ORM\Persisters\Collection\CollectionPersister', $persister); $this->assertInstanceOf(CollectionPersister::class, $persister);
$this->assertInstanceOf('Doctrine\ORM\Cache\Persister\CachedPersister', $persister); $this->assertInstanceOf(CachedPersister::class, $persister);
$this->assertInstanceOf('Doctrine\ORM\Cache\Persister\Collection\CachedCollectionPersister', $persister); $this->assertInstanceOf(CachedCollectionPersister::class, $persister);
} }
public function testInvokeDelete() public function testInvokeDelete()

View File

@ -52,7 +52,7 @@ class ReadWriteCachedCollectionPersisterTest extends AbstractCollectionPersister
$lock = Lock::createLockRead(); $lock = Lock::createLockRead();
$persister = $this->createPersisterDefault(); $persister = $this->createPersisterDefault();
$collection = $this->createCollection($entity); $collection = $this->createCollection($entity);
$key = new CollectionCacheKey(State::CLASSNAME, 'cities', ['id'=>1]); $key = new CollectionCacheKey(State::class, 'cities', ['id'=>1]);
$this->region->expects($this->once()) $this->region->expects($this->once())
->method('lock') ->method('lock')
@ -70,7 +70,7 @@ class ReadWriteCachedCollectionPersisterTest extends AbstractCollectionPersister
$lock = Lock::createLockRead(); $lock = Lock::createLockRead();
$persister = $this->createPersisterDefault(); $persister = $this->createPersisterDefault();
$collection = $this->createCollection($entity); $collection = $this->createCollection($entity);
$key = new CollectionCacheKey(State::CLASSNAME, 'cities', ['id'=>1]); $key = new CollectionCacheKey(State::class, 'cities', ['id'=>1]);
$this->region->expects($this->once()) $this->region->expects($this->once())
->method('lock') ->method('lock')
@ -88,7 +88,7 @@ class ReadWriteCachedCollectionPersisterTest extends AbstractCollectionPersister
$lock = Lock::createLockRead(); $lock = Lock::createLockRead();
$persister = $this->createPersisterDefault(); $persister = $this->createPersisterDefault();
$collection = $this->createCollection($entity); $collection = $this->createCollection($entity);
$key = new CollectionCacheKey(State::CLASSNAME, 'cities', ['id'=>1]); $key = new CollectionCacheKey(State::class, 'cities', ['id'=>1]);
$this->region->expects($this->once()) $this->region->expects($this->once())
->method('lock') ->method('lock')
@ -112,7 +112,7 @@ class ReadWriteCachedCollectionPersisterTest extends AbstractCollectionPersister
$lock = Lock::createLockRead(); $lock = Lock::createLockRead();
$persister = $this->createPersisterDefault(); $persister = $this->createPersisterDefault();
$collection = $this->createCollection($entity); $collection = $this->createCollection($entity);
$key = new CollectionCacheKey(State::CLASSNAME, 'cities', ['id'=>1]); $key = new CollectionCacheKey(State::class, 'cities', ['id'=>1]);
$this->region->expects($this->once()) $this->region->expects($this->once())
->method('lock') ->method('lock')
@ -135,8 +135,8 @@ class ReadWriteCachedCollectionPersisterTest extends AbstractCollectionPersister
$lock = Lock::createLockRead(); $lock = Lock::createLockRead();
$persister = $this->createPersisterDefault(); $persister = $this->createPersisterDefault();
$collection = $this->createCollection($entity); $collection = $this->createCollection($entity);
$key = new CollectionCacheKey(State::CLASSNAME, 'cities', ['id'=>1]); $key = new CollectionCacheKey(State::class, 'cities', ['id'=>1]);
$property = new \ReflectionProperty('Doctrine\ORM\Cache\Persister\Collection\ReadWriteCachedCollectionPersister', 'queuedCache'); $property = new \ReflectionProperty(ReadWriteCachedCollectionPersister::class, 'queuedCache');
$property->setAccessible(true); $property->setAccessible(true);
@ -166,8 +166,8 @@ class ReadWriteCachedCollectionPersisterTest extends AbstractCollectionPersister
$lock = Lock::createLockRead(); $lock = Lock::createLockRead();
$persister = $this->createPersisterDefault(); $persister = $this->createPersisterDefault();
$collection = $this->createCollection($entity); $collection = $this->createCollection($entity);
$key = new CollectionCacheKey(State::CLASSNAME, 'cities', ['id'=>1]); $key = new CollectionCacheKey(State::class, 'cities', ['id'=>1]);
$property = new \ReflectionProperty('Doctrine\ORM\Cache\Persister\Collection\ReadWriteCachedCollectionPersister', 'queuedCache'); $property = new \ReflectionProperty(ReadWriteCachedCollectionPersister::class, 'queuedCache');
$property->setAccessible(true); $property->setAccessible(true);
@ -197,8 +197,8 @@ class ReadWriteCachedCollectionPersisterTest extends AbstractCollectionPersister
$lock = Lock::createLockRead(); $lock = Lock::createLockRead();
$persister = $this->createPersisterDefault(); $persister = $this->createPersisterDefault();
$collection = $this->createCollection($entity); $collection = $this->createCollection($entity);
$key = new CollectionCacheKey(State::CLASSNAME, 'cities', ['id'=>1]); $key = new CollectionCacheKey(State::class, 'cities', ['id'=>1]);
$property = new \ReflectionProperty('Doctrine\ORM\Cache\Persister\Collection\ReadWriteCachedCollectionPersister', 'queuedCache'); $property = new \ReflectionProperty(ReadWriteCachedCollectionPersister::class, 'queuedCache');
$property->setAccessible(true); $property->setAccessible(true);
@ -228,8 +228,8 @@ class ReadWriteCachedCollectionPersisterTest extends AbstractCollectionPersister
$lock = Lock::createLockRead(); $lock = Lock::createLockRead();
$persister = $this->createPersisterDefault(); $persister = $this->createPersisterDefault();
$collection = $this->createCollection($entity); $collection = $this->createCollection($entity);
$key = new CollectionCacheKey(State::CLASSNAME, 'cities', ['id'=>1]); $key = new CollectionCacheKey(State::class, 'cities', ['id'=>1]);
$property = new \ReflectionProperty('Doctrine\ORM\Cache\Persister\Collection\ReadWriteCachedCollectionPersister', 'queuedCache'); $property = new \ReflectionProperty(ReadWriteCachedCollectionPersister::class, 'queuedCache');
$property->setAccessible(true); $property->setAccessible(true);
@ -258,8 +258,8 @@ class ReadWriteCachedCollectionPersisterTest extends AbstractCollectionPersister
$entity = new State("Foo"); $entity = new State("Foo");
$persister = $this->createPersisterDefault(); $persister = $this->createPersisterDefault();
$collection = $this->createCollection($entity); $collection = $this->createCollection($entity);
$key = new CollectionCacheKey(State::CLASSNAME, 'cities', ['id'=>1]); $key = new CollectionCacheKey(State::class, 'cities', ['id'=>1]);
$property = new \ReflectionProperty('Doctrine\ORM\Cache\Persister\Collection\ReadWriteCachedCollectionPersister', 'queuedCache'); $property = new \ReflectionProperty(ReadWriteCachedCollectionPersister::class, 'queuedCache');
$property->setAccessible(true); $property->setAccessible(true);
@ -283,8 +283,8 @@ class ReadWriteCachedCollectionPersisterTest extends AbstractCollectionPersister
$entity = new State("Foo"); $entity = new State("Foo");
$persister = $this->createPersisterDefault(); $persister = $this->createPersisterDefault();
$collection = $this->createCollection($entity); $collection = $this->createCollection($entity);
$key = new CollectionCacheKey(State::CLASSNAME, 'cities', ['id'=>1]); $key = new CollectionCacheKey(State::class, 'cities', ['id'=>1]);
$property = new \ReflectionProperty('Doctrine\ORM\Cache\Persister\Collection\ReadWriteCachedCollectionPersister', 'queuedCache'); $property = new \ReflectionProperty(ReadWriteCachedCollectionPersister::class, 'queuedCache');
$property->setAccessible(true); $property->setAccessible(true);

View File

@ -2,18 +2,18 @@
namespace Doctrine\Tests\ORM\Cache\Persister\Entity; namespace Doctrine\Tests\ORM\Cache\Persister\Entity;
use Doctrine\Tests\OrmTestCase; use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Criteria;
use Doctrine\ORM\Cache\Persister\CachedPersister;
use Doctrine\ORM\Cache\Persister\Entity\CachedEntityPersister;
use Doctrine\ORM\Cache\Region; use Doctrine\ORM\Cache\Region;
use Doctrine\ORM\EntityManager; use Doctrine\ORM\EntityManager;
use Doctrine\ORM\Mapping\ClassMetadata; use Doctrine\ORM\Mapping\ClassMetadata;
use Doctrine\ORM\Persisters\Entity\EntityPersister;
use Doctrine\Tests\Models\Cache\Country;
use Doctrine\Common\Collections\Criteria;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\ORM\Query\ResultSetMappingBuilder;
use Doctrine\ORM\PersistentCollection; use Doctrine\ORM\PersistentCollection;
use Doctrine\ORM\Persisters\Entity\EntityPersister;
use Doctrine\ORM\Query\ResultSetMappingBuilder;
use Doctrine\Tests\Models\Cache\Country;
use Doctrine\Tests\OrmTestCase;
/** /**
* @group DDC-2183 * @group DDC-2183
@ -119,16 +119,16 @@ abstract class AbstractEntityPersisterTest extends OrmTestCase
*/ */
protected function createPersisterDefault() protected function createPersisterDefault()
{ {
return $this->createPersister($this->em, $this->entityPersister, $this->region, $this->em->getClassMetadata('Doctrine\Tests\Models\Cache\Country')); return $this->createPersister($this->em, $this->entityPersister, $this->region, $this->em->getClassMetadata(Country::class));
} }
public function testImplementsEntityPersister() public function testImplementsEntityPersister()
{ {
$persister = $this->createPersisterDefault(); $persister = $this->createPersisterDefault();
$this->assertInstanceOf('Doctrine\ORM\Persisters\Entity\EntityPersister', $persister); $this->assertInstanceOf(EntityPersister::class, $persister);
$this->assertInstanceOf('Doctrine\ORM\Cache\Persister\CachedPersister', $persister); $this->assertInstanceOf(CachedPersister::class, $persister);
$this->assertInstanceOf('Doctrine\ORM\Cache\Persister\Entity\CachedEntityPersister', $persister); $this->assertInstanceOf(CachedEntityPersister::class, $persister);
} }
public function testInvokeAddInsert() public function testInvokeAddInsert()
@ -293,7 +293,7 @@ abstract class AbstractEntityPersisterTest extends OrmTestCase
$persister = $this->createPersisterDefault(); $persister = $this->createPersisterDefault();
$entity = new Country("Foo"); $entity = new Country("Foo");
$rsm->addEntityResult(Country::CLASSNAME, 'c'); $rsm->addEntityResult(Country::class, 'c');
$this->em->getUnitOfWork()->registerManaged($entity, ['id'=>1], ['id'=>1, 'name'=>'Foo']); $this->em->getUnitOfWork()->registerManaged($entity, ['id'=>1], ['id'=>1, 'name'=>'Foo']);
@ -356,7 +356,7 @@ abstract class AbstractEntityPersisterTest extends OrmTestCase
$criteria = new Criteria(); $criteria = new Criteria();
$this->em->getUnitOfWork()->registerManaged($entity, ['id'=>1], ['id'=>1, 'name'=>'Foo']); $this->em->getUnitOfWork()->registerManaged($entity, ['id'=>1], ['id'=>1, 'name'=>'Foo']);
$rsm->addEntityResult(Country::CLASSNAME, 'c'); $rsm->addEntityResult(Country::class, 'c');
$this->entityPersister->expects($this->once()) $this->entityPersister->expects($this->once())
->method('getResultSetMapping') ->method('getResultSetMapping')
@ -398,7 +398,7 @@ abstract class AbstractEntityPersisterTest extends OrmTestCase
public function testInvokeLoadManyToManyCollection() public function testInvokeLoadManyToManyCollection()
{ {
$mapping = $this->em->getClassMetadata('Doctrine\Tests\Models\Cache\Country'); $mapping = $this->em->getClassMetadata(Country::class);
$assoc = ['type' => 1]; $assoc = ['type' => 1];
$coll = new PersistentCollection($this->em, $mapping, new ArrayCollection()); $coll = new PersistentCollection($this->em, $mapping, new ArrayCollection());
$persister = $this->createPersisterDefault(); $persister = $this->createPersisterDefault();
@ -414,7 +414,7 @@ abstract class AbstractEntityPersisterTest extends OrmTestCase
public function testInvokeLoadOneToManyCollection() public function testInvokeLoadOneToManyCollection()
{ {
$mapping = $this->em->getClassMetadata('Doctrine\Tests\Models\Cache\Country'); $mapping = $this->em->getClassMetadata(Country::class);
$assoc = ['type' => 1]; $assoc = ['type' => 1];
$coll = new PersistentCollection($this->em, $mapping, new ArrayCollection()); $coll = new PersistentCollection($this->em, $mapping, new ArrayCollection());
$persister = $this->createPersisterDefault(); $persister = $this->createPersisterDefault();

View File

@ -48,8 +48,8 @@ class NonStrictReadWriteCachedEntityPersisterTest extends AbstractEntityPersiste
{ {
$entity = new Country("Foo"); $entity = new Country("Foo");
$persister = $this->createPersisterDefault(); $persister = $this->createPersisterDefault();
$key = new EntityCacheKey(Country::CLASSNAME, ['id'=>1]); $key = new EntityCacheKey(Country::class, ['id'=>1]);
$entry = new EntityCacheEntry(Country::CLASSNAME, ['id'=>1, 'name'=>'Foo']); $entry = new EntityCacheEntry(Country::class, ['id'=>1, 'name'=>'Foo']);
$property = new \ReflectionProperty($persister, 'queuedCache'); $property = new \ReflectionProperty($persister, 'queuedCache');
$property->setAccessible(true); $property->setAccessible(true);
@ -85,8 +85,8 @@ class NonStrictReadWriteCachedEntityPersisterTest extends AbstractEntityPersiste
{ {
$entity = new Country("Foo"); $entity = new Country("Foo");
$persister = $this->createPersisterDefault(); $persister = $this->createPersisterDefault();
$key = new EntityCacheKey(Country::CLASSNAME, ['id'=>1]); $key = new EntityCacheKey(Country::class, ['id'=>1]);
$entry = new EntityCacheEntry(Country::CLASSNAME, ['id'=>1, 'name'=>'Foo']); $entry = new EntityCacheEntry(Country::class, ['id'=>1, 'name'=>'Foo']);
$property = new \ReflectionProperty($persister, 'queuedCache'); $property = new \ReflectionProperty($persister, 'queuedCache');
$property->setAccessible(true); $property->setAccessible(true);
@ -114,7 +114,7 @@ class NonStrictReadWriteCachedEntityPersisterTest extends AbstractEntityPersiste
{ {
$entity = new Country("Foo"); $entity = new Country("Foo");
$persister = $this->createPersisterDefault(); $persister = $this->createPersisterDefault();
$key = new EntityCacheKey(Country::CLASSNAME, ['id'=>1]); $key = new EntityCacheKey(Country::class, ['id'=>1]);
$property = new \ReflectionProperty($persister, 'queuedCache'); $property = new \ReflectionProperty($persister, 'queuedCache');
$property->setAccessible(true); $property->setAccessible(true);

View File

@ -52,7 +52,7 @@ class ReadWriteCachedEntityPersisterTest extends AbstractEntityPersisterTest
$entity = new Country("Foo"); $entity = new Country("Foo");
$lock = Lock::createLockRead(); $lock = Lock::createLockRead();
$persister = $this->createPersisterDefault(); $persister = $this->createPersisterDefault();
$key = new EntityCacheKey(Country::CLASSNAME, ['id'=>1]); $key = new EntityCacheKey(Country::class, ['id'=>1]);
$this->region->expects($this->once()) $this->region->expects($this->once())
->method('lock') ->method('lock')
@ -69,7 +69,7 @@ class ReadWriteCachedEntityPersisterTest extends AbstractEntityPersisterTest
$entity = new Country("Foo"); $entity = new Country("Foo");
$lock = Lock::createLockRead(); $lock = Lock::createLockRead();
$persister = $this->createPersisterDefault(); $persister = $this->createPersisterDefault();
$key = new EntityCacheKey(Country::CLASSNAME, ['id'=>1]); $key = new EntityCacheKey(Country::class, ['id'=>1]);
$this->region->expects($this->once()) $this->region->expects($this->once())
->method('lock') ->method('lock')
@ -86,7 +86,7 @@ class ReadWriteCachedEntityPersisterTest extends AbstractEntityPersisterTest
$entity = new Country("Foo"); $entity = new Country("Foo");
$lock = Lock::createLockRead(); $lock = Lock::createLockRead();
$persister = $this->createPersisterDefault(); $persister = $this->createPersisterDefault();
$key = new EntityCacheKey(Country::CLASSNAME, ['id'=>1]); $key = new EntityCacheKey(Country::class, ['id'=>1]);
$this->region->expects($this->once()) $this->region->expects($this->once())
->method('lock') ->method('lock')
@ -109,7 +109,7 @@ class ReadWriteCachedEntityPersisterTest extends AbstractEntityPersisterTest
$entity = new Country("Foo"); $entity = new Country("Foo");
$lock = Lock::createLockRead(); $lock = Lock::createLockRead();
$persister = $this->createPersisterDefault(); $persister = $this->createPersisterDefault();
$key = new EntityCacheKey(Country::CLASSNAME, ['id'=>1]); $key = new EntityCacheKey(Country::class, ['id'=>1]);
$this->region->expects($this->once()) $this->region->expects($this->once())
->method('lock') ->method('lock')
@ -131,8 +131,8 @@ class ReadWriteCachedEntityPersisterTest extends AbstractEntityPersisterTest
$entity = new Country("Foo"); $entity = new Country("Foo");
$lock = Lock::createLockRead(); $lock = Lock::createLockRead();
$persister = $this->createPersisterDefault(); $persister = $this->createPersisterDefault();
$key = new EntityCacheKey(Country::CLASSNAME, ['id'=>1]); $key = new EntityCacheKey(Country::class, ['id'=>1]);
$property = new \ReflectionProperty('Doctrine\ORM\Cache\Persister\Entity\ReadWriteCachedEntityPersister', 'queuedCache'); $property = new \ReflectionProperty(ReadWriteCachedEntityPersister::class, 'queuedCache');
$property->setAccessible(true); $property->setAccessible(true);
@ -162,8 +162,8 @@ class ReadWriteCachedEntityPersisterTest extends AbstractEntityPersisterTest
$entity = new Country("Foo"); $entity = new Country("Foo");
$lock = Lock::createLockRead(); $lock = Lock::createLockRead();
$persister = $this->createPersisterDefault(); $persister = $this->createPersisterDefault();
$key = new EntityCacheKey(Country::CLASSNAME, ['id'=>1]); $key = new EntityCacheKey(Country::class, ['id'=>1]);
$property = new \ReflectionProperty('Doctrine\ORM\Cache\Persister\Entity\ReadWriteCachedEntityPersister', 'queuedCache'); $property = new \ReflectionProperty(ReadWriteCachedEntityPersister::class, 'queuedCache');
$property->setAccessible(true); $property->setAccessible(true);
@ -192,8 +192,8 @@ class ReadWriteCachedEntityPersisterTest extends AbstractEntityPersisterTest
{ {
$entity = new Country("Foo"); $entity = new Country("Foo");
$persister = $this->createPersisterDefault(); $persister = $this->createPersisterDefault();
$key = new EntityCacheKey(Country::CLASSNAME, ['id'=>1]); $key = new EntityCacheKey(Country::class, ['id'=>1]);
$property = new \ReflectionProperty('Doctrine\ORM\Cache\Persister\Entity\ReadWriteCachedEntityPersister', 'queuedCache'); $property = new \ReflectionProperty(ReadWriteCachedEntityPersister::class, 'queuedCache');
$property->setAccessible(true); $property->setAccessible(true);
@ -216,8 +216,8 @@ class ReadWriteCachedEntityPersisterTest extends AbstractEntityPersisterTest
{ {
$entity = new Country("Foo"); $entity = new Country("Foo");
$persister = $this->createPersisterDefault(); $persister = $this->createPersisterDefault();
$key = new EntityCacheKey(Country::CLASSNAME, ['id'=>1]); $key = new EntityCacheKey(Country::class, ['id'=>1]);
$property = new \ReflectionProperty('Doctrine\ORM\Cache\Persister\Entity\ReadWriteCachedEntityPersister', 'queuedCache'); $property = new \ReflectionProperty(ReadWriteCachedEntityPersister::class, 'queuedCache');
$property->setAccessible(true); $property->setAccessible(true);

View File

@ -29,7 +29,7 @@ class StatisticsCacheLoggerTest extends DoctrineTestCase
public function testEntityCache() public function testEntityCache()
{ {
$name = 'my_entity_region'; $name = 'my_entity_region';
$key = new EntityCacheKey(State::CLASSNAME, ['id' => 1]); $key = new EntityCacheKey(State::class, ['id' => 1]);
$this->logger->entityCacheHit($name, $key); $this->logger->entityCacheHit($name, $key);
$this->logger->entityCachePut($name, $key); $this->logger->entityCachePut($name, $key);
@ -46,7 +46,7 @@ class StatisticsCacheLoggerTest extends DoctrineTestCase
public function testCollectionCache() public function testCollectionCache()
{ {
$name = 'my_collection_region'; $name = 'my_collection_region';
$key = new CollectionCacheKey(State::CLASSNAME, 'cities', ['id' => 1]); $key = new CollectionCacheKey(State::class, 'cities', ['id' => 1]);
$this->logger->collectionCacheHit($name, $key); $this->logger->collectionCacheHit($name, $key);
$this->logger->collectionCachePut($name, $key); $this->logger->collectionCachePut($name, $key);
@ -83,8 +83,8 @@ class StatisticsCacheLoggerTest extends DoctrineTestCase
$entityRegion = 'my_entity_region'; $entityRegion = 'my_entity_region';
$queryRegion = 'my_query_region'; $queryRegion = 'my_query_region';
$coolKey = new CollectionCacheKey(State::CLASSNAME, 'cities', ['id' => 1]); $coolKey = new CollectionCacheKey(State::class, 'cities', ['id' => 1]);
$entityKey = new EntityCacheKey(State::CLASSNAME, ['id' => 1]); $entityKey = new EntityCacheKey(State::class, ['id' => 1]);
$queryKey = new QueryCacheKey('my_query_hash'); $queryKey = new QueryCacheKey('my_query_hash');
$this->logger->queryCacheHit($queryRegion, $queryKey); $this->logger->queryCacheHit($queryRegion, $queryKey);

View File

@ -24,11 +24,11 @@ class CommitOrderCalculatorTest extends OrmTestCase
public function testCommitOrdering1() public function testCommitOrdering1()
{ {
$class1 = new ClassMetadata(__NAMESPACE__ . '\NodeClass1'); $class1 = new ClassMetadata(NodeClass1::class);
$class2 = new ClassMetadata(__NAMESPACE__ . '\NodeClass2'); $class2 = new ClassMetadata(NodeClass2::class);
$class3 = new ClassMetadata(__NAMESPACE__ . '\NodeClass3'); $class3 = new ClassMetadata(NodeClass3::class);
$class4 = new ClassMetadata(__NAMESPACE__ . '\NodeClass4'); $class4 = new ClassMetadata(NodeClass4::class);
$class5 = new ClassMetadata(__NAMESPACE__ . '\NodeClass5'); $class5 = new ClassMetadata(NodeClass5::class);
$this->_calc->addNode($class1->name, $class1); $this->_calc->addNode($class1->name, $class1);
$this->_calc->addNode($class2->name, $class2); $this->_calc->addNode($class2->name, $class2);
@ -51,8 +51,8 @@ class CommitOrderCalculatorTest extends OrmTestCase
public function testCommitOrdering2() public function testCommitOrdering2()
{ {
$class1 = new ClassMetadata(__NAMESPACE__ . '\NodeClass1'); $class1 = new ClassMetadata(NodeClass1::class);
$class2 = new ClassMetadata(__NAMESPACE__ . '\NodeClass2'); $class2 = new ClassMetadata(NodeClass2::class);
$this->_calc->addNode($class1->name, $class1); $this->_calc->addNode($class1->name, $class1);
$this->_calc->addNode($class2->name, $class2); $this->_calc->addNode($class2->name, $class2);

View File

@ -7,6 +7,7 @@ use Doctrine\Common\Persistence\Mapping\Driver\MappingDriver;
use Doctrine\Common\Proxy\AbstractProxyFactory; use Doctrine\Common\Proxy\AbstractProxyFactory;
use Doctrine\Common\Cache\ArrayCache; use Doctrine\Common\Cache\ArrayCache;
use Doctrine\ORM\Cache\CacheConfiguration; use Doctrine\ORM\Cache\CacheConfiguration;
use Doctrine\ORM\EntityRepository;
use Doctrine\ORM\Mapping as AnnotationNamespace; use Doctrine\ORM\Mapping as AnnotationNamespace;
use Doctrine\ORM\Configuration; use Doctrine\ORM\Configuration;
use Doctrine\ORM\Mapping\EntityListenerResolver; use Doctrine\ORM\Mapping\EntityListenerResolver;
@ -14,6 +15,7 @@ use Doctrine\ORM\Mapping\NamingStrategy;
use Doctrine\ORM\Mapping\QuoteStrategy; use Doctrine\ORM\Mapping\QuoteStrategy;
use Doctrine\ORM\ORMException; use Doctrine\ORM\ORMException;
use Doctrine\ORM\Query\ResultSetMapping; use Doctrine\ORM\Query\ResultSetMapping;
use Doctrine\Tests\Models\DDC753\DDC753CustomRepository;
use ReflectionClass; use ReflectionClass;
use PHPUnit_Framework_TestCase; use PHPUnit_Framework_TestCase;
@ -76,23 +78,23 @@ class ConfigurationTest extends PHPUnit_Framework_TestCase
public function testNewDefaultAnnotationDriver() public function testNewDefaultAnnotationDriver()
{ {
$paths = [__DIR__]; $paths = [__DIR__];
$reflectionClass = new ReflectionClass(__NAMESPACE__ . '\ConfigurationTestAnnotationReaderChecker'); $reflectionClass = new ReflectionClass(ConfigurationTestAnnotationReaderChecker::class);
$annotationDriver = $this->configuration->newDefaultAnnotationDriver($paths, false); $annotationDriver = $this->configuration->newDefaultAnnotationDriver($paths, false);
$reader = $annotationDriver->getReader(); $reader = $annotationDriver->getReader();
$annotation = $reader->getMethodAnnotation( $annotation = $reader->getMethodAnnotation(
$reflectionClass->getMethod('namespacedAnnotationMethod'), $reflectionClass->getMethod('namespacedAnnotationMethod'),
'Doctrine\ORM\Mapping\PrePersist' AnnotationNamespace\PrePersist::class
); );
$this->assertInstanceOf('Doctrine\ORM\Mapping\PrePersist', $annotation); $this->assertInstanceOf(AnnotationNamespace\PrePersist::class, $annotation);
$annotationDriver = $this->configuration->newDefaultAnnotationDriver($paths); $annotationDriver = $this->configuration->newDefaultAnnotationDriver($paths);
$reader = $annotationDriver->getReader(); $reader = $annotationDriver->getReader();
$annotation = $reader->getMethodAnnotation( $annotation = $reader->getMethodAnnotation(
$reflectionClass->getMethod('simpleAnnotationMethod'), $reflectionClass->getMethod('simpleAnnotationMethod'),
'Doctrine\ORM\Mapping\PrePersist' AnnotationNamespace\PrePersist::class
); );
$this->assertInstanceOf('Doctrine\ORM\Mapping\PrePersist', $annotation); $this->assertInstanceOf(AnnotationNamespace\PrePersist::class, $annotation);
} }
public function testSetGetEntityNamespace() public function testSetGetEntityNamespace()
@ -102,7 +104,7 @@ class ConfigurationTest extends PHPUnit_Framework_TestCase
$namespaces = ['OtherNamespace' => __NAMESPACE__]; $namespaces = ['OtherNamespace' => __NAMESPACE__];
$this->configuration->setEntityNamespaces($namespaces); $this->configuration->setEntityNamespaces($namespaces);
$this->assertSame($namespaces, $this->configuration->getEntityNamespaces()); $this->assertSame($namespaces, $this->configuration->getEntityNamespaces());
$this->expectException(\Doctrine\ORM\ORMException::class); $this->expectException(ORMException::class);
$this->configuration->getEntityNamespace('NonExistingNamespace'); $this->configuration->getEntityNamespace('NonExistingNamespace');
} }
@ -135,7 +137,7 @@ class ConfigurationTest extends PHPUnit_Framework_TestCase
$dql = 'SELECT u FROM User u'; $dql = 'SELECT u FROM User u';
$this->configuration->addNamedQuery('QueryName', $dql); $this->configuration->addNamedQuery('QueryName', $dql);
$this->assertSame($dql, $this->configuration->getNamedQuery('QueryName')); $this->assertSame($dql, $this->configuration->getNamedQuery('QueryName'));
$this->expectException(\Doctrine\ORM\ORMException::class); $this->expectException(ORMException::class);
$this->expectExceptionMessage('a named query'); $this->expectExceptionMessage('a named query');
$this->configuration->getNamedQuery('NonExistingQuery'); $this->configuration->getNamedQuery('NonExistingQuery');
} }
@ -148,7 +150,7 @@ class ConfigurationTest extends PHPUnit_Framework_TestCase
$fetched = $this->configuration->getNamedNativeQuery('QueryName'); $fetched = $this->configuration->getNamedNativeQuery('QueryName');
$this->assertSame($sql, $fetched[0]); $this->assertSame($sql, $fetched[0]);
$this->assertSame($rsm, $fetched[1]); $this->assertSame($rsm, $fetched[1]);
$this->expectException(\Doctrine\ORM\ORMException::class); $this->expectException(ORMException::class);
$this->expectExceptionMessage('a named native query'); $this->expectExceptionMessage('a named native query');
$this->configuration->getNamedNativeQuery('NonExistingQuery'); $this->configuration->getNamedNativeQuery('NonExistingQuery');
} }
@ -261,7 +263,7 @@ class ConfigurationTest extends PHPUnit_Framework_TestCase
$this->assertSame(null, $this->configuration->getCustomStringFunction('NonExistingFunction')); $this->assertSame(null, $this->configuration->getCustomStringFunction('NonExistingFunction'));
$this->configuration->setCustomStringFunctions(['OtherFunctionName' => __CLASS__]); $this->configuration->setCustomStringFunctions(['OtherFunctionName' => __CLASS__]);
$this->assertSame(__CLASS__, $this->configuration->getCustomStringFunction('OtherFunctionName')); $this->assertSame(__CLASS__, $this->configuration->getCustomStringFunction('OtherFunctionName'));
$this->expectException(\Doctrine\ORM\ORMException::class); $this->expectException(ORMException::class);
$this->configuration->addCustomStringFunction('concat', __CLASS__); $this->configuration->addCustomStringFunction('concat', __CLASS__);
} }
@ -272,7 +274,7 @@ class ConfigurationTest extends PHPUnit_Framework_TestCase
$this->assertSame(null, $this->configuration->getCustomNumericFunction('NonExistingFunction')); $this->assertSame(null, $this->configuration->getCustomNumericFunction('NonExistingFunction'));
$this->configuration->setCustomNumericFunctions(['OtherFunctionName' => __CLASS__]); $this->configuration->setCustomNumericFunctions(['OtherFunctionName' => __CLASS__]);
$this->assertSame(__CLASS__, $this->configuration->getCustomNumericFunction('OtherFunctionName')); $this->assertSame(__CLASS__, $this->configuration->getCustomNumericFunction('OtherFunctionName'));
$this->expectException(\Doctrine\ORM\ORMException::class); $this->expectException(ORMException::class);
$this->configuration->addCustomNumericFunction('abs', __CLASS__); $this->configuration->addCustomNumericFunction('abs', __CLASS__);
} }
@ -283,7 +285,7 @@ class ConfigurationTest extends PHPUnit_Framework_TestCase
$this->assertSame(null, $this->configuration->getCustomDatetimeFunction('NonExistingFunction')); $this->assertSame(null, $this->configuration->getCustomDatetimeFunction('NonExistingFunction'));
$this->configuration->setCustomDatetimeFunctions(['OtherFunctionName' => __CLASS__]); $this->configuration->setCustomDatetimeFunctions(['OtherFunctionName' => __CLASS__]);
$this->assertSame(__CLASS__, $this->configuration->getCustomDatetimeFunction('OtherFunctionName')); $this->assertSame(__CLASS__, $this->configuration->getCustomDatetimeFunction('OtherFunctionName'));
$this->expectException(\Doctrine\ORM\ORMException::class); $this->expectException(ORMException::class);
$this->configuration->addCustomDatetimeFunction('date_add', __CLASS__); $this->configuration->addCustomDatetimeFunction('date_add', __CLASS__);
} }
@ -311,7 +313,7 @@ class ConfigurationTest extends PHPUnit_Framework_TestCase
public function testSetGetClassMetadataFactoryName() public function testSetGetClassMetadataFactoryName()
{ {
$this->assertSame('Doctrine\ORM\Mapping\ClassMetadataFactory', $this->configuration->getClassMetadataFactoryName()); $this->assertSame(AnnotationNamespace\ClassMetadataFactory::class, $this->configuration->getClassMetadataFactoryName());
$this->configuration->setClassMetadataFactoryName(__CLASS__); $this->configuration->setClassMetadataFactoryName(__CLASS__);
$this->assertSame(__CLASS__, $this->configuration->getClassMetadataFactoryName()); $this->assertSame(__CLASS__, $this->configuration->getClassMetadataFactoryName());
} }
@ -325,17 +327,16 @@ class ConfigurationTest extends PHPUnit_Framework_TestCase
public function setDefaultRepositoryClassName() public function setDefaultRepositoryClassName()
{ {
$this->assertSame('Doctrine\ORM\EntityRepository', $this->configuration->getDefaultRepositoryClassName()); $this->assertSame(EntityRepository::class, $this->configuration->getDefaultRepositoryClassName());
$repositoryClass = 'Doctrine\Tests\Models\DDC753\DDC753CustomRepository'; $this->configuration->setDefaultRepositoryClassName(DDC753CustomRepository::class);
$this->configuration->setDefaultRepositoryClassName($repositoryClass); $this->assertSame(DDC753CustomRepository::class, $this->configuration->getDefaultRepositoryClassName());
$this->assertSame($repositoryClass, $this->configuration->getDefaultRepositoryClassName()); $this->expectException(ORMException::class);
$this->expectException(\Doctrine\ORM\ORMException::class);
$this->configuration->setDefaultRepositoryClassName(__CLASS__); $this->configuration->setDefaultRepositoryClassName(__CLASS__);
} }
public function testSetGetNamingStrategy() public function testSetGetNamingStrategy()
{ {
$this->assertInstanceOf('Doctrine\ORM\Mapping\NamingStrategy', $this->configuration->getNamingStrategy()); $this->assertInstanceOf(NamingStrategy::class, $this->configuration->getNamingStrategy());
$namingStrategy = $this->createMock(NamingStrategy::class); $namingStrategy = $this->createMock(NamingStrategy::class);
$this->configuration->setNamingStrategy($namingStrategy); $this->configuration->setNamingStrategy($namingStrategy);
$this->assertSame($namingStrategy, $this->configuration->getNamingStrategy()); $this->assertSame($namingStrategy, $this->configuration->getNamingStrategy());
@ -343,7 +344,7 @@ class ConfigurationTest extends PHPUnit_Framework_TestCase
public function testSetGetQuoteStrategy() public function testSetGetQuoteStrategy()
{ {
$this->assertInstanceOf('Doctrine\ORM\Mapping\QuoteStrategy', $this->configuration->getQuoteStrategy()); $this->assertInstanceOf(QuoteStrategy::class, $this->configuration->getQuoteStrategy());
$quoteStrategy = $this->createMock(QuoteStrategy::class); $quoteStrategy = $this->createMock(QuoteStrategy::class);
$this->configuration->setQuoteStrategy($quoteStrategy); $this->configuration->setQuoteStrategy($quoteStrategy);
$this->assertSame($quoteStrategy, $this->configuration->getQuoteStrategy()); $this->assertSame($quoteStrategy, $this->configuration->getQuoteStrategy());
@ -354,8 +355,8 @@ class ConfigurationTest extends PHPUnit_Framework_TestCase
*/ */
public function testSetGetEntityListenerResolver() public function testSetGetEntityListenerResolver()
{ {
$this->assertInstanceOf('Doctrine\ORM\Mapping\EntityListenerResolver', $this->configuration->getEntityListenerResolver()); $this->assertInstanceOf(EntityListenerResolver::class, $this->configuration->getEntityListenerResolver());
$this->assertInstanceOf('Doctrine\ORM\Mapping\DefaultEntityListenerResolver', $this->configuration->getEntityListenerResolver()); $this->assertInstanceOf(AnnotationNamespace\DefaultEntityListenerResolver::class, $this->configuration->getEntityListenerResolver());
$resolver = $this->createMock(EntityListenerResolver::class); $resolver = $this->createMock(EntityListenerResolver::class);
$this->configuration->setEntityListenerResolver($resolver); $this->configuration->setEntityListenerResolver($resolver);
$this->assertSame($resolver, $this->configuration->getEntityListenerResolver()); $this->assertSame($resolver, $this->configuration->getEntityListenerResolver());

View File

@ -2,6 +2,8 @@
namespace Doctrine\Tests\ORM\Decorator; namespace Doctrine\Tests\ORM\Decorator;
use Doctrine\ORM\Decorator\EntityManagerDecorator;
use Doctrine\ORM\EntityManager;
use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\EntityManagerInterface;
use Doctrine\ORM\Query\ResultSetMapping; use Doctrine\ORM\Query\ResultSetMapping;
@ -13,7 +15,7 @@ class EntityManagerDecoratorTest extends \PHPUnit_Framework_TestCase
public function setUp() public function setUp()
{ {
$this->wrapped = $this->createMock(EntityManagerInterface::class); $this->wrapped = $this->createMock(EntityManagerInterface::class);
$this->decorator = $this->getMockBuilder('Doctrine\ORM\Decorator\EntityManagerDecorator') $this->decorator = $this->getMockBuilder(EntityManagerDecorator::class)
->setConstructorArgs([$this->wrapped]) ->setConstructorArgs([$this->wrapped])
->setMethods(null) ->setMethods(null)
->getMock(); ->getMock();
@ -21,7 +23,7 @@ class EntityManagerDecoratorTest extends \PHPUnit_Framework_TestCase
public function getMethodParameters() public function getMethodParameters()
{ {
$class = new \ReflectionClass('Doctrine\ORM\EntityManager'); $class = new \ReflectionClass(EntityManager::class);
$methods = []; $methods = [];
foreach ($class->getMethods() as $method) { foreach ($class->getMethods() as $method) {

View File

@ -2,13 +2,22 @@
namespace Doctrine\Tests\ORM; namespace Doctrine\Tests\ORM;
use Doctrine\Common\EventManager;
use Doctrine\Common\Persistence\Mapping\Driver\MappingDriver; use Doctrine\Common\Persistence\Mapping\Driver\MappingDriver;
use Doctrine\Common\Persistence\Mapping\MappingException; use Doctrine\Common\Persistence\Mapping\MappingException;
use Doctrine\DBAL\Connection;
use Doctrine\ORM\Configuration; use Doctrine\ORM\Configuration;
use Doctrine\ORM\EntityManager; use Doctrine\ORM\EntityManager;
use Doctrine\ORM\Mapping\ClassMetadataFactory;
use Doctrine\ORM\NativeQuery;
use Doctrine\ORM\ORMException; use Doctrine\ORM\ORMException;
use Doctrine\ORM\ORMInvalidArgumentException; use Doctrine\ORM\ORMInvalidArgumentException;
use Doctrine\ORM\Proxy\ProxyFactory;
use Doctrine\ORM\Query;
use Doctrine\ORM\Query\ResultSetMapping; use Doctrine\ORM\Query\ResultSetMapping;
use Doctrine\ORM\QueryBuilder;
use Doctrine\ORM\UnitOfWork;
use Doctrine\Tests\Models\CMS\CmsUser;
use Doctrine\Tests\Models\GeoNames\Country; use Doctrine\Tests\Models\GeoNames\Country;
use Doctrine\Tests\OrmTestCase; use Doctrine\Tests\OrmTestCase;
@ -37,32 +46,32 @@ class EntityManagerTest extends OrmTestCase
public function testGetConnection() public function testGetConnection()
{ {
$this->assertInstanceOf('Doctrine\DBAL\Connection', $this->_em->getConnection()); $this->assertInstanceOf(Connection::class, $this->_em->getConnection());
} }
public function testGetMetadataFactory() public function testGetMetadataFactory()
{ {
$this->assertInstanceOf('Doctrine\ORM\Mapping\ClassMetadataFactory', $this->_em->getMetadataFactory()); $this->assertInstanceOf(ClassMetadataFactory::class, $this->_em->getMetadataFactory());
} }
public function testGetConfiguration() public function testGetConfiguration()
{ {
$this->assertInstanceOf('Doctrine\ORM\Configuration', $this->_em->getConfiguration()); $this->assertInstanceOf(Configuration::class, $this->_em->getConfiguration());
} }
public function testGetUnitOfWork() public function testGetUnitOfWork()
{ {
$this->assertInstanceOf('Doctrine\ORM\UnitOfWork', $this->_em->getUnitOfWork()); $this->assertInstanceOf(UnitOfWork::class, $this->_em->getUnitOfWork());
} }
public function testGetProxyFactory() public function testGetProxyFactory()
{ {
$this->assertInstanceOf('Doctrine\ORM\Proxy\ProxyFactory', $this->_em->getProxyFactory()); $this->assertInstanceOf(ProxyFactory::class, $this->_em->getProxyFactory());
} }
public function testGetEventManager() public function testGetEventManager()
{ {
$this->assertInstanceOf('Doctrine\Common\EventManager', $this->_em->getEventManager()); $this->assertInstanceOf(EventManager::class, $this->_em->getEventManager());
} }
public function testCreateNativeQuery() public function testCreateNativeQuery()
@ -83,18 +92,18 @@ class EntityManagerTest extends OrmTestCase
$query = $this->_em->createNamedNativeQuery('foo'); $query = $this->_em->createNamedNativeQuery('foo');
$this->assertInstanceOf('Doctrine\ORM\NativeQuery', $query); $this->assertInstanceOf(NativeQuery::class, $query);
} }
public function testCreateQueryBuilder() public function testCreateQueryBuilder()
{ {
$this->assertInstanceOf('Doctrine\ORM\QueryBuilder', $this->_em->createQueryBuilder()); $this->assertInstanceOf(QueryBuilder::class, $this->_em->createQueryBuilder());
} }
public function testCreateQueryBuilderAliasValid() public function testCreateQueryBuilderAliasValid()
{ {
$q = $this->_em->createQueryBuilder() $q = $this->_em->createQueryBuilder()
->select('u')->from('Doctrine\Tests\Models\CMS\CmsUser', 'u'); ->select('u')->from(CmsUser::class, 'u');
$q2 = clone $q; $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', $q->getQuery()->getDql());
@ -107,12 +116,12 @@ class EntityManagerTest extends OrmTestCase
public function testCreateQuery_DqlIsOptional() public function testCreateQuery_DqlIsOptional()
{ {
$this->assertInstanceOf('Doctrine\ORM\Query', $this->_em->createQuery()); $this->assertInstanceOf(Query::class, $this->_em->createQuery());
} }
public function testGetPartialReference() public function testGetPartialReference()
{ {
$user = $this->_em->getPartialReference('Doctrine\Tests\Models\CMS\CmsUser', 42); $user = $this->_em->getPartialReference(CmsUser::class, 42);
$this->assertTrue($this->_em->contains($user)); $this->assertTrue($this->_em->contains($user));
$this->assertEquals(42, $user->id); $this->assertEquals(42, $user->id);
$this->assertNull($user->getName()); $this->assertNull($user->getName());
@ -121,7 +130,7 @@ class EntityManagerTest extends OrmTestCase
public function testCreateQuery() public function testCreateQuery()
{ {
$q = $this->_em->createQuery('SELECT 1'); $q = $this->_em->createQuery('SELECT 1');
$this->assertInstanceOf('Doctrine\ORM\Query', $q); $this->assertInstanceOf(Query::class, $q);
$this->assertEquals('SELECT 1', $q->getDql()); $this->assertEquals('SELECT 1', $q->getDql());
} }
@ -133,7 +142,7 @@ class EntityManagerTest extends OrmTestCase
$this->_em->getConfiguration()->addNamedQuery('foo', 'SELECT 1'); $this->_em->getConfiguration()->addNamedQuery('foo', 'SELECT 1');
$query = $this->_em->createNamedQuery('foo'); $query = $this->_em->createNamedQuery('foo');
$this->assertInstanceOf('Doctrine\ORM\Query', $query); $this->assertInstanceOf(Query::class, $query);
$this->assertEquals('SELECT 1', $query->getDql()); $this->assertEquals('SELECT 1', $query->getDql());
} }

View File

@ -3,14 +3,13 @@
namespace Doctrine\Tests\ORM; namespace Doctrine\Tests\ORM;
use Doctrine\ORM\EntityNotFoundException; use Doctrine\ORM\EntityNotFoundException;
use PHPUnit_Framework_TestCase;
/** /**
* Tests for {@see \Doctrine\ORM\EntityNotFoundException} * Tests for {@see \Doctrine\ORM\EntityNotFoundException}
* *
* @covers \Doctrine\ORM\EntityNotFoundException * @covers \Doctrine\ORM\EntityNotFoundException
*/ */
class EntityNotFoundExceptionTest extends PHPUnit_Framework_TestCase class EntityNotFoundExceptionTest extends \PHPUnit_Framework_TestCase
{ {
public function testFromClassNameAndIdentifier() public function testFromClassNameAndIdentifier()
{ {
@ -19,7 +18,7 @@ class EntityNotFoundExceptionTest extends PHPUnit_Framework_TestCase
['foo' => 'bar'] ['foo' => 'bar']
); );
$this->assertInstanceOf('Doctrine\ORM\EntityNotFoundException', $exception); $this->assertInstanceOf(EntityNotFoundException::class, $exception);
$this->assertSame('Entity of type \'foo\' for IDs foo(bar) was not found', $exception->getMessage()); $this->assertSame('Entity of type \'foo\' for IDs foo(bar) was not found', $exception->getMessage());
$exception = EntityNotFoundException::fromClassNameAndIdentifier( $exception = EntityNotFoundException::fromClassNameAndIdentifier(
@ -27,7 +26,7 @@ class EntityNotFoundExceptionTest extends PHPUnit_Framework_TestCase
[] []
); );
$this->assertInstanceOf('Doctrine\ORM\EntityNotFoundException', $exception); $this->assertInstanceOf(EntityNotFoundException::class, $exception);
$this->assertSame('Entity of type \'foo\' was not found', $exception->getMessage()); $this->assertSame('Entity of type \'foo\' was not found', $exception->getMessage());
} }
} }

View File

@ -3,7 +3,7 @@
namespace Doctrine\Tests\ORM\Functional; namespace Doctrine\Tests\ORM\Functional;
use Doctrine\Common\Collections\ArrayCollection; use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\ORM\Query; use Doctrine\ORM\PersistentCollection;
use Doctrine\Tests\OrmFunctionalTestCase; use Doctrine\Tests\OrmFunctionalTestCase;
/** /**
@ -18,11 +18,11 @@ class AdvancedAssociationTest extends OrmFunctionalTestCase
try { try {
$this->_schemaTool->createSchema( $this->_schemaTool->createSchema(
[ [
$this->_em->getClassMetadata('Doctrine\Tests\ORM\Functional\Phrase'), $this->_em->getClassMetadata(Phrase::class),
$this->_em->getClassMetadata('Doctrine\Tests\ORM\Functional\PhraseType'), $this->_em->getClassMetadata(PhraseType::class),
$this->_em->getClassMetadata('Doctrine\Tests\ORM\Functional\Definition'), $this->_em->getClassMetadata(Definition::class),
$this->_em->getClassMetadata('Doctrine\Tests\ORM\Functional\Lemma'), $this->_em->getClassMetadata(Lemma::class),
$this->_em->getClassMetadata('Doctrine\Tests\ORM\Functional\Type') $this->_em->getClassMetadata(Type::class)
] ]
); );
} catch (\Exception $e) { } catch (\Exception $e) {
@ -57,7 +57,7 @@ class AdvancedAssociationTest extends OrmFunctionalTestCase
//end setup //end setup
// test1 - lazy-loading many-to-one after find() // test1 - lazy-loading many-to-one after find()
$phrase2 = $this->_em->find('Doctrine\Tests\ORM\Functional\Phrase', $phrase->getId()); $phrase2 = $this->_em->find(Phrase::class, $phrase->getId());
$this->assertTrue(is_numeric($phrase2->getType()->getId())); $this->assertTrue(is_numeric($phrase2->getType()->getId()));
$this->_em->clear(); $this->_em->clear();
@ -66,8 +66,8 @@ class AdvancedAssociationTest extends OrmFunctionalTestCase
$query = $this->_em->createQuery("SELECT p,t FROM Doctrine\Tests\ORM\Functional\Phrase p JOIN p.type t"); $query = $this->_em->createQuery("SELECT p,t FROM Doctrine\Tests\ORM\Functional\Phrase p JOIN p.type t");
$res = $query->getResult(); $res = $query->getResult();
$this->assertEquals(1, count($res)); $this->assertEquals(1, count($res));
$this->assertInstanceOf('Doctrine\Tests\ORM\Functional\PhraseType', $res[0]->getType()); $this->assertInstanceOf(PhraseType::class, $res[0]->getType());
$this->assertInstanceOf('Doctrine\ORM\PersistentCollection', $res[0]->getType()->getPhrases()); $this->assertInstanceOf(PersistentCollection::class, $res[0]->getType()->getPhrases());
$this->assertFalse($res[0]->getType()->getPhrases()->isInitialized()); $this->assertFalse($res[0]->getType()->getPhrases()->isInitialized());
$this->_em->clear(); $this->_em->clear();
@ -76,17 +76,17 @@ class AdvancedAssociationTest extends OrmFunctionalTestCase
$query = $this->_em->createQuery("SELECT p,t,pp FROM Doctrine\Tests\ORM\Functional\Phrase p JOIN p.type t JOIN t.phrases pp"); $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(); $res = $query->getResult();
$this->assertEquals(1, count($res)); $this->assertEquals(1, count($res));
$this->assertInstanceOf('Doctrine\Tests\ORM\Functional\PhraseType', $res[0]->getType()); $this->assertInstanceOf(PhraseType::class, $res[0]->getType());
$this->assertInstanceOf('Doctrine\ORM\PersistentCollection', $res[0]->getType()->getPhrases()); $this->assertInstanceOf(PersistentCollection::class, $res[0]->getType()->getPhrases());
$this->assertTrue($res[0]->getType()->getPhrases()->isInitialized()); $this->assertTrue($res[0]->getType()->getPhrases()->isInitialized());
$this->_em->clear(); $this->_em->clear();
// test3 - lazy-loading one-to-many after find() // test3 - lazy-loading one-to-many after find()
$phrase3 = $this->_em->find('Doctrine\Tests\ORM\Functional\Phrase', $phrase->getId()); $phrase3 = $this->_em->find(Phrase::class, $phrase->getId());
$definitions = $phrase3->getDefinitions(); $definitions = $phrase3->getDefinitions();
$this->assertInstanceOf('Doctrine\ORM\PersistentCollection', $definitions); $this->assertInstanceOf(PersistentCollection::class, $definitions);
$this->assertInstanceOf('Doctrine\Tests\ORM\Functional\Definition', $definitions[0]); $this->assertInstanceOf(Definition::class, $definitions[0]);
$this->_em->clear(); $this->_em->clear();
@ -97,7 +97,7 @@ class AdvancedAssociationTest extends OrmFunctionalTestCase
$this->assertEquals(1, count($res)); $this->assertEquals(1, count($res));
$this->assertInstanceOf('Doctrine\Tests\ORM\Functional\Definition', $definitions[0]); $this->assertInstanceOf(Definition::class, $definitions[0]);
$this->assertEquals(2, $definitions->count()); $this->assertEquals(2, $definitions->count());
} }
@ -121,7 +121,7 @@ class AdvancedAssociationTest extends OrmFunctionalTestCase
$res = $query->getResult(); $res = $query->getResult();
$types = $res[0]->getTypes(); $types = $res[0]->getTypes();
$this->assertInstanceOf('Doctrine\Tests\ORM\Functional\Type', $types[0]); $this->assertInstanceOf(Type::class, $types[0]);
} }
} }

View File

@ -6,13 +6,15 @@ use Doctrine\DBAL\Logging\DebugStack;
use Doctrine\ORM\EntityNotFoundException; use Doctrine\ORM\EntityNotFoundException;
use Doctrine\ORM\Mapping\ClassMetadata; use Doctrine\ORM\Mapping\ClassMetadata;
use Doctrine\ORM\ORMInvalidArgumentException; use Doctrine\ORM\ORMInvalidArgumentException;
use Doctrine\ORM\PersistentCollection;
use Doctrine\ORM\Proxy\Proxy;
use Doctrine\ORM\Query; use Doctrine\ORM\Query;
use Doctrine\ORM\UnitOfWork; use Doctrine\ORM\UnitOfWork;
use Doctrine\Tests\Models\CMS\CmsUser;
use Doctrine\Tests\Models\CMS\CmsPhonenumber;
use Doctrine\Tests\Models\CMS\CmsAddress; use Doctrine\Tests\Models\CMS\CmsAddress;
use Doctrine\Tests\Models\CMS\CmsArticle; use Doctrine\Tests\Models\CMS\CmsArticle;
use Doctrine\Tests\Models\CMS\CmsComment; use Doctrine\Tests\Models\CMS\CmsComment;
use Doctrine\Tests\Models\CMS\CmsPhonenumber;
use Doctrine\Tests\Models\CMS\CmsUser;
use Doctrine\Tests\OrmFunctionalTestCase; use Doctrine\Tests\OrmFunctionalTestCase;
class BasicFunctionalTest extends OrmFunctionalTestCase class BasicFunctionalTest extends OrmFunctionalTestCase
@ -38,7 +40,7 @@ class BasicFunctionalTest extends OrmFunctionalTestCase
$this->assertTrue($this->_em->contains($user)); $this->assertTrue($this->_em->contains($user));
// Read // Read
$user2 = $this->_em->find('Doctrine\Tests\Models\CMS\CmsUser', $user->id); $user2 = $this->_em->find(CmsUser::class, $user->id);
$this->assertTrue($user === $user2); $this->assertTrue($user === $user2);
// Add a phonenumber // Add a phonenumber
@ -138,8 +140,8 @@ class BasicFunctionalTest extends OrmFunctionalTestCase
->getSingleResult(); ->getSingleResult();
// Address has been eager-loaded because it cant be lazy // Address has been eager-loaded because it cant be lazy
$this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsAddress', $user2->address); $this->assertInstanceOf(CmsAddress::class, $user2->address);
$this->assertNotInstanceOf('Doctrine\ORM\Proxy\Proxy', $user2->address); $this->assertNotInstanceOf(Proxy::class, $user2->address);
} }
/** /**
@ -173,7 +175,7 @@ class BasicFunctionalTest extends OrmFunctionalTestCase
$this->assertEquals(UnitOfWork::STATE_NEW, $this->_em->getUnitOfWork()->getEntityState($user), "State should be UnitOfWork::STATE_NEW"); $this->assertEquals(UnitOfWork::STATE_NEW, $this->_em->getUnitOfWork()->getEntityState($user), "State should be UnitOfWork::STATE_NEW");
$this->assertNull($this->_em->find('Doctrine\Tests\Models\CMS\CmsUser', $id)); $this->assertNull($this->_em->find(CmsUser::class, $id));
} }
public function testOneToManyOrphanRemoval() public function testOneToManyOrphanRemoval()
@ -278,7 +280,7 @@ class BasicFunctionalTest extends OrmFunctionalTestCase
$this->assertEquals('Guilherme', $users[0]->name); $this->assertEquals('Guilherme', $users[0]->name);
$this->assertEquals('gblanco', $users[0]->username); $this->assertEquals('gblanco', $users[0]->username);
$this->assertEquals('developer', $users[0]->status); $this->assertEquals('developer', $users[0]->status);
$this->assertInstanceOf('Doctrine\ORM\PersistentCollection', $users[0]->phonenumbers); $this->assertInstanceOf(PersistentCollection::class, $users[0]->phonenumbers);
$this->assertTrue($users[0]->phonenumbers->isInitialized()); $this->assertTrue($users[0]->phonenumbers->isInitialized());
$this->assertEquals(0, $users[0]->phonenumbers->count()); $this->assertEquals(0, $users[0]->phonenumbers->count());
//$this->assertNull($users[0]->articles); //$this->assertNull($users[0]->articles);
@ -395,7 +397,7 @@ class BasicFunctionalTest extends OrmFunctionalTestCase
$this->_em->clear(); $this->_em->clear();
$userId = $user->id; $userId = $user->id;
$user = $this->_em->getReference('Doctrine\Tests\Models\CMS\CmsUser', $user->id); $user = $this->_em->getReference(CmsUser::class, $user->id);
$dql = "SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.id = ?1"; $dql = "SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.id = ?1";
$user = $this->_em->createQuery($dql) $user = $this->_em->createQuery($dql)
@ -508,7 +510,7 @@ class BasicFunctionalTest extends OrmFunctionalTestCase
// Assume we only got the identifier of the address and now want to attach // 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(). // that address to the user without actually loading it, using getReference().
$addressRef = $this->_em->getReference('Doctrine\Tests\Models\CMS\CmsAddress', $address->getId()); $addressRef = $this->_em->getReference(CmsAddress::class, $address->getId());
//$addressRef->getId(); //$addressRef->getId();
//\Doctrine\Common\Util\Debug::dump($addressRef); //\Doctrine\Common\Util\Debug::dump($addressRef);
@ -522,8 +524,8 @@ class BasicFunctionalTest extends OrmFunctionalTestCase
$query = $this->_em->createQuery("select u, a from Doctrine\Tests\Models\CMS\CmsUser u join u.address a where u.username='gblanco'"); $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(); $gblanco = $query->getSingleResult();
$this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsUser', $gblanco); $this->assertInstanceOf(CmsUser::class, $gblanco);
$this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsAddress', $gblanco->getAddress()); $this->assertInstanceOf(CmsAddress::class, $gblanco->getAddress());
$this->assertEquals('Berlin', $gblanco->getAddress()->getCity()); $this->assertEquals('Berlin', $gblanco->getAddress()->getCity());
} }
@ -594,7 +596,7 @@ class BasicFunctionalTest extends OrmFunctionalTestCase
$this->_em->flush(); $this->_em->flush();
$this->_em->clear(); $this->_em->clear();
$articleNew = $this->_em->find('Doctrine\Tests\Models\CMS\CmsArticle', $articleId); $articleNew = $this->_em->find(CmsArticle::class, $articleId);
$this->assertEquals("Lorem ipsum dolor sunt. And stuff!", $articleNew->text); $this->assertEquals("Lorem ipsum dolor sunt. And stuff!", $articleNew->text);
$this->assertTrue($this->_em->contains($articleNew)); $this->assertTrue($this->_em->contains($articleNew));
} }
@ -631,7 +633,7 @@ class BasicFunctionalTest extends OrmFunctionalTestCase
$user2 = $query->getSingleResult(); $user2 = $query->getSingleResult();
$this->assertEquals(1, count($user2->articles)); $this->assertEquals(1, count($user2->articles));
$this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsAddress', $user2->address); $this->assertInstanceOf(CmsAddress::class, $user2->address);
$oldLogger = $this->_em->getConnection()->getConfiguration()->getSQLLogger(); $oldLogger = $this->_em->getConnection()->getConfiguration()->getSQLLogger();
$debugStack = new DebugStack(); $debugStack = new DebugStack();
@ -656,7 +658,7 @@ class BasicFunctionalTest extends OrmFunctionalTestCase
$this->_em->flush(); $this->_em->flush();
$this->_em->clear(); $this->_em->clear();
$userRef = $this->_em->getReference('Doctrine\Tests\Models\CMS\CmsUser', $user->getId()); $userRef = $this->_em->getReference(CmsUser::class, $user->getId());
$this->_em->remove($userRef); $this->_em->remove($userRef);
$this->_em->flush(); $this->_em->flush();
$this->_em->clear(); $this->_em->clear();
@ -687,12 +689,12 @@ class BasicFunctionalTest extends OrmFunctionalTestCase
//$this->_em->getConnection()->getConfiguration()->setSQLLogger(new \Doctrine\DBAL\Logging\EchoSQLLogger); //$this->_em->getConnection()->getConfiguration()->setSQLLogger(new \Doctrine\DBAL\Logging\EchoSQLLogger);
$userRef = $this->_em->getReference('Doctrine\Tests\Models\CMS\CmsUser', $user->getId()); $userRef = $this->_em->getReference(CmsUser::class, $user->getId());
$address2 = $this->_em->createQuery('select a from Doctrine\Tests\Models\CMS\CmsAddress a where a.user = :user') $address2 = $this->_em->createQuery('select a from Doctrine\Tests\Models\CMS\CmsAddress a where a.user = :user')
->setParameter('user', $userRef) ->setParameter('user', $userRef)
->getSingleResult(); ->getSingleResult();
$this->assertInstanceOf('Doctrine\ORM\Proxy\Proxy', $address2->getUser()); $this->assertInstanceOf(Proxy::class, $address2->getUser());
$this->assertTrue($userRef === $address2->getUser()); $this->assertTrue($userRef === $address2->getUser());
$this->assertFalse($userRef->__isInitialized__); $this->assertFalse($userRef->__isInitialized__);
$this->assertEquals('Germany', $address2->country); $this->assertEquals('Germany', $address2->country);
@ -872,7 +874,7 @@ class BasicFunctionalTest extends OrmFunctionalTestCase
$userId = $user->id; $userId = $user->id;
$this->_em->clear(); $this->_em->clear();
$user = $this->_em->getPartialReference('Doctrine\Tests\Models\CMS\CmsUser', $userId); $user = $this->_em->getPartialReference(CmsUser::class, $userId);
$this->assertTrue($this->_em->contains($user)); $this->assertTrue($this->_em->contains($user));
$this->assertNull($user->getName()); $this->assertNull($user->getName());
$this->assertEquals($userId, $user->id); $this->assertEquals($userId, $user->id);
@ -904,7 +906,7 @@ class BasicFunctionalTest extends OrmFunctionalTestCase
$this->_em->clear(); $this->_em->clear();
$user2 = $this->_em->find(get_class($managedUser), $userId); $user2 = $this->_em->find(get_class($managedUser), $userId);
$this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsUser', $user2); $this->assertInstanceOf(CmsUser::class, $user2);
} }
public function testMergeNonPersistedProperties() public function testMergeNonPersistedProperties()
@ -1001,9 +1003,9 @@ class BasicFunctionalTest extends OrmFunctionalTestCase
$dql = "SELECT a FROM Doctrine\Tests\Models\CMS\CmsArticle a WHERE a.id = ?1"; $dql = "SELECT a FROM Doctrine\Tests\Models\CMS\CmsArticle a WHERE a.id = ?1";
$article = $this->_em->createQuery($dql) $article = $this->_em->createQuery($dql)
->setParameter(1, $article->id) ->setParameter(1, $article->id)
->setFetchMode('Doctrine\Tests\Models\CMS\CmsArticle', 'user', ClassMetadata::FETCH_EAGER) ->setFetchMode(CmsArticle::class, 'user', ClassMetadata::FETCH_EAGER)
->getSingleResult(); ->getSingleResult();
$this->assertInstanceOf('Doctrine\ORM\Proxy\Proxy', $article->user, "It IS a proxy, ..."); $this->assertInstanceOf(Proxy::class, $article->user, "It IS a proxy, ...");
$this->assertTrue($article->user->__isInitialized__, "...but its initialized!"); $this->assertTrue($article->user->__isInitialized__, "...but its initialized!");
$this->assertEquals($qc+2, $this->getCurrentQueryCount()); $this->assertEquals($qc+2, $this->getCurrentQueryCount());
} }
@ -1045,7 +1047,7 @@ class BasicFunctionalTest extends OrmFunctionalTestCase
$unitOfWork = $this->_em->getUnitOfWork(); $unitOfWork = $this->_em->getUnitOfWork();
$this->_em->clear('Doctrine\Tests\Models\CMS\CmsUser'); $this->_em->clear(CmsUser::class);
$this->assertEquals(UnitOfWork::STATE_DETACHED, $unitOfWork->getEntityState($user)); $this->assertEquals(UnitOfWork::STATE_DETACHED, $unitOfWork->getEntityState($user));
$this->assertEquals(UnitOfWork::STATE_DETACHED, $unitOfWork->getEntityState($article1)); $this->assertEquals(UnitOfWork::STATE_DETACHED, $unitOfWork->getEntityState($article1));

View File

@ -16,8 +16,8 @@ class CascadeRemoveOrderTest extends OrmFunctionalTestCase
$this->_schemaTool->createSchema( $this->_schemaTool->createSchema(
[ [
$this->_em->getClassMetadata(__NAMESPACE__ . '\CascadeRemoveOrderEntityO'), $this->_em->getClassMetadata(CascadeRemoveOrderEntityO::class),
$this->_em->getClassMetadata(__NAMESPACE__ . '\CascadeRemoveOrderEntityG'), $this->_em->getClassMetadata(CascadeRemoveOrderEntityG::class),
] ]
); );
} }
@ -28,8 +28,8 @@ class CascadeRemoveOrderTest extends OrmFunctionalTestCase
$this->_schemaTool->dropSchema( $this->_schemaTool->dropSchema(
[ [
$this->_em->getClassMetadata(__NAMESPACE__ . '\CascadeRemoveOrderEntityO'), $this->_em->getClassMetadata(CascadeRemoveOrderEntityO::class),
$this->_em->getClassMetadata(__NAMESPACE__ . '\CascadeRemoveOrderEntityG'), $this->_em->getClassMetadata(CascadeRemoveOrderEntityG::class),
] ]
); );
} }
@ -43,7 +43,7 @@ class CascadeRemoveOrderTest extends OrmFunctionalTestCase
$this->_em->flush(); $this->_em->flush();
$this->_em->clear(); $this->_em->clear();
$eOloaded = $this->_em->find('Doctrine\Tests\ORM\Functional\CascadeRemoveOrderEntityO', $eO->getId()); $eOloaded = $this->_em->find(CascadeRemoveOrderEntityO::class, $eO->getId());
$this->_em->remove($eOloaded); $this->_em->remove($eOloaded);
$this->_em->flush(); $this->_em->flush();
@ -62,7 +62,7 @@ class CascadeRemoveOrderTest extends OrmFunctionalTestCase
$this->_em->flush(); $this->_em->flush();
$this->_em->clear(); $this->_em->clear();
$eOloaded = $this->_em->find('Doctrine\Tests\ORM\Functional\CascadeRemoveOrderEntityO', $eO->getId()); $eOloaded = $this->_em->find(CascadeRemoveOrderEntityO::class, $eO->getId());
$this->_em->remove($eOloaded); $this->_em->remove($eOloaded);
$this->_em->flush(); $this->_em->flush();

View File

@ -2,6 +2,8 @@
namespace Doctrine\Tests\ORM\Functional; namespace Doctrine\Tests\ORM\Functional;
use Doctrine\ORM\PersistentCollection;
use Doctrine\ORM\Proxy\Proxy;
use Doctrine\Tests\Models\Company\CompanyPerson, use Doctrine\Tests\Models\Company\CompanyPerson,
Doctrine\Tests\Models\Company\CompanyEmployee, Doctrine\Tests\Models\Company\CompanyEmployee,
Doctrine\Tests\Models\Company\CompanyManager, Doctrine\Tests\Models\Company\CompanyManager,
@ -50,8 +52,8 @@ class ClassTableInheritanceTest extends OrmFunctionalTestCase
$entities = $query->getResult(); $entities = $query->getResult();
$this->assertEquals(2, count($entities)); $this->assertEquals(2, count($entities));
$this->assertInstanceOf('Doctrine\Tests\Models\Company\CompanyPerson', $entities[0]); $this->assertInstanceOf(CompanyPerson::class, $entities[0]);
$this->assertInstanceOf('Doctrine\Tests\Models\Company\CompanyEmployee', $entities[1]); $this->assertInstanceOf(CompanyEmployee::class, $entities[1]);
$this->assertTrue(is_numeric($entities[0]->getId())); $this->assertTrue(is_numeric($entities[0]->getId()));
$this->assertTrue(is_numeric($entities[1]->getId())); $this->assertTrue(is_numeric($entities[1]->getId()));
$this->assertEquals('Roman S. Borschel', $entities[0]->getName()); $this->assertEquals('Roman S. Borschel', $entities[0]->getName());
@ -65,7 +67,7 @@ class ClassTableInheritanceTest extends OrmFunctionalTestCase
$entities = $query->getResult(); $entities = $query->getResult();
$this->assertEquals(1, count($entities)); $this->assertEquals(1, count($entities));
$this->assertInstanceOf('Doctrine\Tests\Models\Company\CompanyEmployee', $entities[0]); $this->assertInstanceOf(CompanyEmployee::class, $entities[0]);
$this->assertTrue(is_numeric($entities[0]->getId())); $this->assertTrue(is_numeric($entities[0]->getId()));
$this->assertEquals('Guilherme Blanco', $entities[0]->getName()); $this->assertEquals('Guilherme Blanco', $entities[0]->getName());
$this->assertEquals(100000, $entities[0]->getSalary()); $this->assertEquals(100000, $entities[0]->getSalary());
@ -73,7 +75,7 @@ class ClassTableInheritanceTest extends OrmFunctionalTestCase
$this->_em->clear(); $this->_em->clear();
$guilherme = $this->_em->getRepository(get_class($employee))->findOneBy(['name' => 'Guilherme Blanco']); $guilherme = $this->_em->getRepository(get_class($employee))->findOneBy(['name' => 'Guilherme Blanco']);
$this->assertInstanceOf('Doctrine\Tests\Models\Company\CompanyEmployee', $guilherme); $this->assertInstanceOf(CompanyEmployee::class, $guilherme);
$this->assertEquals('Guilherme Blanco', $guilherme->getName()); $this->assertEquals('Guilherme Blanco', $guilherme->getName());
$this->_em->clear(); $this->_em->clear();
@ -108,9 +110,9 @@ class ClassTableInheritanceTest extends OrmFunctionalTestCase
$this->_em->clear(); $this->_em->clear();
$manager = $this->_em->find('Doctrine\Tests\Models\Company\CompanyManager', $manager->getId()); $manager = $this->_em->find(CompanyManager::class, $manager->getId());
$this->assertInstanceOf('Doctrine\Tests\Models\Company\CompanyManager', $manager); $this->assertInstanceOf(CompanyManager::class, $manager);
$this->assertEquals('Roman B.', $manager->getName()); $this->assertEquals('Roman B.', $manager->getName());
$this->assertEquals(119000, $manager->getSalary()); $this->assertEquals(119000, $manager->getSalary());
$this->assertEquals('CEO', $manager->getTitle()); $this->assertEquals('CEO', $manager->getTitle());
@ -128,9 +130,9 @@ class ClassTableInheritanceTest extends OrmFunctionalTestCase
$this->_em->clear(); $this->_em->clear();
$person = $this->_em->find('Doctrine\Tests\Models\Company\CompanyPerson', $manager->getId()); $person = $this->_em->find(CompanyPerson::class, $manager->getId());
$this->assertInstanceOf('Doctrine\Tests\Models\Company\CompanyManager', $person); $this->assertInstanceOf(CompanyManager::class, $person);
$this->assertEquals('Roman S. Borschel', $person->getName()); $this->assertEquals('Roman S. Borschel', $person->getName());
$this->assertEquals(100000, $person->getSalary()); $this->assertEquals(100000, $person->getSalary());
$this->assertEquals('CTO', $person->getTitle()); $this->assertEquals('CTO', $person->getTitle());
@ -167,9 +169,9 @@ class ClassTableInheritanceTest extends OrmFunctionalTestCase
$result = $query->getResult(); $result = $query->getResult();
$this->assertEquals(1, count($result)); $this->assertEquals(1, count($result));
$this->assertInstanceOf('Doctrine\Tests\Models\Company\CompanyPerson', $result[0]); $this->assertInstanceOf(CompanyPerson::class, $result[0]);
$this->assertEquals('Mary Smith', $result[0]->getName()); $this->assertEquals('Mary Smith', $result[0]->getName());
$this->assertInstanceOf('Doctrine\Tests\Models\Company\CompanyEmployee', $result[0]->getSpouse()); $this->assertInstanceOf(CompanyEmployee::class, $result[0]->getSpouse());
$this->assertEquals('John Smith', $result[0]->getSpouse()->getName()); $this->assertEquals('John Smith', $result[0]->getSpouse()->getName());
$this->assertSame($result[0], $result[0]->getSpouse()->getSpouse()); $this->assertSame($result[0], $result[0]->getSpouse()->getSpouse());
} }
@ -229,20 +231,20 @@ class ClassTableInheritanceTest extends OrmFunctionalTestCase
$result = $q->getResult(); $result = $q->getResult();
$this->assertEquals(1, count($result)); $this->assertEquals(1, count($result));
$this->assertInstanceOf('Doctrine\Tests\Models\Company\CompanyOrganization', $result[0]); $this->assertInstanceOf(CompanyOrganization::class, $result[0]);
$this->assertNull($result[0]->getMainEvent()); $this->assertNull($result[0]->getMainEvent());
$events = $result[0]->getEvents(); $events = $result[0]->getEvents();
$this->assertInstanceOf('Doctrine\ORM\PersistentCollection', $events); $this->assertInstanceOf(PersistentCollection::class, $events);
$this->assertFalse($events->isInitialized()); $this->assertFalse($events->isInitialized());
$this->assertEquals(2, count($events)); $this->assertEquals(2, count($events));
if ($events[0] instanceof CompanyAuction) { if ($events[0] instanceof CompanyAuction) {
$this->assertInstanceOf('Doctrine\Tests\Models\Company\CompanyRaffle', $events[1]); $this->assertInstanceOf(CompanyRaffle::class, $events[1]);
} else { } else {
$this->assertInstanceOf('Doctrine\Tests\Models\Company\CompanyRaffle', $events[0]); $this->assertInstanceOf(CompanyRaffle::class, $events[0]);
$this->assertInstanceOf('Doctrine\Tests\Models\Company\CompanyAuction', $events[1]); $this->assertInstanceOf(CompanyAuction::class, $events[1]);
} }
} }
@ -263,7 +265,7 @@ class ClassTableInheritanceTest extends OrmFunctionalTestCase
$result = $q->getResult(); $result = $q->getResult();
$this->assertEquals(1, count($result)); $this->assertEquals(1, count($result));
$this->assertInstanceOf('Doctrine\Tests\Models\Company\CompanyAuction', $result[0], sprintf("Is of class %s",get_class($result[0]))); $this->assertInstanceOf(CompanyAuction::class, $result[0], sprintf("Is of class %s",get_class($result[0])));
$this->_em->clear(); $this->_em->clear();
@ -273,12 +275,12 @@ class ClassTableInheritanceTest extends OrmFunctionalTestCase
$result = $q->getResult(); $result = $q->getResult();
$this->assertEquals(1, count($result)); $this->assertEquals(1, count($result));
$this->assertInstanceOf('Doctrine\Tests\Models\Company\CompanyOrganization', $result[0]); $this->assertInstanceOf(CompanyOrganization::class, $result[0]);
$mainEvent = $result[0]->getMainEvent(); $mainEvent = $result[0]->getMainEvent();
// mainEvent should have been loaded because it can't be lazy // mainEvent should have been loaded because it can't be lazy
$this->assertInstanceOf('Doctrine\Tests\Models\Company\CompanyAuction', $mainEvent); $this->assertInstanceOf(CompanyAuction::class, $mainEvent);
$this->assertNotInstanceOf('Doctrine\ORM\Proxy\Proxy', $mainEvent); $this->assertNotInstanceOf(Proxy::class, $mainEvent);
} }
/** /**
@ -388,12 +390,12 @@ class ClassTableInheritanceTest extends OrmFunctionalTestCase
$this->_em->flush(); $this->_em->flush();
$this->_em->clear(); $this->_em->clear();
$repos = $this->_em->getRepository('Doctrine\Tests\Models\Company\CompanyManager'); $repos = $this->_em->getRepository(CompanyManager::class);
$pmanager = $repos->findOneBy(['spouse' => $person->getId()]); $pmanager = $repos->findOneBy(['spouse' => $person->getId()]);
$this->assertEquals($manager->getId(), $pmanager->getId()); $this->assertEquals($manager->getId(), $pmanager->getId());
$repos = $this->_em->getRepository('Doctrine\Tests\Models\Company\CompanyPerson'); $repos = $this->_em->getRepository(CompanyPerson::class);
$pmanager = $repos->findOneBy(['spouse' => $person->getId()]); $pmanager = $repos->findOneBy(['spouse' => $person->getId()]);
$this->assertEquals($manager->getId(), $pmanager->getId()); $this->assertEquals($manager->getId(), $pmanager->getId());
@ -414,14 +416,14 @@ class ClassTableInheritanceTest extends OrmFunctionalTestCase
$this->_em->flush(); $this->_em->flush();
$this->_em->clear(); $this->_em->clear();
$ref = $this->_em->getReference('Doctrine\Tests\Models\Company\CompanyPerson', $manager->getId()); $ref = $this->_em->getReference(CompanyPerson::class, $manager->getId());
$this->assertNotInstanceOf('Doctrine\ORM\Proxy\Proxy', $ref, "Cannot Request a proxy from a class that has subclasses."); $this->assertNotInstanceOf(Proxy::class, $ref, "Cannot Request a proxy from a class that has subclasses.");
$this->assertInstanceOf('Doctrine\Tests\Models\Company\CompanyPerson', $ref); $this->assertInstanceOf(CompanyPerson::class, $ref);
$this->assertInstanceOf('Doctrine\Tests\Models\Company\CompanyEmployee', $ref, "Direct fetch of the reference has to load the child class Employee directly."); $this->assertInstanceOf(CompanyEmployee::class, $ref, "Direct fetch of the reference has to load the child class Employee directly.");
$this->_em->clear(); $this->_em->clear();
$ref = $this->_em->getReference('Doctrine\Tests\Models\Company\CompanyManager', $manager->getId()); $ref = $this->_em->getReference(CompanyManager::class, $manager->getId());
$this->assertInstanceOf('Doctrine\ORM\Proxy\Proxy', $ref, "A proxy can be generated only if no subclasses exists for the requested reference."); $this->assertInstanceOf(Proxy::class, $ref, "A proxy can be generated only if no subclasses exists for the requested reference.");
} }
/** /**
@ -445,7 +447,7 @@ class ClassTableInheritanceTest extends OrmFunctionalTestCase
$this->_em->flush(); $this->_em->flush();
$this->_em->clear(); $this->_em->clear();
$manager = $this->_em->find('Doctrine\Tests\Models\Company\CompanyManager', $manager->getId()); $manager = $this->_em->find(CompanyManager::class, $manager->getId());
$this->assertEquals(1, count($manager->getFriends())); $this->assertEquals(1, count($manager->getFriends()));
} }
@ -482,13 +484,13 @@ class ClassTableInheritanceTest extends OrmFunctionalTestCase
$this->_em->persist($manager); $this->_em->persist($manager);
$this->_em->flush(); $this->_em->flush();
$repository = $this->_em->getRepository("Doctrine\Tests\Models\Company\CompanyEmployee"); $repository = $this->_em->getRepository(CompanyEmployee::class);
$users = $repository->matching(new Criteria( $users = $repository->matching(new Criteria(
Criteria::expr()->eq('department', 'IT') Criteria::expr()->eq('department', 'IT')
)); ));
$this->assertEquals(1, count($users)); $this->assertEquals(1, count($users));
$repository = $this->_em->getRepository("Doctrine\Tests\Models\Company\CompanyManager"); $repository = $this->_em->getRepository(CompanyManager::class);
$users = $repository->matching(new Criteria( $users = $repository->matching(new Criteria(
Criteria::expr()->eq('department', 'IT') Criteria::expr()->eq('department', 'IT')
)); ));

View File

@ -2,6 +2,7 @@
namespace Doctrine\Tests\ORM\Functional; namespace Doctrine\Tests\ORM\Functional;
use Doctrine\Common\Collections\ArrayCollection; use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\ORM\Proxy\Proxy;
use Doctrine\Tests\OrmFunctionalTestCase; use Doctrine\Tests\OrmFunctionalTestCase;
/** /**
@ -17,10 +18,10 @@ class ClassTableInheritanceTest2 extends OrmFunctionalTestCase
try { try {
$this->_schemaTool->createSchema( $this->_schemaTool->createSchema(
[ [
$this->_em->getClassMetadata('Doctrine\Tests\ORM\Functional\CTIParent'), $this->_em->getClassMetadata(CTIParent::class),
$this->_em->getClassMetadata('Doctrine\Tests\ORM\Functional\CTIChild'), $this->_em->getClassMetadata(CTIChild::class),
$this->_em->getClassMetadata('Doctrine\Tests\ORM\Functional\CTIRelated'), $this->_em->getClassMetadata(CTIRelated::class),
$this->_em->getClassMetadata('Doctrine\Tests\ORM\Functional\CTIRelated2') $this->_em->getClassMetadata(CTIRelated2::class)
] ]
); );
} catch (\Exception $ignored) { } catch (\Exception $ignored) {
@ -44,11 +45,11 @@ class ClassTableInheritanceTest2 extends OrmFunctionalTestCase
$relatedId = $related->getId(); $relatedId = $related->getId();
$related2 = $this->_em->find('Doctrine\Tests\ORM\Functional\CTIRelated', $relatedId); $related2 = $this->_em->find(CTIRelated::class, $relatedId);
$this->assertInstanceOf('Doctrine\Tests\ORM\Functional\CTIRelated', $related2); $this->assertInstanceOf(CTIRelated::class, $related2);
$this->assertInstanceOf('Doctrine\Tests\ORM\Functional\CTIChild', $related2->getCTIParent()); $this->assertInstanceOf(CTIChild::class, $related2->getCTIParent());
$this->assertNotInstanceOf('Doctrine\ORM\Proxy\Proxy', $related2->getCTIParent()); $this->assertNotInstanceOf(Proxy::class, $related2->getCTIParent());
$this->assertEquals('hello', $related2->getCTIParent()->getData()); $this->assertEquals('hello', $related2->getCTIParent()->getData());
$this->assertSame($related2, $related2->getCTIParent()->getRelated()); $this->assertSame($related2, $related2->getCTIParent()->getRelated());
@ -72,7 +73,7 @@ class ClassTableInheritanceTest2 extends OrmFunctionalTestCase
$this->assertFalse($mmrel2->getCTIChildren()->isInitialized()); $this->assertFalse($mmrel2->getCTIChildren()->isInitialized());
$this->assertEquals(1, count($mmrel2->getCTIChildren())); $this->assertEquals(1, count($mmrel2->getCTIChildren()));
$this->assertTrue($mmrel2->getCTIChildren()->isInitialized()); $this->assertTrue($mmrel2->getCTIChildren()->isInitialized());
$this->assertInstanceOf('Doctrine\Tests\ORM\Functional\CTIChild', $mmrel2->getCTIChildren()->get(0)); $this->assertInstanceOf(CTIChild::class, $mmrel2->getCTIChildren()->get(0));
} }
} }

View File

@ -30,7 +30,7 @@ class CompositePrimaryKeyTest extends OrmFunctionalTestCase
public function putTripAroundEurope() public function putTripAroundEurope()
{ {
$poi = $this->_em->find('Doctrine\Tests\Models\Navigation\NavPointOfInterest', ['lat' => 100, 'long' => 200]); $poi = $this->_em->find(NavPointOfInterest::class, ['lat' => 100, 'long' => 200]);
$tour = new NavTour("Trip around Europe"); $tour = new NavTour("Trip around Europe");
$tour->addPointOfInterest($poi); $tour->addPointOfInterest($poi);
@ -46,9 +46,9 @@ class CompositePrimaryKeyTest extends OrmFunctionalTestCase
{ {
$this->putGermanysBrandenburderTor(); $this->putGermanysBrandenburderTor();
$poi = $this->_em->find('Doctrine\Tests\Models\Navigation\NavPointOfInterest', ['lat' => 100, 'long' => 200]); $poi = $this->_em->find(NavPointOfInterest::class, ['lat' => 100, 'long' => 200]);
$this->assertInstanceOf('Doctrine\Tests\Models\Navigation\NavPointOfInterest', $poi); $this->assertInstanceOf(NavPointOfInterest::class, $poi);
$this->assertEquals(100, $poi->getLat()); $this->assertEquals(100, $poi->getLat());
$this->assertEquals(200, $poi->getLong()); $this->assertEquals(200, $poi->getLong());
$this->assertEquals('Brandenburger Tor', $poi->getName()); $this->assertEquals('Brandenburger Tor', $poi->getName());
@ -61,7 +61,7 @@ class CompositePrimaryKeyTest extends OrmFunctionalTestCase
{ {
$this->putGermanysBrandenburderTor(); $this->putGermanysBrandenburderTor();
$poi = $this->_em->find('Doctrine\Tests\Models\Navigation\NavPointOfInterest', ['lat' => 100, 'long' => 200]); $poi = $this->_em->find(NavPointOfInterest::class, ['lat' => 100, 'long' => 200]);
$photo = new NavPhotos($poi, "asdf"); $photo = new NavPhotos($poi, "asdf");
$this->_em->persist($photo); $this->_em->persist($photo);
$this->_em->flush(); $this->_em->flush();
@ -79,7 +79,7 @@ class CompositePrimaryKeyTest extends OrmFunctionalTestCase
{ {
$this->putGermanysBrandenburderTor(); $this->putGermanysBrandenburderTor();
$poi = $this->_em->find('Doctrine\Tests\Models\Navigation\NavPointOfInterest', ['lat' => 100, 'long' => 200]); $poi = $this->_em->find(NavPointOfInterest::class, ['lat' => 100, 'long' => 200]);
$photo = new NavPhotos($poi, "asdf"); $photo = new NavPhotos($poi, "asdf");
$this->_em->persist($photo); $this->_em->persist($photo);
$this->_em->flush(); $this->_em->flush();
@ -98,7 +98,7 @@ class CompositePrimaryKeyTest extends OrmFunctionalTestCase
$this->putGermanysBrandenburderTor(); $this->putGermanysBrandenburderTor();
$tour = $this->putTripAroundEurope(); $tour = $this->putTripAroundEurope();
$tour = $this->_em->find('Doctrine\Tests\Models\Navigation\NavTour', $tour->getId()); $tour = $this->_em->find(NavTour::class, $tour->getId());
$this->assertEquals(1, count($tour->getPointOfInterests())); $this->assertEquals(1, count($tour->getPointOfInterests()));
} }
@ -140,7 +140,7 @@ class CompositePrimaryKeyTest extends OrmFunctionalTestCase
$this->expectException(ORMException::class); $this->expectException(ORMException::class);
$this->expectExceptionMessage('The identifier long is missing for a query of Doctrine\Tests\Models\Navigation\NavPointOfInterest'); $this->expectExceptionMessage('The identifier long is missing for a query of Doctrine\Tests\Models\Navigation\NavPointOfInterest');
$poi = $this->_em->find('Doctrine\Tests\Models\Navigation\NavPointOfInterest', ['key1' => 100]); $poi = $this->_em->find(NavPointOfInterest::class, ['key1' => 100]);
} }
public function testUnrecognizedIdentifierFieldsOnGetReference() public function testUnrecognizedIdentifierFieldsOnGetReference()
@ -148,7 +148,7 @@ class CompositePrimaryKeyTest extends OrmFunctionalTestCase
$this->expectException(ORMException::class); $this->expectException(ORMException::class);
$this->expectExceptionMessage("Unrecognized identifier fields: 'key1'"); $this->expectExceptionMessage("Unrecognized identifier fields: 'key1'");
$poi = $this->_em->getReference('Doctrine\Tests\Models\Navigation\NavPointOfInterest', ['lat' => 10, 'long' => 20, 'key1' => 100] $poi = $this->_em->getReference(NavPointOfInterest::class, ['lat' => 10, 'long' => 20, 'key1' => 100]
); );
} }
@ -159,7 +159,7 @@ class CompositePrimaryKeyTest extends OrmFunctionalTestCase
{ {
$this->putGermanysBrandenburderTor(); $this->putGermanysBrandenburderTor();
$poi = $this->_em->find('Doctrine\Tests\Models\Navigation\NavPointOfInterest', ['lat' => 100, 'long' => 200]); $poi = $this->_em->find(NavPointOfInterest::class, ['lat' => 100, 'long' => 200]);
$poi->addVisitor(new NavUser("test1")); $poi->addVisitor(new NavUser("test1"));
$poi->addVisitor(new NavUser("test2")); $poi->addVisitor(new NavUser("test2"));
@ -170,7 +170,7 @@ class CompositePrimaryKeyTest extends OrmFunctionalTestCase
$this->_em->flush(); $this->_em->flush();
$this->_em->clear(); $this->_em->clear();
$poi = $this->_em->find('Doctrine\Tests\Models\Navigation\NavPointOfInterest', ['lat' => 100, 'long' => 200]); $poi = $this->_em->find(NavPointOfInterest::class, ['lat' => 100, 'long' => 200]);
$this->assertEquals(0, count($poi->getVisitors())); $this->assertEquals(0, count($poi->getVisitors()));
} }
} }

View File

@ -41,8 +41,8 @@ class CompositePrimaryKeyWithAssociationsTest extends OrmFunctionalTestCase
public function testFindByAbleToGetCompositeEntitiesWithMixedTypeIdentifiers() public function testFindByAbleToGetCompositeEntitiesWithMixedTypeIdentifiers()
{ {
$admin1Repo = $this->_em->getRepository('Doctrine\Tests\Models\GeoNames\Admin1'); $admin1Repo = $this->_em->getRepository(Admin1::class);
$admin1NamesRepo = $this->_em->getRepository('Doctrine\Tests\Models\GeoNames\Admin1AlternateName'); $admin1NamesRepo = $this->_em->getRepository(Admin1AlternateName::class);
$admin1Rome = $admin1Repo->findOneBy(['country' => 'IT', 'id' => 1]); $admin1Rome = $admin1Repo->findOneBy(['country' => 'IT', 'id' => 1]);

View File

@ -14,9 +14,9 @@ class CustomIdObjectTypeTest extends OrmFunctionalTestCase
protected function setUp() protected function setUp()
{ {
if (DBALType::hasType(CustomIdObjectType::NAME)) { if (DBALType::hasType(CustomIdObjectType::NAME)) {
DBALType::overrideType(CustomIdObjectType::NAME, CustomIdObjectType::CLASSNAME); DBALType::overrideType(CustomIdObjectType::NAME, CustomIdObjectType::class);
} else { } else {
DBALType::addType(CustomIdObjectType::NAME, CustomIdObjectType::CLASSNAME); DBALType::addType(CustomIdObjectType::NAME, CustomIdObjectType::class);
} }
$this->useModelSet('custom_id_object_type'); $this->useModelSet('custom_id_object_type');
@ -31,7 +31,7 @@ class CustomIdObjectTypeTest extends OrmFunctionalTestCase
$this->_em->persist($parent); $this->_em->persist($parent);
$this->_em->flush(); $this->_em->flush();
$result = $this->_em->find(CustomIdObjectTypeParent::CLASSNAME, $parent->id); $result = $this->_em->find(CustomIdObjectTypeParent::class, $parent->id);
$this->assertSame($parent, $result); $this->assertSame($parent, $result);
} }
@ -53,7 +53,7 @@ class CustomIdObjectTypeTest extends OrmFunctionalTestCase
->_em ->_em
->createQuery( ->createQuery(
'SELECT parent, children FROM ' 'SELECT parent, children FROM '
. CustomIdObjectTypeParent::CLASSNAME . CustomIdObjectTypeParent::class
. ' parent LEFT JOIN parent.children children' . ' parent LEFT JOIN parent.children children'
) )
->getResult(); ->getResult();
@ -80,7 +80,7 @@ class CustomIdObjectTypeTest extends OrmFunctionalTestCase
->_em ->_em
->createQuery( ->createQuery(
'SELECT parent, children FROM ' 'SELECT parent, children FROM '
. CustomIdObjectTypeParent::CLASSNAME . CustomIdObjectTypeParent::class
. ' parent LEFT JOIN parent.children children ' . ' parent LEFT JOIN parent.children children '
. 'WHERE children.id = ?1' . 'WHERE children.id = ?1'
) )

View File

@ -1,6 +1,7 @@
<?php <?php
namespace Doctrine\Tests\ORM\Functional; namespace Doctrine\Tests\ORM\Functional;
use Doctrine\Tests\OrmFunctionalTestCase; use Doctrine\Tests\OrmFunctionalTestCase;
/** /**
@ -16,8 +17,8 @@ class DefaultValuesTest extends OrmFunctionalTestCase
try { try {
$this->_schemaTool->createSchema( $this->_schemaTool->createSchema(
[ [
$this->_em->getClassMetadata('Doctrine\Tests\ORM\Functional\DefaultValueUser'), $this->_em->getClassMetadata(DefaultValueUser::class),
$this->_em->getClassMetadata('Doctrine\Tests\ORM\Functional\DefaultValueAddress') $this->_em->getClassMetadata(DefaultValueAddress::class)
] ]
); );
} catch (\Exception $e) { } catch (\Exception $e) {
@ -55,7 +56,7 @@ class DefaultValuesTest extends OrmFunctionalTestCase
$this->_em->clear(); $this->_em->clear();
$a2 = $this->_em->find(get_class($a), $a->id); $a2 = $this->_em->find(get_class($a), $a->id);
$this->assertInstanceOf('Doctrine\Tests\ORM\Functional\DefaultValueUser', $a2->getUser()); $this->assertInstanceOf(DefaultValueUser::class, $a2->getUser());
$this->assertEquals($userId, $a2->getUser()->getId()); $this->assertEquals($userId, $a2->getUser()->getId());
$this->assertEquals('Poweruser', $a2->getUser()->type); $this->assertEquals('Poweruser', $a2->getUser()->type);
} }
@ -73,13 +74,13 @@ class DefaultValuesTest extends OrmFunctionalTestCase
$this->_em->flush(); $this->_em->flush();
$this->_em->clear(); $this->_em->clear();
$user = $this->_em->getPartialReference('Doctrine\Tests\ORM\Functional\DefaultValueUser', $user->id); $user = $this->_em->getPartialReference(DefaultValueUser::class, $user->id);
$this->assertTrue($this->_em->getUnitOfWork()->isReadOnly($user)); $this->assertTrue($this->_em->getUnitOfWork()->isReadOnly($user));
$this->_em->flush(); $this->_em->flush();
$this->_em->clear(); $this->_em->clear();
$user = $this->_em->find('Doctrine\Tests\ORM\Functional\DefaultValueUser', $user->id); $user = $this->_em->find(DefaultValueUser::class, $user->id);
$this->assertEquals('Normaluser', $user->type); $this->assertEquals('Normaluser', $user->type);
} }

View File

@ -3,6 +3,7 @@
namespace Doctrine\Tests\ORM\Functional; namespace Doctrine\Tests\ORM\Functional;
use Doctrine\ORM\OptimisticLockException; use Doctrine\ORM\OptimisticLockException;
use Doctrine\ORM\Proxy\Proxy;
use Doctrine\Tests\Models\CMS\CmsUser; use Doctrine\Tests\Models\CMS\CmsUser;
use Doctrine\Tests\Models\CMS\CmsPhonenumber; use Doctrine\Tests\Models\CMS\CmsPhonenumber;
use Doctrine\Tests\Models\CMS\CmsAddress; use Doctrine\Tests\Models\CMS\CmsAddress;
@ -90,8 +91,8 @@ class DetachedEntityTest extends OrmFunctionalTestCase
// Merge back in // Merge back in
$user = $this->_em->merge($user); // merge cascaded to phonenumbers $user = $this->_em->merge($user); // merge cascaded to phonenumbers
$this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsUser', $user->phonenumbers[0]->user); $this->assertInstanceOf(CmsUser::class, $user->phonenumbers[0]->user);
$this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsUser', $user->phonenumbers[1]->user); $this->assertInstanceOf(CmsUser::class, $user->phonenumbers[1]->user);
$im = $this->_em->getUnitOfWork()->getIdentityMap(); $im = $this->_em->getUnitOfWork()->getIdentityMap();
$this->_em->flush(); $this->_em->flush();
@ -100,10 +101,10 @@ class DetachedEntityTest extends OrmFunctionalTestCase
$this->assertNotSame($oldPhonenumbers, $phonenumbers, "Merge should replace the Detached Collection with a new PersistentCollection."); $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."); $this->assertEquals(2, count($phonenumbers), "Failed to assert that two phonenumbers are contained in the merged users phonenumber collection.");
$this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsPhonenumber', $phonenumbers[1]); $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."); $this->assertTrue($this->_em->contains($phonenumbers[1]), "Failed to assert that second phonenumber in collection is contained inside EntityManager persistence context.");
$this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsPhonenumber', $phonenumbers[0]); $this->assertInstanceOf(CmsPhonenumber::class, $phonenumbers[0]);
$this->assertTrue($this->_em->getUnitOfWork()->isInIdentityMap($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."); $this->assertTrue($this->_em->contains($phonenumbers[0]), "Failed to assert that first phonenumber in collection is contained inside EntityManager persistence context.");
} }
@ -145,14 +146,14 @@ class DetachedEntityTest extends OrmFunctionalTestCase
$this->_em->clear(); $this->_em->clear();
$address2 = $this->_em->find(get_class($address), $address->id); $address2 = $this->_em->find(get_class($address), $address->id);
$this->assertInstanceOf('Doctrine\ORM\Proxy\Proxy', $address2->user); $this->assertInstanceOf(Proxy::class, $address2->user);
$this->assertFalse($address2->user->__isInitialized__); $this->assertFalse($address2->user->__isInitialized__);
$detachedAddress2 = unserialize(serialize($address2)); $detachedAddress2 = unserialize(serialize($address2));
$this->assertInstanceOf('Doctrine\ORM\Proxy\Proxy', $detachedAddress2->user); $this->assertInstanceOf(Proxy::class, $detachedAddress2->user);
$this->assertFalse($detachedAddress2->user->__isInitialized__); $this->assertFalse($detachedAddress2->user->__isInitialized__);
$managedAddress2 = $this->_em->merge($detachedAddress2); $managedAddress2 = $this->_em->merge($detachedAddress2);
$this->assertInstanceOf('Doctrine\ORM\Proxy\Proxy', $managedAddress2->user); $this->assertInstanceOf(Proxy::class, $managedAddress2->user);
$this->assertFalse($managedAddress2->user === $detachedAddress2->user); $this->assertFalse($managedAddress2->user === $detachedAddress2->user);
$this->assertFalse($managedAddress2->user->__isInitialized__); $this->assertFalse($managedAddress2->user->__isInitialized__);
} }
@ -178,7 +179,7 @@ class DetachedEntityTest extends OrmFunctionalTestCase
$newUser = $query->getSingleResult(); $newUser = $query->getSingleResult();
$this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsUser', $newUser); $this->assertInstanceOf(CmsUser::class, $newUser);
$this->assertEquals('gblanco', $newUser->username); $this->assertEquals('gblanco', $newUser->username);
} }

View File

@ -2,6 +2,10 @@
namespace Doctrine\Tests\ORM\Functional; namespace Doctrine\Tests\ORM\Functional;
use Doctrine\Common\Persistence\Event\LifecycleEventArgs;
use Doctrine\ORM\Event\PreFlushEventArgs;
use Doctrine\ORM\Event\PreUpdateEventArgs;
use Doctrine\Tests\Models\Company\CompanyContractListener;
use Doctrine\Tests\Models\Company\CompanyFixContract; use Doctrine\Tests\Models\Company\CompanyFixContract;
use Doctrine\Tests\OrmFunctionalTestCase; use Doctrine\Tests\OrmFunctionalTestCase;
@ -23,7 +27,7 @@ class EntityListenersTest extends OrmFunctionalTestCase
$this->listener = $this->_em->getConfiguration() $this->listener = $this->_em->getConfiguration()
->getEntityListenerResolver() ->getEntityListenerResolver()
->resolve('Doctrine\Tests\Models\Company\CompanyContractListener'); ->resolve(CompanyContractListener::class);
} }
public function testPreFlushListeners() public function testPreFlushListeners()
@ -37,18 +41,9 @@ class EntityListenersTest extends OrmFunctionalTestCase
$this->_em->flush(); $this->_em->flush();
$this->assertCount(1,$this->listener->preFlushCalls); $this->assertCount(1,$this->listener->preFlushCalls);
$this->assertSame($fix, $this->listener->preFlushCalls[0][0]); $this->assertSame($fix, $this->listener->preFlushCalls[0][0]);
$this->assertInstanceOf(CompanyFixContract::class, $this->listener->preFlushCalls[0][0]);
$this->assertInstanceOf( $this->assertInstanceOf(PreFlushEventArgs::class, $this->listener->preFlushCalls[0][1]);
'Doctrine\Tests\Models\Company\CompanyFixContract',
$this->listener->preFlushCalls[0][0]
);
$this->assertInstanceOf(
'Doctrine\ORM\Event\PreFlushEventArgs',
$this->listener->preFlushCalls[0][1]
);
} }
public function testPostLoadListeners() public function testPostLoadListeners()
@ -66,18 +61,9 @@ class EntityListenersTest extends OrmFunctionalTestCase
$fix = $this->_em->createQuery($dql)->setParameter(1, $fix->getId())->getSingleResult(); $fix = $this->_em->createQuery($dql)->setParameter(1, $fix->getId())->getSingleResult();
$this->assertCount(1,$this->listener->postLoadCalls); $this->assertCount(1,$this->listener->postLoadCalls);
$this->assertSame($fix, $this->listener->postLoadCalls[0][0]); $this->assertSame($fix, $this->listener->postLoadCalls[0][0]);
$this->assertInstanceOf(CompanyFixContract::class, $this->listener->postLoadCalls[0][0]);
$this->assertInstanceOf( $this->assertInstanceOf(LifecycleEventArgs::class, $this->listener->postLoadCalls[0][1]);
'Doctrine\Tests\Models\Company\CompanyFixContract',
$this->listener->postLoadCalls[0][0]
);
$this->assertInstanceOf(
'Doctrine\ORM\Event\LifecycleEventArgs',
$this->listener->postLoadCalls[0][1]
);
} }
public function testPrePersistListeners() public function testPrePersistListeners()
@ -91,18 +77,9 @@ class EntityListenersTest extends OrmFunctionalTestCase
$this->_em->flush(); $this->_em->flush();
$this->assertCount(1,$this->listener->prePersistCalls); $this->assertCount(1,$this->listener->prePersistCalls);
$this->assertSame($fix, $this->listener->prePersistCalls[0][0]); $this->assertSame($fix, $this->listener->prePersistCalls[0][0]);
$this->assertInstanceOf(CompanyFixContract::class, $this->listener->prePersistCalls[0][0]);
$this->assertInstanceOf( $this->assertInstanceOf(LifecycleEventArgs::class, $this->listener->prePersistCalls[0][1]);
'Doctrine\Tests\Models\Company\CompanyFixContract',
$this->listener->prePersistCalls[0][0]
);
$this->assertInstanceOf(
'Doctrine\ORM\Event\LifecycleEventArgs',
$this->listener->prePersistCalls[0][1]
);
} }
public function testPostPersistListeners() public function testPostPersistListeners()
@ -116,18 +93,9 @@ class EntityListenersTest extends OrmFunctionalTestCase
$this->_em->flush(); $this->_em->flush();
$this->assertCount(1,$this->listener->postPersistCalls); $this->assertCount(1,$this->listener->postPersistCalls);
$this->assertSame($fix, $this->listener->postPersistCalls[0][0]); $this->assertSame($fix, $this->listener->postPersistCalls[0][0]);
$this->assertInstanceOf(CompanyFixContract::class, $this->listener->postPersistCalls[0][0]);
$this->assertInstanceOf( $this->assertInstanceOf(LifecycleEventArgs::class, $this->listener->postPersistCalls[0][1]);
'Doctrine\Tests\Models\Company\CompanyFixContract',
$this->listener->postPersistCalls[0][0]
);
$this->assertInstanceOf(
'Doctrine\ORM\Event\LifecycleEventArgs',
$this->listener->postPersistCalls[0][1]
);
} }
public function testPreUpdateListeners() public function testPreUpdateListeners()
@ -146,18 +114,9 @@ class EntityListenersTest extends OrmFunctionalTestCase
$this->_em->flush(); $this->_em->flush();
$this->assertCount(1,$this->listener->preUpdateCalls); $this->assertCount(1,$this->listener->preUpdateCalls);
$this->assertSame($fix, $this->listener->preUpdateCalls[0][0]); $this->assertSame($fix, $this->listener->preUpdateCalls[0][0]);
$this->assertInstanceOf(CompanyFixContract::class, $this->listener->preUpdateCalls[0][0]);
$this->assertInstanceOf( $this->assertInstanceOf(PreUpdateEventArgs::class, $this->listener->preUpdateCalls[0][1]);
'Doctrine\Tests\Models\Company\CompanyFixContract',
$this->listener->preUpdateCalls[0][0]
);
$this->assertInstanceOf(
'Doctrine\ORM\Event\PreUpdateEventArgs',
$this->listener->preUpdateCalls[0][1]
);
} }
public function testPostUpdateListeners() public function testPostUpdateListeners()
@ -176,18 +135,9 @@ class EntityListenersTest extends OrmFunctionalTestCase
$this->_em->flush(); $this->_em->flush();
$this->assertCount(1,$this->listener->postUpdateCalls); $this->assertCount(1,$this->listener->postUpdateCalls);
$this->assertSame($fix, $this->listener->postUpdateCalls[0][0]); $this->assertSame($fix, $this->listener->postUpdateCalls[0][0]);
$this->assertInstanceOf(CompanyFixContract::class, $this->listener->postUpdateCalls[0][0]);
$this->assertInstanceOf( $this->assertInstanceOf(LifecycleEventArgs::class, $this->listener->postUpdateCalls[0][1]);
'Doctrine\Tests\Models\Company\CompanyFixContract',
$this->listener->postUpdateCalls[0][0]
);
$this->assertInstanceOf(
'Doctrine\ORM\Event\LifecycleEventArgs',
$this->listener->postUpdateCalls[0][1]
);
} }
public function testPreRemoveListeners() public function testPreRemoveListeners()
@ -204,18 +154,9 @@ class EntityListenersTest extends OrmFunctionalTestCase
$this->_em->flush(); $this->_em->flush();
$this->assertCount(1,$this->listener->preRemoveCalls); $this->assertCount(1,$this->listener->preRemoveCalls);
$this->assertSame($fix, $this->listener->preRemoveCalls[0][0]); $this->assertSame($fix, $this->listener->preRemoveCalls[0][0]);
$this->assertInstanceOf(CompanyFixContract::class, $this->listener->preRemoveCalls[0][0]);
$this->assertInstanceOf( $this->assertInstanceOf(LifecycleEventArgs::class, $this->listener->preRemoveCalls[0][1]);
'Doctrine\Tests\Models\Company\CompanyFixContract',
$this->listener->preRemoveCalls[0][0]
);
$this->assertInstanceOf(
'Doctrine\ORM\Event\LifecycleEventArgs',
$this->listener->preRemoveCalls[0][1]
);
} }
public function testPostRemoveListeners() public function testPostRemoveListeners()
@ -232,17 +173,8 @@ class EntityListenersTest extends OrmFunctionalTestCase
$this->_em->flush(); $this->_em->flush();
$this->assertCount(1,$this->listener->postRemoveCalls); $this->assertCount(1,$this->listener->postRemoveCalls);
$this->assertSame($fix, $this->listener->postRemoveCalls[0][0]); $this->assertSame($fix, $this->listener->postRemoveCalls[0][0]);
$this->assertInstanceOf(CompanyFixContract::class, $this->listener->postRemoveCalls[0][0]);
$this->assertInstanceOf( $this->assertInstanceOf(LifecycleEventArgs::class, $this->listener->postRemoveCalls[0][1]);
'Doctrine\Tests\Models\Company\CompanyFixContract',
$this->listener->postRemoveCalls[0][0]
);
$this->assertInstanceOf(
'Doctrine\ORM\Event\LifecycleEventArgs',
$this->listener->postRemoveCalls[0][1]
);
} }
} }

View File

@ -2,6 +2,7 @@
namespace Doctrine\Tests\ORM\Functional; namespace Doctrine\Tests\ORM\Functional;
use Doctrine\ORM\LazyCriteriaCollection;
use Doctrine\Tests\Models\Generic\DateTimeModel; use Doctrine\Tests\Models\Generic\DateTimeModel;
use Doctrine\Common\Collections\Criteria; use Doctrine\Common\Collections\Criteria;
use Doctrine\Tests\Models\Tweet\Tweet; use Doctrine\Tests\Models\Tweet\Tweet;
@ -64,7 +65,7 @@ class EntityRepositoryCriteriaTest extends OrmFunctionalTestCase
{ {
$this->loadFixture(); $this->loadFixture();
$repository = $this->_em->getRepository('Doctrine\Tests\Models\Generic\DateTimeModel'); $repository = $this->_em->getRepository(DateTimeModel::class);
$dates = $repository->matching(new Criteria( $dates = $repository->matching(new Criteria(
Criteria::expr()->lte('datetime', new \DateTime('today')) Criteria::expr()->lte('datetime', new \DateTime('today'))
)); ));
@ -95,7 +96,7 @@ class EntityRepositoryCriteriaTest extends OrmFunctionalTestCase
public function testIsNullComparison() public function testIsNullComparison()
{ {
$this->loadNullFieldFixtures(); $this->loadNullFieldFixtures();
$repository = $this->_em->getRepository('Doctrine\Tests\Models\Generic\DateTimeModel'); $repository = $this->_em->getRepository(DateTimeModel::class);
$dates = $repository->matching(new Criteria( $dates = $repository->matching(new Criteria(
Criteria::expr()->isNull('time') Criteria::expr()->isNull('time')
@ -107,7 +108,7 @@ class EntityRepositoryCriteriaTest extends OrmFunctionalTestCase
public function testEqNullComparison() public function testEqNullComparison()
{ {
$this->loadNullFieldFixtures(); $this->loadNullFieldFixtures();
$repository = $this->_em->getRepository('Doctrine\Tests\Models\Generic\DateTimeModel'); $repository = $this->_em->getRepository(DateTimeModel::class);
$dates = $repository->matching(new Criteria( $dates = $repository->matching(new Criteria(
Criteria::expr()->eq('time', null) Criteria::expr()->eq('time', null)
@ -119,7 +120,7 @@ class EntityRepositoryCriteriaTest extends OrmFunctionalTestCase
public function testNotEqNullComparison() public function testNotEqNullComparison()
{ {
$this->loadNullFieldFixtures(); $this->loadNullFieldFixtures();
$repository = $this->_em->getRepository('Doctrine\Tests\Models\Generic\DateTimeModel'); $repository = $this->_em->getRepository(DateTimeModel::class);
$dates = $repository->matching(new Criteria( $dates = $repository->matching(new Criteria(
Criteria::expr()->neq('time', null) Criteria::expr()->neq('time', null)
@ -131,7 +132,7 @@ class EntityRepositoryCriteriaTest extends OrmFunctionalTestCase
public function testCanCountWithoutLoadingCollection() public function testCanCountWithoutLoadingCollection()
{ {
$this->loadFixture(); $this->loadFixture();
$repository = $this->_em->getRepository('Doctrine\Tests\Models\Generic\DateTimeModel'); $repository = $this->_em->getRepository(DateTimeModel::class);
$dates = $repository->matching(new Criteria()); $dates = $repository->matching(new Criteria());
@ -171,10 +172,10 @@ class EntityRepositoryCriteriaTest extends OrmFunctionalTestCase
$criteria = new Criteria(); $criteria = new Criteria();
$criteria->andWhere($criteria->expr()->contains('content', 'Criteria')); $criteria->andWhere($criteria->expr()->contains('content', 'Criteria'));
$user = $this->_em->find('Doctrine\Tests\Models\Tweet\User', $user->id); $user = $this->_em->find(User::class, $user->id);
$tweets = $user->tweets->matching($criteria); $tweets = $user->tweets->matching($criteria);
$this->assertInstanceOf('Doctrine\ORM\LazyCriteriaCollection', $tweets); $this->assertInstanceOf(LazyCriteriaCollection::class, $tweets);
$this->assertFalse($tweets->isInitialized()); $this->assertFalse($tweets->isInitialized());
$tweets->contains($tweet); $tweets->contains($tweet);

View File

@ -2,16 +2,23 @@
namespace Doctrine\Tests\ORM\Functional; namespace Doctrine\Tests\ORM\Functional;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Criteria;
use Doctrine\DBAL\Connection; use Doctrine\DBAL\Connection;
use Doctrine\DBAL\LockMode; use Doctrine\DBAL\LockMode;
use Doctrine\ORM\EntityRepository;
use Doctrine\ORM\OptimisticLockException; use Doctrine\ORM\OptimisticLockException;
use Doctrine\ORM\ORMException; use Doctrine\ORM\ORMException;
use Doctrine\ORM\Query;
use Doctrine\ORM\TransactionRequiredException; use Doctrine\ORM\TransactionRequiredException;
use Doctrine\Tests\Models\CMS\CmsUser;
use Doctrine\Tests\Models\CMS\CmsEmail;
use Doctrine\Tests\Models\CMS\CmsAddress; use Doctrine\Tests\Models\CMS\CmsAddress;
use Doctrine\Common\Collections\Criteria; use Doctrine\Tests\Models\CMS\CmsEmail;
use Doctrine\Common\Collections\ArrayCollection; use Doctrine\Tests\Models\CMS\CmsUser;
use Doctrine\Tests\Models\DDC753\DDC753CustomRepository;
use Doctrine\Tests\Models\DDC753\DDC753DefaultRepository;
use Doctrine\Tests\Models\DDC753\DDC753EntityWithCustomRepository;
use Doctrine\Tests\Models\DDC753\DDC753EntityWithDefaultCustomRepository;
use Doctrine\Tests\Models\DDC753\DDC753InvalidRepository;
use Doctrine\Tests\OrmFunctionalTestCase; use Doctrine\Tests\OrmFunctionalTestCase;
/** /**
@ -170,10 +177,10 @@ class EntityRepositoryTest extends OrmFunctionalTestCase
public function testBasicFind() public function testBasicFind()
{ {
$user1Id = $this->loadFixture(); $user1Id = $this->loadFixture();
$repos = $this->_em->getRepository('Doctrine\Tests\Models\CMS\CmsUser'); $repos = $this->_em->getRepository(CmsUser::class);
$user = $repos->find($user1Id); $user = $repos->find($user1Id);
$this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsUser',$user); $this->assertInstanceOf(CmsUser::class,$user);
$this->assertEquals('Roman', $user->name); $this->assertEquals('Roman', $user->name);
$this->assertEquals('freak', $user->status); $this->assertEquals('freak', $user->status);
} }
@ -181,11 +188,11 @@ class EntityRepositoryTest extends OrmFunctionalTestCase
public function testFindByField() public function testFindByField()
{ {
$user1Id = $this->loadFixture(); $user1Id = $this->loadFixture();
$repos = $this->_em->getRepository('Doctrine\Tests\Models\CMS\CmsUser'); $repos = $this->_em->getRepository(CmsUser::class);
$users = $repos->findBy(['status' => 'dev']); $users = $repos->findBy(['status' => 'dev']);
$this->assertEquals(2, count($users)); $this->assertEquals(2, count($users));
$this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsUser',$users[0]); $this->assertInstanceOf(CmsUser::class,$users[0]);
$this->assertEquals('Guilherme', $users[0]->name); $this->assertEquals('Guilherme', $users[0]->name);
$this->assertEquals('dev', $users[0]->status); $this->assertEquals('dev', $users[0]->status);
} }
@ -207,11 +214,11 @@ class EntityRepositoryTest extends OrmFunctionalTestCase
$this->_em->clear(); $this->_em->clear();
$repository = $this->_em->getRepository('Doctrine\Tests\Models\CMS\CmsAddress'); $repository = $this->_em->getRepository(CmsAddress::class);
$addresses = $repository->findBy(['user' => [$user1->getId(), $user2->getId()]]); $addresses = $repository->findBy(['user' => [$user1->getId(), $user2->getId()]]);
$this->assertEquals(2, count($addresses)); $this->assertEquals(2, count($addresses));
$this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsAddress',$addresses[0]); $this->assertInstanceOf(CmsAddress::class,$addresses[0]);
} }
public function testFindByAssociationWithObjectAsParameter() public function testFindByAssociationWithObjectAsParameter()
@ -231,21 +238,21 @@ class EntityRepositoryTest extends OrmFunctionalTestCase
$this->_em->clear(); $this->_em->clear();
$repository = $this->_em->getRepository('Doctrine\Tests\Models\CMS\CmsAddress'); $repository = $this->_em->getRepository(CmsAddress::class);
$addresses = $repository->findBy(['user' => [$user1, $user2]]); $addresses = $repository->findBy(['user' => [$user1, $user2]]);
$this->assertEquals(2, count($addresses)); $this->assertEquals(2, count($addresses));
$this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsAddress',$addresses[0]); $this->assertInstanceOf(CmsAddress::class,$addresses[0]);
} }
public function testFindFieldByMagicCall() public function testFindFieldByMagicCall()
{ {
$user1Id = $this->loadFixture(); $user1Id = $this->loadFixture();
$repos = $this->_em->getRepository('Doctrine\Tests\Models\CMS\CmsUser'); $repos = $this->_em->getRepository(CmsUser::class);
$users = $repos->findByStatus('dev'); $users = $repos->findByStatus('dev');
$this->assertEquals(2, count($users)); $this->assertEquals(2, count($users));
$this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsUser',$users[0]); $this->assertInstanceOf(CmsUser::class,$users[0]);
$this->assertEquals('Guilherme', $users[0]->name); $this->assertEquals('Guilherme', $users[0]->name);
$this->assertEquals('dev', $users[0]->status); $this->assertEquals('dev', $users[0]->status);
} }
@ -253,7 +260,7 @@ class EntityRepositoryTest extends OrmFunctionalTestCase
public function testFindAll() public function testFindAll()
{ {
$user1Id = $this->loadFixture(); $user1Id = $this->loadFixture();
$repos = $this->_em->getRepository('Doctrine\Tests\Models\CMS\CmsUser'); $repos = $this->_em->getRepository(CmsUser::class);
$users = $repos->findAll(); $users = $repos->findAll();
$this->assertEquals(4, count($users)); $this->assertEquals(4, count($users));
@ -262,7 +269,7 @@ class EntityRepositoryTest extends OrmFunctionalTestCase
public function testFindByAlias() public function testFindByAlias()
{ {
$user1Id = $this->loadFixture(); $user1Id = $this->loadFixture();
$repos = $this->_em->getRepository('Doctrine\Tests\Models\CMS\CmsUser'); $repos = $this->_em->getRepository(CmsUser::class);
$this->_em->getConfiguration()->addEntityNamespace('CMS', 'Doctrine\Tests\Models\CMS'); $this->_em->getConfiguration()->addEntityNamespace('CMS', 'Doctrine\Tests\Models\CMS');
@ -300,7 +307,7 @@ class EntityRepositoryTest extends OrmFunctionalTestCase
* @expectedException \Doctrine\ORM\ORMException * @expectedException \Doctrine\ORM\ORMException
*/ */
public function testExceptionIsThrownWhenCallingFindByWithoutParameter() { public function testExceptionIsThrownWhenCallingFindByWithoutParameter() {
$this->_em->getRepository('Doctrine\Tests\Models\CMS\CmsUser') $this->_em->getRepository(CmsUser::class)
->findByStatus(); ->findByStatus();
} }
@ -308,7 +315,7 @@ class EntityRepositoryTest extends OrmFunctionalTestCase
* @expectedException \Doctrine\ORM\ORMException * @expectedException \Doctrine\ORM\ORMException
*/ */
public function testExceptionIsThrownWhenUsingInvalidFieldName() { public function testExceptionIsThrownWhenUsingInvalidFieldName() {
$this->_em->getRepository('Doctrine\Tests\Models\CMS\CmsUser') $this->_em->getRepository(CmsUser::class)
->findByThisFieldDoesNotExist('testvalue'); ->findByThisFieldDoesNotExist('testvalue');
} }
@ -320,7 +327,7 @@ class EntityRepositoryTest extends OrmFunctionalTestCase
{ {
$this->expectException(TransactionRequiredException::class); $this->expectException(TransactionRequiredException::class);
$this->_em->getRepository('Doctrine\Tests\Models\CMS\CmsUser') $this->_em->getRepository(CmsUser::class)
->find(1, LockMode::PESSIMISTIC_READ); ->find(1, LockMode::PESSIMISTIC_READ);
} }
@ -332,7 +339,7 @@ class EntityRepositoryTest extends OrmFunctionalTestCase
{ {
$this->expectException(TransactionRequiredException::class); $this->expectException(TransactionRequiredException::class);
$this->_em->getRepository('Doctrine\Tests\Models\CMS\CmsUser') $this->_em->getRepository(CmsUser::class)
->find(1, LockMode::PESSIMISTIC_WRITE); ->find(1, LockMode::PESSIMISTIC_WRITE);
} }
@ -344,7 +351,7 @@ class EntityRepositoryTest extends OrmFunctionalTestCase
{ {
$this->expectException(OptimisticLockException::class); $this->expectException(OptimisticLockException::class);
$this->_em->getRepository('Doctrine\Tests\Models\CMS\CmsUser') $this->_em->getRepository(CmsUser::class)
->find(1, LockMode::OPTIMISTIC); ->find(1, LockMode::OPTIMISTIC);
} }
@ -363,11 +370,11 @@ class EntityRepositoryTest extends OrmFunctionalTestCase
$userId = $user->id; $userId = $user->id;
$this->_em->find('Doctrine\Tests\Models\CMS\CmsUser', $userId); $this->_em->find(CmsUser::class, $userId);
$this->expectException(OptimisticLockException::class); $this->expectException(OptimisticLockException::class);
$this->_em->find('Doctrine\Tests\Models\CMS\CmsUser', $userId, LockMode::OPTIMISTIC); $this->_em->find(CmsUser::class, $userId, LockMode::OPTIMISTIC);
} }
/** /**
@ -377,7 +384,7 @@ class EntityRepositoryTest extends OrmFunctionalTestCase
{ {
$this->loadFixture(); $this->loadFixture();
$repos = $this->_em->getRepository('Doctrine\Tests\Models\CMS\CmsUser'); $repos = $this->_em->getRepository(CmsUser::class);
$users = $repos->findByStatus(null); $users = $repos->findByStatus(null);
$this->assertEquals(1, count($users)); $this->assertEquals(1, count($users));
@ -390,7 +397,7 @@ class EntityRepositoryTest extends OrmFunctionalTestCase
{ {
$this->expectException(\BadMethodCallException::class); $this->expectException(\BadMethodCallException::class);
$repos = $this->_em->getRepository('Doctrine\Tests\Models\CMS\CmsUser'); $repos = $this->_em->getRepository(CmsUser::class);
$repos->foo(); $repos->foo();
} }
@ -400,7 +407,7 @@ class EntityRepositoryTest extends OrmFunctionalTestCase
public function testFindByAssociationKey_ExceptionOnInverseSide() public function testFindByAssociationKey_ExceptionOnInverseSide()
{ {
list($userId, $addressId) = $this->loadAssociatedFixture(); list($userId, $addressId) = $this->loadAssociatedFixture();
$repos = $this->_em->getRepository('Doctrine\Tests\Models\CMS\CmsUser'); $repos = $this->_em->getRepository(CmsUser::class);
$this->expectException(ORMException::class); $this->expectException(ORMException::class);
$this->expectExceptionMessage("You cannot search for the association field 'Doctrine\Tests\Models\CMS\CmsUser#address', because it is the inverse side of an association. Find methods only work on owning side associations."); $this->expectExceptionMessage("You cannot search for the association field 'Doctrine\Tests\Models\CMS\CmsUser#address', because it is the inverse side of an association. Find methods only work on owning side associations.");
@ -414,10 +421,10 @@ class EntityRepositoryTest extends OrmFunctionalTestCase
public function testFindOneByAssociationKey() public function testFindOneByAssociationKey()
{ {
list($userId, $addressId) = $this->loadAssociatedFixture(); list($userId, $addressId) = $this->loadAssociatedFixture();
$repos = $this->_em->getRepository('Doctrine\Tests\Models\CMS\CmsAddress'); $repos = $this->_em->getRepository(CmsAddress::class);
$address = $repos->findOneBy(['user' => $userId]); $address = $repos->findOneBy(['user' => $userId]);
$this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsAddress', $address); $this->assertInstanceOf(CmsAddress::class, $address);
$this->assertEquals($addressId, $address->id); $this->assertEquals($addressId, $address->id);
} }
@ -428,7 +435,7 @@ class EntityRepositoryTest extends OrmFunctionalTestCase
{ {
$this->loadFixture(); $this->loadFixture();
$repos = $this->_em->getRepository('Doctrine\Tests\Models\CMS\CmsUser'); $repos = $this->_em->getRepository(CmsUser::class);
$userAsc = $repos->findOneBy([], ["username" => "ASC"]); $userAsc = $repos->findOneBy([], ["username" => "ASC"]);
$userDesc = $repos->findOneBy([], ["username" => "DESC"]); $userDesc = $repos->findOneBy([], ["username" => "DESC"]);
@ -441,10 +448,10 @@ class EntityRepositoryTest extends OrmFunctionalTestCase
public function testFindByAssociationKey() public function testFindByAssociationKey()
{ {
list($userId, $addressId) = $this->loadAssociatedFixture(); list($userId, $addressId) = $this->loadAssociatedFixture();
$repos = $this->_em->getRepository('Doctrine\Tests\Models\CMS\CmsAddress'); $repos = $this->_em->getRepository(CmsAddress::class);
$addresses = $repos->findBy(['user' => $userId]); $addresses = $repos->findBy(['user' => $userId]);
$this->assertContainsOnly('Doctrine\Tests\Models\CMS\CmsAddress', $addresses); $this->assertContainsOnly(CmsAddress::class, $addresses);
$this->assertEquals(1, count($addresses)); $this->assertEquals(1, count($addresses));
$this->assertEquals($addressId, $addresses[0]->id); $this->assertEquals($addressId, $addresses[0]->id);
} }
@ -455,10 +462,10 @@ class EntityRepositoryTest extends OrmFunctionalTestCase
public function testFindAssociationByMagicCall() public function testFindAssociationByMagicCall()
{ {
list($userId, $addressId) = $this->loadAssociatedFixture(); list($userId, $addressId) = $this->loadAssociatedFixture();
$repos = $this->_em->getRepository('Doctrine\Tests\Models\CMS\CmsAddress'); $repos = $this->_em->getRepository(CmsAddress::class);
$addresses = $repos->findByUser($userId); $addresses = $repos->findByUser($userId);
$this->assertContainsOnly('Doctrine\Tests\Models\CMS\CmsAddress', $addresses); $this->assertContainsOnly(CmsAddress::class, $addresses);
$this->assertEquals(1, count($addresses)); $this->assertEquals(1, count($addresses));
$this->assertEquals($addressId, $addresses[0]->id); $this->assertEquals($addressId, $addresses[0]->id);
} }
@ -469,26 +476,26 @@ class EntityRepositoryTest extends OrmFunctionalTestCase
public function testFindOneAssociationByMagicCall() public function testFindOneAssociationByMagicCall()
{ {
list($userId, $addressId) = $this->loadAssociatedFixture(); list($userId, $addressId) = $this->loadAssociatedFixture();
$repos = $this->_em->getRepository('Doctrine\Tests\Models\CMS\CmsAddress'); $repos = $this->_em->getRepository(CmsAddress::class);
$address = $repos->findOneByUser($userId); $address = $repos->findOneByUser($userId);
$this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsAddress', $address); $this->assertInstanceOf(CmsAddress::class, $address);
$this->assertEquals($addressId, $address->id); $this->assertEquals($addressId, $address->id);
} }
public function testValidNamedQueryRetrieval() public function testValidNamedQueryRetrieval()
{ {
$repos = $this->_em->getRepository('Doctrine\Tests\Models\CMS\CmsUser'); $repos = $this->_em->getRepository(CmsUser::class);
$query = $repos->createNamedQuery('all'); $query = $repos->createNamedQuery('all');
$this->assertInstanceOf('Doctrine\ORM\Query', $query); $this->assertInstanceOf(Query::class, $query);
$this->assertEquals('SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u', $query->getDQL()); $this->assertEquals('SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u', $query->getDQL());
} }
public function testInvalidNamedQueryRetrieval() public function testInvalidNamedQueryRetrieval()
{ {
$repos = $this->_em->getRepository('Doctrine\Tests\Models\CMS\CmsUser'); $repos = $this->_em->getRepository(CmsUser::class);
$this->expectException(\Doctrine\ORM\Mapping\MappingException::class); $this->expectException(\Doctrine\ORM\Mapping\MappingException::class);
@ -500,7 +507,7 @@ class EntityRepositoryTest extends OrmFunctionalTestCase
*/ */
public function testIsNullCriteriaDoesNotGenerateAParameter() public function testIsNullCriteriaDoesNotGenerateAParameter()
{ {
$repos = $this->_em->getRepository('Doctrine\Tests\Models\CMS\CmsUser'); $repos = $this->_em->getRepository(CmsUser::class);
$users = $repos->findBy(['status' => null, 'username' => 'romanb']); $users = $repos->findBy(['status' => null, 'username' => 'romanb']);
$params = $this->_sqlLoggerStack->queries[$this->_sqlLoggerStack->currentQuery]['params']; $params = $this->_sqlLoggerStack->queries[$this->_sqlLoggerStack->currentQuery]['params'];
@ -512,7 +519,7 @@ class EntityRepositoryTest extends OrmFunctionalTestCase
{ {
$this->loadFixture(); $this->loadFixture();
$repos = $this->_em->getRepository('Doctrine\Tests\Models\CMS\CmsUser'); $repos = $this->_em->getRepository(CmsUser::class);
$users = $repos->findBy(['status' => null]); $users = $repos->findBy(['status' => null]);
$this->assertEquals(1, count($users)); $this->assertEquals(1, count($users));
@ -525,7 +532,7 @@ class EntityRepositoryTest extends OrmFunctionalTestCase
{ {
$this->loadFixture(); $this->loadFixture();
$repos = $this->_em->getRepository('Doctrine\Tests\Models\CMS\CmsUser'); $repos = $this->_em->getRepository(CmsUser::class);
$users1 = $repos->findBy([], null, 1, 0); $users1 = $repos->findBy([], null, 1, 0);
$users2 = $repos->findBy([], null, 1, 1); $users2 = $repos->findBy([], null, 1, 1);
@ -543,7 +550,7 @@ class EntityRepositoryTest extends OrmFunctionalTestCase
{ {
$this->loadFixture(); $this->loadFixture();
$repos = $this->_em->getRepository('Doctrine\Tests\Models\CMS\CmsUser'); $repos = $this->_em->getRepository(CmsUser::class);
$usersAsc = $repos->findBy([], ["username" => "ASC"]); $usersAsc = $repos->findBy([], ["username" => "ASC"]);
$usersDesc = $repos->findBy([], ["username" => "DESC"]); $usersDesc = $repos->findBy([], ["username" => "DESC"]);
@ -560,7 +567,7 @@ class EntityRepositoryTest extends OrmFunctionalTestCase
{ {
$this->loadFixtureUserEmail(); $this->loadFixtureUserEmail();
$repository = $this->_em->getRepository('Doctrine\Tests\Models\CMS\CmsUser'); $repository = $this->_em->getRepository(CmsUser::class);
$resultAsc = $repository->findBy([], ['email' => 'ASC']); $resultAsc = $repository->findBy([], ['email' => 'ASC']);
$resultDesc = $repository->findBy([], ['email' => 'DESC']); $resultDesc = $repository->findBy([], ['email' => 'DESC']);
@ -577,7 +584,7 @@ class EntityRepositoryTest extends OrmFunctionalTestCase
public function testFindFieldByMagicCallOrderBy() public function testFindFieldByMagicCallOrderBy()
{ {
$this->loadFixture(); $this->loadFixture();
$repos = $this->_em->getRepository('Doctrine\Tests\Models\CMS\CmsUser'); $repos = $this->_em->getRepository(CmsUser::class);
$usersAsc = $repos->findByStatus('dev', ['username' => "ASC"]); $usersAsc = $repos->findByStatus('dev', ['username' => "ASC"]);
$usersDesc = $repos->findByStatus('dev', ['username' => "DESC"]); $usersDesc = $repos->findByStatus('dev', ['username' => "DESC"]);
@ -585,7 +592,7 @@ class EntityRepositoryTest extends OrmFunctionalTestCase
$this->assertEquals(2, count($usersAsc)); $this->assertEquals(2, count($usersAsc));
$this->assertEquals(2, count($usersDesc)); $this->assertEquals(2, count($usersDesc));
$this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsUser',$usersAsc[0]); $this->assertInstanceOf(CmsUser::class,$usersAsc[0]);
$this->assertEquals('Alexander', $usersAsc[0]->name); $this->assertEquals('Alexander', $usersAsc[0]->name);
$this->assertEquals('dev', $usersAsc[0]->status); $this->assertEquals('dev', $usersAsc[0]->status);
@ -599,7 +606,7 @@ class EntityRepositoryTest extends OrmFunctionalTestCase
public function testFindFieldByMagicCallLimitOffset() public function testFindFieldByMagicCallLimitOffset()
{ {
$this->loadFixture(); $this->loadFixture();
$repos = $this->_em->getRepository('Doctrine\Tests\Models\CMS\CmsUser'); $repos = $this->_em->getRepository(CmsUser::class);
$users1 = $repos->findByStatus('dev', [], 1, 0); $users1 = $repos->findByStatus('dev', [], 1, 0);
$users2 = $repos->findByStatus('dev', [], 1, 1); $users2 = $repos->findByStatus('dev', [], 1, 1);
@ -614,22 +621,22 @@ class EntityRepositoryTest extends OrmFunctionalTestCase
*/ */
public function testDefaultRepositoryClassName() public function testDefaultRepositoryClassName()
{ {
$this->assertEquals($this->_em->getConfiguration()->getDefaultRepositoryClassName(), "Doctrine\ORM\EntityRepository"); $this->assertEquals($this->_em->getConfiguration()->getDefaultRepositoryClassName(), EntityRepository::class);
$this->_em->getConfiguration()->setDefaultRepositoryClassName("Doctrine\Tests\Models\DDC753\DDC753DefaultRepository"); $this->_em->getConfiguration()->setDefaultRepositoryClassName(DDC753DefaultRepository::class);
$this->assertEquals($this->_em->getConfiguration()->getDefaultRepositoryClassName(), "Doctrine\Tests\Models\DDC753\DDC753DefaultRepository"); $this->assertEquals($this->_em->getConfiguration()->getDefaultRepositoryClassName(), DDC753DefaultRepository::class);
$repos = $this->_em->getRepository('Doctrine\Tests\Models\DDC753\DDC753EntityWithDefaultCustomRepository'); $repos = $this->_em->getRepository(DDC753EntityWithDefaultCustomRepository::class);
$this->assertInstanceOf("Doctrine\Tests\Models\DDC753\DDC753DefaultRepository", $repos); $this->assertInstanceOf(DDC753DefaultRepository::class, $repos);
$this->assertTrue($repos->isDefaultRepository()); $this->assertTrue($repos->isDefaultRepository());
$repos = $this->_em->getRepository('Doctrine\Tests\Models\DDC753\DDC753EntityWithCustomRepository'); $repos = $this->_em->getRepository(DDC753EntityWithCustomRepository::class);
$this->assertInstanceOf("Doctrine\Tests\Models\DDC753\DDC753CustomRepository", $repos); $this->assertInstanceOf(DDC753CustomRepository::class, $repos);
$this->assertTrue($repos->isCustomRepository()); $this->assertTrue($repos->isCustomRepository());
$this->assertEquals($this->_em->getConfiguration()->getDefaultRepositoryClassName(), "Doctrine\Tests\Models\DDC753\DDC753DefaultRepository"); $this->assertEquals($this->_em->getConfiguration()->getDefaultRepositoryClassName(), DDC753DefaultRepository::class);
$this->_em->getConfiguration()->setDefaultRepositoryClassName("Doctrine\ORM\EntityRepository"); $this->_em->getConfiguration()->setDefaultRepositoryClassName(EntityRepository::class);
$this->assertEquals($this->_em->getConfiguration()->getDefaultRepositoryClassName(), "Doctrine\ORM\EntityRepository"); $this->assertEquals($this->_em->getConfiguration()->getDefaultRepositoryClassName(), EntityRepository::class);
} }
@ -640,8 +647,8 @@ class EntityRepositoryTest extends OrmFunctionalTestCase
*/ */
public function testSetDefaultRepositoryInvalidClassError() public function testSetDefaultRepositoryInvalidClassError()
{ {
$this->assertEquals($this->_em->getConfiguration()->getDefaultRepositoryClassName(), "Doctrine\ORM\EntityRepository"); $this->assertEquals($this->_em->getConfiguration()->getDefaultRepositoryClassName(), EntityRepository::class);
$this->_em->getConfiguration()->setDefaultRepositoryClassName("Doctrine\Tests\Models\DDC753\DDC753InvalidRepository"); $this->_em->getConfiguration()->setDefaultRepositoryClassName(DDC753InvalidRepository::class);
} }
/** /**
@ -654,7 +661,7 @@ class EntityRepositoryTest extends OrmFunctionalTestCase
$config->addEntityNamespace('Aliased', 'Doctrine\Tests\Models\CMS'); $config->addEntityNamespace('Aliased', 'Doctrine\Tests\Models\CMS');
$config->addEntityNamespace('AliasedAgain', 'Doctrine\Tests\Models\CMS'); $config->addEntityNamespace('AliasedAgain', 'Doctrine\Tests\Models\CMS');
$repository = $this->_em->getRepository('Doctrine\Tests\Models\CMS\CmsUser'); $repository = $this->_em->getRepository(CmsUser::class);
$this->assertSame($repository, $this->_em->getRepository('Aliased:CmsUser')); $this->assertSame($repository, $this->_em->getRepository('Aliased:CmsUser'));
$this->assertSame($repository, $this->_em->getRepository('AliasedAgain:CmsUser')); $this->assertSame($repository, $this->_em->getRepository('AliasedAgain:CmsUser'));
@ -666,8 +673,8 @@ class EntityRepositoryTest extends OrmFunctionalTestCase
public function testCanRetrieveRepositoryFromClassNameWithLeadingBackslash() public function testCanRetrieveRepositoryFromClassNameWithLeadingBackslash()
{ {
$this->assertSame( $this->assertSame(
$this->_em->getRepository('\\Doctrine\\Tests\\Models\\CMS\\CmsUser'), $this->_em->getRepository('\\' . CmsUser::class),
$this->_em->getRepository('Doctrine\\Tests\\Models\\CMS\\CmsUser') $this->_em->getRepository(CmsUser::class)
); );
} }
@ -679,7 +686,7 @@ class EntityRepositoryTest extends OrmFunctionalTestCase
*/ */
public function testInvalidOrderByAssociation() public function testInvalidOrderByAssociation()
{ {
$this->_em->getRepository('Doctrine\Tests\Models\CMS\CmsUser') $this->_em->getRepository(CmsUser::class)
->findBy(['status' => 'test'], ['address' => 'ASC']); ->findBy(['status' => 'test'], ['address' => 'ASC']);
} }
@ -691,7 +698,7 @@ class EntityRepositoryTest extends OrmFunctionalTestCase
$this->expectException(ORMException::class); $this->expectException(ORMException::class);
$this->expectExceptionMessage('Invalid order by orientation specified for Doctrine\Tests\Models\CMS\CmsUser#username'); $this->expectExceptionMessage('Invalid order by orientation specified for Doctrine\Tests\Models\CMS\CmsUser#username');
$repo = $this->_em->getRepository('Doctrine\Tests\Models\CMS\CmsUser'); $repo = $this->_em->getRepository(CmsUser::class);
$repo->findBy(['status' => 'test'], ['username' => 'INVALID']); $repo->findBy(['status' => 'test'], ['username' => 'INVALID']);
} }
@ -700,7 +707,7 @@ class EntityRepositoryTest extends OrmFunctionalTestCase
*/ */
public function testFindByAssociationArray() public function testFindByAssociationArray()
{ {
$repo = $this->_em->getRepository('Doctrine\Tests\Models\CMS\CmsArticle'); $repo = $this->_em->getRepository(CmsAddress::class);
$data = $repo->findBy(['user' => [1, 2, 3]]); $data = $repo->findBy(['user' => [1, 2, 3]]);
$query = array_pop($this->_sqlLoggerStack->queries); $query = array_pop($this->_sqlLoggerStack->queries);
@ -715,7 +722,7 @@ class EntityRepositoryTest extends OrmFunctionalTestCase
{ {
$this->loadFixture(); $this->loadFixture();
$repository = $this->_em->getRepository('Doctrine\Tests\Models\CMS\CmsUser'); $repository = $this->_em->getRepository(CmsUser::class);
$users = $repository->matching(new Criteria()); $users = $repository->matching(new Criteria());
$this->assertEquals(4, count($users)); $this->assertEquals(4, count($users));
@ -728,7 +735,7 @@ class EntityRepositoryTest extends OrmFunctionalTestCase
{ {
$this->loadFixture(); $this->loadFixture();
$repository = $this->_em->getRepository('Doctrine\Tests\Models\CMS\CmsUser'); $repository = $this->_em->getRepository(CmsUser::class);
$users = $repository->matching(new Criteria( $users = $repository->matching(new Criteria(
Criteria::expr()->eq('username', 'beberlei') Criteria::expr()->eq('username', 'beberlei')
)); ));
@ -743,7 +750,7 @@ class EntityRepositoryTest extends OrmFunctionalTestCase
{ {
$this->loadFixture(); $this->loadFixture();
$repository = $this->_em->getRepository('Doctrine\Tests\Models\CMS\CmsUser'); $repository = $this->_em->getRepository(CmsUser::class);
$users = $repository->matching(new Criteria( $users = $repository->matching(new Criteria(
Criteria::expr()->neq('username', 'beberlei') Criteria::expr()->neq('username', 'beberlei')
)); ));
@ -758,7 +765,7 @@ class EntityRepositoryTest extends OrmFunctionalTestCase
{ {
$this->loadFixture(); $this->loadFixture();
$repository = $this->_em->getRepository('Doctrine\Tests\Models\CMS\CmsUser'); $repository = $this->_em->getRepository(CmsUser::class);
$users = $repository->matching(new Criteria( $users = $repository->matching(new Criteria(
Criteria::expr()->in('username', ['beberlei', 'gblanco']) Criteria::expr()->in('username', ['beberlei', 'gblanco'])
)); ));
@ -773,7 +780,7 @@ class EntityRepositoryTest extends OrmFunctionalTestCase
{ {
$this->loadFixture(); $this->loadFixture();
$repository = $this->_em->getRepository('Doctrine\Tests\Models\CMS\CmsUser'); $repository = $this->_em->getRepository(CmsUser::class);
$users = $repository->matching(new Criteria( $users = $repository->matching(new Criteria(
Criteria::expr()->notIn('username', ['beberlei', 'gblanco', 'asm89']) Criteria::expr()->notIn('username', ['beberlei', 'gblanco', 'asm89'])
)); ));
@ -788,7 +795,7 @@ class EntityRepositoryTest extends OrmFunctionalTestCase
{ {
$firstUserId = $this->loadFixture(); $firstUserId = $this->loadFixture();
$repository = $this->_em->getRepository('Doctrine\Tests\Models\CMS\CmsUser'); $repository = $this->_em->getRepository(CmsUser::class);
$users = $repository->matching(new Criteria( $users = $repository->matching(new Criteria(
Criteria::expr()->lt('id', $firstUserId + 1) Criteria::expr()->lt('id', $firstUserId + 1)
)); ));
@ -803,7 +810,7 @@ class EntityRepositoryTest extends OrmFunctionalTestCase
{ {
$firstUserId = $this->loadFixture(); $firstUserId = $this->loadFixture();
$repository = $this->_em->getRepository('Doctrine\Tests\Models\CMS\CmsUser'); $repository = $this->_em->getRepository(CmsUser::class);
$users = $repository->matching(new Criteria( $users = $repository->matching(new Criteria(
Criteria::expr()->lte('id', $firstUserId + 1) Criteria::expr()->lte('id', $firstUserId + 1)
)); ));
@ -818,7 +825,7 @@ class EntityRepositoryTest extends OrmFunctionalTestCase
{ {
$firstUserId = $this->loadFixture(); $firstUserId = $this->loadFixture();
$repository = $this->_em->getRepository('Doctrine\Tests\Models\CMS\CmsUser'); $repository = $this->_em->getRepository(CmsUser::class);
$users = $repository->matching(new Criteria( $users = $repository->matching(new Criteria(
Criteria::expr()->gt('id', $firstUserId) Criteria::expr()->gt('id', $firstUserId)
)); ));
@ -833,7 +840,7 @@ class EntityRepositoryTest extends OrmFunctionalTestCase
{ {
$firstUserId = $this->loadFixture(); $firstUserId = $this->loadFixture();
$repository = $this->_em->getRepository('Doctrine\Tests\Models\CMS\CmsUser'); $repository = $this->_em->getRepository(CmsUser::class);
$users = $repository->matching(new Criteria( $users = $repository->matching(new Criteria(
Criteria::expr()->gte('id', $firstUserId) Criteria::expr()->gte('id', $firstUserId)
)); ));
@ -848,13 +855,13 @@ class EntityRepositoryTest extends OrmFunctionalTestCase
{ {
list($userId, $addressId) = $this->loadAssociatedFixture(); list($userId, $addressId) = $this->loadAssociatedFixture();
$user = $this->_em->find('Doctrine\Tests\Models\CMS\CmsUser', $userId); $user = $this->_em->find(CmsUser::class, $userId);
$criteria = new Criteria( $criteria = new Criteria(
Criteria::expr()->eq('user', $user) Criteria::expr()->eq('user', $user)
); );
$repository = $this->_em->getRepository('Doctrine\Tests\Models\CMS\CmsAddress'); $repository = $this->_em->getRepository(CmsAddress::class);
$addresses = $repository->matching($criteria); $addresses = $repository->matching($criteria);
$this->assertEquals(1, count($addresses)); $this->assertEquals(1, count($addresses));
@ -871,13 +878,13 @@ class EntityRepositoryTest extends OrmFunctionalTestCase
{ {
list($userId, $addressId) = $this->loadAssociatedFixture(); list($userId, $addressId) = $this->loadAssociatedFixture();
$user = $this->_em->find('Doctrine\Tests\Models\CMS\CmsUser', $userId); $user = $this->_em->find(CmsUser::class, $userId);
$criteria = new Criteria( $criteria = new Criteria(
Criteria::expr()->in('user', [$user]) Criteria::expr()->in('user', [$user])
); );
$repository = $this->_em->getRepository('Doctrine\Tests\Models\CMS\CmsAddress'); $repository = $this->_em->getRepository(CmsAddress::class);
$addresses = $repository->matching($criteria); $addresses = $repository->matching($criteria);
$this->assertEquals(1, count($addresses)); $this->assertEquals(1, count($addresses));
@ -891,7 +898,7 @@ class EntityRepositoryTest extends OrmFunctionalTestCase
{ {
$this->loadFixture(); $this->loadFixture();
$repository = $this->_em->getRepository('Doctrine\Tests\Models\CMS\CmsUser'); $repository = $this->_em->getRepository(CmsUser::class);
$users = $repository->matching(new Criteria(Criteria::expr()->contains('name', 'Foobar'))); $users = $repository->matching(new Criteria(Criteria::expr()->contains('name', 'Foobar')));
$this->assertEquals(0, count($users)); $this->assertEquals(0, count($users));
@ -910,7 +917,7 @@ class EntityRepositoryTest extends OrmFunctionalTestCase
{ {
$fixtures = $this->loadFixtureUserEmail(); $fixtures = $this->loadFixtureUserEmail();
$user = $this->_em->merge($fixtures[0]); $user = $this->_em->merge($fixtures[0]);
$repository = $this->_em->getRepository('Doctrine\Tests\Models\CMS\CmsUser'); $repository = $this->_em->getRepository(CmsUser::class);
$criteriaIsNull = Criteria::create()->where(Criteria::expr()->isNull('email')); $criteriaIsNull = Criteria::create()->where(Criteria::expr()->isNull('email'));
$criteriaEqNull = Criteria::create()->where(Criteria::expr()->eq('email', null)); $criteriaEqNull = Criteria::create()->where(Criteria::expr()->eq('email', null));
@ -925,8 +932,8 @@ class EntityRepositoryTest extends OrmFunctionalTestCase
$this->assertCount(1, $usersIsNull); $this->assertCount(1, $usersIsNull);
$this->assertCount(1, $usersEqNull); $this->assertCount(1, $usersEqNull);
$this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsUser', $usersIsNull[0]); $this->assertInstanceOf(CmsUser::class, $usersIsNull[0]);
$this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsUser', $usersEqNull[0]); $this->assertInstanceOf(CmsUser::class, $usersEqNull[0]);
$this->assertNull($usersIsNull[0]->getEmail()); $this->assertNull($usersIsNull[0]->getEmail());
$this->assertNull($usersEqNull[0]->getEmail()); $this->assertNull($usersEqNull[0]->getEmail());
@ -937,11 +944,11 @@ class EntityRepositoryTest extends OrmFunctionalTestCase
*/ */
public function testCreateResultSetMappingBuilder() public function testCreateResultSetMappingBuilder()
{ {
$repository = $this->_em->getRepository('Doctrine\Tests\Models\CMS\CmsUser'); $repository = $this->_em->getRepository(CmsUser::class);
$rsm = $repository->createResultSetMappingBuilder('u'); $rsm = $repository->createResultSetMappingBuilder('u');
$this->assertInstanceOf('Doctrine\ORM\Query\ResultSetMappingBuilder', $rsm); $this->assertInstanceOf(Query\ResultSetMappingBuilder::class, $rsm);
$this->assertEquals(['u' => 'Doctrine\Tests\Models\CMS\CmsUser'], $rsm->aliasMap); $this->assertEquals(['u' => CmsUser::class], $rsm->aliasMap);
} }
/** /**
@ -952,7 +959,7 @@ class EntityRepositoryTest extends OrmFunctionalTestCase
$this->expectException(ORMException::class); $this->expectException(ORMException::class);
$this->expectExceptionMessage('Unrecognized field: '); $this->expectExceptionMessage('Unrecognized field: ');
$repository = $this->_em->getRepository('Doctrine\Tests\Models\CMS\CmsUser'); $repository = $this->_em->getRepository(CmsUser::class);
$repository->findBy(['username = ?; DELETE FROM cms_users; SELECT 1 WHERE 1' => 'test']); $repository->findBy(['username = ?; DELETE FROM cms_users; SELECT 1 WHERE 1' => 'test']);
} }
@ -964,7 +971,7 @@ class EntityRepositoryTest extends OrmFunctionalTestCase
$this->expectException(ORMException::class); $this->expectException(ORMException::class);
$this->expectExceptionMessage('Unrecognized field: '); $this->expectExceptionMessage('Unrecognized field: ');
$repository = $this->_em->getRepository('Doctrine\Tests\Models\CMS\CmsUser'); $repository = $this->_em->getRepository(CmsUser::class);
$repository->findOneBy(['username = ?; DELETE FROM cms_users; SELECT 1 WHERE 1' => 'test']); $repository->findOneBy(['username = ?; DELETE FROM cms_users; SELECT 1 WHERE 1' => 'test']);
} }
@ -976,7 +983,7 @@ class EntityRepositoryTest extends OrmFunctionalTestCase
$this->expectException(ORMException::class); $this->expectException(ORMException::class);
$this->expectExceptionMessage('Unrecognized field: '); $this->expectExceptionMessage('Unrecognized field: ');
$repository = $this->_em->getRepository('Doctrine\Tests\Models\CMS\CmsUser'); $repository = $this->_em->getRepository(CmsUser::class);
$result = $repository->matching(new Criteria( $result = $repository->matching(new Criteria(
Criteria::expr()->eq('username = ?; DELETE FROM cms_users; SELECT 1 WHERE 1', 'beberlei') Criteria::expr()->eq('username = ?; DELETE FROM cms_users; SELECT 1 WHERE 1', 'beberlei')
)); ));
@ -993,7 +1000,7 @@ class EntityRepositoryTest extends OrmFunctionalTestCase
$this->expectException(ORMException::class); $this->expectException(ORMException::class);
$this->expectExceptionMessage('Unrecognized identifier fields: '); $this->expectExceptionMessage('Unrecognized identifier fields: ');
$repository = $this->_em->getRepository('Doctrine\Tests\Models\CMS\CmsUser'); $repository = $this->_em->getRepository(CmsUser::class);
$repository->find(['username = ?; DELETE FROM cms_users; SELECT 1 WHERE 1' => 'test', 'id' => 1]); $repository->find(['username = ?; DELETE FROM cms_users; SELECT 1 WHERE 1' => 'test', 'id' => 1]);
} }
@ -1016,7 +1023,7 @@ class EntityRepositoryTest extends OrmFunctionalTestCase
$this->_em->persist($user2); $this->_em->persist($user2);
$this->_em->flush(); $this->_em->flush();
$users = $this->_em->getRepository('Doctrine\Tests\Models\CMS\CmsUser')->findBy(['status' => [null]]); $users = $this->_em->getRepository(CmsUser::class)->findBy(['status' => [null]]);
$this->assertCount(1, $users); $this->assertCount(1, $users);
$this->assertSame($user1, reset($users)); $this->assertSame($user1, reset($users));
@ -1043,7 +1050,7 @@ class EntityRepositoryTest extends OrmFunctionalTestCase
$users = $this $users = $this
->_em ->_em
->getRepository('Doctrine\Tests\Models\CMS\CmsUser') ->getRepository(CmsUser::class)
->findBy(['status' => ['foo', null]]); ->findBy(['status' => ['foo', null]]);
$this->assertCount(1, $users); $this->assertCount(1, $users);
@ -1071,7 +1078,7 @@ class EntityRepositoryTest extends OrmFunctionalTestCase
$users = $this $users = $this
->_em ->_em
->getRepository('Doctrine\Tests\Models\CMS\CmsUser') ->getRepository(CmsUser::class)
->findBy(['status' => ['dbal maintainer', null]]); ->findBy(['status' => ['dbal maintainer', null]]);
$this->assertCount(2, $users); $this->assertCount(2, $users);

View File

@ -40,7 +40,7 @@ class ExtraLazyCollectionTest extends OrmFunctionalTestCase
$this->useModelSet('ddc2504'); $this->useModelSet('ddc2504');
parent::setUp(); parent::setUp();
$class = $this->_em->getClassMetadata('Doctrine\Tests\Models\CMS\CmsUser'); $class = $this->_em->getClassMetadata(CmsUser::class);
$class->associationMappings['groups']['fetch'] = ClassMetadataInfo::FETCH_EXTRA_LAZY; $class->associationMappings['groups']['fetch'] = ClassMetadataInfo::FETCH_EXTRA_LAZY;
$class->associationMappings['groups']['indexBy'] = 'name'; $class->associationMappings['groups']['indexBy'] = 'name';
$class->associationMappings['articles']['fetch'] = ClassMetadataInfo::FETCH_EXTRA_LAZY; $class->associationMappings['articles']['fetch'] = ClassMetadataInfo::FETCH_EXTRA_LAZY;
@ -52,7 +52,7 @@ class ExtraLazyCollectionTest extends OrmFunctionalTestCase
unset($class->associationMappings['articles']['cache']); unset($class->associationMappings['articles']['cache']);
unset($class->associationMappings['users']['cache']); unset($class->associationMappings['users']['cache']);
$class = $this->_em->getClassMetadata('Doctrine\Tests\Models\CMS\CmsGroup'); $class = $this->_em->getClassMetadata(CmsGroup::class);
$class->associationMappings['users']['fetch'] = ClassMetadataInfo::FETCH_EXTRA_LAZY; $class->associationMappings['users']['fetch'] = ClassMetadataInfo::FETCH_EXTRA_LAZY;
$class->associationMappings['users']['indexBy'] = 'username'; $class->associationMappings['users']['indexBy'] = 'username';
@ -63,7 +63,7 @@ class ExtraLazyCollectionTest extends OrmFunctionalTestCase
{ {
parent::tearDown(); parent::tearDown();
$class = $this->_em->getClassMetadata('Doctrine\Tests\Models\CMS\CmsUser'); $class = $this->_em->getClassMetadata(CmsUser::class);
$class->associationMappings['groups']['fetch'] = ClassMetadataInfo::FETCH_LAZY; $class->associationMappings['groups']['fetch'] = ClassMetadataInfo::FETCH_LAZY;
$class->associationMappings['articles']['fetch'] = ClassMetadataInfo::FETCH_LAZY; $class->associationMappings['articles']['fetch'] = ClassMetadataInfo::FETCH_LAZY;
$class->associationMappings['phonenumbers']['fetch'] = ClassMetadataInfo::FETCH_LAZY; $class->associationMappings['phonenumbers']['fetch'] = ClassMetadataInfo::FETCH_LAZY;
@ -72,7 +72,7 @@ class ExtraLazyCollectionTest extends OrmFunctionalTestCase
unset($class->associationMappings['articles']['indexBy']); unset($class->associationMappings['articles']['indexBy']);
unset($class->associationMappings['phonenumbers']['indexBy']); unset($class->associationMappings['phonenumbers']['indexBy']);
$class = $this->_em->getClassMetadata('Doctrine\Tests\Models\CMS\CmsGroup'); $class = $this->_em->getClassMetadata(CmsGroup::class);
$class->associationMappings['users']['fetch'] = ClassMetadataInfo::FETCH_LAZY; $class->associationMappings['users']['fetch'] = ClassMetadataInfo::FETCH_LAZY;
unset($class->associationMappings['users']['indexBy']); unset($class->associationMappings['users']['indexBy']);
@ -84,7 +84,7 @@ class ExtraLazyCollectionTest extends OrmFunctionalTestCase
*/ */
public function testCountNotInitializesCollection() public function testCountNotInitializesCollection()
{ {
$user = $this->_em->find('Doctrine\Tests\Models\CMS\CmsUser', $this->userId); $user = $this->_em->find(CmsUser::class, $this->userId);
$queryCount = $this->getCurrentQueryCount(); $queryCount = $this->getCurrentQueryCount();
$this->assertFalse($user->groups->isInitialized()); $this->assertFalse($user->groups->isInitialized());
@ -101,7 +101,7 @@ class ExtraLazyCollectionTest extends OrmFunctionalTestCase
*/ */
public function testCountWhenNewEntityPresent() public function testCountWhenNewEntityPresent()
{ {
$user = $this->_em->find('Doctrine\Tests\Models\CMS\CmsUser', $this->userId); $user = $this->_em->find(CmsUser::class, $this->userId);
$newGroup = new CmsGroup(); $newGroup = new CmsGroup();
$newGroup->name = "Test4"; $newGroup->name = "Test4";
@ -120,7 +120,7 @@ class ExtraLazyCollectionTest extends OrmFunctionalTestCase
*/ */
public function testCountWhenInitialized() public function testCountWhenInitialized()
{ {
$user = $this->_em->find('Doctrine\Tests\Models\CMS\CmsUser', $this->userId); $user = $this->_em->find(CmsUser::class, $this->userId);
$queryCount = $this->getCurrentQueryCount(); $queryCount = $this->getCurrentQueryCount();
foreach ($user->groups AS $group) { } foreach ($user->groups AS $group) { }
@ -135,7 +135,7 @@ class ExtraLazyCollectionTest extends OrmFunctionalTestCase
*/ */
public function testCountInverseCollection() public function testCountInverseCollection()
{ {
$group = $this->_em->find('Doctrine\Tests\Models\CMS\CmsGroup', $this->groupId); $group = $this->_em->find(CmsGroup::class, $this->groupId);
$this->assertFalse($group->users->isInitialized(), "Pre-Condition"); $this->assertFalse($group->users->isInitialized(), "Pre-Condition");
$this->assertEquals(4, count($group->users)); $this->assertEquals(4, count($group->users));
@ -147,7 +147,7 @@ class ExtraLazyCollectionTest extends OrmFunctionalTestCase
*/ */
public function testCountOneToMany() public function testCountOneToMany()
{ {
$user = $this->_em->find('Doctrine\Tests\Models\CMS\CmsUser', $this->userId); $user = $this->_em->find(CmsUser::class, $this->userId);
$this->assertFalse($user->groups->isInitialized(), "Pre-Condition"); $this->assertFalse($user->groups->isInitialized(), "Pre-Condition");
$this->assertEquals(2, count($user->articles)); $this->assertEquals(2, count($user->articles));
@ -158,7 +158,7 @@ class ExtraLazyCollectionTest extends OrmFunctionalTestCase
*/ */
public function testCountOneToManyJoinedInheritance() public function testCountOneToManyJoinedInheritance()
{ {
$otherClass = $this->_em->find(DDC2504OtherClass::CLASSNAME, $this->ddc2504OtherClassId); $otherClass = $this->_em->find(DDC2504OtherClass::class, $this->ddc2504OtherClassId);
$this->assertFalse($otherClass->childClasses->isInitialized(), "Pre-Condition"); $this->assertFalse($otherClass->childClasses->isInitialized(), "Pre-Condition");
$this->assertEquals(2, count($otherClass->childClasses)); $this->assertEquals(2, count($otherClass->childClasses));
@ -169,7 +169,7 @@ class ExtraLazyCollectionTest extends OrmFunctionalTestCase
*/ */
public function testFullSlice() public function testFullSlice()
{ {
$user = $this->_em->find('Doctrine\Tests\Models\CMS\CmsUser', $this->userId); $user = $this->_em->find(CmsUser::class, $this->userId);
$this->assertFalse($user->groups->isInitialized(), "Pre-Condition: Collection is not initialized."); $this->assertFalse($user->groups->isInitialized(), "Pre-Condition: Collection is not initialized.");
$someGroups = $user->groups->slice(null); $someGroups = $user->groups->slice(null);
@ -182,20 +182,20 @@ class ExtraLazyCollectionTest extends OrmFunctionalTestCase
*/ */
public function testSlice() public function testSlice()
{ {
$user = $this->_em->find('Doctrine\Tests\Models\CMS\CmsUser', $this->userId); $user = $this->_em->find(CmsUser::class, $this->userId);
$this->assertFalse($user->groups->isInitialized(), "Pre-Condition: Collection is not initialized."); $this->assertFalse($user->groups->isInitialized(), "Pre-Condition: Collection is not initialized.");
$queryCount = $this->getCurrentQueryCount(); $queryCount = $this->getCurrentQueryCount();
$someGroups = $user->groups->slice(0, 2); $someGroups = $user->groups->slice(0, 2);
$this->assertContainsOnly('Doctrine\Tests\Models\CMS\CmsGroup', $someGroups); $this->assertContainsOnly(CmsGroup::class, $someGroups);
$this->assertEquals(2, count($someGroups)); $this->assertEquals(2, count($someGroups));
$this->assertFalse($user->groups->isInitialized(), "Slice should not initialize the collection if it wasn't before!"); $this->assertFalse($user->groups->isInitialized(), "Slice should not initialize the collection if it wasn't before!");
$otherGroup = $user->groups->slice(2, 1); $otherGroup = $user->groups->slice(2, 1);
$this->assertContainsOnly('Doctrine\Tests\Models\CMS\CmsGroup', $otherGroup); $this->assertContainsOnly(CmsGroup::class, $otherGroup);
$this->assertEquals(1, count($otherGroup)); $this->assertEquals(1, count($otherGroup));
$this->assertFalse($user->groups->isInitialized()); $this->assertFalse($user->groups->isInitialized());
@ -213,7 +213,7 @@ class ExtraLazyCollectionTest extends OrmFunctionalTestCase
*/ */
public function testSliceInitializedCollection() public function testSliceInitializedCollection()
{ {
$user = $this->_em->find('Doctrine\Tests\Models\CMS\CmsUser', $this->userId); $user = $this->_em->find(CmsUser::class, $this->userId);
$queryCount = $this->getCurrentQueryCount(); $queryCount = $this->getCurrentQueryCount();
foreach ($user->groups AS $group) { } foreach ($user->groups AS $group) { }
@ -232,15 +232,15 @@ class ExtraLazyCollectionTest extends OrmFunctionalTestCase
*/ */
public function testSliceInverseCollection() public function testSliceInverseCollection()
{ {
$group = $this->_em->find('Doctrine\Tests\Models\CMS\CmsGroup', $this->groupId); $group = $this->_em->find(CmsGroup::class, $this->groupId);
$this->assertFalse($group->users->isInitialized(), "Pre-Condition"); $this->assertFalse($group->users->isInitialized(), "Pre-Condition");
$queryCount = $this->getCurrentQueryCount(); $queryCount = $this->getCurrentQueryCount();
$someUsers = $group->users->slice(0, 2); $someUsers = $group->users->slice(0, 2);
$otherUsers = $group->users->slice(2, 2); $otherUsers = $group->users->slice(2, 2);
$this->assertContainsOnly('Doctrine\Tests\Models\CMS\CmsUser', $someUsers); $this->assertContainsOnly(CmsUser::class, $someUsers);
$this->assertContainsOnly('Doctrine\Tests\Models\CMS\CmsUser', $otherUsers); $this->assertContainsOnly(CmsUser::class, $otherUsers);
$this->assertEquals(2, count($someUsers)); $this->assertEquals(2, count($someUsers));
$this->assertEquals(2, count($otherUsers)); $this->assertEquals(2, count($otherUsers));
@ -253,7 +253,7 @@ class ExtraLazyCollectionTest extends OrmFunctionalTestCase
*/ */
public function testSliceOneToMany() public function testSliceOneToMany()
{ {
$user = $this->_em->find('Doctrine\Tests\Models\CMS\CmsUser', $this->userId); $user = $this->_em->find(CmsUser::class, $this->userId);
$this->assertFalse($user->articles->isInitialized(), "Pre-Condition: Collection is not initialized."); $this->assertFalse($user->articles->isInitialized(), "Pre-Condition: Collection is not initialized.");
$queryCount = $this->getCurrentQueryCount(); $queryCount = $this->getCurrentQueryCount();
@ -269,11 +269,11 @@ class ExtraLazyCollectionTest extends OrmFunctionalTestCase
*/ */
public function testContainsOneToMany() public function testContainsOneToMany()
{ {
$user = $this->_em->find('Doctrine\Tests\Models\CMS\CmsUser', $this->userId); $user = $this->_em->find(CmsUser::class, $this->userId);
$this->assertFalse($user->articles->isInitialized(), "Pre-Condition: Collection is not initialized."); $this->assertFalse($user->articles->isInitialized(), "Pre-Condition: Collection is not initialized.");
// Test One to Many existence retrieved from DB // Test One to Many existence retrieved from DB
$article = $this->_em->find('Doctrine\Tests\Models\CMS\CmsArticle', $this->articleId); $article = $this->_em->find(CmsArticle::class, $this->articleId);
$queryCount = $this->getCurrentQueryCount(); $queryCount = $this->getCurrentQueryCount();
$this->assertTrue($user->articles->contains($article)); $this->assertTrue($user->articles->contains($article));
@ -317,7 +317,7 @@ class ExtraLazyCollectionTest extends OrmFunctionalTestCase
*/ */
public function testLazyOneToManyJoinedInheritanceIsLazilyInitialized() public function testLazyOneToManyJoinedInheritanceIsLazilyInitialized()
{ {
$otherClass = $this->_em->find(DDC2504OtherClass::CLASSNAME, $this->ddc2504OtherClassId); $otherClass = $this->_em->find(DDC2504OtherClass::class, $this->ddc2504OtherClassId);
$this->assertFalse($otherClass->childClasses->isInitialized(), 'Collection is not initialized.'); $this->assertFalse($otherClass->childClasses->isInitialized(), 'Collection is not initialized.');
} }
@ -327,10 +327,10 @@ class ExtraLazyCollectionTest extends OrmFunctionalTestCase
*/ */
public function testContainsOnOneToManyJoinedInheritanceWillNotInitializeCollectionWhenMatchingItemIsFound() public function testContainsOnOneToManyJoinedInheritanceWillNotInitializeCollectionWhenMatchingItemIsFound()
{ {
$otherClass = $this->_em->find(DDC2504OtherClass::CLASSNAME, $this->ddc2504OtherClassId); $otherClass = $this->_em->find(DDC2504OtherClass::class, $this->ddc2504OtherClassId);
// Test One to Many existence retrieved from DB // Test One to Many existence retrieved from DB
$childClass = $this->_em->find(DDC2504ChildClass::CLASSNAME, $this->ddc2504ChildClassId); $childClass = $this->_em->find(DDC2504ChildClass::class, $this->ddc2504ChildClassId);
$queryCount = $this->getCurrentQueryCount(); $queryCount = $this->getCurrentQueryCount();
$this->assertTrue($otherClass->childClasses->contains($childClass)); $this->assertTrue($otherClass->childClasses->contains($childClass));
@ -343,7 +343,7 @@ class ExtraLazyCollectionTest extends OrmFunctionalTestCase
*/ */
public function testContainsOnOneToManyJoinedInheritanceWillNotCauseQueriesWhenNonPersistentItemIsMatched() public function testContainsOnOneToManyJoinedInheritanceWillNotCauseQueriesWhenNonPersistentItemIsMatched()
{ {
$otherClass = $this->_em->find(DDC2504OtherClass::CLASSNAME, $this->ddc2504OtherClassId); $otherClass = $this->_em->find(DDC2504OtherClass::class, $this->ddc2504OtherClassId);
$queryCount = $this->getCurrentQueryCount(); $queryCount = $this->getCurrentQueryCount();
$this->assertFalse($otherClass->childClasses->contains(new DDC2504ChildClass())); $this->assertFalse($otherClass->childClasses->contains(new DDC2504ChildClass()));
@ -359,7 +359,7 @@ class ExtraLazyCollectionTest extends OrmFunctionalTestCase
*/ */
public function testContainsOnOneToManyJoinedInheritanceWillNotInitializeCollectionWithClearStateMatchingItem() public function testContainsOnOneToManyJoinedInheritanceWillNotInitializeCollectionWithClearStateMatchingItem()
{ {
$otherClass = $this->_em->find(DDC2504OtherClass::CLASSNAME, $this->ddc2504OtherClassId); $otherClass = $this->_em->find(DDC2504OtherClass::class, $this->ddc2504OtherClassId);
$childClass = new DDC2504ChildClass(); $childClass = new DDC2504ChildClass();
// Test One to Many existence with state clear // Test One to Many existence with state clear
@ -377,7 +377,7 @@ class ExtraLazyCollectionTest extends OrmFunctionalTestCase
*/ */
public function testContainsOnOneToManyJoinedInheritanceWillNotInitializeCollectionWithNewStateNotMatchingItem() public function testContainsOnOneToManyJoinedInheritanceWillNotInitializeCollectionWithNewStateNotMatchingItem()
{ {
$otherClass = $this->_em->find(DDC2504OtherClass::CLASSNAME, $this->ddc2504OtherClassId); $otherClass = $this->_em->find(DDC2504OtherClass::class, $this->ddc2504OtherClassId);
$childClass = new DDC2504ChildClass(); $childClass = new DDC2504ChildClass();
$this->_em->persist($childClass); $this->_em->persist($childClass);
@ -394,7 +394,7 @@ class ExtraLazyCollectionTest extends OrmFunctionalTestCase
*/ */
public function testCountingOnOneToManyJoinedInheritanceWillNotInitializeCollection() public function testCountingOnOneToManyJoinedInheritanceWillNotInitializeCollection()
{ {
$otherClass = $this->_em->find(DDC2504OtherClass::CLASSNAME, $this->ddc2504OtherClassId); $otherClass = $this->_em->find(DDC2504OtherClass::class, $this->ddc2504OtherClassId);
$this->assertEquals(2, count($otherClass->childClasses)); $this->assertEquals(2, count($otherClass->childClasses));
@ -406,11 +406,11 @@ class ExtraLazyCollectionTest extends OrmFunctionalTestCase
*/ */
public function testContainsManyToMany() public function testContainsManyToMany()
{ {
$user = $this->_em->find('Doctrine\Tests\Models\CMS\CmsUser', $this->userId); $user = $this->_em->find(CmsUser::class, $this->userId);
$this->assertFalse($user->groups->isInitialized(), "Pre-Condition: Collection is not initialized."); $this->assertFalse($user->groups->isInitialized(), "Pre-Condition: Collection is not initialized.");
// Test Many to Many existence retrieved from DB // Test Many to Many existence retrieved from DB
$group = $this->_em->find('Doctrine\Tests\Models\CMS\CmsGroup', $this->groupId); $group = $this->_em->find(CmsGroup::class, $this->groupId);
$queryCount = $this->getCurrentQueryCount(); $queryCount = $this->getCurrentQueryCount();
$this->assertTrue($user->groups->contains($group)); $this->assertTrue($user->groups->contains($group));
@ -455,10 +455,10 @@ class ExtraLazyCollectionTest extends OrmFunctionalTestCase
*/ */
public function testContainsManyToManyInverse() public function testContainsManyToManyInverse()
{ {
$group = $this->_em->find('Doctrine\Tests\Models\CMS\CmsGroup', $this->groupId); $group = $this->_em->find(CmsGroup::class, $this->groupId);
$this->assertFalse($group->users->isInitialized(), "Pre-Condition: Collection is not initialized."); $this->assertFalse($group->users->isInitialized(), "Pre-Condition: Collection is not initialized.");
$user = $this->_em->find('Doctrine\Tests\Models\CMS\CmsUser', $this->userId); $user = $this->_em->find(CmsUser::class, $this->userId);
$queryCount = $this->getCurrentQueryCount(); $queryCount = $this->getCurrentQueryCount();
$this->assertTrue($group->users->contains($user)); $this->assertTrue($group->users->contains($user));
@ -479,11 +479,11 @@ class ExtraLazyCollectionTest extends OrmFunctionalTestCase
*/ */
public function testRemoveElementOneToMany() public function testRemoveElementOneToMany()
{ {
$user = $this->_em->find('Doctrine\Tests\Models\CMS\CmsUser', $this->userId); $user = $this->_em->find(CmsUser::class, $this->userId);
$this->assertFalse($user->articles->isInitialized(), "Pre-Condition: Collection is not initialized."); $this->assertFalse($user->articles->isInitialized(), "Pre-Condition: Collection is not initialized.");
// Test One to Many removal with Entity retrieved from DB // Test One to Many removal with Entity retrieved from DB
$article = $this->_em->find('Doctrine\Tests\Models\CMS\CmsArticle', $this->articleId); $article = $this->_em->find(CmsArticle::class, $this->articleId);
$queryCount = $this->getCurrentQueryCount(); $queryCount = $this->getCurrentQueryCount();
$user->articles->removeElement($article); $user->articles->removeElement($article);
@ -533,9 +533,9 @@ class ExtraLazyCollectionTest extends OrmFunctionalTestCase
public function testRemovalOfManagedElementFromOneToManyJoinedInheritanceCollectionDoesNotInitializeIt() public function testRemovalOfManagedElementFromOneToManyJoinedInheritanceCollectionDoesNotInitializeIt()
{ {
/* @var $otherClass DDC2504OtherClass */ /* @var $otherClass DDC2504OtherClass */
$otherClass = $this->_em->find(DDC2504OtherClass::CLASSNAME, $this->ddc2504OtherClassId); $otherClass = $this->_em->find(DDC2504OtherClass::class, $this->ddc2504OtherClassId);
/* @var $childClass DDC2504ChildClass */ /* @var $childClass DDC2504ChildClass */
$childClass = $this->_em->find(DDC2504ChildClass::CLASSNAME, $this->ddc2504ChildClassId); $childClass = $this->_em->find(DDC2504ChildClass::class, $this->ddc2504ChildClassId);
$queryCount = $this->getCurrentQueryCount(); $queryCount = $this->getCurrentQueryCount();
@ -571,7 +571,7 @@ class ExtraLazyCollectionTest extends OrmFunctionalTestCase
public function testRemovalOfNonManagedElementFromOneToManyJoinedInheritanceCollectionDoesNotInitializeIt() public function testRemovalOfNonManagedElementFromOneToManyJoinedInheritanceCollectionDoesNotInitializeIt()
{ {
/* @var $otherClass DDC2504OtherClass */ /* @var $otherClass DDC2504OtherClass */
$otherClass = $this->_em->find(DDC2504OtherClass::CLASSNAME, $this->ddc2504OtherClassId); $otherClass = $this->_em->find(DDC2504OtherClass::class, $this->ddc2504OtherClassId);
$queryCount = $this->getCurrentQueryCount(); $queryCount = $this->getCurrentQueryCount();
$otherClass->childClasses->removeElement(new DDC2504ChildClass()); $otherClass->childClasses->removeElement(new DDC2504ChildClass());
@ -589,7 +589,7 @@ class ExtraLazyCollectionTest extends OrmFunctionalTestCase
public function testRemovalOfNewElementFromOneToManyJoinedInheritanceCollectionDoesNotInitializeIt() public function testRemovalOfNewElementFromOneToManyJoinedInheritanceCollectionDoesNotInitializeIt()
{ {
/* @var $otherClass DDC2504OtherClass */ /* @var $otherClass DDC2504OtherClass */
$otherClass = $this->_em->find(DDC2504OtherClass::CLASSNAME, $this->ddc2504OtherClassId); $otherClass = $this->_em->find(DDC2504OtherClass::class, $this->ddc2504OtherClassId);
$childClass = new DDC2504ChildClass(); $childClass = new DDC2504ChildClass();
$this->_em->persist($childClass); $this->_em->persist($childClass);
@ -610,7 +610,7 @@ class ExtraLazyCollectionTest extends OrmFunctionalTestCase
*/ */
public function testRemovalOfNewManagedElementFromOneToManyJoinedInheritanceCollectionDoesNotInitializeIt() public function testRemovalOfNewManagedElementFromOneToManyJoinedInheritanceCollectionDoesNotInitializeIt()
{ {
$otherClass = $this->_em->find(DDC2504OtherClass::CLASSNAME, $this->ddc2504OtherClassId); $otherClass = $this->_em->find(DDC2504OtherClass::class, $this->ddc2504OtherClassId);
$childClass = new DDC2504ChildClass(); $childClass = new DDC2504ChildClass();
$this->_em->persist($childClass); $this->_em->persist($childClass);
@ -633,11 +633,11 @@ class ExtraLazyCollectionTest extends OrmFunctionalTestCase
*/ */
public function testRemoveElementManyToMany() public function testRemoveElementManyToMany()
{ {
$user = $this->_em->find('Doctrine\Tests\Models\CMS\CmsUser', $this->userId); $user = $this->_em->find(CmsUser::class, $this->userId);
$this->assertFalse($user->groups->isInitialized(), "Pre-Condition: Collection is not initialized."); $this->assertFalse($user->groups->isInitialized(), "Pre-Condition: Collection is not initialized.");
// Test Many to Many removal with Entity retrieved from DB // Test Many to Many removal with Entity retrieved from DB
$group = $this->_em->find('Doctrine\Tests\Models\CMS\CmsGroup', $this->groupId); $group = $this->_em->find(CmsGroup::class, $this->groupId);
$queryCount = $this->getCurrentQueryCount(); $queryCount = $this->getCurrentQueryCount();
$user->groups->removeElement($group); $user->groups->removeElement($group);
@ -686,10 +686,10 @@ class ExtraLazyCollectionTest extends OrmFunctionalTestCase
*/ */
public function testRemoveElementManyToManyInverse() public function testRemoveElementManyToManyInverse()
{ {
$group = $this->_em->find('Doctrine\Tests\Models\CMS\CmsGroup', $this->groupId); $group = $this->_em->find(CmsGroup::class, $this->groupId);
$this->assertFalse($group->users->isInitialized(), "Pre-Condition: Collection is not initialized."); $this->assertFalse($group->users->isInitialized(), "Pre-Condition: Collection is not initialized.");
$user = $this->_em->find('Doctrine\Tests\Models\CMS\CmsUser', $this->userId); $user = $this->_em->find(CmsUser::class, $this->userId);
$queryCount = $this->getCurrentQueryCount(); $queryCount = $this->getCurrentQueryCount();
$group->users->removeElement($user); $group->users->removeElement($user);
@ -713,7 +713,7 @@ class ExtraLazyCollectionTest extends OrmFunctionalTestCase
*/ */
public function testCountAfterAddThenFlush() public function testCountAfterAddThenFlush()
{ {
$user = $this->_em->find('Doctrine\Tests\Models\CMS\CmsUser', $this->userId); $user = $this->_em->find(CmsUser::class, $this->userId);
$newGroup = new CmsGroup(); $newGroup = new CmsGroup();
$newGroup->name = "Test4"; $newGroup->name = "Test4";
@ -736,7 +736,7 @@ class ExtraLazyCollectionTest extends OrmFunctionalTestCase
*/ */
public function testSliceOnDirtyCollection() public function testSliceOnDirtyCollection()
{ {
$user = $this->_em->find('Doctrine\Tests\Models\CMS\CmsUser', $this->userId); $user = $this->_em->find(CmsUser::class, $this->userId);
/* @var $user CmsUser */ /* @var $user CmsUser */
$newGroup = new CmsGroup(); $newGroup = new CmsGroup();
@ -758,7 +758,7 @@ class ExtraLazyCollectionTest extends OrmFunctionalTestCase
*/ */
public function testGetIndexByIdentifier() public function testGetIndexByIdentifier()
{ {
$user = $this->_em->find('Doctrine\Tests\Models\CMS\CmsUser', $this->userId); $user = $this->_em->find(CmsUser::class, $this->userId);
/* @var $user CmsUser */ /* @var $user CmsUser */
$queryCount = $this->getCurrentQueryCount(); $queryCount = $this->getCurrentQueryCount();
@ -766,7 +766,7 @@ class ExtraLazyCollectionTest extends OrmFunctionalTestCase
$this->assertFalse($user->phonenumbers->isInitialized()); $this->assertFalse($user->phonenumbers->isInitialized());
$this->assertEquals($queryCount + 1, $this->getCurrentQueryCount()); $this->assertEquals($queryCount + 1, $this->getCurrentQueryCount());
$this->assertSame($phonenumber, $this->_em->find('Doctrine\Tests\Models\CMS\CmsPhonenumber', $this->phonenumber)); $this->assertSame($phonenumber, $this->_em->find(CmsPhonenumber::class, $this->phonenumber));
$article = $user->phonenumbers->get($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"); $this->assertEquals($queryCount + 1, $this->getCurrentQueryCount(), "Getting the same entity should not cause an extra query to be executed");
@ -777,7 +777,7 @@ class ExtraLazyCollectionTest extends OrmFunctionalTestCase
*/ */
public function testGetIndexByOneToMany() public function testGetIndexByOneToMany()
{ {
$user = $this->_em->find('Doctrine\Tests\Models\CMS\CmsUser', $this->userId); $user = $this->_em->find(CmsUser::class, $this->userId);
/* @var $user CmsUser */ /* @var $user CmsUser */
$queryCount = $this->getCurrentQueryCount(); $queryCount = $this->getCurrentQueryCount();
@ -786,7 +786,7 @@ class ExtraLazyCollectionTest extends OrmFunctionalTestCase
$this->assertFalse($user->articles->isInitialized()); $this->assertFalse($user->articles->isInitialized());
$this->assertEquals($queryCount + 1, $this->getCurrentQueryCount()); $this->assertEquals($queryCount + 1, $this->getCurrentQueryCount());
$this->assertSame($article, $this->_em->find('Doctrine\Tests\Models\CMS\CmsArticle', $this->articleId)); $this->assertSame($article, $this->_em->find(CmsArticle::class, $this->articleId));
} }
/** /**
@ -794,7 +794,7 @@ class ExtraLazyCollectionTest extends OrmFunctionalTestCase
*/ */
public function testGetIndexByManyToManyInverseSide() public function testGetIndexByManyToManyInverseSide()
{ {
$group = $this->_em->find('Doctrine\Tests\Models\CMS\CmsGroup', $this->groupId); $group = $this->_em->find(CmsGroup::class, $this->groupId);
/* @var $group CmsGroup */ /* @var $group CmsGroup */
$queryCount = $this->getCurrentQueryCount(); $queryCount = $this->getCurrentQueryCount();
@ -803,7 +803,7 @@ class ExtraLazyCollectionTest extends OrmFunctionalTestCase
$this->assertFalse($group->users->isInitialized()); $this->assertFalse($group->users->isInitialized());
$this->assertEquals($queryCount + 1, $this->getCurrentQueryCount()); $this->assertEquals($queryCount + 1, $this->getCurrentQueryCount());
$this->assertSame($user, $this->_em->find('Doctrine\Tests\Models\CMS\CmsUser', $this->userId)); $this->assertSame($user, $this->_em->find(CmsUser::class, $this->userId));
} }
/** /**
@ -811,7 +811,7 @@ class ExtraLazyCollectionTest extends OrmFunctionalTestCase
*/ */
public function testGetIndexByManyToManyOwningSide() public function testGetIndexByManyToManyOwningSide()
{ {
$user = $this->_em->find('Doctrine\Tests\Models\CMS\CmsUser', $this->userId); $user = $this->_em->find(CmsUser::class, $this->userId);
/* @var $user CmsUser */ /* @var $user CmsUser */
$queryCount = $this->getCurrentQueryCount(); $queryCount = $this->getCurrentQueryCount();
@ -820,7 +820,7 @@ class ExtraLazyCollectionTest extends OrmFunctionalTestCase
$this->assertFalse($user->groups->isInitialized()); $this->assertFalse($user->groups->isInitialized());
$this->assertEquals($queryCount + 1, $this->getCurrentQueryCount()); $this->assertEquals($queryCount + 1, $this->getCurrentQueryCount());
$this->assertSame($group, $this->_em->find('Doctrine\Tests\Models\CMS\CmsGroup', $this->groupId)); $this->assertSame($group, $this->_em->find(CmsGroup::class, $this->groupId));
} }
/** /**
@ -828,14 +828,14 @@ class ExtraLazyCollectionTest extends OrmFunctionalTestCase
*/ */
public function testGetNonExistentIndexBy() public function testGetNonExistentIndexBy()
{ {
$user = $this->_em->find('Doctrine\Tests\Models\CMS\CmsUser', $this->userId); $user = $this->_em->find(CmsUser::class, $this->userId);
$this->assertNull($user->articles->get(-1)); $this->assertNull($user->articles->get(-1));
$this->assertNull($user->groups->get(-1)); $this->assertNull($user->groups->get(-1));
} }
public function testContainsKeyIndexByOneToMany() public function testContainsKeyIndexByOneToMany()
{ {
$user = $this->_em->find('Doctrine\Tests\Models\CMS\CmsUser', $this->userId); $user = $this->_em->find(CmsUser::class, $this->userId);
/* @var $user CmsUser */ /* @var $user CmsUser */
$queryCount = $this->getCurrentQueryCount(); $queryCount = $this->getCurrentQueryCount();
@ -849,10 +849,10 @@ class ExtraLazyCollectionTest extends OrmFunctionalTestCase
public function testContainsKeyIndexByOneToManyJoinedInheritance() public function testContainsKeyIndexByOneToManyJoinedInheritance()
{ {
$class = $this->_em->getClassMetadata(DDC2504OtherClass::CLASSNAME); $class = $this->_em->getClassMetadata(DDC2504OtherClass::class);
$class->associationMappings['childClasses']['indexBy'] = 'id'; $class->associationMappings['childClasses']['indexBy'] = 'id';
$otherClass = $this->_em->find(DDC2504OtherClass::CLASSNAME, $this->ddc2504OtherClassId); $otherClass = $this->_em->find(DDC2504OtherClass::class, $this->ddc2504OtherClassId);
$queryCount = $this->getCurrentQueryCount(); $queryCount = $this->getCurrentQueryCount();
@ -865,9 +865,9 @@ class ExtraLazyCollectionTest extends OrmFunctionalTestCase
public function testContainsKeyIndexByManyToMany() public function testContainsKeyIndexByManyToMany()
{ {
$user = $this->_em->find('Doctrine\Tests\Models\CMS\CmsUser', $this->userId2); $user = $this->_em->find(CmsUser::class, $this->userId2);
$group = $this->_em->find('Doctrine\Tests\Models\CMS\CmsGroup', $this->groupId); $group = $this->_em->find(CmsGroup::class, $this->groupId);
$queryCount = $this->getCurrentQueryCount(); $queryCount = $this->getCurrentQueryCount();
@ -879,8 +879,8 @@ class ExtraLazyCollectionTest extends OrmFunctionalTestCase
} }
public function testContainsKeyIndexByManyToManyNonOwning() public function testContainsKeyIndexByManyToManyNonOwning()
{ {
$user = $this->_em->find('Doctrine\Tests\Models\CMS\CmsUser', $this->userId2); $user = $this->_em->find(CmsUser::class, $this->userId2);
$group = $this->_em->find('Doctrine\Tests\Models\CMS\CmsGroup', $this->groupId); $group = $this->_em->find(CmsGroup::class, $this->groupId);
$queryCount = $this->getCurrentQueryCount(); $queryCount = $this->getCurrentQueryCount();
@ -893,10 +893,10 @@ class ExtraLazyCollectionTest extends OrmFunctionalTestCase
public function testContainsKeyIndexByWithPkManyToMany() public function testContainsKeyIndexByWithPkManyToMany()
{ {
$class = $this->_em->getClassMetadata('Doctrine\Tests\Models\CMS\CmsUser'); $class = $this->_em->getClassMetadata(CmsUser::class);
$class->associationMappings['groups']['indexBy'] = 'id'; $class->associationMappings['groups']['indexBy'] = 'id';
$user = $this->_em->find('Doctrine\Tests\Models\CMS\CmsUser', $this->userId2); $user = $this->_em->find(CmsUser::class, $this->userId2);
$queryCount = $this->getCurrentQueryCount(); $queryCount = $this->getCurrentQueryCount();
@ -908,10 +908,10 @@ class ExtraLazyCollectionTest extends OrmFunctionalTestCase
} }
public function testContainsKeyIndexByWithPkManyToManyNonOwning() public function testContainsKeyIndexByWithPkManyToManyNonOwning()
{ {
$class = $this->_em->getClassMetadata('Doctrine\Tests\Models\CMS\CmsGroup'); $class = $this->_em->getClassMetadata(CmsGroup::class);
$class->associationMappings['users']['indexBy'] = 'id'; $class->associationMappings['users']['indexBy'] = 'id';
$group = $this->_em->find('Doctrine\Tests\Models\CMS\CmsGroup', $this->groupId); $group = $this->_em->find(CmsGroup::class, $this->groupId);
$queryCount = $this->getCurrentQueryCount(); $queryCount = $this->getCurrentQueryCount();
@ -924,7 +924,7 @@ class ExtraLazyCollectionTest extends OrmFunctionalTestCase
public function testContainsKeyNonExistentIndexByOneToMany() public function testContainsKeyNonExistentIndexByOneToMany()
{ {
$user = $this->_em->find('Doctrine\Tests\Models\CMS\CmsUser', $this->userId2); $user = $this->_em->find(CmsUser::class, $this->userId2);
$queryCount = $this->getCurrentQueryCount(); $queryCount = $this->getCurrentQueryCount();
@ -937,7 +937,7 @@ class ExtraLazyCollectionTest extends OrmFunctionalTestCase
public function testContainsKeyNonExistentIndexByManyToMany() public function testContainsKeyNonExistentIndexByManyToMany()
{ {
$user = $this->_em->find('Doctrine\Tests\Models\CMS\CmsUser', $this->userId2); $user = $this->_em->find(CmsUser::class, $this->userId2);
$queryCount = $this->getCurrentQueryCount(); $queryCount = $this->getCurrentQueryCount();
@ -1061,14 +1061,14 @@ class ExtraLazyCollectionTest extends OrmFunctionalTestCase
list($userId, $tweetId) = $this->loadTweetFixture(); list($userId, $tweetId) = $this->loadTweetFixture();
/* @var $user User */ /* @var $user User */
$user = $this->_em->find(User::CLASSNAME, $userId); $user = $this->_em->find(User::class, $userId);
$user->tweets->removeElement($this->_em->find(Tweet::CLASSNAME, $tweetId)); $user->tweets->removeElement($this->_em->find(Tweet::class, $tweetId));
$this->_em->clear(); $this->_em->clear();
/* @var $user User */ /* @var $user User */
$user = $this->_em->find(User::CLASSNAME, $userId); $user = $this->_em->find(User::class, $userId);
$this->assertCount(1, $user->tweets, 'Element was not removed - need to update the owning side first'); $this->assertCount(1, $user->tweets, 'Element was not removed - need to update the owning side first');
} }
@ -1081,23 +1081,23 @@ class ExtraLazyCollectionTest extends OrmFunctionalTestCase
list($userId, $tweetId) = $this->loadTweetFixture(); list($userId, $tweetId) = $this->loadTweetFixture();
/* @var $user User */ /* @var $user User */
$user = $this->_em->find(User::CLASSNAME, $userId); $user = $this->_em->find(User::class, $userId);
$tweet = $this->_em->find(Tweet::CLASSNAME, $tweetId); $tweet = $this->_em->find(Tweet::class, $tweetId);
$user->tweets->removeElement($tweet); $user->tweets->removeElement($tweet);
$this->_em->clear(); $this->_em->clear();
/* @var $tweet Tweet */ /* @var $tweet Tweet */
$tweet = $this->_em->find(Tweet::CLASSNAME, $tweetId); $tweet = $this->_em->find(Tweet::class, $tweetId);
$this->assertInstanceOf( $this->assertInstanceOf(
Tweet::CLASSNAME, Tweet::class,
$tweet, $tweet,
'Even though the collection is extra lazy, the tweet should not have been deleted' 'Even though the collection is extra lazy, the tweet should not have been deleted'
); );
$this->assertInstanceOf( $this->assertInstanceOf(
User::CLASSNAME, User::class,
$tweet->author, $tweet->author,
'Tweet author link has not been removed - need to update the owning side first' 'Tweet author link has not been removed - need to update the owning side first'
); );
@ -1111,25 +1111,25 @@ class ExtraLazyCollectionTest extends OrmFunctionalTestCase
list($userId, $tweetId) = $this->loadTweetFixture(); list($userId, $tweetId) = $this->loadTweetFixture();
/* @var $user User */ /* @var $user User */
$user = $this->_em->find(User::CLASSNAME, $userId); $user = $this->_em->find(User::class, $userId);
$tweet = $this->_em->getReference(Tweet::CLASSNAME, $tweetId); $tweet = $this->_em->getReference(Tweet::class, $tweetId);
$user->tweets->removeElement($this->_em->getReference(Tweet::CLASSNAME, $tweetId)); $user->tweets->removeElement($this->_em->getReference(Tweet::class, $tweetId));
$this->_em->clear(); $this->_em->clear();
/* @var $tweet Tweet */ /* @var $tweet Tweet */
$tweet = $this->_em->find(Tweet::CLASSNAME, $tweet->id); $tweet = $this->_em->find(Tweet::class, $tweet->id);
$this->assertInstanceOf( $this->assertInstanceOf(
Tweet::CLASSNAME, Tweet::class,
$tweet, $tweet,
'Even though the collection is extra lazy, the tweet should not have been deleted' 'Even though the collection is extra lazy, the tweet should not have been deleted'
); );
$this->assertInstanceOf(User::CLASSNAME, $tweet->author); $this->assertInstanceOf(User::class, $tweet->author);
/* @var $user User */ /* @var $user User */
$user = $this->_em->find(User::CLASSNAME, $userId); $user = $this->_em->find(User::class, $userId);
$this->assertCount(1, $user->tweets, 'Element was not removed - need to update the owning side first'); $this->assertCount(1, $user->tweets, 'Element was not removed - need to update the owning side first');
} }
@ -1142,18 +1142,18 @@ class ExtraLazyCollectionTest extends OrmFunctionalTestCase
list($userId, $userListId) = $this->loadUserListFixture(); list($userId, $userListId) = $this->loadUserListFixture();
/* @var $user User */ /* @var $user User */
$user = $this->_em->find(User::CLASSNAME, $userId); $user = $this->_em->find(User::class, $userId);
$user->userLists->removeElement($this->_em->find(UserList::CLASSNAME, $userListId)); $user->userLists->removeElement($this->_em->find(UserList::class, $userListId));
$this->_em->clear(); $this->_em->clear();
/* @var $user User */ /* @var $user User */
$user = $this->_em->find(User::CLASSNAME, $userId); $user = $this->_em->find(User::class, $userId);
$this->assertCount(0, $user->userLists, 'Element was removed from association due to orphan removal'); $this->assertCount(0, $user->userLists, 'Element was removed from association due to orphan removal');
$this->assertNull( $this->assertNull(
$this->_em->find(UserList::CLASSNAME, $userListId), $this->_em->find(UserList::class, $userListId),
'Element was deleted due to orphan removal' 'Element was deleted due to orphan removal'
); );
} }
@ -1166,22 +1166,22 @@ class ExtraLazyCollectionTest extends OrmFunctionalTestCase
list($userId, $userListId) = $this->loadUserListFixture(); list($userId, $userListId) = $this->loadUserListFixture();
/* @var $user User */ /* @var $user User */
$user = $this->_em->find(User::CLASSNAME, $userId); $user = $this->_em->find(User::class, $userId);
$user->userLists->removeElement(new UserList()); $user->userLists->removeElement(new UserList());
$this->_em->clear(); $this->_em->clear();
/* @var $userList UserList */ /* @var $userList UserList */
$userList = $this->_em->find(UserList::CLASSNAME, $userListId); $userList = $this->_em->find(UserList::class, $userListId);
$this->assertInstanceOf( $this->assertInstanceOf(
UserList::CLASSNAME, UserList::class,
$userList, $userList,
'Even though the collection is extra lazy + orphan removal, the user list should not have been deleted' 'Even though the collection is extra lazy + orphan removal, the user list should not have been deleted'
); );
$this->assertInstanceOf( $this->assertInstanceOf(
User::CLASSNAME, User::class,
$userList->owner, $userList->owner,
'User list to owner link has not been removed' 'User list to owner link has not been removed'
); );
@ -1195,18 +1195,18 @@ class ExtraLazyCollectionTest extends OrmFunctionalTestCase
list($userId, $userListId) = $this->loadUserListFixture(); list($userId, $userListId) = $this->loadUserListFixture();
/* @var $user User */ /* @var $user User */
$user = $this->_em->find(User::CLASSNAME, $userId); $user = $this->_em->find(User::class, $userId);
$user->userLists->removeElement($this->_em->getReference(UserList::CLASSNAME, $userListId)); $user->userLists->removeElement($this->_em->getReference(UserList::class, $userListId));
$this->_em->clear(); $this->_em->clear();
/* @var $user User */ /* @var $user User */
$user = $this->_em->find(User::CLASSNAME, $userId); $user = $this->_em->find(User::class, $userId);
$this->assertCount(0, $user->userLists, 'Element was removed from association due to orphan removal'); $this->assertCount(0, $user->userLists, 'Element was removed from association due to orphan removal');
$this->assertNull( $this->assertNull(
$this->_em->find(UserList::CLASSNAME, $userListId), $this->_em->find(UserList::class, $userListId),
'Element was deleted due to orphan removal' 'Element was deleted due to orphan removal'
); );
} }

View File

@ -46,8 +46,8 @@ class IndexByAssociationTest extends OrmFunctionalTestCase
public function testManyToOneFinder() public function testManyToOneFinder()
{ {
/* @var $market Doctrine\Tests\Models\StockExchange\Market */ /* @var $market Market */
$market = $this->_em->find('Doctrine\Tests\Models\StockExchange\Market', $this->market->getId()); $market = $this->_em->find(Market::class, $this->market->getId());
$this->assertEquals(2, count($market->stocks)); $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['AAPL']), "AAPL symbol has to be key in indexed association.");
@ -70,7 +70,7 @@ class IndexByAssociationTest extends OrmFunctionalTestCase
public function testManyToMany() public function testManyToMany()
{ {
$bond = $this->_em->find('Doctrine\Tests\Models\StockExchange\Bond', $this->bond->getId()); $bond = $this->_em->find(Bond::class, $this->bond->getId());
$this->assertEquals(2, count($bond->stocks)); $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['AAPL']), "AAPL symbol has to be key in indexed association.");

View File

@ -1,6 +1,7 @@
<?php <?php
namespace Doctrine\Tests\ORM\Functional; namespace Doctrine\Tests\ORM\Functional;
use Doctrine\Tests\Models\CompositeKeyInheritance\JoinedRootClass;
use Doctrine\Tests\OrmFunctionalTestCase; use Doctrine\Tests\OrmFunctionalTestCase;
use Doctrine\Tests\Models\CompositeKeyInheritance\JoinedChildClass; use Doctrine\Tests\Models\CompositeKeyInheritance\JoinedChildClass;
@ -57,7 +58,7 @@ class JoinedTableCompositeKeyTest extends OrmFunctionalTestCase
private function findEntity() private function findEntity()
{ {
return $this->_em->find( return $this->_em->find(
'Doctrine\Tests\Models\CompositeKeyInheritance\JoinedRootClass', JoinedRootClass::class,
['keyPart1' => 'part-1', 'keyPart2' => 'part-2'] ['keyPart1' => 'part-1', 'keyPart2' => 'part-2']
); );
} }

View File

@ -17,10 +17,10 @@ class LifecycleCallbackTest extends OrmFunctionalTestCase
try { try {
$this->_schemaTool->createSchema( $this->_schemaTool->createSchema(
[ [
$this->_em->getClassMetadata('Doctrine\Tests\ORM\Functional\LifecycleCallbackEventArgEntity'), $this->_em->getClassMetadata(LifecycleCallbackEventArgEntity::class),
$this->_em->getClassMetadata('Doctrine\Tests\ORM\Functional\LifecycleCallbackTestEntity'), $this->_em->getClassMetadata(LifecycleCallbackTestEntity::class),
$this->_em->getClassMetadata('Doctrine\Tests\ORM\Functional\LifecycleCallbackTestUser'), $this->_em->getClassMetadata(LifecycleCallbackTestUser::class),
$this->_em->getClassMetadata('Doctrine\Tests\ORM\Functional\LifecycleCallbackCascader'), $this->_em->getClassMetadata(LifecycleCallbackCascader::class),
] ]
); );
} catch (\Exception $e) { } catch (\Exception $e) {
@ -106,7 +106,7 @@ class LifecycleCallbackTest extends OrmFunctionalTestCase
$this->_em->clear(); $this->_em->clear();
$reference = $this->_em->getReference('Doctrine\Tests\ORM\Functional\LifecycleCallbackTestEntity', $id); $reference = $this->_em->getReference(LifecycleCallbackTestEntity::class, $id);
$this->assertFalse($reference->postLoadCallbackInvoked); $this->assertFalse($reference->postLoadCallbackInvoked);
$reference->getValue(); // trigger proxy load $reference->getValue(); // trigger proxy load
@ -126,7 +126,7 @@ class LifecycleCallbackTest extends OrmFunctionalTestCase
$this->_em->clear(); $this->_em->clear();
$reference = $this->_em->find('Doctrine\Tests\ORM\Functional\LifecycleCallbackTestEntity', $id); $reference = $this->_em->find(LifecycleCallbackTestEntity::class, $id);
$this->assertTrue($reference->postLoadCallbackInvoked); $this->assertTrue($reference->postLoadCallbackInvoked);
$reference->postLoadCallbackInvoked = false; $reference->postLoadCallbackInvoked = false;
@ -271,7 +271,7 @@ DQL;
public function testLifecycleCallbacksGetInherited() public function testLifecycleCallbacksGetInherited()
{ {
$childMeta = $this->_em->getClassMetadata(__NAMESPACE__ . '\LifecycleCallbackChildEntity'); $childMeta = $this->_em->getClassMetadata(LifecycleCallbackChildEntity::class);
$this->assertEquals(['prePersist' => [0 => 'doStuff']], $childMeta->lifecycleCallbacks); $this->assertEquals(['prePersist' => [0 => 'doStuff']], $childMeta->lifecycleCallbacks);
} }
@ -331,45 +331,14 @@ DQL;
$this->assertArrayHasKey('preRemoveHandler', $e->calls); $this->assertArrayHasKey('preRemoveHandler', $e->calls);
$this->assertArrayHasKey('postRemoveHandler', $e->calls); $this->assertArrayHasKey('postRemoveHandler', $e->calls);
$this->assertInstanceOf( $this->assertInstanceOf(PreFlushEventArgs::class, $e->calls['preFlushHandler']);
'Doctrine\ORM\Event\PreFlushEventArgs', $this->assertInstanceOf(LifecycleEventArgs::class, $e->calls['postLoadHandler']);
$e->calls['preFlushHandler'] $this->assertInstanceOf(LifecycleEventArgs::class, $e->calls['prePersistHandler']);
); $this->assertInstanceOf(LifecycleEventArgs::class, $e->calls['postPersistHandler']);
$this->assertInstanceOf(PreUpdateEventArgs::class, $e->calls['preUpdateHandler']);
$this->assertInstanceOf( $this->assertInstanceOf(LifecycleEventArgs::class, $e->calls['postUpdateHandler']);
'Doctrine\ORM\Event\LifecycleEventArgs', $this->assertInstanceOf(LifecycleEventArgs::class, $e->calls['preRemoveHandler']);
$e->calls['postLoadHandler'] $this->assertInstanceOf(LifecycleEventArgs::class, $e->calls['postRemoveHandler']);
);
$this->assertInstanceOf(
'Doctrine\ORM\Event\LifecycleEventArgs',
$e->calls['prePersistHandler']
);
$this->assertInstanceOf(
'Doctrine\ORM\Event\LifecycleEventArgs',
$e->calls['postPersistHandler']
);
$this->assertInstanceOf(
'Doctrine\ORM\Event\PreUpdateEventArgs',
$e->calls['preUpdateHandler']
);
$this->assertInstanceOf(
'Doctrine\ORM\Event\LifecycleEventArgs',
$e->calls['postUpdateHandler']
);
$this->assertInstanceOf(
'Doctrine\ORM\Event\LifecycleEventArgs',
$e->calls['preRemoveHandler']
);
$this->assertInstanceOf(
'Doctrine\ORM\Event\LifecycleEventArgs',
$e->calls['postRemoveHandler']
);
} }
} }

View File

@ -46,32 +46,32 @@ class GearmanLockTest extends OrmFunctionalTestCase
public function testFindWithLock() public function testFindWithLock()
{ {
$this->asyncFindWithLock('Doctrine\Tests\Models\CMS\CmsArticle', $this->articleId, LockMode::PESSIMISTIC_WRITE); $this->asyncFindWithLock(CmsArticle::class, $this->articleId, LockMode::PESSIMISTIC_WRITE);
$this->asyncFindWithLock('Doctrine\Tests\Models\CMS\CmsArticle', $this->articleId, LockMode::PESSIMISTIC_WRITE); $this->asyncFindWithLock(CmsArticle::class, $this->articleId, LockMode::PESSIMISTIC_WRITE);
$this->assertLockWorked(); $this->assertLockWorked();
} }
public function testFindWithWriteThenReadLock() public function testFindWithWriteThenReadLock()
{ {
$this->asyncFindWithLock('Doctrine\Tests\Models\CMS\CmsArticle', $this->articleId, LockMode::PESSIMISTIC_WRITE); $this->asyncFindWithLock(CmsArticle::class, $this->articleId, LockMode::PESSIMISTIC_WRITE);
$this->asyncFindWithLock('Doctrine\Tests\Models\CMS\CmsArticle', $this->articleId, LockMode::PESSIMISTIC_READ); $this->asyncFindWithLock(CmsArticle::class, $this->articleId, LockMode::PESSIMISTIC_READ);
$this->assertLockWorked(); $this->assertLockWorked();
} }
public function testFindWithReadThenWriteLock() public function testFindWithReadThenWriteLock()
{ {
$this->asyncFindWithLock('Doctrine\Tests\Models\CMS\CmsArticle', $this->articleId, LockMode::PESSIMISTIC_READ); $this->asyncFindWithLock(CmsArticle::class, $this->articleId, LockMode::PESSIMISTIC_READ);
$this->asyncFindWithLock('Doctrine\Tests\Models\CMS\CmsArticle', $this->articleId, LockMode::PESSIMISTIC_WRITE); $this->asyncFindWithLock(CmsArticle::class, $this->articleId, LockMode::PESSIMISTIC_WRITE);
$this->assertLockWorked(); $this->assertLockWorked();
} }
public function testFindWithOneLock() public function testFindWithOneLock()
{ {
$this->asyncFindWithLock('Doctrine\Tests\Models\CMS\CmsArticle', $this->articleId, LockMode::PESSIMISTIC_WRITE); $this->asyncFindWithLock(CmsArticle::class, $this->articleId, LockMode::PESSIMISTIC_WRITE);
$this->asyncFindWithLock('Doctrine\Tests\Models\CMS\CmsArticle', $this->articleId, LockMode::NONE); $this->asyncFindWithLock(CmsArticle::class, $this->articleId, LockMode::NONE);
$this->assertLockDoesNotBlock(); $this->assertLockDoesNotBlock();
} }
@ -79,39 +79,39 @@ class GearmanLockTest extends OrmFunctionalTestCase
public function testDqlWithLock() public function testDqlWithLock()
{ {
$this->asyncDqlWithLock('SELECT a FROM Doctrine\Tests\Models\CMS\CmsArticle a', [], LockMode::PESSIMISTIC_WRITE); $this->asyncDqlWithLock('SELECT a FROM Doctrine\Tests\Models\CMS\CmsArticle a', [], LockMode::PESSIMISTIC_WRITE);
$this->asyncFindWithLock('Doctrine\Tests\Models\CMS\CmsArticle', $this->articleId, LockMode::PESSIMISTIC_WRITE); $this->asyncFindWithLock(CmsArticle::class, $this->articleId, LockMode::PESSIMISTIC_WRITE);
$this->assertLockWorked(); $this->assertLockWorked();
} }
public function testLock() public function testLock()
{ {
$this->asyncFindWithLock('Doctrine\Tests\Models\CMS\CmsArticle', $this->articleId, LockMode::PESSIMISTIC_WRITE); $this->asyncFindWithLock(CmsArticle::class, $this->articleId, LockMode::PESSIMISTIC_WRITE);
$this->asyncLock('Doctrine\Tests\Models\CMS\CmsArticle', $this->articleId, LockMode::PESSIMISTIC_WRITE); $this->asyncLock(CmsArticle::class, $this->articleId, LockMode::PESSIMISTIC_WRITE);
$this->assertLockWorked(); $this->assertLockWorked();
} }
public function testLock2() public function testLock2()
{ {
$this->asyncFindWithLock('Doctrine\Tests\Models\CMS\CmsArticle', $this->articleId, LockMode::PESSIMISTIC_WRITE); $this->asyncFindWithLock(CmsArticle::class, $this->articleId, LockMode::PESSIMISTIC_WRITE);
$this->asyncLock('Doctrine\Tests\Models\CMS\CmsArticle', $this->articleId, LockMode::PESSIMISTIC_READ); $this->asyncLock(CmsArticle::class, $this->articleId, LockMode::PESSIMISTIC_READ);
$this->assertLockWorked(); $this->assertLockWorked();
} }
public function testLock3() public function testLock3()
{ {
$this->asyncFindWithLock('Doctrine\Tests\Models\CMS\CmsArticle', $this->articleId, LockMode::PESSIMISTIC_READ); $this->asyncFindWithLock(CmsArticle::class, $this->articleId, LockMode::PESSIMISTIC_READ);
$this->asyncLock('Doctrine\Tests\Models\CMS\CmsArticle', $this->articleId, LockMode::PESSIMISTIC_WRITE); $this->asyncLock(CmsArticle::class, $this->articleId, LockMode::PESSIMISTIC_WRITE);
$this->assertLockWorked(); $this->assertLockWorked();
} }
public function testLock4() public function testLock4()
{ {
$this->asyncFindWithLock('Doctrine\Tests\Models\CMS\CmsArticle', $this->articleId, LockMode::NONE); $this->asyncFindWithLock(CmsArticle::class, $this->articleId, LockMode::NONE);
$this->asyncLock('Doctrine\Tests\Models\CMS\CmsArticle', $this->articleId, LockMode::PESSIMISTIC_WRITE); $this->asyncLock(CmsArticle::class, $this->articleId, LockMode::PESSIMISTIC_WRITE);
$this->assertLockDoesNotBlock(); $this->assertLockDoesNotBlock();
} }

View File

@ -2,9 +2,9 @@
namespace Doctrine\Tests\ORM\Functional\Locking; namespace Doctrine\Tests\ORM\Functional\Locking;
use Doctrine\ORM\OptimisticLockException;
use Doctrine\DBAL\LockMode;
use DateTime; use DateTime;
use Doctrine\DBAL\LockMode;
use Doctrine\ORM\OptimisticLockException;
use Doctrine\Tests\OrmFunctionalTestCase; use Doctrine\Tests\OrmFunctionalTestCase;
class OptimisticTest extends OrmFunctionalTestCase class OptimisticTest extends OrmFunctionalTestCase
@ -16,10 +16,10 @@ class OptimisticTest extends OrmFunctionalTestCase
try { try {
$this->_schemaTool->createSchema( $this->_schemaTool->createSchema(
[ [
$this->_em->getClassMetadata('Doctrine\Tests\ORM\Functional\Locking\OptimisticJoinedParent'), $this->_em->getClassMetadata(OptimisticJoinedParent::class),
$this->_em->getClassMetadata('Doctrine\Tests\ORM\Functional\Locking\OptimisticJoinedChild'), $this->_em->getClassMetadata(OptimisticJoinedChild::class),
$this->_em->getClassMetadata('Doctrine\Tests\ORM\Functional\Locking\OptimisticStandard'), $this->_em->getClassMetadata(OptimisticStandard::class),
$this->_em->getClassMetadata('Doctrine\Tests\ORM\Functional\Locking\OptimisticTimestamp') $this->_em->getClassMetadata(OptimisticTimestamp::class)
] ]
); );
} catch (\Exception $e) { } catch (\Exception $e) {
@ -175,7 +175,7 @@ class OptimisticTest extends OrmFunctionalTestCase
$this->_em->flush(); $this->_em->flush();
$this->_em->clear(); $this->_em->clear();
$proxy = $this->_em->getReference('Doctrine\Tests\ORM\Functional\Locking\OptimisticStandard', $test->id); $proxy = $this->_em->getReference(OptimisticStandard::class, $test->id);
$this->_em->lock($proxy, LockMode::OPTIMISTIC, 1); $this->_em->lock($proxy, LockMode::OPTIMISTIC, 1);
} }

View File

@ -2,12 +2,13 @@
namespace Doctrine\Tests\ORM\Functional; namespace Doctrine\Tests\ORM\Functional;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Criteria; use Doctrine\Common\Collections\Criteria;
use Doctrine\ORM\PersistentCollection;
use Doctrine\ORM\UnitOfWork; use Doctrine\ORM\UnitOfWork;
use Doctrine\Tests\Models\CMS\CmsGroup;
use Doctrine\Tests\Models\CMS\CmsTag; use Doctrine\Tests\Models\CMS\CmsTag;
use Doctrine\Tests\Models\CMS\CmsUser, use Doctrine\Tests\Models\CMS\CmsUser;
Doctrine\Tests\Models\CMS\CmsGroup,
Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Tests\OrmFunctionalTestCase; use Doctrine\Tests\OrmFunctionalTestCase;
/** /**
@ -49,7 +50,7 @@ class ManyToManyBasicAssociationTest extends OrmFunctionalTestCase
$result = $query->getResult(); $result = $query->getResult();
$this->assertEquals(2, $this->_em->getUnitOfWork()->size()); $this->assertEquals(2, $this->_em->getUnitOfWork()->size());
$this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsUser', $result[0]); $this->assertInstanceOf(CmsUser::class, $result[0]);
$this->assertEquals('Guilherme', $result[0]->name); $this->assertEquals('Guilherme', $result[0]->name);
$this->assertEquals(1, $result[0]->getGroups()->count()); $this->assertEquals(1, $result[0]->getGroups()->count());
$groups = $result[0]->getGroups(); $groups = $result[0]->getGroups();
@ -58,8 +59,8 @@ class ManyToManyBasicAssociationTest extends OrmFunctionalTestCase
$this->assertEquals(UnitOfWork::STATE_MANAGED, $this->_em->getUnitOfWork()->getEntityState($result[0])); $this->assertEquals(UnitOfWork::STATE_MANAGED, $this->_em->getUnitOfWork()->getEntityState($result[0]));
$this->assertEquals(UnitOfWork::STATE_MANAGED, $this->_em->getUnitOfWork()->getEntityState($groups[0])); $this->assertEquals(UnitOfWork::STATE_MANAGED, $this->_em->getUnitOfWork()->getEntityState($groups[0]));
$this->assertInstanceOf('Doctrine\ORM\PersistentCollection', $groups); $this->assertInstanceOf(PersistentCollection::class, $groups);
$this->assertInstanceOf('Doctrine\ORM\PersistentCollection', $groups[0]->getUsers()); $this->assertInstanceOf(PersistentCollection::class, $groups[0]->getUsers());
$groups[0]->getUsers()->clear(); $groups[0]->getUsers()->clear();
$groups->clear(); $groups->clear();
@ -152,7 +153,7 @@ class ManyToManyBasicAssociationTest extends OrmFunctionalTestCase
$user->groups[] = $group; $user->groups[] = $group;
} }
$this->assertInstanceOf('Doctrine\ORM\PersistentCollection', $user->groups); $this->assertInstanceOf(PersistentCollection::class, $user->groups);
$this->assertTrue($user->groups->isDirty()); $this->assertTrue($user->groups->isDirty());
$this->assertEquals($groupCount, count($user->groups), "There should be 10 groups in the collection."); $this->assertEquals($groupCount, count($user->groups), "There should be 10 groups in the collection.");
@ -187,7 +188,7 @@ class ManyToManyBasicAssociationTest extends OrmFunctionalTestCase
$this->_em->clear(); $this->_em->clear();
/* @var $freshUser CmsUser */ /* @var $freshUser CmsUser */
$freshUser = $this->_em->find('Doctrine\Tests\Models\CMS\CmsUser', $user->getId()); $freshUser = $this->_em->find(CmsUser::class, $user->getId());
$newGroup = new CmsGroup(); $newGroup = new CmsGroup();
$newGroup->setName('12Monkeys'); $newGroup->setName('12Monkeys');
$freshUser->addGroup($newGroup); $freshUser->addGroup($newGroup);
@ -202,7 +203,7 @@ class ManyToManyBasicAssociationTest extends OrmFunctionalTestCase
$this->_em->clear(); $this->_em->clear();
$freshUser = $this->_em->find('Doctrine\Tests\Models\CMS\CmsUser', $user->getId()); $freshUser = $this->_em->find(CmsUser::class, $user->getId());
$this->assertEquals(3, count($freshUser->getGroups())); $this->assertEquals(3, count($freshUser->getGroups()));
} }
@ -333,7 +334,7 @@ class ManyToManyBasicAssociationTest extends OrmFunctionalTestCase
$coll = new ArrayCollection([$group1, $group2]); $coll = new ArrayCollection([$group1, $group2]);
$user->groups = $coll; $user->groups = $coll;
$this->_em->flush(); $this->_em->flush();
$this->assertInstanceOf('Doctrine\ORM\PersistentCollection', $user->groups, $this->assertInstanceOf(PersistentCollection::class, $user->groups,
"UnitOfWork should have replaced ArrayCollection with PersistentCollection."); "UnitOfWork should have replaced ArrayCollection with PersistentCollection.");
$this->_em->flush(); $this->_em->flush();

View File

@ -115,8 +115,8 @@ class ManyToManyBidirectionalAssociationTest extends AbstractManyToManyAssociati
//$query->setHint(Query::HINT_FORCE_PARTIAL_LOAD, true); //$query->setHint(Query::HINT_FORCE_PARTIAL_LOAD, true);
$result = $query->getResult(); $result = $query->getResult();
$this->assertEquals(2, count($result)); $this->assertEquals(2, count($result));
$this->assertInstanceOf('Doctrine\Tests\Models\ECommerce\ECommerceCategory', $result[0]); $this->assertInstanceOf(ECommerceCategory::class, $result[0]);
$this->assertInstanceOf('Doctrine\Tests\Models\ECommerce\ECommerceCategory', $result[1]); $this->assertInstanceOf(ECommerceCategory::class, $result[1]);
$prods1 = $result[0]->getProducts(); $prods1 = $result[0]->getProducts();
$prods2 = $result[1]->getProducts(); $prods2 = $result[1]->getProducts();
$this->assertTrue($prods1->isInitialized()); $this->assertTrue($prods1->isInitialized());
@ -155,10 +155,10 @@ class ManyToManyBidirectionalAssociationTest extends AbstractManyToManyAssociati
$this->assertEquals(2, count($secondCategoryProducts)); // lazy-load $this->assertEquals(2, count($secondCategoryProducts)); // lazy-load
$this->assertTrue($secondCategoryProducts->isInitialized()); $this->assertTrue($secondCategoryProducts->isInitialized());
$this->assertInstanceOf('Doctrine\Tests\Models\ECommerce\ECommerceProduct', $firstCategoryProducts[0]); $this->assertInstanceOf(ECommerceProduct::class, $firstCategoryProducts[0]);
$this->assertInstanceOf('Doctrine\Tests\Models\ECommerce\ECommerceProduct', $firstCategoryProducts[1]); $this->assertInstanceOf(ECommerceProduct::class, $firstCategoryProducts[1]);
$this->assertInstanceOf('Doctrine\Tests\Models\ECommerce\ECommerceProduct', $secondCategoryProducts[0]); $this->assertInstanceOf(ECommerceProduct::class, $secondCategoryProducts[0]);
$this->assertInstanceOf('Doctrine\Tests\Models\ECommerce\ECommerceProduct', $secondCategoryProducts[1]); $this->assertInstanceOf(ECommerceProduct::class, $secondCategoryProducts[1]);
$this->assertCollectionEquals($firstCategoryProducts, $secondCategoryProducts); $this->assertCollectionEquals($firstCategoryProducts, $secondCategoryProducts);
} }
@ -190,10 +190,10 @@ class ManyToManyBidirectionalAssociationTest extends AbstractManyToManyAssociati
$this->assertEquals(2, count($secondProductCategories)); // lazy-load $this->assertEquals(2, count($secondProductCategories)); // lazy-load
$this->assertTrue($secondProductCategories->isInitialized()); $this->assertTrue($secondProductCategories->isInitialized());
$this->assertInstanceOf('Doctrine\Tests\Models\ECommerce\ECommerceCategory', $firstProductCategories[0]); $this->assertInstanceOf(ECommerceCategory::class, $firstProductCategories[0]);
$this->assertInstanceOf('Doctrine\Tests\Models\ECommerce\ECommerceCategory', $firstProductCategories[1]); $this->assertInstanceOf(ECommerceCategory::class, $firstProductCategories[1]);
$this->assertInstanceOf('Doctrine\Tests\Models\ECommerce\ECommerceCategory', $secondProductCategories[0]); $this->assertInstanceOf(ECommerceCategory::class, $secondProductCategories[0]);
$this->assertInstanceOf('Doctrine\Tests\Models\ECommerce\ECommerceCategory', $secondProductCategories[1]); $this->assertInstanceOf(ECommerceCategory::class, $secondProductCategories[1]);
$this->assertCollectionEquals($firstProductCategories, $secondProductCategories); $this->assertCollectionEquals($firstProductCategories, $secondProductCategories);
} }

View File

@ -72,7 +72,7 @@ class ManyToManySelfReferentialAssociationTest extends AbstractManyToManyAssocia
{ {
$this->_createLoadingFixture(); $this->_createLoadingFixture();
$metadata = $this->_em->getClassMetadata('Doctrine\Tests\Models\ECommerce\ECommerceProduct'); $metadata = $this->_em->getClassMetadata(ECommerceProduct::class);
$metadata->associationMappings['related']['fetch'] = ClassMetadata::FETCH_LAZY; $metadata->associationMappings['related']['fetch'] = ClassMetadata::FETCH_LAZY;
$query = $this->_em->createQuery('SELECT p FROM Doctrine\Tests\Models\ECommerce\ECommerceProduct p'); $query = $this->_em->createQuery('SELECT p FROM Doctrine\Tests\Models\ECommerce\ECommerceProduct p');
@ -93,10 +93,10 @@ class ManyToManySelfReferentialAssociationTest extends AbstractManyToManyAssocia
$this->assertEquals(2, count($firstRelatedBy)); $this->assertEquals(2, count($firstRelatedBy));
$this->assertEquals(2, count($secondRelatedBy)); $this->assertEquals(2, count($secondRelatedBy));
$this->assertInstanceOf('Doctrine\Tests\Models\ECommerce\ECommerceProduct', $firstRelatedBy[0]); $this->assertInstanceOf(ECommerceProduct::class, $firstRelatedBy[0]);
$this->assertInstanceOf('Doctrine\Tests\Models\ECommerce\ECommerceProduct', $firstRelatedBy[1]); $this->assertInstanceOf(ECommerceProduct::class, $firstRelatedBy[1]);
$this->assertInstanceOf('Doctrine\Tests\Models\ECommerce\ECommerceProduct', $secondRelatedBy[0]); $this->assertInstanceOf(ECommerceProduct::class, $secondRelatedBy[0]);
$this->assertInstanceOf('Doctrine\Tests\Models\ECommerce\ECommerceProduct', $secondRelatedBy[1]); $this->assertInstanceOf(ECommerceProduct::class, $secondRelatedBy[1]);
$this->assertCollectionEquals($firstRelatedBy, $secondRelatedBy); $this->assertCollectionEquals($firstRelatedBy, $secondRelatedBy);
} }

View File

@ -67,8 +67,8 @@ class ManyToManyUnidirectionalAssociationTest extends AbstractManyToManyAssociat
$products = $firstCart->getProducts(); $products = $firstCart->getProducts();
$secondCart = $result[1]; $secondCart = $result[1];
$this->assertInstanceOf('Doctrine\Tests\Models\ECommerce\ECommerceProduct', $products[0]); $this->assertInstanceOf(ECommerceProduct::class, $products[0]);
$this->assertInstanceOf('Doctrine\Tests\Models\ECommerce\ECommerceProduct', $products[1]); $this->assertInstanceOf(ECommerceProduct::class, $products[1]);
$this->assertCollectionEquals($products, $secondCart->getProducts()); $this->assertCollectionEquals($products, $secondCart->getProducts());
//$this->assertEquals("Doctrine 1.x Manual", $products[0]->getName()); //$this->assertEquals("Doctrine 1.x Manual", $products[0]->getName());
//$this->assertEquals("Doctrine 2.x Manual", $products[1]->getName()); //$this->assertEquals("Doctrine 2.x Manual", $products[1]->getName());
@ -77,7 +77,7 @@ class ManyToManyUnidirectionalAssociationTest extends AbstractManyToManyAssociat
public function testLazyLoadsCollection() public function testLazyLoadsCollection()
{ {
$this->_createFixture(); $this->_createFixture();
$metadata = $this->_em->getClassMetadata('Doctrine\Tests\Models\ECommerce\ECommerceCart'); $metadata = $this->_em->getClassMetadata(ECommerceCart::class);
$metadata->associationMappings['products']['fetch'] = ClassMetadata::FETCH_LAZY; $metadata->associationMappings['products']['fetch'] = ClassMetadata::FETCH_LAZY;
$query = $this->_em->createQuery('SELECT c FROM Doctrine\Tests\Models\ECommerce\ECommerceCart c'); $query = $this->_em->createQuery('SELECT c FROM Doctrine\Tests\Models\ECommerce\ECommerceCart c');
@ -86,8 +86,8 @@ class ManyToManyUnidirectionalAssociationTest extends AbstractManyToManyAssociat
$products = $firstCart->getProducts(); $products = $firstCart->getProducts();
$secondCart = $result[1]; $secondCart = $result[1];
$this->assertInstanceOf('Doctrine\Tests\Models\ECommerce\ECommerceProduct', $products[0]); $this->assertInstanceOf(ECommerceProduct::class, $products[0]);
$this->assertInstanceOf('Doctrine\Tests\Models\ECommerce\ECommerceProduct', $products[1]); $this->assertInstanceOf(ECommerceProduct::class, $products[1]);
$this->assertCollectionEquals($products, $secondCart->getProducts()); $this->assertCollectionEquals($products, $secondCart->getProducts());
} }

View File

@ -1,6 +1,8 @@
<?php <?php
namespace Doctrine\Tests\ORM\Functional; namespace Doctrine\Tests\ORM\Functional;
use Doctrine\ORM\Proxy\Proxy;
use Doctrine\Tests\Models\DirectoryTree\Directory; use Doctrine\Tests\Models\DirectoryTree\Directory;
use Doctrine\Tests\Models\DirectoryTree\File; use Doctrine\Tests\Models\DirectoryTree\File;
use Doctrine\Tests\OrmFunctionalTestCase; use Doctrine\Tests\OrmFunctionalTestCase;
@ -39,10 +41,10 @@ class MappedSuperclassTest extends OrmFunctionalTestCase
$cleanFile = $this->_em->find(get_class($file), $file->getId()); $cleanFile = $this->_em->find(get_class($file), $file->getId());
$this->assertInstanceOf('Doctrine\Tests\Models\DirectoryTree\Directory', $cleanFile->getParent()); $this->assertInstanceOf(Directory::class, $cleanFile->getParent());
$this->assertInstanceOf('Doctrine\ORM\Proxy\Proxy', $cleanFile->getParent()); $this->assertInstanceOf(Proxy::class, $cleanFile->getParent());
$this->assertEquals($directory->getId(), $cleanFile->getParent()->getId()); $this->assertEquals($directory->getId(), $cleanFile->getParent()->getId());
$this->assertInstanceOf('Doctrine\Tests\Models\DirectoryTree\Directory', $cleanFile->getParent()->getParent()); $this->assertInstanceOf(Directory::class, $cleanFile->getParent()->getParent());
$this->assertEquals($root->getId(), $cleanFile->getParent()->getParent()->getId()); $this->assertEquals($root->getId(), $cleanFile->getParent()->getParent()->getId());
} }
} }

View File

@ -17,8 +17,8 @@ class MergeCompositeToOneKeyTest extends OrmFunctionalTestCase
$this->_schemaTool->createSchema( $this->_schemaTool->createSchema(
[ [
$this->_em->getClassMetadata(Country::CLASSNAME), $this->_em->getClassMetadata(Country::class),
$this->_em->getClassMetadata(CompositeToOneKeyState::CLASSNAME), $this->_em->getClassMetadata(CompositeToOneKeyState::class),
] ]
); );
} }
@ -39,9 +39,9 @@ class MergeCompositeToOneKeyTest extends OrmFunctionalTestCase
/* @var $merged CompositeToOneKeyState */ /* @var $merged CompositeToOneKeyState */
$merged = $this->_em->merge($state); $merged = $this->_em->merge($state);
$this->assertInstanceOf(CompositeToOneKeyState::CLASSNAME, $state); $this->assertInstanceOf(CompositeToOneKeyState::class, $state);
$this->assertNotSame($state, $merged); $this->assertNotSame($state, $merged);
$this->assertInstanceOf(Country::CLASSNAME, $merged->country); $this->assertInstanceOf(Country::class, $merged->country);
$this->assertNotSame($country, $merged->country); $this->assertNotSame($country, $merged->country);
} }
} }

View File

@ -7,6 +7,7 @@ use Doctrine\DBAL\Logging\DebugStack;
use Doctrine\DBAL\Logging\SQLLogger; use Doctrine\DBAL\Logging\SQLLogger;
use Doctrine\ORM\Configuration; use Doctrine\ORM\Configuration;
use Doctrine\ORM\EntityManager; use Doctrine\ORM\EntityManager;
use Doctrine\ORM\Proxy\Proxy;
use Doctrine\ORM\Tools\SchemaTool; use Doctrine\ORM\Tools\SchemaTool;
use Doctrine\Tests\Models\Generic\DateTimeModel; use Doctrine\Tests\Models\Generic\DateTimeModel;
use Doctrine\Tests\OrmFunctionalTestCase; use Doctrine\Tests\OrmFunctionalTestCase;
@ -31,11 +32,11 @@ class MergeProxiesTest extends OrmFunctionalTestCase
*/ */
public function testMergeDetachedUnInitializedProxy() public function testMergeDetachedUnInitializedProxy()
{ {
$detachedUninitialized = $this->_em->getReference(DateTimeModel::CLASSNAME, 123); $detachedUninitialized = $this->_em->getReference(DateTimeModel::class, 123);
$this->_em->clear(); $this->_em->clear();
$managed = $this->_em->getReference(DateTimeModel::CLASSNAME, 123); $managed = $this->_em->getReference(DateTimeModel::class, 123);
$this->assertSame($managed, $this->_em->merge($detachedUninitialized)); $this->assertSame($managed, $this->_em->merge($detachedUninitialized));
@ -51,11 +52,11 @@ class MergeProxiesTest extends OrmFunctionalTestCase
*/ */
public function testMergeUnserializedUnInitializedProxy() public function testMergeUnserializedUnInitializedProxy()
{ {
$detachedUninitialized = $this->_em->getReference(DateTimeModel::CLASSNAME, 123); $detachedUninitialized = $this->_em->getReference(DateTimeModel::class, 123);
$this->_em->clear(); $this->_em->clear();
$managed = $this->_em->getReference(DateTimeModel::CLASSNAME, 123); $managed = $this->_em->getReference(DateTimeModel::class, 123);
$this->assertSame( $this->assertSame(
$managed, $managed,
@ -74,7 +75,7 @@ class MergeProxiesTest extends OrmFunctionalTestCase
*/ */
public function testMergeManagedProxy() public function testMergeManagedProxy()
{ {
$managed = $this->_em->getReference(DateTimeModel::CLASSNAME, 123); $managed = $this->_em->getReference(DateTimeModel::class, 123);
$this->assertSame($managed, $this->_em->merge($managed)); $this->assertSame($managed, $this->_em->merge($managed));
@ -98,9 +99,9 @@ class MergeProxiesTest extends OrmFunctionalTestCase
$this->_em->flush($date); $this->_em->flush($date);
$this->_em->clear(); $this->_em->clear();
$managed = $this->_em->getReference(DateTimeModel::CLASSNAME, $date->id); $managed = $this->_em->getReference(DateTimeModel::class, $date->id);
$this->assertInstanceOf('Doctrine\Common\Proxy\Proxy', $managed); $this->assertInstanceOf(Proxy::class, $managed);
$this->assertFalse($managed->__isInitialized()); $this->assertFalse($managed->__isInitialized());
$date->date = $dateTime = new \DateTime(); $date->date = $dateTime = new \DateTime();
@ -134,8 +135,8 @@ class MergeProxiesTest extends OrmFunctionalTestCase
$queryCount1 = count($logger1->queries); $queryCount1 = count($logger1->queries);
$queryCount2 = count($logger2->queries); $queryCount2 = count($logger2->queries);
$proxy1 = $em1->getReference(DateTimeModel::CLASSNAME, $file1->id); $proxy1 = $em1->getReference(DateTimeModel::class, $file1->id);
$proxy2 = $em2->getReference(DateTimeModel::CLASSNAME, $file1->id); $proxy2 = $em2->getReference(DateTimeModel::class, $file1->id);
$merged2 = $em2->merge($proxy1); $merged2 = $em2->merge($proxy1);
$this->assertNotSame($proxy1, $merged2); $this->assertNotSame($proxy1, $merged2);
@ -195,10 +196,10 @@ class MergeProxiesTest extends OrmFunctionalTestCase
$queryCount1 = count($logger1->queries); $queryCount1 = count($logger1->queries);
$queryCount2 = count($logger1->queries); $queryCount2 = count($logger1->queries);
$unManagedProxy = $em1->getReference(DateTimeModel::CLASSNAME, $file1->id); $unManagedProxy = $em1->getReference(DateTimeModel::class, $file1->id);
$mergedInstance = $em2->merge($unManagedProxy); $mergedInstance = $em2->merge($unManagedProxy);
$this->assertNotInstanceOf('Doctrine\Common\Proxy\Proxy', $mergedInstance); $this->assertNotInstanceOf(Proxy::class, $mergedInstance);
$this->assertNotSame($unManagedProxy, $mergedInstance); $this->assertNotSame($unManagedProxy, $mergedInstance);
$this->assertFalse($unManagedProxy->__isInitialized()); $this->assertFalse($unManagedProxy->__isInitialized());
@ -258,7 +259,7 @@ class MergeProxiesTest extends OrmFunctionalTestCase
$entityManager = EntityManager::create($connection, $config); $entityManager = EntityManager::create($connection, $config);
(new SchemaTool($entityManager))->createSchema([$entityManager->getClassMetadata(DateTimeModel::CLASSNAME)]); (new SchemaTool($entityManager))->createSchema([$entityManager->getClassMetadata(DateTimeModel::class)]);
return $entityManager; return $entityManager;
} }

View File

@ -17,8 +17,8 @@ class MergeSharedEntitiesTest extends OrmFunctionalTestCase
try { try {
$this->_schemaTool->createSchema( $this->_schemaTool->createSchema(
[ [
$this->_em->getClassMetadata(__NAMESPACE__ . '\MSEFile'), $this->_em->getClassMetadata(MSEFile::class),
$this->_em->getClassMetadata(__NAMESPACE__ . '\MSEPicture'), $this->_em->getClassMetadata(MSEPicture::class),
] ]
); );
} catch (ToolsException $ignored) { } catch (ToolsException $ignored) {

View File

@ -3,17 +3,22 @@
namespace Doctrine\Tests\ORM\Functional; namespace Doctrine\Tests\ORM\Functional;
use Doctrine\Common\Collections\ArrayCollection; use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\ORM\Internal\Hydration\HydrationException; use Doctrine\ORM\Internal\Hydration\HydrationException;
use Doctrine\ORM\PersistentCollection;
use Doctrine\ORM\Query\Parameter;
use Doctrine\ORM\Query\ResultSetMapping; use Doctrine\ORM\Query\ResultSetMapping;
use Doctrine\ORM\Query\ResultSetMappingBuilder; use Doctrine\ORM\Query\ResultSetMappingBuilder;
use Doctrine\ORM\Query\Parameter;
use Doctrine\Tests\Models\CMS\CmsUser;
use Doctrine\Tests\Models\CMS\CmsPhonenumber;
use Doctrine\Tests\Models\CMS\CmsAddress; use Doctrine\Tests\Models\CMS\CmsAddress;
use Doctrine\Tests\Models\CMS\CmsEmail; use Doctrine\Tests\Models\CMS\CmsEmail;
use Doctrine\Tests\Models\CMS\CmsPhonenumber;
use Doctrine\Tests\Models\CMS\CmsUser;
use Doctrine\Tests\Models\Company\CompanyContract;
use Doctrine\Tests\Models\Company\CompanyEmployee; use Doctrine\Tests\Models\Company\CompanyEmployee;
use Doctrine\Tests\Models\Company\CompanyFixContract;
use Doctrine\Tests\Models\Company\CompanyFlexContract;
use Doctrine\Tests\Models\Company\CompanyPerson; use Doctrine\Tests\Models\Company\CompanyPerson;
use Doctrine\Tests\Models\DDC3899\DDC3899FixContract;
use Doctrine\Tests\Models\DDC3899\DDC3899User;
use Doctrine\Tests\OrmFunctionalTestCase; use Doctrine\Tests\OrmFunctionalTestCase;
/** /**
@ -45,7 +50,7 @@ class NativeQueryTest extends OrmFunctionalTestCase
$this->_em->clear(); $this->_em->clear();
$rsm = new ResultSetMapping; $rsm = new ResultSetMapping;
$rsm->addEntityResult('Doctrine\Tests\Models\CMS\CmsUser', 'u'); $rsm->addEntityResult(CmsUser::class, 'u');
$rsm->addFieldResult('u', $this->platform->getSQLResultCasing('id'), 'id'); $rsm->addFieldResult('u', $this->platform->getSQLResultCasing('id'), 'id');
$rsm->addFieldResult('u', $this->platform->getSQLResultCasing('name'), 'name'); $rsm->addFieldResult('u', $this->platform->getSQLResultCasing('name'), 'name');
@ -55,7 +60,7 @@ class NativeQueryTest extends OrmFunctionalTestCase
$users = $query->getResult(); $users = $query->getResult();
$this->assertEquals(1, count($users)); $this->assertEquals(1, count($users));
$this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsUser', $users[0]); $this->assertInstanceOf(CmsUser::class, $users[0]);
$this->assertEquals('Roman', $users[0]->name); $this->assertEquals('Roman', $users[0]->name);
} }
@ -80,7 +85,7 @@ class NativeQueryTest extends OrmFunctionalTestCase
$this->_em->clear(); $this->_em->clear();
$rsm = new ResultSetMapping; $rsm = new ResultSetMapping;
$rsm->addEntityResult('Doctrine\Tests\Models\CMS\CmsAddress', 'a'); $rsm->addEntityResult(CmsAddress::class, 'a');
$rsm->addFieldResult('a', $this->platform->getSQLResultCasing('id'), 'id'); $rsm->addFieldResult('a', $this->platform->getSQLResultCasing('id'), 'id');
$rsm->addFieldResult('a', $this->platform->getSQLResultCasing('country'), 'country'); $rsm->addFieldResult('a', $this->platform->getSQLResultCasing('country'), 'country');
$rsm->addFieldResult('a', $this->platform->getSQLResultCasing('zip'), 'zip'); $rsm->addFieldResult('a', $this->platform->getSQLResultCasing('zip'), 'zip');
@ -119,11 +124,11 @@ class NativeQueryTest extends OrmFunctionalTestCase
$this->_em->clear(); $this->_em->clear();
$rsm = new ResultSetMapping; $rsm = new ResultSetMapping;
$rsm->addEntityResult('Doctrine\Tests\Models\CMS\CmsUser', 'u'); $rsm->addEntityResult(CmsUser::class, 'u');
$rsm->addFieldResult('u', $this->platform->getSQLResultCasing('id'), 'id'); $rsm->addFieldResult('u', $this->platform->getSQLResultCasing('id'), 'id');
$rsm->addFieldResult('u', $this->platform->getSQLResultCasing('name'), 'name'); $rsm->addFieldResult('u', $this->platform->getSQLResultCasing('name'), 'name');
$rsm->addFieldResult('u', $this->platform->getSQLResultCasing('status'), 'status'); $rsm->addFieldResult('u', $this->platform->getSQLResultCasing('status'), 'status');
$rsm->addJoinedEntityResult('Doctrine\Tests\Models\CMS\CmsPhonenumber', 'p', 'u', 'phonenumbers'); $rsm->addJoinedEntityResult(CmsPhonenumber::class, 'p', 'u', 'phonenumbers');
$rsm->addFieldResult('p', $this->platform->getSQLResultCasing('phonenumber'), 'phonenumber'); $rsm->addFieldResult('p', $this->platform->getSQLResultCasing('phonenumber'), 'phonenumber');
$query = $this->_em->createNativeQuery('SELECT id, name, status, phonenumber FROM cms_users INNER JOIN cms_phonenumbers ON id = user_id WHERE username = ?', $rsm); $query = $this->_em->createNativeQuery('SELECT id, name, status, phonenumber FROM cms_users INNER JOIN cms_phonenumbers ON id = user_id WHERE username = ?', $rsm);
@ -131,9 +136,9 @@ class NativeQueryTest extends OrmFunctionalTestCase
$users = $query->getResult(); $users = $query->getResult();
$this->assertEquals(1, count($users)); $this->assertEquals(1, count($users));
$this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsUser', $users[0]); $this->assertInstanceOf(CmsUser::class, $users[0]);
$this->assertEquals('Roman', $users[0]->name); $this->assertEquals('Roman', $users[0]->name);
$this->assertInstanceOf('Doctrine\ORM\PersistentCollection', $users[0]->getPhonenumbers()); $this->assertInstanceOf(PersistentCollection::class, $users[0]->getPhonenumbers());
$this->assertTrue($users[0]->getPhonenumbers()->isInitialized()); $this->assertTrue($users[0]->getPhonenumbers()->isInitialized());
$this->assertEquals(1, count($users[0]->getPhonenumbers())); $this->assertEquals(1, count($users[0]->getPhonenumbers()));
$phones = $users[0]->getPhonenumbers(); $phones = $users[0]->getPhonenumbers();
@ -164,11 +169,11 @@ class NativeQueryTest extends OrmFunctionalTestCase
$rsm = new ResultSetMapping; $rsm = new ResultSetMapping;
$rsm->addEntityResult('Doctrine\Tests\Models\CMS\CmsUser', 'u'); $rsm->addEntityResult(CmsUser::class, 'u');
$rsm->addFieldResult('u', $this->platform->getSQLResultCasing('id'), 'id'); $rsm->addFieldResult('u', $this->platform->getSQLResultCasing('id'), 'id');
$rsm->addFieldResult('u', $this->platform->getSQLResultCasing('name'), 'name'); $rsm->addFieldResult('u', $this->platform->getSQLResultCasing('name'), 'name');
$rsm->addFieldResult('u', $this->platform->getSQLResultCasing('status'), 'status'); $rsm->addFieldResult('u', $this->platform->getSQLResultCasing('status'), 'status');
$rsm->addJoinedEntityResult('Doctrine\Tests\Models\CMS\CmsAddress', 'a', 'u', 'address'); $rsm->addJoinedEntityResult(CmsAddress::class, 'a', 'u', 'address');
$rsm->addFieldResult('a', $this->platform->getSQLResultCasing('a_id'), 'id'); $rsm->addFieldResult('a', $this->platform->getSQLResultCasing('a_id'), 'id');
$rsm->addFieldResult('a', $this->platform->getSQLResultCasing('country'), 'country'); $rsm->addFieldResult('a', $this->platform->getSQLResultCasing('country'), 'country');
$rsm->addFieldResult('a', $this->platform->getSQLResultCasing('zip'), 'zip'); $rsm->addFieldResult('a', $this->platform->getSQLResultCasing('zip'), 'zip');
@ -180,11 +185,11 @@ class NativeQueryTest extends OrmFunctionalTestCase
$users = $query->getResult(); $users = $query->getResult();
$this->assertEquals(1, count($users)); $this->assertEquals(1, count($users));
$this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsUser', $users[0]); $this->assertInstanceOf(CmsUser::class, $users[0]);
$this->assertEquals('Roman', $users[0]->name); $this->assertEquals('Roman', $users[0]->name);
$this->assertInstanceOf('Doctrine\ORM\PersistentCollection', $users[0]->getPhonenumbers()); $this->assertInstanceOf(PersistentCollection::class, $users[0]->getPhonenumbers());
$this->assertFalse($users[0]->getPhonenumbers()->isInitialized()); $this->assertFalse($users[0]->getPhonenumbers()->isInitialized());
$this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsAddress', $users[0]->getAddress()); $this->assertInstanceOf(CmsAddress::class, $users[0]->getAddress());
$this->assertTrue($users[0]->getAddress()->getUser() == $users[0]); $this->assertTrue($users[0]->getAddress()->getUser() == $users[0]);
$this->assertEquals('germany', $users[0]->getAddress()->getCountry()); $this->assertEquals('germany', $users[0]->getAddress()->getCountry());
$this->assertEquals(10827, $users[0]->getAddress()->getZipCode()); $this->assertEquals(10827, $users[0]->getAddress()->getZipCode());
@ -230,16 +235,16 @@ class NativeQueryTest extends OrmFunctionalTestCase
$this->_em->clear(); $this->_em->clear();
$rsm = new ResultSetMappingBuilder($this->_em); $rsm = new ResultSetMappingBuilder($this->_em);
$rsm->addRootEntityFromClassMetadata('Doctrine\Tests\Models\CMS\CmsUser', 'u'); $rsm->addRootEntityFromClassMetadata(CmsUser::class, 'u');
$rsm->addJoinedEntityFromClassMetadata('Doctrine\Tests\Models\CMS\CmsPhonenumber', 'p', 'u', 'phonenumbers'); $rsm->addJoinedEntityFromClassMetadata(CmsPhonenumber::class, 'p', 'u', 'phonenumbers');
$query = $this->_em->createNativeQuery('SELECT u.*, p.* FROM cms_users u LEFT JOIN cms_phonenumbers p ON u.id = p.user_id WHERE username = ?', $rsm); $query = $this->_em->createNativeQuery('SELECT u.*, p.* FROM cms_users u LEFT JOIN cms_phonenumbers p ON u.id = p.user_id WHERE username = ?', $rsm);
$query->setParameter(1, 'romanb'); $query->setParameter(1, 'romanb');
$users = $query->getResult(); $users = $query->getResult();
$this->assertEquals(1, count($users)); $this->assertEquals(1, count($users));
$this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsUser', $users[0]); $this->assertInstanceOf(CmsUser::class, $users[0]);
$this->assertEquals('Roman', $users[0]->name); $this->assertEquals('Roman', $users[0]->name);
$this->assertInstanceOf('Doctrine\ORM\PersistentCollection', $users[0]->getPhonenumbers()); $this->assertInstanceOf(PersistentCollection::class, $users[0]->getPhonenumbers());
$this->assertTrue($users[0]->getPhonenumbers()->isInitialized()); $this->assertTrue($users[0]->getPhonenumbers()->isInitialized());
$this->assertEquals(1, count($users[0]->getPhonenumbers())); $this->assertEquals(1, count($users[0]->getPhonenumbers()));
$phones = $users[0]->getPhonenumbers(); $phones = $users[0]->getPhonenumbers();
@ -249,7 +254,7 @@ class NativeQueryTest extends OrmFunctionalTestCase
$this->_em->clear(); $this->_em->clear();
$rsm = new ResultSetMappingBuilder($this->_em); $rsm = new ResultSetMappingBuilder($this->_em);
$rsm->addRootEntityFromClassMetadata('Doctrine\Tests\Models\CMS\CmsPhonenumber', 'p'); $rsm->addRootEntityFromClassMetadata(CmsPhonenumber::class, 'p');
$query = $this->_em->createNativeQuery('SELECT p.* FROM cms_phonenumbers p WHERE p.phonenumber = ?', $rsm); $query = $this->_em->createNativeQuery('SELECT p.* FROM cms_phonenumbers p WHERE p.phonenumber = ?', $rsm);
$query->setParameter(1, $phone->phonenumber); $query->setParameter(1, $phone->phonenumber);
$phone = $query->getSingleResult(); $phone = $query->getSingleResult();
@ -280,8 +285,8 @@ class NativeQueryTest extends OrmFunctionalTestCase
$rsm = new ResultSetMappingBuilder($this->_em); $rsm = new ResultSetMappingBuilder($this->_em);
$rsm->addRootEntityFromClassMetadata('Doctrine\Tests\Models\CMS\CmsUser', 'u'); $rsm->addRootEntityFromClassMetadata(CmsUser::class, 'u');
$rsm->addJoinedEntityFromClassMetadata('Doctrine\Tests\Models\CMS\CmsAddress', 'a', 'u', 'address', ['id' => 'a_id'] $rsm->addJoinedEntityFromClassMetadata(CmsAddress::class, 'a', 'u', 'address', ['id' => 'a_id']
); );
$query = $this->_em->createNativeQuery('SELECT u.*, a.*, a.id AS a_id FROM cms_users u INNER JOIN cms_addresses a ON u.id = a.user_id WHERE u.username = ?', $rsm); $query = $this->_em->createNativeQuery('SELECT u.*, a.*, a.id AS a_id FROM cms_users u INNER JOIN cms_addresses a ON u.id = a.user_id WHERE u.username = ?', $rsm);
@ -290,11 +295,11 @@ class NativeQueryTest extends OrmFunctionalTestCase
$users = $query->getResult(); $users = $query->getResult();
$this->assertEquals(1, count($users)); $this->assertEquals(1, count($users));
$this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsUser', $users[0]); $this->assertInstanceOf(CmsUser::class, $users[0]);
$this->assertEquals('Roman', $users[0]->name); $this->assertEquals('Roman', $users[0]->name);
$this->assertInstanceOf('Doctrine\ORM\PersistentCollection', $users[0]->getPhonenumbers()); $this->assertInstanceOf(PersistentCollection::class, $users[0]->getPhonenumbers());
$this->assertFalse($users[0]->getPhonenumbers()->isInitialized()); $this->assertFalse($users[0]->getPhonenumbers()->isInitialized());
$this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsAddress', $users[0]->getAddress()); $this->assertInstanceOf(CmsAddress::class, $users[0]->getAddress());
$this->assertTrue($users[0]->getAddress()->getUser() == $users[0]); $this->assertTrue($users[0]->getAddress()->getUser() == $users[0]);
$this->assertEquals('germany', $users[0]->getAddress()->getCountry()); $this->assertEquals('germany', $users[0]->getAddress()->getCountry());
$this->assertEquals(10827, $users[0]->getAddress()->getZipCode()); $this->assertEquals(10827, $users[0]->getAddress()->getZipCode());
@ -303,7 +308,7 @@ class NativeQueryTest extends OrmFunctionalTestCase
$this->_em->clear(); $this->_em->clear();
$rsm = new ResultSetMappingBuilder($this->_em); $rsm = new ResultSetMappingBuilder($this->_em);
$rsm->addRootEntityFromClassMetadata('Doctrine\Tests\Models\CMS\CmsAddress', 'a'); $rsm->addRootEntityFromClassMetadata(CmsAddress::class, 'a');
$query = $this->_em->createNativeQuery('SELECT a.* FROM cms_addresses a WHERE a.id = ?', $rsm); $query = $this->_em->createNativeQuery('SELECT a.* FROM cms_addresses a WHERE a.id = ?', $rsm);
$query->setParameter(1, $addr->getId()); $query->setParameter(1, $addr->getId());
$address = $query->getSingleResult(); $address = $query->getSingleResult();
@ -318,7 +323,7 @@ class NativeQueryTest extends OrmFunctionalTestCase
public function testConcreteClassInSingleTableInheritanceSchemaWithRSMBuilderIsFine() public function testConcreteClassInSingleTableInheritanceSchemaWithRSMBuilderIsFine()
{ {
$rsm = new ResultSetMappingBuilder($this->_em); $rsm = new ResultSetMappingBuilder($this->_em);
$rsm->addRootEntityFromClassMetadata('Doctrine\Tests\Models\Company\CompanyFixContract', 'c'); $rsm->addRootEntityFromClassMetadata(CompanyFixContract::class, 'c');
} }
/** /**
@ -330,7 +335,7 @@ class NativeQueryTest extends OrmFunctionalTestCase
$this->expectExceptionMessage('ResultSetMapping builder does not currently support your inheritance scheme.'); $this->expectExceptionMessage('ResultSetMapping builder does not currently support your inheritance scheme.');
$rsm = new ResultSetMappingBuilder($this->_em); $rsm = new ResultSetMappingBuilder($this->_em);
$rsm->addRootEntityFromClassMetadata('Doctrine\Tests\Models\Company\CompanyContract', 'c'); $rsm->addRootEntityFromClassMetadata(CompanyContract::class, 'c');
} }
/** /**
@ -339,8 +344,8 @@ class NativeQueryTest extends OrmFunctionalTestCase
public function testRSMBuilderThrowsExceptionOnColumnConflict() public function testRSMBuilderThrowsExceptionOnColumnConflict()
{ {
$rsm = new ResultSetMappingBuilder($this->_em); $rsm = new ResultSetMappingBuilder($this->_em);
$rsm->addRootEntityFromClassMetadata('Doctrine\Tests\Models\CMS\CmsUser', 'u'); $rsm->addRootEntityFromClassMetadata(CmsUser::class, 'u');
$rsm->addJoinedEntityFromClassMetadata('Doctrine\Tests\Models\CMS\CmsAddress', 'a', 'u', 'address'); $rsm->addJoinedEntityFromClassMetadata(CmsAddress::class, 'a', 'u', 'address');
} }
/** /**
@ -349,8 +354,8 @@ class NativeQueryTest extends OrmFunctionalTestCase
public function testUnknownParentAliasThrowsException() public function testUnknownParentAliasThrowsException()
{ {
$rsm = new ResultSetMappingBuilder($this->_em); $rsm = new ResultSetMappingBuilder($this->_em);
$rsm->addRootEntityFromClassMetadata('Doctrine\Tests\Models\CMS\CmsUser', 'u'); $rsm->addRootEntityFromClassMetadata(CmsUser::class, 'u');
$rsm->addJoinedEntityFromClassMetadata('Doctrine\Tests\Models\CMS\CmsAddress', 'a', 'un', 'address', ['id' => 'a_id'] $rsm->addJoinedEntityFromClassMetadata(CmsAddress::class, 'a', 'un', 'address', ['id' => 'a_id']
); );
$query = $this->_em->createNativeQuery('SELECT u.*, a.*, a.id AS a_id FROM cms_users u INNER JOIN cms_addresses a ON u.id = a.user_id WHERE u.username = ?', $rsm); $query = $this->_em->createNativeQuery('SELECT u.*, a.*, a.id AS a_id FROM cms_users u INNER JOIN cms_addresses a ON u.id = a.user_id WHERE u.username = ?', $rsm);
@ -387,12 +392,12 @@ class NativeQueryTest extends OrmFunctionalTestCase
$this->_em->clear(); $this->_em->clear();
$repository = $this->_em->getRepository('Doctrine\Tests\Models\CMS\CmsAddress'); $repository = $this->_em->getRepository(CmsAddress::class);
$query = $repository->createNativeNamedQuery('find-all'); $query = $repository->createNativeNamedQuery('find-all');
$result = $query->getResult(); $result = $query->getResult();
$this->assertCount(1, $result); $this->assertCount(1, $result);
$this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsAddress', $result[0]); $this->assertInstanceOf(CmsAddress::class, $result[0]);
$this->assertEquals($addr->id, $result[0]->id); $this->assertEquals($addr->id, $result[0]->id);
$this->assertEquals($addr->city, $result[0]->city); $this->assertEquals($addr->city, $result[0]->city);
$this->assertEquals($addr->country, $result[0]->country); $this->assertEquals($addr->country, $result[0]->country);
@ -419,14 +424,14 @@ class NativeQueryTest extends OrmFunctionalTestCase
$this->_em->clear(); $this->_em->clear();
$repository = $this->_em->getRepository('Doctrine\Tests\Models\CMS\CmsUser'); $repository = $this->_em->getRepository(CmsUser::class);
$result = $repository->createNativeNamedQuery('fetchIdAndUsernameWithResultClass') $result = $repository->createNativeNamedQuery('fetchIdAndUsernameWithResultClass')
->setParameter(1, 'FabioBatSilva')->getResult(); ->setParameter(1, 'FabioBatSilva')->getResult();
$this->assertEquals(1, count($result)); $this->assertEquals(1, count($result));
$this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsUser', $result[0]); $this->assertInstanceOf(CmsUser::class, $result[0]);
$this->assertNull($result[0]->name); $this->assertNull($result[0]->name);
$this->assertNull($result[0]->email); $this->assertNull($result[0]->email);
$this->assertEquals($user->id, $result[0]->id); $this->assertEquals($user->id, $result[0]->id);
@ -439,12 +444,12 @@ class NativeQueryTest extends OrmFunctionalTestCase
->setParameter(1, 'FabioBatSilva')->getResult(); ->setParameter(1, 'FabioBatSilva')->getResult();
$this->assertEquals(1, count($result)); $this->assertEquals(1, count($result));
$this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsUser', $result[0]); $this->assertInstanceOf(CmsUser::class, $result[0]);
$this->assertEquals($user->id, $result[0]->id); $this->assertEquals($user->id, $result[0]->id);
$this->assertEquals('Fabio B. Silva', $result[0]->name); $this->assertEquals('Fabio B. Silva', $result[0]->name);
$this->assertEquals('FabioBatSilva', $result[0]->username); $this->assertEquals('FabioBatSilva', $result[0]->username);
$this->assertEquals('dev', $result[0]->status); $this->assertEquals('dev', $result[0]->status);
$this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsEmail', $result[0]->email); $this->assertInstanceOf(CmsEmail::class, $result[0]->email);
} }
@ -471,18 +476,18 @@ class NativeQueryTest extends OrmFunctionalTestCase
$this->_em->clear(); $this->_em->clear();
$repository = $this->_em->getRepository('Doctrine\Tests\Models\CMS\CmsUser'); $repository = $this->_em->getRepository(CmsUser::class);
$result = $repository->createNativeNamedQuery('fetchJoinedAddress') $result = $repository->createNativeNamedQuery('fetchJoinedAddress')
->setParameter(1, 'FabioBatSilva')->getResult(); ->setParameter(1, 'FabioBatSilva')->getResult();
$this->assertEquals(1, count($result)); $this->assertEquals(1, count($result));
$this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsUser', $result[0]); $this->assertInstanceOf(CmsUser::class, $result[0]);
$this->assertEquals('Fabio B. Silva', $result[0]->name); $this->assertEquals('Fabio B. Silva', $result[0]->name);
$this->assertInstanceOf('Doctrine\ORM\PersistentCollection', $result[0]->getPhonenumbers()); $this->assertInstanceOf(PersistentCollection::class, $result[0]->getPhonenumbers());
$this->assertFalse($result[0]->getPhonenumbers()->isInitialized()); $this->assertFalse($result[0]->getPhonenumbers()->isInitialized());
$this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsAddress', $result[0]->getAddress()); $this->assertInstanceOf(CmsAddress::class, $result[0]->getAddress());
$this->assertTrue($result[0]->getAddress()->getUser() == $result[0]); $this->assertTrue($result[0]->getAddress()->getUser() == $result[0]);
$this->assertEquals('Brazil', $result[0]->getAddress()->getCountry()); $this->assertEquals('Brazil', $result[0]->getAddress()->getCountry());
$this->assertEquals(10827, $result[0]->getAddress()->getZipCode()); $this->assertEquals(10827, $result[0]->getAddress()->getZipCode());
@ -509,15 +514,15 @@ class NativeQueryTest extends OrmFunctionalTestCase
$this->_em->clear(); $this->_em->clear();
$repository = $this->_em->getRepository('Doctrine\Tests\Models\CMS\CmsUser'); $repository = $this->_em->getRepository(CmsUser::class);
$result = $repository->createNativeNamedQuery('fetchJoinedPhonenumber') $result = $repository->createNativeNamedQuery('fetchJoinedPhonenumber')
->setParameter(1, 'FabioBatSilva')->getResult(); ->setParameter(1, 'FabioBatSilva')->getResult();
$this->assertEquals(1, count($result)); $this->assertEquals(1, count($result));
$this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsUser', $result[0]); $this->assertInstanceOf(CmsUser::class, $result[0]);
$this->assertEquals('Fabio B. Silva', $result[0]->name); $this->assertEquals('Fabio B. Silva', $result[0]->name);
$this->assertInstanceOf('Doctrine\ORM\PersistentCollection', $result[0]->getPhonenumbers()); $this->assertInstanceOf(PersistentCollection::class, $result[0]->getPhonenumbers());
$this->assertTrue($result[0]->getPhonenumbers()->isInitialized()); $this->assertTrue($result[0]->getPhonenumbers()->isInitialized());
$this->assertEquals(1, count($result[0]->getPhonenumbers())); $this->assertEquals(1, count($result[0]->getPhonenumbers()));
$phones = $result[0]->getPhonenumbers(); $phones = $result[0]->getPhonenumbers();
@ -557,7 +562,7 @@ class NativeQueryTest extends OrmFunctionalTestCase
$this->_em->clear(); $this->_em->clear();
$repository = $this->_em->getRepository('Doctrine\Tests\Models\CMS\CmsUser'); $repository = $this->_em->getRepository(CmsUser::class);
$result = $repository->createNativeNamedQuery('fetchUserPhonenumberCount') $result = $repository->createNativeNamedQuery('fetchUserPhonenumberCount')
->setParameter(1, ['test','FabioBatSilva'])->getResult(); ->setParameter(1, ['test','FabioBatSilva'])->getResult();
@ -567,12 +572,12 @@ class NativeQueryTest extends OrmFunctionalTestCase
$this->assertTrue(is_array($result[1])); $this->assertTrue(is_array($result[1]));
// first user => 2 phonenumbers // first user => 2 phonenumbers
$this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsUser', $result[0][0]); $this->assertInstanceOf(CmsUser::class, $result[0][0]);
$this->assertEquals('Fabio B. Silva', $result[0][0]->name); $this->assertEquals('Fabio B. Silva', $result[0][0]->name);
$this->assertEquals(2, $result[0]['numphones']); $this->assertEquals(2, $result[0]['numphones']);
// second user => 1 phonenumbers // second user => 1 phonenumbers
$this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsUser', $result[1][0]); $this->assertInstanceOf(CmsUser::class, $result[1][0]);
$this->assertEquals('test tester', $result[1][0]->name); $this->assertEquals('test tester', $result[1][0]->name);
$this->assertEquals(1, $result[1]['numphones']); $this->assertEquals(1, $result[1]['numphones']);
} }
@ -596,14 +601,14 @@ class NativeQueryTest extends OrmFunctionalTestCase
$this->_em->flush(); $this->_em->flush();
$this->_em->clear(); $this->_em->clear();
$repository = $this->_em->getRepository('Doctrine\Tests\Models\Company\CompanyPerson'); $repository = $this->_em->getRepository(CompanyPerson::class);
$result = $repository->createNativeNamedQuery('fetchAllWithSqlResultSetMapping') $result = $repository->createNativeNamedQuery('fetchAllWithSqlResultSetMapping')
->getResult(); ->getResult();
$this->assertEquals(2, count($result)); $this->assertEquals(2, count($result));
$this->assertInstanceOf('Doctrine\Tests\Models\Company\CompanyPerson', $result[0]); $this->assertInstanceOf(CompanyPerson::class, $result[0]);
$this->assertInstanceOf('Doctrine\Tests\Models\Company\CompanyEmployee', $result[1]); $this->assertInstanceOf(CompanyEmployee::class, $result[1]);
$this->assertTrue(is_numeric($result[0]->getId())); $this->assertTrue(is_numeric($result[0]->getId()));
$this->assertTrue(is_numeric($result[1]->getId())); $this->assertTrue(is_numeric($result[1]->getId()));
$this->assertEquals('Fabio B. Silva', $result[0]->getName()); $this->assertEquals('Fabio B. Silva', $result[0]->getName());
@ -617,8 +622,8 @@ class NativeQueryTest extends OrmFunctionalTestCase
->getResult(); ->getResult();
$this->assertEquals(2, count($result)); $this->assertEquals(2, count($result));
$this->assertInstanceOf('Doctrine\Tests\Models\Company\CompanyPerson', $result[0]); $this->assertInstanceOf(CompanyPerson::class, $result[0]);
$this->assertInstanceOf('Doctrine\Tests\Models\Company\CompanyEmployee', $result[1]); $this->assertInstanceOf(CompanyEmployee::class, $result[1]);
$this->assertTrue(is_numeric($result[0]->getId())); $this->assertTrue(is_numeric($result[0]->getId()));
$this->assertTrue(is_numeric($result[1]->getId())); $this->assertTrue(is_numeric($result[1]->getId()));
$this->assertEquals('Fabio B. Silva', $result[0]->getName()); $this->assertEquals('Fabio B. Silva', $result[0]->getName());
@ -657,7 +662,7 @@ class NativeQueryTest extends OrmFunctionalTestCase
$this->_em->clear(); $this->_em->clear();
$repository = $this->_em->getRepository('Doctrine\Tests\Models\CMS\CmsUser'); $repository = $this->_em->getRepository(CmsUser::class);
$query = $repository->createNativeNamedQuery('fetchMultipleJoinsEntityResults'); $query = $repository->createNativeNamedQuery('fetchMultipleJoinsEntityResults');
$result = $query->getResult(); $result = $query->getResult();
@ -665,9 +670,9 @@ class NativeQueryTest extends OrmFunctionalTestCase
$this->assertEquals(1, count($result)); $this->assertEquals(1, count($result));
$this->assertTrue(is_array($result[0])); $this->assertTrue(is_array($result[0]));
$this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsUser', $result[0][0]); $this->assertInstanceOf(CmsUser::class, $result[0][0]);
$this->assertEquals('Fabio B. Silva', $result[0][0]->name); $this->assertEquals('Fabio B. Silva', $result[0][0]->name);
$this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsAddress', $result[0][0]->getAddress()); $this->assertInstanceOf(CmsAddress::class, $result[0][0]->getAddress());
$this->assertTrue($result[0][0]->getAddress()->getUser() == $result[0][0]); $this->assertTrue($result[0][0]->getAddress()->getUser() == $result[0][0]);
$this->assertEquals('Brazil', $result[0][0]->getAddress()->getCountry()); $this->assertEquals('Brazil', $result[0][0]->getAddress()->getCountry());
$this->assertEquals(10827, $result[0][0]->getAddress()->getZipCode()); $this->assertEquals(10827, $result[0][0]->getAddress()->getZipCode());
@ -681,8 +686,8 @@ class NativeQueryTest extends OrmFunctionalTestCase
*/ */
public function testNamedNativeQueryInheritance() public function testNamedNativeQueryInheritance()
{ {
$contractMetadata = $this->_em->getClassMetadata('Doctrine\Tests\Models\Company\CompanyContract'); $contractMetadata = $this->_em->getClassMetadata(CompanyContract::class);
$flexMetadata = $this->_em->getClassMetadata('Doctrine\Tests\Models\Company\CompanyFlexContract'); $flexMetadata = $this->_em->getClassMetadata(CompanyFlexContract::class);
$contractQueries = $contractMetadata->getNamedNativeQueries(); $contractQueries = $contractMetadata->getNamedNativeQueries();
$flexQueries = $flexMetadata->getNamedNativeQueries(); $flexQueries = $flexMetadata->getNamedNativeQueries();
@ -693,39 +698,39 @@ class NativeQueryTest extends OrmFunctionalTestCase
// contract queries // contract queries
$this->assertEquals('all-contracts', $contractQueries['all-contracts']['name']); $this->assertEquals('all-contracts', $contractQueries['all-contracts']['name']);
$this->assertEquals('Doctrine\Tests\Models\Company\CompanyContract', $contractQueries['all-contracts']['resultClass']); $this->assertEquals(CompanyContract::class, $contractQueries['all-contracts']['resultClass']);
$this->assertEquals('all', $contractQueries['all']['name']); $this->assertEquals('all', $contractQueries['all']['name']);
$this->assertEquals('Doctrine\Tests\Models\Company\CompanyContract', $contractQueries['all']['resultClass']); $this->assertEquals(CompanyContract::class, $contractQueries['all']['resultClass']);
// flex contract queries // flex contract queries
$this->assertEquals('all-contracts', $flexQueries['all-contracts']['name']); $this->assertEquals('all-contracts', $flexQueries['all-contracts']['name']);
$this->assertEquals('Doctrine\Tests\Models\Company\CompanyFlexContract', $flexQueries['all-contracts']['resultClass']); $this->assertEquals(CompanyFlexContract::class, $flexQueries['all-contracts']['resultClass']);
$this->assertEquals('all-flex', $flexQueries['all-flex']['name']); $this->assertEquals('all-flex', $flexQueries['all-flex']['name']);
$this->assertEquals('Doctrine\Tests\Models\Company\CompanyFlexContract', $flexQueries['all-flex']['resultClass']); $this->assertEquals(CompanyFlexContract::class, $flexQueries['all-flex']['resultClass']);
$this->assertEquals('all', $flexQueries['all']['name']); $this->assertEquals('all', $flexQueries['all']['name']);
$this->assertEquals('Doctrine\Tests\Models\Company\CompanyFlexContract', $flexQueries['all']['resultClass']); $this->assertEquals(CompanyFlexContract::class, $flexQueries['all']['resultClass']);
// contract result mapping // contract result mapping
$this->assertEquals('mapping-all-contracts', $contractMappings['mapping-all-contracts']['name']); $this->assertEquals('mapping-all-contracts', $contractMappings['mapping-all-contracts']['name']);
$this->assertEquals('Doctrine\Tests\Models\Company\CompanyContract', $contractMappings['mapping-all-contracts']['entities'][0]['entityClass']); $this->assertEquals(CompanyContract::class, $contractMappings['mapping-all-contracts']['entities'][0]['entityClass']);
$this->assertEquals('mapping-all', $contractMappings['mapping-all']['name']); $this->assertEquals('mapping-all', $contractMappings['mapping-all']['name']);
$this->assertEquals('Doctrine\Tests\Models\Company\CompanyContract', $contractMappings['mapping-all-contracts']['entities'][0]['entityClass']); $this->assertEquals(CompanyContract::class, $contractMappings['mapping-all-contracts']['entities'][0]['entityClass']);
// flex contract result mapping // flex contract result mapping
$this->assertEquals('mapping-all-contracts', $flexMappings['mapping-all-contracts']['name']); $this->assertEquals('mapping-all-contracts', $flexMappings['mapping-all-contracts']['name']);
$this->assertEquals('Doctrine\Tests\Models\Company\CompanyFlexContract', $flexMappings['mapping-all-contracts']['entities'][0]['entityClass']); $this->assertEquals(CompanyFlexContract::class, $flexMappings['mapping-all-contracts']['entities'][0]['entityClass']);
$this->assertEquals('mapping-all', $flexMappings['mapping-all']['name']); $this->assertEquals('mapping-all', $flexMappings['mapping-all']['name']);
$this->assertEquals('Doctrine\Tests\Models\Company\CompanyFlexContract', $flexMappings['mapping-all']['entities'][0]['entityClass']); $this->assertEquals(CompanyFlexContract::class, $flexMappings['mapping-all']['entities'][0]['entityClass']);
$this->assertEquals('mapping-all-flex', $flexMappings['mapping-all-flex']['name']); $this->assertEquals('mapping-all-flex', $flexMappings['mapping-all-flex']['name']);
$this->assertEquals('Doctrine\Tests\Models\Company\CompanyFlexContract', $flexMappings['mapping-all-flex']['entities'][0]['entityClass']); $this->assertEquals(CompanyFlexContract::class, $flexMappings['mapping-all-flex']['entities'][0]['entityClass']);
} }
@ -735,7 +740,7 @@ class NativeQueryTest extends OrmFunctionalTestCase
public function testGenerateSelectClauseNoRenameSingleEntity() public function testGenerateSelectClauseNoRenameSingleEntity()
{ {
$rsm = new ResultSetMappingBuilder($this->_em); $rsm = new ResultSetMappingBuilder($this->_em);
$rsm->addRootEntityFromClassMetadata('Doctrine\Tests\Models\CMS\CmsUser', 'u'); $rsm->addRootEntityFromClassMetadata(CmsUser::class, 'u');
$selectClause = $rsm->generateSelectClause(); $selectClause = $rsm->generateSelectClause();
@ -748,7 +753,7 @@ class NativeQueryTest extends OrmFunctionalTestCase
public function testGenerateSelectClauseCustomRenames() public function testGenerateSelectClauseCustomRenames()
{ {
$rsm = new ResultSetMappingBuilder($this->_em); $rsm = new ResultSetMappingBuilder($this->_em);
$rsm->addRootEntityFromClassMetadata('Doctrine\Tests\Models\CMS\CmsUser', 'u', [ $rsm->addRootEntityFromClassMetadata(CmsUser::class, 'u', [
'id' => 'id1', 'id' => 'id1',
'username' => 'username2' 'username' => 'username2'
] ]
@ -765,7 +770,7 @@ class NativeQueryTest extends OrmFunctionalTestCase
public function testGenerateSelectClauseRenameTableAlias() public function testGenerateSelectClauseRenameTableAlias()
{ {
$rsm = new ResultSetMappingBuilder($this->_em); $rsm = new ResultSetMappingBuilder($this->_em);
$rsm->addRootEntityFromClassMetadata('Doctrine\Tests\Models\CMS\CmsUser', 'u'); $rsm->addRootEntityFromClassMetadata(CmsUser::class, 'u');
$selectClause = $rsm->generateSelectClause(['u' => 'u1']); $selectClause = $rsm->generateSelectClause(['u' => 'u1']);
@ -778,7 +783,7 @@ class NativeQueryTest extends OrmFunctionalTestCase
public function testGenerateSelectClauseIncrement() public function testGenerateSelectClauseIncrement()
{ {
$rsm = new ResultSetMappingBuilder($this->_em, ResultSetMappingBuilder::COLUMN_RENAMING_INCREMENT); $rsm = new ResultSetMappingBuilder($this->_em, ResultSetMappingBuilder::COLUMN_RENAMING_INCREMENT);
$rsm->addRootEntityFromClassMetadata('Doctrine\Tests\Models\CMS\CmsUser', 'u'); $rsm->addRootEntityFromClassMetadata(CmsUser::class, 'u');
$selectClause = $rsm->generateSelectClause(); $selectClause = $rsm->generateSelectClause();
@ -791,7 +796,7 @@ class NativeQueryTest extends OrmFunctionalTestCase
public function testGenerateSelectClauseToString() public function testGenerateSelectClauseToString()
{ {
$rsm = new ResultSetMappingBuilder($this->_em, ResultSetMappingBuilder::COLUMN_RENAMING_INCREMENT); $rsm = new ResultSetMappingBuilder($this->_em, ResultSetMappingBuilder::COLUMN_RENAMING_INCREMENT);
$rsm->addRootEntityFromClassMetadata('Doctrine\Tests\Models\CMS\CmsUser', 'u'); $rsm->addRootEntityFromClassMetadata(CmsUser::class, 'u');
$this->assertSQLEquals('u.id AS id0, u.status AS status1, u.username AS username2, u.name AS name3, u.email_id AS email_id4', (string)$rsm); $this->assertSQLEquals('u.id AS id0, u.status AS status1, u.username AS username2, u.name AS name3, u.email_id AS email_id4', (string)$rsm);
} }
@ -802,8 +807,8 @@ class NativeQueryTest extends OrmFunctionalTestCase
public function testGenerateSelectClauseWithDiscriminatorColumn() public function testGenerateSelectClauseWithDiscriminatorColumn()
{ {
$rsm = new ResultSetMappingBuilder($this->_em, ResultSetMappingBuilder::COLUMN_RENAMING_INCREMENT); $rsm = new ResultSetMappingBuilder($this->_em, ResultSetMappingBuilder::COLUMN_RENAMING_INCREMENT);
$rsm->addEntityResult('Doctrine\Tests\Models\DDC3899\DDC3899User', 'u'); $rsm->addEntityResult(DDC3899User::class, 'u');
$rsm->addJoinedEntityResult('Doctrine\Tests\Models\DDC3899\DDC3899FixContract', 'c', 'u', 'contracts'); $rsm->addJoinedEntityResult(DDC3899FixContract::class, 'c', 'u', 'contracts');
$rsm->addFieldResult('u', $this->platform->getSQLResultCasing('id'), 'id'); $rsm->addFieldResult('u', $this->platform->getSQLResultCasing('id'), 'id');
$rsm->setDiscriminatorColumn('c', $this->platform->getSQLResultCasing('discr')); $rsm->setDiscriminatorColumn('c', $this->platform->getSQLResultCasing('discr'));

View File

@ -3,10 +3,12 @@
namespace Doctrine\Tests\ORM\Functional; namespace Doctrine\Tests\ORM\Functional;
use Doctrine\ORM\Query; use Doctrine\ORM\Query;
use Doctrine\Tests\Models\CMS\CmsAddressDTO;
use Doctrine\Tests\Models\CMS\CmsUser; use Doctrine\Tests\Models\CMS\CmsUser;
use Doctrine\Tests\Models\CMS\CmsEmail; use Doctrine\Tests\Models\CMS\CmsEmail;
use Doctrine\Tests\Models\CMS\CmsAddress; use Doctrine\Tests\Models\CMS\CmsAddress;
use Doctrine\Tests\Models\CMS\CmsPhonenumber; use Doctrine\Tests\Models\CMS\CmsPhonenumber;
use Doctrine\Tests\Models\CMS\CmsUserDTO;
use Doctrine\Tests\OrmFunctionalTestCase; use Doctrine\Tests\OrmFunctionalTestCase;
/** /**
@ -122,9 +124,9 @@ class NewOperatorTest extends OrmFunctionalTestCase
$this->assertCount(3, $result); $this->assertCount(3, $result);
$this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsUserDTO', $result[0]); $this->assertInstanceOf(CmsUserDTO::class, $result[0]);
$this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsUserDTO', $result[1]); $this->assertInstanceOf(CmsUserDTO::class, $result[1]);
$this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsUserDTO', $result[2]); $this->assertInstanceOf(CmsUserDTO::class, $result[2]);
$this->assertEquals($this->fixtures[0]->name, $result[0]->name); $this->assertEquals($this->fixtures[0]->name, $result[0]->name);
$this->assertEquals($this->fixtures[1]->name, $result[1]->name); $this->assertEquals($this->fixtures[1]->name, $result[1]->name);
@ -165,9 +167,9 @@ class NewOperatorTest extends OrmFunctionalTestCase
$this->assertCount(3, $result); $this->assertCount(3, $result);
$this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsUserDTO', $result[0]); $this->assertInstanceOf(CmsUserDTO::class, $result[0]);
$this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsUserDTO', $result[1]); $this->assertInstanceOf(CmsUserDTO::class, $result[1]);
$this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsUserDTO', $result[2]); $this->assertInstanceOf(CmsUserDTO::class, $result[2]);
$this->assertEquals($this->fixtures[0]->name, $result[0]->name); $this->assertEquals($this->fixtures[0]->name, $result[0]->name);
$this->assertEquals($this->fixtures[1]->name, $result[1]->name); $this->assertEquals($this->fixtures[1]->name, $result[1]->name);
@ -201,9 +203,9 @@ class NewOperatorTest extends OrmFunctionalTestCase
$this->assertCount(3, $result); $this->assertCount(3, $result);
$this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsUserDTO', $result[0]); $this->assertInstanceOf(CmsUserDTO::class, $result[0]);
$this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsUserDTO', $result[1]); $this->assertInstanceOf(CmsUserDTO::class, $result[1]);
$this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsUserDTO', $result[2]); $this->assertInstanceOf(CmsUserDTO::class, $result[2]);
} }
public function testShouldSupportFromEntityNamespaceAlias() public function testShouldSupportFromEntityNamespaceAlias()
@ -229,9 +231,9 @@ class NewOperatorTest extends OrmFunctionalTestCase
$this->assertCount(3, $result); $this->assertCount(3, $result);
$this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsUserDTO', $result[0]); $this->assertInstanceOf(CmsUserDTO::class, $result[0]);
$this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsUserDTO', $result[1]); $this->assertInstanceOf(CmsUserDTO::class, $result[1]);
$this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsUserDTO', $result[2]); $this->assertInstanceOf(CmsUserDTO::class, $result[2]);
} }
public function testShouldSupportValueObjectNamespaceAlias() public function testShouldSupportValueObjectNamespaceAlias()
@ -257,9 +259,9 @@ class NewOperatorTest extends OrmFunctionalTestCase
$this->assertCount(3, $result); $this->assertCount(3, $result);
$this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsUserDTO', $result[0]); $this->assertInstanceOf(CmsUserDTO::class, $result[0]);
$this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsUserDTO', $result[1]); $this->assertInstanceOf(CmsUserDTO::class, $result[1]);
$this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsUserDTO', $result[2]); $this->assertInstanceOf(CmsUserDTO::class, $result[2]);
} }
public function testShouldSupportLiteralExpression() public function testShouldSupportLiteralExpression()
@ -290,9 +292,9 @@ class NewOperatorTest extends OrmFunctionalTestCase
$this->assertCount(3, $result); $this->assertCount(3, $result);
$this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsUserDTO', $result[0]); $this->assertInstanceOf(CmsUserDTO::class, $result[0]);
$this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsUserDTO', $result[1]); $this->assertInstanceOf(CmsUserDTO::class, $result[1]);
$this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsUserDTO', $result[2]); $this->assertInstanceOf(CmsUserDTO::class, $result[2]);
$this->assertEquals($this->fixtures[0]->name, $result[0]->name); $this->assertEquals($this->fixtures[0]->name, $result[0]->name);
@ -338,9 +340,9 @@ class NewOperatorTest extends OrmFunctionalTestCase
$this->assertCount(3, $result); $this->assertCount(3, $result);
$this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsUserDTO', $result[0]); $this->assertInstanceOf(CmsUserDTO::class, $result[0]);
$this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsUserDTO', $result[1]); $this->assertInstanceOf(CmsUserDTO::class, $result[1]);
$this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsUserDTO', $result[2]); $this->assertInstanceOf(CmsUserDTO::class, $result[2]);
$this->assertEquals($this->fixtures[0]->name, $result[0]->name); $this->assertEquals($this->fixtures[0]->name, $result[0]->name);
@ -380,9 +382,9 @@ class NewOperatorTest extends OrmFunctionalTestCase
$this->assertCount(3, $result); $this->assertCount(3, $result);
$this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsUserDTO', $result[0]); $this->assertInstanceOf(CmsUserDTO::class, $result[0]);
$this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsUserDTO', $result[1]); $this->assertInstanceOf(CmsUserDTO::class, $result[1]);
$this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsUserDTO', $result[2]); $this->assertInstanceOf(CmsUserDTO::class, $result[2]);
$this->assertEquals($this->fixtures[0]->name, $result[0]->name); $this->assertEquals($this->fixtures[0]->name, $result[0]->name);
$this->assertEquals($this->fixtures[1]->name, $result[1]->name); $this->assertEquals($this->fixtures[1]->name, $result[1]->name);
@ -440,9 +442,9 @@ class NewOperatorTest extends OrmFunctionalTestCase
$this->assertCount(3, $result); $this->assertCount(3, $result);
$this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsUserDTO', $result[0]); $this->assertInstanceOf(CmsUserDTO::class, $result[0]);
$this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsUserDTO', $result[1]); $this->assertInstanceOf(CmsUserDTO::class, $result[1]);
$this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsUserDTO', $result[2]); $this->assertInstanceOf(CmsUserDTO::class, $result[2]);
$this->assertEquals($this->fixtures[0]->name, $result[0]->name); $this->assertEquals($this->fixtures[0]->name, $result[0]->name);
$this->assertEquals($this->fixtures[1]->name, $result[1]->name); $this->assertEquals($this->fixtures[1]->name, $result[1]->name);
@ -500,9 +502,9 @@ class NewOperatorTest extends OrmFunctionalTestCase
$this->assertCount(3, $result); $this->assertCount(3, $result);
$this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsUserDTO', $result[0]); $this->assertInstanceOf(CmsUserDTO::class, $result[0]);
$this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsUserDTO', $result[1]); $this->assertInstanceOf(CmsUserDTO::class, $result[1]);
$this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsUserDTO', $result[2]); $this->assertInstanceOf(CmsUserDTO::class, $result[2]);
$this->assertEquals($this->fixtures[0]->name, $result[0]->name); $this->assertEquals($this->fixtures[0]->name, $result[0]->name);
$this->assertEquals($this->fixtures[1]->name, $result[1]->name); $this->assertEquals($this->fixtures[1]->name, $result[1]->name);
@ -558,13 +560,13 @@ class NewOperatorTest extends OrmFunctionalTestCase
$this->assertCount(3, $result); $this->assertCount(3, $result);
$this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsUserDTO', $result[0][0]); $this->assertInstanceOf(CmsUserDTO::class, $result[0][0]);
$this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsUserDTO', $result[1][0]); $this->assertInstanceOf(CmsUserDTO::class, $result[1][0]);
$this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsUserDTO', $result[2][0]); $this->assertInstanceOf(CmsUserDTO::class, $result[2][0]);
$this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsAddressDTO', $result[0][1]); $this->assertInstanceOf(CmsAddressDTO::class, $result[0][1]);
$this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsAddressDTO', $result[1][1]); $this->assertInstanceOf(CmsAddressDTO::class, $result[1][1]);
$this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsAddressDTO', $result[2][1]); $this->assertInstanceOf(CmsAddressDTO::class, $result[2][1]);
$this->assertEquals($this->fixtures[0]->name, $result[0][0]->name); $this->assertEquals($this->fixtures[0]->name, $result[0][0]->name);
$this->assertEquals($this->fixtures[1]->name, $result[1][0]->name); $this->assertEquals($this->fixtures[1]->name, $result[1][0]->name);
@ -610,13 +612,13 @@ class NewOperatorTest extends OrmFunctionalTestCase
$this->assertCount(3, $result); $this->assertCount(3, $result);
$this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsUserDTO', $result[0]['cmsUser']); $this->assertInstanceOf(CmsUserDTO::class, $result[0]['cmsUser']);
$this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsUserDTO', $result[1]['cmsUser']); $this->assertInstanceOf(CmsUserDTO::class, $result[1]['cmsUser']);
$this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsUserDTO', $result[2]['cmsUser']); $this->assertInstanceOf(CmsUserDTO::class, $result[2]['cmsUser']);
$this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsAddressDTO', $result[0]['cmsAddress']); $this->assertInstanceOf(CmsAddressDTO::class, $result[0]['cmsAddress']);
$this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsAddressDTO', $result[1]['cmsAddress']); $this->assertInstanceOf(CmsAddressDTO::class, $result[1]['cmsAddress']);
$this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsAddressDTO', $result[2]['cmsAddress']); $this->assertInstanceOf(CmsAddressDTO::class, $result[2]['cmsAddress']);
$this->assertEquals($this->fixtures[0]->name, $result[0]['cmsUser']->name); $this->assertEquals($this->fixtures[0]->name, $result[0]['cmsUser']->name);
$this->assertEquals($this->fixtures[1]->name, $result[1]['cmsUser']->name); $this->assertEquals($this->fixtures[1]->name, $result[1]['cmsUser']->name);
@ -662,13 +664,13 @@ class NewOperatorTest extends OrmFunctionalTestCase
$this->assertCount(3, $result); $this->assertCount(3, $result);
$this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsUserDTO', $result[0]['cmsUser']); $this->assertInstanceOf(CmsUserDTO::class, $result[0]['cmsUser']);
$this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsUserDTO', $result[1]['cmsUser']); $this->assertInstanceOf(CmsUserDTO::class, $result[1]['cmsUser']);
$this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsUserDTO', $result[2]['cmsUser']); $this->assertInstanceOf(CmsUserDTO::class, $result[2]['cmsUser']);
$this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsAddressDTO', $result[0][0]); $this->assertInstanceOf(CmsAddressDTO::class, $result[0][0]);
$this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsAddressDTO', $result[1][0]); $this->assertInstanceOf(CmsAddressDTO::class, $result[1][0]);
$this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsAddressDTO', $result[2][0]); $this->assertInstanceOf(CmsAddressDTO::class, $result[2][0]);
$this->assertEquals($this->fixtures[0]->name, $result[0]['cmsUser']->name); $this->assertEquals($this->fixtures[0]->name, $result[0]['cmsUser']->name);
$this->assertEquals($this->fixtures[1]->name, $result[1]['cmsUser']->name); $this->assertEquals($this->fixtures[1]->name, $result[1]['cmsUser']->name);
@ -715,13 +717,13 @@ class NewOperatorTest extends OrmFunctionalTestCase
$this->assertCount(3, $result); $this->assertCount(3, $result);
$this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsUserDTO', $result[0][0]); $this->assertInstanceOf(CmsUserDTO::class, $result[0][0]);
$this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsUserDTO', $result[1][0]); $this->assertInstanceOf(CmsUserDTO::class, $result[1][0]);
$this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsUserDTO', $result[2][0]); $this->assertInstanceOf(CmsUserDTO::class, $result[2][0]);
$this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsAddressDTO', $result[0][1]); $this->assertInstanceOf(CmsAddressDTO::class, $result[0][1]);
$this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsAddressDTO', $result[1][1]); $this->assertInstanceOf(CmsAddressDTO::class, $result[1][1]);
$this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsAddressDTO', $result[2][1]); $this->assertInstanceOf(CmsAddressDTO::class, $result[2][1]);
$this->assertEquals($this->fixtures[0]->name, $result[0][0]->name); $this->assertEquals($this->fixtures[0]->name, $result[0][0]->name);
$this->assertEquals($this->fixtures[1]->name, $result[1][0]->name); $this->assertEquals($this->fixtures[1]->name, $result[1][0]->name);
@ -772,13 +774,13 @@ class NewOperatorTest extends OrmFunctionalTestCase
$this->assertCount(3, $result); $this->assertCount(3, $result);
$this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsUserDTO', $result[0]['cmsUser']); $this->assertInstanceOf(CmsUserDTO::class, $result[0]['cmsUser']);
$this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsUserDTO', $result[1]['cmsUser']); $this->assertInstanceOf(CmsUserDTO::class, $result[1]['cmsUser']);
$this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsUserDTO', $result[2]['cmsUser']); $this->assertInstanceOf(CmsUserDTO::class, $result[2]['cmsUser']);
$this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsAddressDTO', $result[0]['cmsAddress']); $this->assertInstanceOf(CmsAddressDTO::class, $result[0]['cmsAddress']);
$this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsAddressDTO', $result[1]['cmsAddress']); $this->assertInstanceOf(CmsAddressDTO::class, $result[1]['cmsAddress']);
$this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsAddressDTO', $result[2]['cmsAddress']); $this->assertInstanceOf(CmsAddressDTO::class, $result[2]['cmsAddress']);
$this->assertEquals($this->fixtures[0]->name, $result[0]['cmsUser']->name); $this->assertEquals($this->fixtures[0]->name, $result[0]['cmsUser']->name);
$this->assertEquals($this->fixtures[1]->name, $result[1]['cmsUser']->name); $this->assertEquals($this->fixtures[1]->name, $result[1]['cmsUser']->name);
@ -829,13 +831,13 @@ class NewOperatorTest extends OrmFunctionalTestCase
$this->assertCount(3, $result); $this->assertCount(3, $result);
$this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsUserDTO', $result[0]['cmsUser']); $this->assertInstanceOf(CmsUserDTO::class, $result[0]['cmsUser']);
$this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsUserDTO', $result[1]['cmsUser']); $this->assertInstanceOf(CmsUserDTO::class, $result[1]['cmsUser']);
$this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsUserDTO', $result[2]['cmsUser']); $this->assertInstanceOf(CmsUserDTO::class, $result[2]['cmsUser']);
$this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsAddressDTO', $result[0][0]); $this->assertInstanceOf(CmsAddressDTO::class, $result[0][0]);
$this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsAddressDTO', $result[1][0]); $this->assertInstanceOf(CmsAddressDTO::class, $result[1][0]);
$this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsAddressDTO', $result[2][0]); $this->assertInstanceOf(CmsAddressDTO::class, $result[2][0]);
$this->assertEquals($this->fixtures[0]->name, $result[0]['cmsUser']->name); $this->assertEquals($this->fixtures[0]->name, $result[0]['cmsUser']->name);
$this->assertEquals($this->fixtures[1]->name, $result[1]['cmsUser']->name); $this->assertEquals($this->fixtures[1]->name, $result[1]['cmsUser']->name);
@ -887,13 +889,13 @@ class NewOperatorTest extends OrmFunctionalTestCase
$this->assertCount(3, $result); $this->assertCount(3, $result);
$this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsUserDTO', $result[0][0]); $this->assertInstanceOf(CmsUserDTO::class, $result[0][0]);
$this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsUserDTO', $result[1][0]); $this->assertInstanceOf(CmsUserDTO::class, $result[1][0]);
$this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsUserDTO', $result[2][0]); $this->assertInstanceOf(CmsUserDTO::class, $result[2][0]);
$this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsAddressDTO', $result[0][1]); $this->assertInstanceOf(CmsAddressDTO::class, $result[0][1]);
$this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsAddressDTO', $result[1][1]); $this->assertInstanceOf(CmsAddressDTO::class, $result[1][1]);
$this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsAddressDTO', $result[2][1]); $this->assertInstanceOf(CmsAddressDTO::class, $result[2][1]);
$this->assertEquals($this->fixtures[0]->name, $result[0][0]->name); $this->assertEquals($this->fixtures[0]->name, $result[0][0]->name);
$this->assertEquals($this->fixtures[1]->name, $result[1][0]->name); $this->assertEquals($this->fixtures[1]->name, $result[1][0]->name);
@ -949,13 +951,13 @@ class NewOperatorTest extends OrmFunctionalTestCase
$this->assertCount(3, $result); $this->assertCount(3, $result);
$this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsUserDTO', $result[0]['cmsUser']); $this->assertInstanceOf(CmsUserDTO::class, $result[0]['cmsUser']);
$this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsUserDTO', $result[1]['cmsUser']); $this->assertInstanceOf(CmsUserDTO::class, $result[1]['cmsUser']);
$this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsUserDTO', $result[2]['cmsUser']); $this->assertInstanceOf(CmsUserDTO::class, $result[2]['cmsUser']);
$this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsAddressDTO', $result[0]['cmsAddress']); $this->assertInstanceOf(CmsAddressDTO::class, $result[0]['cmsAddress']);
$this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsAddressDTO', $result[1]['cmsAddress']); $this->assertInstanceOf(CmsAddressDTO::class, $result[1]['cmsAddress']);
$this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsAddressDTO', $result[2]['cmsAddress']); $this->assertInstanceOf(CmsAddressDTO::class, $result[2]['cmsAddress']);
$this->assertEquals($this->fixtures[0]->name, $result[0]['cmsUser']->name); $this->assertEquals($this->fixtures[0]->name, $result[0]['cmsUser']->name);
$this->assertEquals($this->fixtures[1]->name, $result[1]['cmsUser']->name); $this->assertEquals($this->fixtures[1]->name, $result[1]['cmsUser']->name);
@ -1011,13 +1013,13 @@ class NewOperatorTest extends OrmFunctionalTestCase
$this->assertCount(3, $result); $this->assertCount(3, $result);
$this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsUserDTO', $result[0]['cmsUser']); $this->assertInstanceOf(CmsUserDTO::class, $result[0]['cmsUser']);
$this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsUserDTO', $result[1]['cmsUser']); $this->assertInstanceOf(CmsUserDTO::class, $result[1]['cmsUser']);
$this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsUserDTO', $result[2]['cmsUser']); $this->assertInstanceOf(CmsUserDTO::class, $result[2]['cmsUser']);
$this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsAddressDTO', $result[0][0]); $this->assertInstanceOf(CmsAddressDTO::class, $result[0][0]);
$this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsAddressDTO', $result[1][0]); $this->assertInstanceOf(CmsAddressDTO::class, $result[1][0]);
$this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsAddressDTO', $result[2][0]); $this->assertInstanceOf(CmsAddressDTO::class, $result[2][0]);
$this->assertEquals($this->fixtures[0]->name, $result[0]['cmsUser']->name); $this->assertEquals($this->fixtures[0]->name, $result[0]['cmsUser']->name);
$this->assertEquals($this->fixtures[1]->name, $result[1]['cmsUser']->name); $this->assertEquals($this->fixtures[1]->name, $result[1]['cmsUser']->name);

View File

@ -20,8 +20,8 @@ class NotifyPolicyTest extends OrmFunctionalTestCase
try { try {
$this->_schemaTool->createSchema( $this->_schemaTool->createSchema(
[ [
$this->_em->getClassMetadata('Doctrine\Tests\ORM\Functional\NotifyUser'), $this->_em->getClassMetadata(NotifyUser::class),
$this->_em->getClassMetadata('Doctrine\Tests\ORM\Functional\NotifyGroup') $this->_em->getClassMetadata(NotifyGroup::class)
] ]
); );
} catch (\Exception $e) { } catch (\Exception $e) {
@ -57,9 +57,9 @@ class NotifyPolicyTest extends OrmFunctionalTestCase
$groupId = $group->getId(); $groupId = $group->getId();
unset($user, $group); unset($user, $group);
$user = $this->_em->find(__NAMESPACE__.'\NotifyUser', $userId); $user = $this->_em->find(NotifyUser::class, $userId);
$this->assertEquals(1, $user->getGroups()->count()); $this->assertEquals(1, $user->getGroups()->count());
$group = $this->_em->find(__NAMESPACE__.'\NotifyGroup', $groupId); $group = $this->_em->find(NotifyGroup::class, $groupId);
$this->assertEquals(1, $group->getUsers()->count()); $this->assertEquals(1, $group->getUsers()->count());
$this->assertEquals(1, count($user->listeners)); $this->assertEquals(1, count($user->listeners));
@ -82,11 +82,11 @@ class NotifyPolicyTest extends OrmFunctionalTestCase
$group2Id = $group2->getId(); $group2Id = $group2->getId();
unset($group2, $user); unset($group2, $user);
$user = $this->_em->find(__NAMESPACE__.'\NotifyUser', $userId); $user = $this->_em->find(NotifyUser::class, $userId);
$this->assertEquals(2, $user->getGroups()->count()); $this->assertEquals(2, $user->getGroups()->count());
$group2 = $this->_em->find(__NAMESPACE__.'\NotifyGroup', $group2Id); $group2 = $this->_em->find(NotifyGroup::class, $group2Id);
$this->assertEquals(1, $group2->getUsers()->count()); $this->assertEquals(1, $group2->getUsers()->count());
$group = $this->_em->find(__NAMESPACE__.'\NotifyGroup', $groupId); $group = $this->_em->find(NotifyGroup::class, $groupId);
$this->assertEquals(1, $group->getUsers()->count()); $this->assertEquals(1, $group->getUsers()->count());
$this->assertEquals('geeks', $group->getName()); $this->assertEquals('geeks', $group->getName());
} }

View File

@ -2,9 +2,11 @@
namespace Doctrine\Tests\ORM\Functional; namespace Doctrine\Tests\ORM\Functional;
use Doctrine\Tests\Models\ECommerce\ECommerceProduct; use Doctrine\Common\Collections\Collection;
use Doctrine\Tests\Models\ECommerce\ECommerceFeature;
use Doctrine\Common\Collections\Criteria; use Doctrine\Common\Collections\Criteria;
use Doctrine\ORM\Proxy\Proxy;
use Doctrine\Tests\Models\ECommerce\ECommerceFeature;
use Doctrine\Tests\Models\ECommerce\ECommerceProduct;
use Doctrine\Tests\OrmFunctionalTestCase; use Doctrine\Tests\OrmFunctionalTestCase;
/** /**
@ -76,13 +78,13 @@ class OneToManyBidirectionalAssociationTest extends OrmFunctionalTestCase
$features = $product->getFeatures(); $features = $product->getFeatures();
$this->assertInstanceOf('Doctrine\Tests\Models\ECommerce\ECommerceFeature', $features[0]); $this->assertInstanceOf(ECommerceFeature::class, $features[0]);
$this->assertNotInstanceOf('Doctrine\ORM\Proxy\Proxy', $features[0]->getProduct()); $this->assertNotInstanceOf(Proxy::class, $features[0]->getProduct());
$this->assertSame($product, $features[0]->getProduct()); $this->assertSame($product, $features[0]->getProduct());
$this->assertEquals('Model writing tutorial', $features[0]->getDescription()); $this->assertEquals('Model writing tutorial', $features[0]->getDescription());
$this->assertInstanceOf('Doctrine\Tests\Models\ECommerce\ECommerceFeature', $features[1]); $this->assertInstanceOf(ECommerceFeature::class, $features[1]);
$this->assertSame($product, $features[1]->getProduct()); $this->assertSame($product, $features[1]->getProduct());
$this->assertNotInstanceOf('Doctrine\ORM\Proxy\Proxy', $features[1]->getProduct()); $this->assertNotInstanceOf(Proxy::class, $features[1]->getProduct());
$this->assertEquals('Annotations examples', $features[1]->getDescription()); $this->assertEquals('Annotations examples', $features[1]->getDescription());
} }
@ -96,11 +98,11 @@ class OneToManyBidirectionalAssociationTest extends OrmFunctionalTestCase
$features = $product->getFeatures(); $features = $product->getFeatures();
$this->assertFalse($features->isInitialized()); $this->assertFalse($features->isInitialized());
$this->assertInstanceOf('Doctrine\Tests\Models\ECommerce\ECommerceFeature', $features[0]); $this->assertInstanceOf(ECommerceFeature::class, $features[0]);
$this->assertTrue($features->isInitialized()); $this->assertTrue($features->isInitialized());
$this->assertSame($product, $features[0]->getProduct()); $this->assertSame($product, $features[0]->getProduct());
$this->assertEquals('Model writing tutorial', $features[0]->getDescription()); $this->assertEquals('Model writing tutorial', $features[0]->getDescription());
$this->assertInstanceOf('Doctrine\Tests\Models\ECommerce\ECommerceFeature', $features[1]); $this->assertInstanceOf(ECommerceFeature::class, $features[1]);
$this->assertSame($product, $features[1]->getProduct()); $this->assertSame($product, $features[1]->getProduct());
$this->assertEquals('Annotations examples', $features[1]->getDescription()); $this->assertEquals('Annotations examples', $features[1]->getDescription());
} }
@ -113,8 +115,8 @@ class OneToManyBidirectionalAssociationTest extends OrmFunctionalTestCase
$features = $query->getResult(); $features = $query->getResult();
$product = $features[0]->getProduct(); $product = $features[0]->getProduct();
$this->assertInstanceOf('Doctrine\ORM\Proxy\Proxy', $product); $this->assertInstanceOf(Proxy::class, $product);
$this->assertInstanceOf('Doctrine\Tests\Models\ECommerce\ECommerceProduct', $product); $this->assertInstanceOf(ECommerceProduct::class, $product);
$this->assertFalse($product->__isInitialized__); $this->assertFalse($product->__isInitialized__);
$this->assertSame('Doctrine Cookbook', $product->getName()); $this->assertSame('Doctrine Cookbook', $product->getName());
$this->assertTrue($product->__isInitialized__); $this->assertTrue($product->__isInitialized__);
@ -129,8 +131,8 @@ class OneToManyBidirectionalAssociationTest extends OrmFunctionalTestCase
$features = $query->getResult(); $features = $query->getResult();
$product = $features[0]->getProduct(); $product = $features[0]->getProduct();
$this->assertNotInstanceOf('Doctrine\ORM\Proxy\Proxy', $product); $this->assertNotInstanceOf(Proxy::class, $product);
$this->assertInstanceOf('Doctrine\Tests\Models\ECommerce\ECommerceProduct', $product); $this->assertInstanceOf(ECommerceProduct::class, $product);
$this->assertSame('Doctrine Cookbook', $product->getName()); $this->assertSame('Doctrine Cookbook', $product->getName());
$this->assertFalse($product->getFeatures()->isInitialized()); $this->assertFalse($product->getFeatures()->isInitialized());
@ -157,19 +159,19 @@ class OneToManyBidirectionalAssociationTest extends OrmFunctionalTestCase
{ {
$this->_createFixture(); $this->_createFixture();
$product = $this->_em->find('Doctrine\Tests\Models\ECommerce\ECommerceProduct', $this->product->getId()); $product = $this->_em->find(ECommerceProduct::class, $this->product->getId());
$features = $product->getFeatures(); $features = $product->getFeatures();
$results = $features->matching(new Criteria( $results = $features->matching(new Criteria(
Criteria::expr()->eq('description', 'Model writing tutorial') Criteria::expr()->eq('description', 'Model writing tutorial')
)); ));
$this->assertInstanceOf('Doctrine\Common\Collections\Collection', $results); $this->assertInstanceOf(Collection::class, $results);
$this->assertEquals(1, count($results)); $this->assertEquals(1, count($results));
$results = $features->matching(new Criteria()); $results = $features->matching(new Criteria());
$this->assertInstanceOf('Doctrine\Common\Collections\Collection', $results); $this->assertInstanceOf(Collection::class, $results);
$this->assertEquals(2, count($results)); $this->assertEquals(2, count($results));
} }
@ -180,7 +182,7 @@ class OneToManyBidirectionalAssociationTest extends OrmFunctionalTestCase
{ {
$this->_createFixture(); $this->_createFixture();
$product = $this->_em->find('Doctrine\Tests\Models\ECommerce\ECommerceProduct', $this->product->getId()); $product = $this->_em->find(ECommerceProduct::class, $this->product->getId());
$thirdFeature = new ECommerceFeature(); $thirdFeature = new ECommerceFeature();
$thirdFeature->setDescription('Model writing tutorial'); $thirdFeature->setDescription('Model writing tutorial');
@ -199,7 +201,7 @@ class OneToManyBidirectionalAssociationTest extends OrmFunctionalTestCase
{ {
$this->_createFixture(); $this->_createFixture();
$product = $this->_em->find('Doctrine\Tests\Models\ECommerce\ECommerceProduct', $this->product->getId()); $product = $this->_em->find(ECommerceProduct::class, $this->product->getId());
$features = $product->getFeatures(); $features = $product->getFeatures();
$thirdFeature = new ECommerceFeature(); $thirdFeature = new ECommerceFeature();
@ -210,12 +212,12 @@ class OneToManyBidirectionalAssociationTest extends OrmFunctionalTestCase
Criteria::expr()->eq('description', 'Third feature') Criteria::expr()->eq('description', 'Third feature')
)); ));
$this->assertInstanceOf('Doctrine\Common\Collections\Collection', $results); $this->assertInstanceOf(Collection::class, $results);
$this->assertCount(1, $results); $this->assertCount(1, $results);
$results = $features->matching(new Criteria()); $results = $features->matching(new Criteria());
$this->assertInstanceOf('Doctrine\Common\Collections\Collection', $results); $this->assertInstanceOf(Collection::class, $results);
$this->assertCount(3, $results); $this->assertCount(3, $results);
} }

View File

@ -2,8 +2,8 @@
namespace Doctrine\Tests\ORM\Functional; namespace Doctrine\Tests\ORM\Functional;
use Doctrine\Tests\Models\CMS\CmsUser, use Doctrine\Tests\Models\CMS\CmsPhonenumber;
Doctrine\Tests\Models\CMS\CmsPhonenumber; use Doctrine\Tests\Models\CMS\CmsUser;
use Doctrine\Tests\OrmFunctionalTestCase; use Doctrine\Tests\OrmFunctionalTestCase;
/** /**
@ -42,7 +42,7 @@ class OneToManyOrphanRemovalTest extends OrmFunctionalTestCase
public function testOrphanRemoval() public function testOrphanRemoval()
{ {
$userProxy = $this->_em->getReference('Doctrine\Tests\Models\CMS\CmsUser', $this->userId); $userProxy = $this->_em->getReference(CmsUser::class, $this->userId);
$this->_em->remove($userProxy); $this->_em->remove($userProxy);
$this->_em->flush(); $this->_em->flush();
@ -64,7 +64,7 @@ class OneToManyOrphanRemovalTest extends OrmFunctionalTestCase
*/ */
public function testOrphanRemovalRemoveFromCollection() public function testOrphanRemovalRemoveFromCollection()
{ {
$user = $this->_em->find('Doctrine\Tests\Models\CMS\CmsUser', $this->userId); $user = $this->_em->find(CmsUser::class, $this->userId);
$phonenumber = $user->getPhonenumbers()->remove(0); $phonenumber = $user->getPhonenumbers()->remove(0);
@ -82,7 +82,7 @@ class OneToManyOrphanRemovalTest extends OrmFunctionalTestCase
*/ */
public function testOrphanRemovalClearCollectionAndReAdd() public function testOrphanRemovalClearCollectionAndReAdd()
{ {
$user = $this->_em->find('Doctrine\Tests\Models\CMS\CmsUser', $this->userId); $user = $this->_em->find(CmsUser::class, $this->userId);
$phone1 = $user->getPhonenumbers()->first(); $phone1 = $user->getPhonenumbers()->first();
@ -102,7 +102,7 @@ class OneToManyOrphanRemovalTest extends OrmFunctionalTestCase
*/ */
public function testOrphanRemovalClearCollectionAndAddNew() public function testOrphanRemovalClearCollectionAndAddNew()
{ {
$user = $this->_em->find('Doctrine\Tests\Models\CMS\CmsUser', $this->userId); $user = $this->_em->find(CmsUser::class, $this->userId);
$newPhone = new CmsPhonenumber(); $newPhone = new CmsPhonenumber();
$newPhone->phonenumber = '654321'; $newPhone->phonenumber = '654321';
@ -123,7 +123,7 @@ class OneToManyOrphanRemovalTest extends OrmFunctionalTestCase
*/ */
public function testOrphanRemovalUnitializedCollection() public function testOrphanRemovalUnitializedCollection()
{ {
$user = $this->_em->find('Doctrine\Tests\Models\CMS\CmsUser', $this->userId); $user = $this->_em->find(CmsUser::class, $this->userId);
$user->phonenumbers->clear(); $user->phonenumbers->clear();
$this->_em->flush(); $this->_em->flush();

View File

@ -2,9 +2,9 @@
namespace Doctrine\Tests\ORM\Functional; namespace Doctrine\Tests\ORM\Functional;
use Doctrine\Tests\Models\ECommerce\ECommerceCategory;
use Doctrine\ORM\Mapping\AssociationMapping; use Doctrine\ORM\Mapping\AssociationMapping;
use Doctrine\ORM\Mapping\ClassMetadata; use Doctrine\ORM\Mapping\ClassMetadata;
use Doctrine\Tests\Models\ECommerce\ECommerceCategory;
use Doctrine\Tests\OrmFunctionalTestCase; use Doctrine\Tests\OrmFunctionalTestCase;
/** /**
@ -78,10 +78,10 @@ class OneToManySelfReferentialAssociationTest extends OrmFunctionalTestCase
$parent = $result[0]; $parent = $result[0];
$children = $parent->getChildren(); $children = $parent->getChildren();
$this->assertInstanceOf('Doctrine\Tests\Models\ECommerce\ECommerceCategory', $children[0]); $this->assertInstanceOf(ECommerceCategory::class, $children[0]);
$this->assertSame($parent, $children[0]->getParent()); $this->assertSame($parent, $children[0]->getParent());
$this->assertEquals(' books', strstr($children[0]->getName(), ' books')); $this->assertEquals(' books', strstr($children[0]->getName(), ' books'));
$this->assertInstanceOf('Doctrine\Tests\Models\ECommerce\ECommerceCategory', $children[1]); $this->assertInstanceOf(ECommerceCategory::class, $children[1]);
$this->assertSame($parent, $children[1]->getParent()); $this->assertSame($parent, $children[1]->getParent());
$this->assertEquals(' books', strstr($children[1]->getName(), ' books')); $this->assertEquals(' books', strstr($children[1]->getName(), ' books'));
} }
@ -89,7 +89,7 @@ class OneToManySelfReferentialAssociationTest extends OrmFunctionalTestCase
public function testLazyLoadsOneToManyAssociation() public function testLazyLoadsOneToManyAssociation()
{ {
$this->_createFixture(); $this->_createFixture();
$metadata = $this->_em->getClassMetadata('Doctrine\Tests\Models\ECommerce\ECommerceCategory'); $metadata = $this->_em->getClassMetadata(ECommerceCategory::class);
$metadata->associationMappings['children']['fetch'] = ClassMetadata::FETCH_LAZY; $metadata->associationMappings['children']['fetch'] = ClassMetadata::FETCH_LAZY;
$query = $this->_em->createQuery('select c from Doctrine\Tests\Models\ECommerce\ECommerceCategory c order by c.id asc'); $query = $this->_em->createQuery('select c from Doctrine\Tests\Models\ECommerce\ECommerceCategory c order by c.id asc');
@ -97,10 +97,10 @@ class OneToManySelfReferentialAssociationTest extends OrmFunctionalTestCase
$parent = $result[0]; $parent = $result[0];
$children = $parent->getChildren(); $children = $parent->getChildren();
$this->assertInstanceOf('Doctrine\Tests\Models\ECommerce\ECommerceCategory', $children[0]); $this->assertInstanceOf(ECommerceCategory::class, $children[0]);
$this->assertSame($parent, $children[0]->getParent()); $this->assertSame($parent, $children[0]->getParent());
$this->assertEquals(' books', strstr($children[0]->getName(), ' books')); $this->assertEquals(' books', strstr($children[0]->getName(), ' books'));
$this->assertInstanceOf('Doctrine\Tests\Models\ECommerce\ECommerceCategory', $children[1]); $this->assertInstanceOf(ECommerceCategory::class, $children[1]);
$this->assertSame($parent, $children[1]->getParent()); $this->assertSame($parent, $children[1]->getParent());
$this->assertEquals(' books', strstr($children[1]->getName(), ' books')); $this->assertEquals(' books', strstr($children[1]->getName(), ' books'));
} }

View File

@ -2,10 +2,11 @@
namespace Doctrine\Tests\ORM\Functional; namespace Doctrine\Tests\ORM\Functional;
use Doctrine\Tests\Models\ECommerce\ECommerceCart;
use Doctrine\Tests\Models\ECommerce\ECommerceCustomer;
use Doctrine\ORM\Mapping\AssociationMapping; use Doctrine\ORM\Mapping\AssociationMapping;
use Doctrine\ORM\Mapping\ClassMetadata; use Doctrine\ORM\Mapping\ClassMetadata;
use Doctrine\ORM\Proxy\Proxy;
use Doctrine\Tests\Models\ECommerce\ECommerceCart;
use Doctrine\Tests\Models\ECommerce\ECommerceCustomer;
use Doctrine\Tests\OrmFunctionalTestCase; use Doctrine\Tests\OrmFunctionalTestCase;
/** /**
@ -61,27 +62,27 @@ class OneToOneBidirectionalAssociationTest extends OrmFunctionalTestCase
$result = $query->getResult(); $result = $query->getResult();
$customer = $result[0]; $customer = $result[0];
$this->assertInstanceOf('Doctrine\Tests\Models\ECommerce\ECommerceCart', $customer->getCart()); $this->assertInstanceOf(ECommerceCart::class, $customer->getCart());
$this->assertEquals('paypal', $customer->getCart()->getPayment()); $this->assertEquals('paypal', $customer->getCart()->getPayment());
} }
public function testLazyLoadsObjectsOnTheOwningSide() { public function testLazyLoadsObjectsOnTheOwningSide() {
$this->_createFixture(); $this->_createFixture();
$metadata = $this->_em->getClassMetadata('Doctrine\Tests\Models\ECommerce\ECommerceCart'); $metadata = $this->_em->getClassMetadata(ECommerceCart::class);
$metadata->associationMappings['customer']['fetchMode'] = ClassMetadata::FETCH_LAZY; $metadata->associationMappings['customer']['fetchMode'] = ClassMetadata::FETCH_LAZY;
$query = $this->_em->createQuery('select c from Doctrine\Tests\Models\ECommerce\ECommerceCart c'); $query = $this->_em->createQuery('select c from Doctrine\Tests\Models\ECommerce\ECommerceCart c');
$result = $query->getResult(); $result = $query->getResult();
$cart = $result[0]; $cart = $result[0];
$this->assertInstanceOf('Doctrine\Tests\Models\ECommerce\ECommerceCustomer', $cart->getCustomer()); $this->assertInstanceOf(ECommerceCustomer::class, $cart->getCustomer());
$this->assertEquals('Giorgio', $cart->getCustomer()->getName()); $this->assertEquals('Giorgio', $cart->getCustomer()->getName());
} }
public function testInverseSideIsNeverLazy() public function testInverseSideIsNeverLazy()
{ {
$this->_createFixture(); $this->_createFixture();
$metadata = $this->_em->getClassMetadata('Doctrine\Tests\Models\ECommerce\ECommerceCustomer'); $metadata = $this->_em->getClassMetadata(ECommerceCustomer::class);
$metadata->associationMappings['mentor']['fetch'] = ClassMetadata::FETCH_EAGER; $metadata->associationMappings['mentor']['fetch'] = ClassMetadata::FETCH_EAGER;
$query = $this->_em->createQuery('select c from Doctrine\Tests\Models\ECommerce\ECommerceCustomer c'); $query = $this->_em->createQuery('select c from Doctrine\Tests\Models\ECommerce\ECommerceCustomer c');
@ -89,8 +90,8 @@ class OneToOneBidirectionalAssociationTest extends OrmFunctionalTestCase
$customer = $result[0]; $customer = $result[0];
$this->assertNull($customer->getMentor()); $this->assertNull($customer->getMentor());
$this->assertInstanceOf('Doctrine\Tests\Models\ECommerce\ECommerceCart', $customer->getCart()); $this->assertInstanceOf(ECommerceCart::class, $customer->getCart());
$this->assertNotInstanceOf('Doctrine\ORM\Proxy\Proxy', $customer->getCart()); $this->assertNotInstanceOf(Proxy::class, $customer->getCart());
$this->assertEquals('paypal', $customer->getCart()->getPayment()); $this->assertEquals('paypal', $customer->getCart()->getPayment());
} }
@ -106,7 +107,7 @@ class OneToOneBidirectionalAssociationTest extends OrmFunctionalTestCase
$this->_em->flush(); $this->_em->flush();
$this->_em->clear(); $this->_em->clear();
$this->assertInstanceOf('Doctrine\Tests\Models\ECommerce\ECommerceCart', $cust->getCart()); $this->assertInstanceOf(ECommerceCart::class, $cust->getCart());
$this->assertEquals('Roman', $cust->getName()); $this->assertEquals('Roman', $cust->getName());
$this->assertSame($cust, $cart->getCustomer()); $this->assertSame($cust, $cart->getCustomer());
@ -125,7 +126,7 @@ class OneToOneBidirectionalAssociationTest extends OrmFunctionalTestCase
$cart3 = $query2->getSingleResult(); $cart3 = $query2->getSingleResult();
$this->assertInstanceOf('Doctrine\Tests\Models\ECommerce\ECommerceCustomer', $cart3->getCustomer()); $this->assertInstanceOf(ECommerceCustomer::class, $cart3->getCustomer());
$this->assertEquals('Roman', $cart3->getCustomer()->getName()); $this->assertEquals('Roman', $cart3->getCustomer()->getName());
} }

View File

@ -2,6 +2,7 @@
namespace Doctrine\Tests\ORM\Functional; namespace Doctrine\Tests\ORM\Functional;
use Doctrine\Common\Collections\ArrayCollection; use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\ORM\Proxy\Proxy;
use Doctrine\ORM\Tools\SchemaTool; use Doctrine\ORM\Tools\SchemaTool;
use Doctrine\Tests\OrmFunctionalTestCase; use Doctrine\Tests\OrmFunctionalTestCase;
@ -17,11 +18,11 @@ class OneToOneEagerLoadingTest extends OrmFunctionalTestCase
try { try {
$schemaTool->createSchema( $schemaTool->createSchema(
[ [
$this->_em->getClassMetadata('Doctrine\Tests\ORM\Functional\Train'), $this->_em->getClassMetadata(Train::class),
$this->_em->getClassMetadata('Doctrine\Tests\ORM\Functional\TrainDriver'), $this->_em->getClassMetadata(TrainDriver::class),
$this->_em->getClassMetadata('Doctrine\Tests\ORM\Functional\TrainOwner'), $this->_em->getClassMetadata(TrainOwner::class),
$this->_em->getClassMetadata('Doctrine\Tests\ORM\Functional\Waggon'), $this->_em->getClassMetadata(Waggon::class),
$this->_em->getClassMetadata('Doctrine\Tests\ORM\Functional\TrainOrder'), $this->_em->getClassMetadata(TrainOrder::class),
] ]
); );
} catch(\Exception $e) {} } catch(\Exception $e) {}
@ -46,7 +47,7 @@ class OneToOneEagerLoadingTest extends OrmFunctionalTestCase
$sqlCount = count($this->_sqlLoggerStack->queries); $sqlCount = count($this->_sqlLoggerStack->queries);
$train = $this->_em->find(get_class($train), $train->id); $train = $this->_em->find(get_class($train), $train->id);
$this->assertNotInstanceOf('Doctrine\ORM\Proxy\Proxy', $train->driver); $this->assertNotInstanceOf(Proxy::class, $train->driver);
$this->assertEquals("Benjamin", $train->driver->name); $this->assertEquals("Benjamin", $train->driver->name);
$this->assertEquals($sqlCount + 1, count($this->_sqlLoggerStack->queries)); $this->assertEquals($sqlCount + 1, count($this->_sqlLoggerStack->queries));
@ -66,7 +67,7 @@ class OneToOneEagerLoadingTest extends OrmFunctionalTestCase
$sqlCount = count($this->_sqlLoggerStack->queries); $sqlCount = count($this->_sqlLoggerStack->queries);
$train = $this->_em->find(get_class($train), $train->id); $train = $this->_em->find(get_class($train), $train->id);
$this->assertNotInstanceOf('Doctrine\ORM\Proxy\Proxy', $train->driver); $this->assertNotInstanceOf(Proxy::class, $train->driver);
$this->assertNull($train->driver); $this->assertNull($train->driver);
$this->assertEquals($sqlCount + 1, count($this->_sqlLoggerStack->queries)); $this->assertEquals($sqlCount + 1, count($this->_sqlLoggerStack->queries));
@ -87,7 +88,7 @@ class OneToOneEagerLoadingTest extends OrmFunctionalTestCase
$sqlCount = count($this->_sqlLoggerStack->queries); $sqlCount = count($this->_sqlLoggerStack->queries);
$driver = $this->_em->find(get_class($owner), $owner->id); $driver = $this->_em->find(get_class($owner), $owner->id);
$this->assertNotInstanceOf('Doctrine\ORM\Proxy\Proxy', $owner->train); $this->assertNotInstanceOf(Proxy::class, $owner->train);
$this->assertNotNull($owner->train); $this->assertNotNull($owner->train);
$this->assertEquals($sqlCount + 1, count($this->_sqlLoggerStack->queries)); $this->assertEquals($sqlCount + 1, count($this->_sqlLoggerStack->queries));
@ -109,7 +110,7 @@ class OneToOneEagerLoadingTest extends OrmFunctionalTestCase
$sqlCount = count($this->_sqlLoggerStack->queries); $sqlCount = count($this->_sqlLoggerStack->queries);
$driver = $this->_em->find(get_class($driver), $driver->id); $driver = $this->_em->find(get_class($driver), $driver->id);
$this->assertNotInstanceOf('Doctrine\ORM\Proxy\Proxy', $driver->train); $this->assertNotInstanceOf(Proxy::class, $driver->train);
$this->assertNull($driver->train); $this->assertNull($driver->train);
$this->assertEquals($sqlCount + 1, count($this->_sqlLoggerStack->queries)); $this->assertEquals($sqlCount + 1, count($this->_sqlLoggerStack->queries));
@ -126,7 +127,7 @@ class OneToOneEagerLoadingTest extends OrmFunctionalTestCase
$this->_em->clear(); $this->_em->clear();
$waggon = $this->_em->find(get_class($waggon), $waggon->id); $waggon = $this->_em->find(get_class($waggon), $waggon->id);
$this->assertNotInstanceOf('Doctrine\ORM\Proxy\Proxy', $waggon->train); $this->assertNotInstanceOf(Proxy::class, $waggon->train);
$this->assertNotNull($waggon->train); $this->assertNotNull($waggon->train);
} }

View File

@ -2,9 +2,9 @@
namespace Doctrine\Tests\ORM\Functional; namespace Doctrine\Tests\ORM\Functional;
use Doctrine\Tests\Models\CMS\CmsUser, use Doctrine\Tests\Models\CMS\CmsAddress;
Doctrine\Tests\Models\CMS\CmsEmail, use Doctrine\Tests\Models\CMS\CmsEmail;
Doctrine\Tests\Models\CMS\CmsAddress; use Doctrine\Tests\Models\CMS\CmsUser;
use Doctrine\Tests\OrmFunctionalTestCase; use Doctrine\Tests\OrmFunctionalTestCase;
/** /**
@ -40,7 +40,7 @@ class OneToOneOrphanRemovalTest extends OrmFunctionalTestCase
$this->_em->clear(); $this->_em->clear();
$userProxy = $this->_em->getReference('Doctrine\Tests\Models\CMS\CmsUser', $userId); $userProxy = $this->_em->getReference(CmsUser::class, $userId);
$this->_em->remove($userProxy); $this->_em->remove($userProxy);
$this->_em->flush(); $this->_em->flush();
@ -76,7 +76,7 @@ class OneToOneOrphanRemovalTest extends OrmFunctionalTestCase
$this->_em->clear(); $this->_em->clear();
$user = $this->_em->find('Doctrine\Tests\Models\CMS\CmsUser', $userId); $user = $this->_em->find(CmsUser::class, $userId);
$user->setEmail(null); $user->setEmail(null);

View File

@ -2,9 +2,10 @@
namespace Doctrine\Tests\ORM\Functional; namespace Doctrine\Tests\ORM\Functional;
use Doctrine\Tests\Models\ECommerce\ECommerceCustomer;
use Doctrine\ORM\Mapping\AssociationMapping; use Doctrine\ORM\Mapping\AssociationMapping;
use Doctrine\ORM\Mapping\ClassMetadata; use Doctrine\ORM\Mapping\ClassMetadata;
use Doctrine\ORM\Proxy\Proxy;
use Doctrine\Tests\Models\ECommerce\ECommerceCustomer;
use Doctrine\Tests\OrmFunctionalTestCase; use Doctrine\Tests\OrmFunctionalTestCase;
/** /**
@ -52,8 +53,8 @@ class OneToOneSelfReferentialAssociationTest extends OrmFunctionalTestCase
{ {
$id = $this->_createFixture(); $id = $this->_createFixture();
$customer = $this->_em->find('Doctrine\Tests\Models\ECommerce\ECommerceCustomer', $id); $customer = $this->_em->find(ECommerceCustomer::class, $id);
$this->assertNotInstanceOf('Doctrine\ORM\Proxy\Proxy', $customer->getMentor()); $this->assertNotInstanceOf(Proxy::class, $customer->getMentor());
} }
public function testEagerLoadsAssociation() public function testEagerLoadsAssociation()
@ -74,7 +75,7 @@ class OneToOneSelfReferentialAssociationTest extends OrmFunctionalTestCase
{ {
$this->_createFixture(); $this->_createFixture();
$metadata = $this->_em->getClassMetadata('Doctrine\Tests\Models\ECommerce\ECommerceCustomer'); $metadata = $this->_em->getClassMetadata(ECommerceCustomer::class);
$metadata->associationMappings['mentor']['fetch'] = ClassMetadata::FETCH_LAZY; $metadata->associationMappings['mentor']['fetch'] = ClassMetadata::FETCH_LAZY;
$query = $this->_em->createQuery("select c from Doctrine\Tests\Models\ECommerce\ECommerceCustomer c where c.name='Luke Skywalker'"); $query = $this->_em->createQuery("select c from Doctrine\Tests\Models\ECommerce\ECommerceCustomer c where c.name='Luke Skywalker'");
@ -88,7 +89,7 @@ class OneToOneSelfReferentialAssociationTest extends OrmFunctionalTestCase
try { try {
$this->_schemaTool->createSchema( $this->_schemaTool->createSchema(
[ [
$this->_em->getClassMetadata('Doctrine\Tests\ORM\Functional\MultiSelfReference') $this->_em->getClassMetadata(MultiSelfReference::class)
] ]
); );
} catch (\Exception $e) { } catch (\Exception $e) {
@ -105,8 +106,8 @@ class OneToOneSelfReferentialAssociationTest extends OrmFunctionalTestCase
$entity2 = $this->_em->find(get_class($entity1), $entity1->getId()); $entity2 = $this->_em->find(get_class($entity1), $entity1->getId());
$this->assertInstanceOf('Doctrine\Tests\ORM\Functional\MultiSelfReference', $entity2->getOther1()); $this->assertInstanceOf(MultiSelfReference::class, $entity2->getOther1());
$this->assertInstanceOf('Doctrine\Tests\ORM\Functional\MultiSelfReference', $entity2->getOther2()); $this->assertInstanceOf(MultiSelfReference::class, $entity2->getOther2());
$this->assertNull($entity2->getOther1()->getOther1()); $this->assertNull($entity2->getOther1()->getOther1());
$this->assertNull($entity2->getOther1()->getOther2()); $this->assertNull($entity2->getOther1()->getOther2());
$this->assertNull($entity2->getOther2()->getOther1()); $this->assertNull($entity2->getOther2()->getOther1());
@ -115,7 +116,7 @@ class OneToOneSelfReferentialAssociationTest extends OrmFunctionalTestCase
public function assertLoadingOfAssociation($customer) public function assertLoadingOfAssociation($customer)
{ {
$this->assertInstanceOf('Doctrine\Tests\Models\ECommerce\ECommerceCustomer', $customer->getMentor()); $this->assertInstanceOf(ECommerceCustomer::class, $customer->getMentor());
$this->assertEquals('Obi-wan Kenobi', $customer->getMentor()->getName()); $this->assertEquals('Obi-wan Kenobi', $customer->getMentor()->getName());
} }

View File

@ -15,9 +15,9 @@ class OneToOneSingleTableInheritanceTest extends OrmFunctionalTestCase
parent::setUp(); parent::setUp();
$this->_schemaTool->createSchema([ $this->_schemaTool->createSchema([
$this->_em->getClassMetadata(Pet::CLASSNAME), $this->_em->getClassMetadata(Pet::class),
$this->_em->getClassMetadata(Cat::CLASSNAME), $this->_em->getClassMetadata(Cat::class),
$this->_em->getClassMetadata(LitterBox::CLASSNAME), $this->_em->getClassMetadata(LitterBox::class),
]); ]);
} }
@ -38,11 +38,11 @@ class OneToOneSingleTableInheritanceTest extends OrmFunctionalTestCase
$this->_em->clear(); $this->_em->clear();
/* @var $foundCat Cat */ /* @var $foundCat Cat */
$foundCat = $this->_em->find(Pet::CLASSNAME, $cat->id); $foundCat = $this->_em->find(Pet::class, $cat->id);
$this->assertInstanceOf(Cat::CLASSNAME, $foundCat); $this->assertInstanceOf(Cat::class, $foundCat);
$this->assertSame($cat->id, $foundCat->id); $this->assertSame($cat->id, $foundCat->id);
$this->assertInstanceOf(LitterBox::CLASSNAME, $foundCat->litterBox); $this->assertInstanceOf(LitterBox::class, $foundCat->litterBox);
$this->assertSame($cat->litterBox->id, $foundCat->litterBox->id); $this->assertSame($cat->litterBox->id, $foundCat->litterBox->id);
} }
} }

View File

@ -2,11 +2,11 @@
namespace Doctrine\Tests\ORM\Functional; namespace Doctrine\Tests\ORM\Functional;
use Doctrine\Tests\Models\ECommerce\ECommerceProduct;
use Doctrine\Tests\Models\ECommerce\ECommerceShipping;
use Doctrine\ORM\Mapping\AssociationMapping; use Doctrine\ORM\Mapping\AssociationMapping;
use Doctrine\ORM\Mapping\ClassMetadata; use Doctrine\ORM\Mapping\ClassMetadata;
use Doctrine\ORM\Query; use Doctrine\ORM\Query;
use Doctrine\Tests\Models\ECommerce\ECommerceProduct;
use Doctrine\Tests\Models\ECommerce\ECommerceShipping;
use Doctrine\Tests\OrmFunctionalTestCase; use Doctrine\Tests\OrmFunctionalTestCase;
/** /**
@ -55,20 +55,20 @@ class OneToOneUnidirectionalAssociationTest extends OrmFunctionalTestCase
$result = $query->getResult(); $result = $query->getResult();
$product = $result[0]; $product = $result[0];
$this->assertInstanceOf('Doctrine\Tests\Models\ECommerce\ECommerceShipping', $product->getShipping()); $this->assertInstanceOf(ECommerceShipping::class, $product->getShipping());
$this->assertEquals(1, $product->getShipping()->getDays()); $this->assertEquals(1, $product->getShipping()->getDays());
} }
public function testLazyLoadsObjects() { public function testLazyLoadsObjects() {
$this->_createFixture(); $this->_createFixture();
$metadata = $this->_em->getClassMetadata('Doctrine\Tests\Models\ECommerce\ECommerceProduct'); $metadata = $this->_em->getClassMetadata(ECommerceProduct::class);
$metadata->associationMappings['shipping']['fetch'] = ClassMetadata::FETCH_LAZY; $metadata->associationMappings['shipping']['fetch'] = ClassMetadata::FETCH_LAZY;
$query = $this->_em->createQuery('select p from Doctrine\Tests\Models\ECommerce\ECommerceProduct p'); $query = $this->_em->createQuery('select p from Doctrine\Tests\Models\ECommerce\ECommerceProduct p');
$result = $query->getResult(); $result = $query->getResult();
$product = $result[0]; $product = $result[0];
$this->assertInstanceOf('Doctrine\Tests\Models\ECommerce\ECommerceShipping', $product->getShipping()); $this->assertInstanceOf(ECommerceShipping::class, $product->getShipping());
$this->assertEquals(1, $product->getShipping()->getDays()); $this->assertEquals(1, $product->getShipping()->getDays());
} }

View File

@ -2,9 +2,9 @@
namespace Doctrine\Tests\ORM\Functional; namespace Doctrine\Tests\ORM\Functional;
use Doctrine\Tests\Models\Routing\RoutingRoute;
use Doctrine\Tests\Models\Routing\RoutingLocation;
use Doctrine\Tests\Models\Routing\RoutingLeg; use Doctrine\Tests\Models\Routing\RoutingLeg;
use Doctrine\Tests\Models\Routing\RoutingLocation;
use Doctrine\Tests\Models\Routing\RoutingRoute;
use Doctrine\Tests\Models\Routing\RoutingRouteBooking; use Doctrine\Tests\Models\Routing\RoutingRouteBooking;
use Doctrine\Tests\OrmFunctionalTestCase; use Doctrine\Tests\OrmFunctionalTestCase;
@ -59,7 +59,7 @@ class OrderedCollectionTest extends OrmFunctionalTestCase
{ {
$routeId = $this->createPersistedRouteWithLegs(); $routeId = $this->createPersistedRouteWithLegs();
$route = $this->_em->find('Doctrine\Tests\Models\Routing\RoutingRoute', $routeId); $route = $this->_em->find(RoutingRoute::class, $routeId);
$this->assertEquals(2, count($route->legs)); $this->assertEquals(2, count($route->legs));
$this->assertEquals("Berlin", $route->legs[0]->fromLocation->getName()); $this->assertEquals("Berlin", $route->legs[0]->fromLocation->getName());
@ -90,7 +90,7 @@ class OrderedCollectionTest extends OrmFunctionalTestCase
$this->_em->flush(); $this->_em->flush();
$this->_em->clear(); $this->_em->clear();
$route = $this->_em->find('Doctrine\Tests\Models\Routing\RoutingRoute', $routeId); $route = $this->_em->find(RoutingRoute::class, $routeId);
$this->assertEquals(2, count($route->bookings)); $this->assertEquals(2, count($route->bookings));
$this->assertEquals('Benjamin', $route->bookings[0]->getPassengerName()); $this->assertEquals('Benjamin', $route->bookings[0]->getPassengerName());

View File

@ -18,9 +18,9 @@ class OrderedJoinedTableInheritanceCollectionTest extends OrmFunctionalTestCase
try { try {
$this->_schemaTool->createSchema( $this->_schemaTool->createSchema(
[ [
$this->_em->getClassMetadata('Doctrine\Tests\ORM\Functional\OJTIC_Pet'), $this->_em->getClassMetadata(OJTIC_Pet::class),
$this->_em->getClassMetadata('Doctrine\Tests\ORM\Functional\OJTIC_Cat'), $this->_em->getClassMetadata(OJTIC_Cat::class),
$this->_em->getClassMetadata('Doctrine\Tests\ORM\Functional\OJTIC_Dog'), $this->_em->getClassMetadata(OJTIC_Dog::class),
] ]
); );
} catch (\Exception $e) { } catch (\Exception $e) {

View File

@ -3,11 +3,11 @@
namespace Doctrine\Tests\ORM\Functional; namespace Doctrine\Tests\ORM\Functional;
use Doctrine\ORM\Query; use Doctrine\ORM\Query;
use Doctrine\ORM\Tools\Pagination\Paginator;
use Doctrine\Tests\Models\CMS\CmsArticle; use Doctrine\Tests\Models\CMS\CmsArticle;
use Doctrine\Tests\Models\CMS\CmsEmail; use Doctrine\Tests\Models\CMS\CmsEmail;
use Doctrine\Tests\Models\CMS\CmsUser;
use Doctrine\Tests\Models\CMS\CmsGroup; use Doctrine\Tests\Models\CMS\CmsGroup;
use Doctrine\ORM\Tools\Pagination\Paginator; use Doctrine\Tests\Models\CMS\CmsUser;
use Doctrine\Tests\Models\Company\CompanyManager; use Doctrine\Tests\Models\Company\CompanyManager;
use Doctrine\Tests\Models\Pagination\Company; use Doctrine\Tests\Models\Pagination\Company;
use Doctrine\Tests\Models\Pagination\Department; use Doctrine\Tests\Models\Pagination\Department;
@ -595,7 +595,7 @@ class PaginationTest extends OrmFunctionalTestCase
// If the Paginator detects the custom output walker it should fall back to using the // If the Paginator detects the custom output walker it should fall back to using the
// Tree walkers for pagination, which leads to an exception. If the query works, the output walkers were used // Tree walkers for pagination, which leads to an exception. If the query works, the output walkers were used
$query->setHint(Query::HINT_CUSTOM_OUTPUT_WALKER, 'Doctrine\ORM\Query\SqlWalker'); $query->setHint(Query::HINT_CUSTOM_OUTPUT_WALKER, Query\SqlWalker::class);
$paginator = new Paginator($query); $paginator = new Paginator($query);
$this->expectException(\RuntimeException::class); $this->expectException(\RuntimeException::class);
@ -633,8 +633,7 @@ class PaginationTest extends OrmFunctionalTestCase
{ {
$dql = 'SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u'; $dql = 'SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u';
$query = $this->_em->createQuery($dql); $query = $this->_em->createQuery($dql);
$query->setHint(Query::HINT_CUSTOM_TREE_WALKERS, ['Doctrine\Tests\ORM\Functional\CustomPaginationTestTreeWalker'] $query->setHint(Query::HINT_CUSTOM_TREE_WALKERS, [CustomPaginationTestTreeWalker::class]);
);
$paginator = new Paginator($query, true); $paginator = new Paginator($query, true);
$paginator->setUseOutputWalkers(false); $paginator->setUseOutputWalkers(false);
@ -662,7 +661,7 @@ class PaginationTest extends OrmFunctionalTestCase
$this->assertCount(2, $getCountQuery->invoke($paginator)->getParameters()); $this->assertCount(2, $getCountQuery->invoke($paginator)->getParameters());
$this->assertCount(9, $paginator); $this->assertCount(9, $paginator);
$query->setHint(Query::HINT_CUSTOM_OUTPUT_WALKER, 'Doctrine\ORM\Query\SqlWalker'); $query->setHint(Query::HINT_CUSTOM_OUTPUT_WALKER, Query\SqlWalker::class);
$paginator = new Paginator($query); $paginator = new Paginator($query);

View File

@ -3,9 +3,11 @@
namespace Doctrine\Tests\ORM\Functional; namespace Doctrine\Tests\ORM\Functional;
use Doctrine\Common\Collections\Criteria; use Doctrine\Common\Collections\Criteria;
use Doctrine\ORM\LazyCriteriaCollection;
use Doctrine\Tests\Models\Quote\Group; use Doctrine\Tests\Models\Quote\Group;
use Doctrine\Tests\Models\Quote\User as QuoteUser; use Doctrine\Tests\Models\Quote\User as QuoteUser;
use Doctrine\Tests\Models\Tweet\Tweet; use Doctrine\Tests\Models\Tweet\Tweet;
use Doctrine\Tests\Models\Tweet\User;
use Doctrine\Tests\Models\Tweet\User as TweetUser; use Doctrine\Tests\Models\Tweet\User as TweetUser;
use Doctrine\Tests\OrmFunctionalTestCase; use Doctrine\Tests\OrmFunctionalTestCase;
@ -73,12 +75,12 @@ class PersistentCollectionCriteriaTest extends OrmFunctionalTestCase
{ {
$this->loadTweetFixture(); $this->loadTweetFixture();
$repository = $this->_em->getRepository('Doctrine\Tests\Models\Tweet\User'); $repository = $this->_em->getRepository(User::class);
$user = $repository->findOneBy(['name' => 'ngal']); $user = $repository->findOneBy(['name' => 'ngal']);
$tweets = $user->tweets->matching(new Criteria()); $tweets = $user->tweets->matching(new Criteria());
$this->assertInstanceOf('Doctrine\ORM\LazyCriteriaCollection', $tweets); $this->assertInstanceOf(LazyCriteriaCollection::class, $tweets);
$this->assertFalse($tweets->isInitialized()); $this->assertFalse($tweets->isInitialized());
$this->assertCount(2, $tweets); $this->assertCount(2, $tweets);
$this->assertFalse($tweets->isInitialized()); $this->assertFalse($tweets->isInitialized());
@ -88,7 +90,7 @@ class PersistentCollectionCriteriaTest extends OrmFunctionalTestCase
Criteria::expr()->eq('content', 'Foo') Criteria::expr()->eq('content', 'Foo')
)); ));
$this->assertInstanceOf('Doctrine\ORM\LazyCriteriaCollection', $tweets); $this->assertInstanceOf(LazyCriteriaCollection::class, $tweets);
$this->assertFalse($tweets->isInitialized()); $this->assertFalse($tweets->isInitialized());
$this->assertCount(1, $tweets); $this->assertCount(1, $tweets);
$this->assertFalse($tweets->isInitialized()); $this->assertFalse($tweets->isInitialized());

View File

@ -15,8 +15,8 @@ class PersistentCollectionTest extends OrmFunctionalTestCase
try { try {
$this->_schemaTool->createSchema( $this->_schemaTool->createSchema(
[ [
$this->_em->getClassMetadata(__NAMESPACE__ . '\PersistentCollectionHolder'), $this->_em->getClassMetadata(PersistentCollectionHolder::class),
$this->_em->getClassMetadata(__NAMESPACE__ . '\PersistentCollectionContent'), $this->_em->getClassMetadata(PersistentCollectionContent::class),
] ]
); );
} catch (\Exception $e) { } catch (\Exception $e) {
@ -35,7 +35,7 @@ class PersistentCollectionTest extends OrmFunctionalTestCase
$this->_em->flush(); $this->_em->flush();
$this->_em->clear(); $this->_em->clear();
$collectionHolder = $this->_em->find(__NAMESPACE__ . '\PersistentCollectionHolder', $collectionHolder->getId()); $collectionHolder = $this->_em->find(PersistentCollectionHolder::class, $collectionHolder->getId());
$collectionHolder->getCollection(); $collectionHolder->getCollection();
$content = new PersistentCollectionContent('second element'); $content = new PersistentCollectionContent('second element');
@ -55,7 +55,7 @@ class PersistentCollectionTest extends OrmFunctionalTestCase
$this->_em->flush(); $this->_em->flush();
$this->_em->clear(); $this->_em->clear();
$collectionHolder = $this->_em->find(__NAMESPACE__ . '\PersistentCollectionHolder', $collectionHolder->getId()); $collectionHolder = $this->_em->find(PersistentCollectionHolder::class, $collectionHolder->getId());
$collection = $collectionHolder->getRawCollection(); $collection = $collectionHolder->getRawCollection();
$this->assertTrue($collection->isEmpty()); $this->assertTrue($collection->isEmpty());
@ -66,7 +66,7 @@ class PersistentCollectionTest extends OrmFunctionalTestCase
$this->_em->flush(); $this->_em->flush();
$this->_em->clear(); $this->_em->clear();
$collectionHolder = $this->_em->find(__NAMESPACE__ . '\PersistentCollectionHolder', $collectionHolder->getId()); $collectionHolder = $this->_em->find(PersistentCollectionHolder::class, $collectionHolder->getId());
$collection = $collectionHolder->getRawCollection(); $collection = $collectionHolder->getRawCollection();
$this->assertFalse($collection->isEmpty()); $this->assertFalse($collection->isEmpty());
@ -87,7 +87,7 @@ class PersistentCollectionTest extends OrmFunctionalTestCase
$criteria = new Criteria(); $criteria = new Criteria();
$collectionHolder = $this->_em->find(__NAMESPACE__ . '\PersistentCollectionHolder', $collectionHolder->getId()); $collectionHolder = $this->_em->find(PersistentCollectionHolder::class, $collectionHolder->getId());
$collectionHolder->getCollection()->matching($criteria); $collectionHolder->getCollection()->matching($criteria);
$this->assertEmpty($criteria->getWhereExpression()); $this->assertEmpty($criteria->getWhereExpression());

View File

@ -19,7 +19,7 @@ class PersistentObjectTest extends OrmFunctionalTestCase
try { try {
$this->_schemaTool->createSchema( $this->_schemaTool->createSchema(
[ [
$this->_em->getClassMetadata('Doctrine\Tests\ORM\Functional\PersistentEntity'), $this->_em->getClassMetadata(PersistentEntity::class),
] ]
); );
} catch (\Exception $e) { } catch (\Exception $e) {
@ -46,7 +46,7 @@ class PersistentObjectTest extends OrmFunctionalTestCase
$this->_em->flush(); $this->_em->flush();
$this->_em->clear(); $this->_em->clear();
$entity = $this->_em->find(__NAMESPACE__ . '\PersistentEntity', $entity->getId()); $entity = $this->_em->find(PersistentEntity::class, $entity->getId());
$this->assertEquals('test', $entity->getName()); $this->assertEquals('test', $entity->getName());
$entity->setName('foobar'); $entity->setName('foobar');
@ -63,7 +63,7 @@ class PersistentObjectTest extends OrmFunctionalTestCase
$this->_em->flush(); $this->_em->flush();
$this->_em->clear(); $this->_em->clear();
$entity = $this->_em->getReference(__NAMESPACE__ . '\PersistentEntity', $entity->getId()); $entity = $this->_em->getReference(PersistentEntity::class, $entity->getId());
$this->assertEquals('test', $entity->getName()); $this->assertEquals('test', $entity->getName());
} }
@ -78,7 +78,7 @@ class PersistentObjectTest extends OrmFunctionalTestCase
$this->_em->flush(); $this->_em->flush();
$this->_em->clear(); $this->_em->clear();
$entity = $this->_em->getReference(__NAMESPACE__ . '\PersistentEntity', $entity->getId()); $entity = $this->_em->getReference(PersistentEntity::class, $entity->getId());
$this->assertSame($entity, $entity->getParent()); $this->assertSame($entity, $entity->getParent());
} }
} }

View File

@ -2,12 +2,12 @@
namespace Doctrine\Tests\ORM\Functional; namespace Doctrine\Tests\ORM\Functional;
use Doctrine\Common\Util\ClassUtils; use Doctrine\Common\Util\ClassUtils;
use Doctrine\Tests\Models\CMS\CmsUser;
use Doctrine\Tests\Models\CMS\CmsPhonenumber;
use Doctrine\Tests\Models\CMS\CmsAddress;
use Doctrine\Tests\Models\CMS\CmsEmail;
use Doctrine\ORM\Event\LifecycleEventArgs; use Doctrine\ORM\Event\LifecycleEventArgs;
use Doctrine\ORM\Events; use Doctrine\ORM\Events;
use Doctrine\Tests\Models\CMS\CmsAddress;
use Doctrine\Tests\Models\CMS\CmsEmail;
use Doctrine\Tests\Models\CMS\CmsPhonenumber;
use Doctrine\Tests\Models\CMS\CmsUser;
use Doctrine\Tests\OrmFunctionalTestCase; use Doctrine\Tests\OrmFunctionalTestCase;
/** /**
@ -48,7 +48,7 @@ class PostLoadEventTest extends OrmFunctionalTestCase
$eventManager->addEventListener([Events::postLoad], $mockListener); $eventManager->addEventListener([Events::postLoad], $mockListener);
$this->_em->find('Doctrine\Tests\Models\CMS\CmsUser', $this->userId); $this->_em->find(CmsUser::class, $this->userId);
} }
public function testLoadedEntityUsingQueryShouldTriggerEvent() public function testLoadedEntityUsingQueryShouldTriggerEvent()
@ -125,7 +125,7 @@ class PostLoadEventTest extends OrmFunctionalTestCase
$eventManager->addEventListener([Events::postLoad], $mockListener); $eventManager->addEventListener([Events::postLoad], $mockListener);
$userProxy = $this->_em->getReference('Doctrine\Tests\Models\CMS\CmsUser', $this->userId); $userProxy = $this->_em->getReference(CmsUser::class, $this->userId);
// Now deactivate original listener and attach new one // Now deactivate original listener and attach new one
$eventManager->removeEventListener([Events::postLoad], $mockListener); $eventManager->removeEventListener([Events::postLoad], $mockListener);
@ -165,7 +165,7 @@ class PostLoadEventTest extends OrmFunctionalTestCase
public function testLoadedProxyAssociationToOneShouldTriggerEvent() public function testLoadedProxyAssociationToOneShouldTriggerEvent()
{ {
$user = $this->_em->find('Doctrine\Tests\Models\CMS\CmsUser', $this->userId); $user = $this->_em->find(CmsUser::class, $this->userId);
$mockListener = $this->createMock(PostLoadListener::class); $mockListener = $this->createMock(PostLoadListener::class);
@ -186,7 +186,7 @@ class PostLoadEventTest extends OrmFunctionalTestCase
public function testLoadedProxyAssociationToManyShouldTriggerEvent() public function testLoadedProxyAssociationToManyShouldTriggerEvent()
{ {
$user = $this->_em->find('Doctrine\Tests\Models\CMS\CmsUser', $this->userId); $user = $this->_em->find(CmsUser::class, $this->userId);
$mockListener = $this->createMock(PostLoadListener::class); $mockListener = $this->createMock(PostLoadListener::class);
@ -213,7 +213,7 @@ class PostLoadEventTest extends OrmFunctionalTestCase
$checkerListener = new PostLoadListenerCheckAssociationsArePopulated(); $checkerListener = new PostLoadListenerCheckAssociationsArePopulated();
$this->_em->getEventManager()->addEventListener([Events::postLoad], $checkerListener); $this->_em->getEventManager()->addEventListener([Events::postLoad], $checkerListener);
$qb = $this->_em->getRepository('Doctrine\Tests\Models\CMS\CmsUser')->createQueryBuilder('u'); $qb = $this->_em->getRepository(CmsUser::class)->createQueryBuilder('u');
$qb->leftJoin('u.email', 'email'); $qb->leftJoin('u.email', 'email');
$qb->addSelect('email'); $qb->addSelect('email');
$qb->getQuery()->getSingleResult(); $qb->getQuery()->getSingleResult();
@ -231,9 +231,9 @@ class PostLoadEventTest extends OrmFunctionalTestCase
$listener = new PostLoadListenerLoadEntityInEventHandler(); $listener = new PostLoadListenerLoadEntityInEventHandler();
$eventManager->addEventListener([Events::postLoad], $listener); $eventManager->addEventListener([Events::postLoad], $listener);
$this->_em->find('Doctrine\Tests\Models\CMS\CmsUser', $this->userId); $this->_em->find(CmsUser::class, $this->userId);
$this->assertSame(1, $listener->countHandledEvents('Doctrine\Tests\Models\CMS\CmsUser'), 'Doctrine\Tests\Models\CMS\CmsUser should be handled once!'); $this->assertSame(1, $listener->countHandledEvents(CmsUser::class), CmsUser::class . ' should be handled once!');
$this->assertSame(1, $listener->countHandledEvents('Doctrine\Tests\Models\CMS\CmsEmail'), '\Doctrine\Tests\Models\CMS\CmsEmail should be handled once!'); $this->assertSame(1, $listener->countHandledEvents(CmsEmail::class), CmsEmail::class . ' should be handled once!');
} }
private function loadFixture() private function loadFixture()

View File

@ -2,8 +2,15 @@
namespace Doctrine\Tests\ORM\Functional; namespace Doctrine\Tests\ORM\Functional;
use Doctrine\Tests\Models\CMS\CmsAddress;
use Doctrine\Tests\Models\CMS\CmsArticle;
use Doctrine\Tests\Models\CMS\CmsEmail;
use Doctrine\Tests\Models\CMS\CmsGroup;
use Doctrine\Tests\Models\CMS\CmsPhonenumber;
use Doctrine\Tests\Models\CMS\CmsTag;
use Doctrine\Tests\Models\CMS\CmsUser; use Doctrine\Tests\Models\CMS\CmsUser;
use Doctrine\Tests\OrmFunctionalTestCase; use Doctrine\Tests\OrmFunctionalTestCase;
use Doctrine\Tests\Proxies\__CG__\Doctrine\Tests\Models\CMS\CmsUser as CmsUserProxy;
/** /**
* Test that Doctrine ORM correctly works with proxy instances exactly like with ordinary Entities * Test that Doctrine ORM correctly works with proxy instances exactly like with ordinary Entities
@ -26,12 +33,13 @@ class ProxiesLikeEntitiesTest extends OrmFunctionalTestCase
try { try {
$this->_schemaTool->createSchema( $this->_schemaTool->createSchema(
[ [
$this->_em->getClassMetadata('Doctrine\Tests\Models\CMS\CmsUser'), $this->_em->getClassMetadata(CmsUser::class),
$this->_em->getClassMetadata('Doctrine\Tests\Models\CMS\CmsPhonenumber'), $this->_em->getClassMetadata(CmsTag::class),
$this->_em->getClassMetadata('Doctrine\Tests\Models\CMS\CmsArticle'), $this->_em->getClassMetadata(CmsPhonenumber::class),
$this->_em->getClassMetadata('Doctrine\Tests\Models\CMS\CmsAddress'), $this->_em->getClassMetadata(CmsArticle::class),
$this->_em->getClassMetadata('Doctrine\Tests\Models\CMS\CmsEmail'), $this->_em->getClassMetadata(CmsAddress::class),
$this->_em->getClassMetadata('Doctrine\Tests\Models\CMS\CmsGroup'), $this->_em->getClassMetadata(CmsEmail::class),
$this->_em->getClassMetadata(CmsGroup::class),
] ]
); );
} catch (\Exception $e) { } catch (\Exception $e) {
@ -50,7 +58,7 @@ class ProxiesLikeEntitiesTest extends OrmFunctionalTestCase
public function testPersistUpdate() public function testPersistUpdate()
{ {
// Considering case (a) // Considering case (a)
$proxy = $this->_em->getProxyFactory()->getProxy('Doctrine\Tests\Models\CMS\CmsUser', ['id' => 123]); $proxy = $this->_em->getProxyFactory()->getProxy(CmsUser::class, ['id' => 123]);
$proxy->__isInitialized__ = true; $proxy->__isInitialized__ = true;
$proxy->id = null; $proxy->id = null;
$proxy->username = 'ocra'; $proxy->username = 'ocra';
@ -59,12 +67,10 @@ class ProxiesLikeEntitiesTest extends OrmFunctionalTestCase
$this->_em->flush(); $this->_em->flush();
$this->assertNotNull($proxy->getId()); $this->assertNotNull($proxy->getId());
$proxy->name = 'Marco Pivetta'; $proxy->name = 'Marco Pivetta';
$this $this->_em->getUnitOfWork()
->_em ->computeChangeSet($this->_em->getClassMetadata(CmsUser::class), $proxy);
->getUnitOfWork()
->computeChangeSet($this->_em->getClassMetadata('Doctrine\Tests\Models\CMS\CmsUser'), $proxy);
$this->assertNotEmpty($this->_em->getUnitOfWork()->getEntityChangeSet($proxy)); $this->assertNotEmpty($this->_em->getUnitOfWork()->getEntityChangeSet($proxy));
$this->assertEquals('Marco Pivetta', $this->_em->find('Doctrine\Tests\Models\CMS\CmsUser', $proxy->getId())->name); $this->assertEquals('Marco Pivetta', $this->_em->find(CmsUser::class, $proxy->getId())->name);
$this->_em->remove($proxy); $this->_em->remove($proxy);
$this->_em->flush(); $this->_em->flush();
} }
@ -72,9 +78,9 @@ class ProxiesLikeEntitiesTest extends OrmFunctionalTestCase
public function testEntityWithIdentifier() public function testEntityWithIdentifier()
{ {
$userId = $this->user->getId(); $userId = $this->user->getId();
/* @var $uninitializedProxy \Doctrine\Tests\Proxies\__CG__\Doctrine\Tests\Models\CMS\CmsUser */ /* @var $uninitializedProxy CmsUserProxy */
$uninitializedProxy = $this->_em->getReference('Doctrine\Tests\Models\CMS\CmsUser', $userId); $uninitializedProxy = $this->_em->getReference(CmsUser::class, $userId);
$this->assertInstanceOf('Doctrine\Tests\Proxies\__CG__\Doctrine\Tests\Models\CMS\CmsUser', $uninitializedProxy); $this->assertInstanceOf(CmsUserProxy::class, $uninitializedProxy);
$this->_em->persist($uninitializedProxy); $this->_em->persist($uninitializedProxy);
$this->_em->flush($uninitializedProxy); $this->_em->flush($uninitializedProxy);
@ -89,7 +95,7 @@ class ProxiesLikeEntitiesTest extends OrmFunctionalTestCase
*/ */
public function testProxyAsDqlParameterPersist() public function testProxyAsDqlParameterPersist()
{ {
$proxy = $this->_em->getProxyFactory()->getProxy('Doctrine\Tests\Models\CMS\CmsUser', ['id' => $this->user->getId()] $proxy = $this->_em->getProxyFactory()->getProxy(CmsUser::class, ['id' => $this->user->getId()]
); );
$proxy->id = $this->user->getId(); $proxy->id = $this->user->getId();
$result = $this $result = $this
@ -107,27 +113,23 @@ class ProxiesLikeEntitiesTest extends OrmFunctionalTestCase
*/ */
public function testFindWithProxyName() public function testFindWithProxyName()
{ {
$result = $this $result = $this->_em->find(CmsUserProxy::class, $this->user->getId());
->_em
->find('Doctrine\Tests\Proxies\__CG__\Doctrine\Tests\Models\CMS\CmsUser', $this->user->getId());
$this->assertSame($this->user->getId(), $result->getId()); $this->assertSame($this->user->getId(), $result->getId());
$this->_em->clear(); $this->_em->clear();
$result = $this
->_em $result = $this->_em->getReference(CmsUserProxy::class, $this->user->getId());
->getReference('Doctrine\Tests\Proxies\__CG__\Doctrine\Tests\Models\CMS\CmsUser', $this->user->getId());
$this->assertSame($this->user->getId(), $result->getId()); $this->assertSame($this->user->getId(), $result->getId());
$this->_em->clear(); $this->_em->clear();
$result = $this
->_em $result = $this->_em->getRepository(CmsUserProxy::class)->findOneBy(['username' => $this->user->username]);
->getRepository('Doctrine\Tests\Proxies\__CG__\Doctrine\Tests\Models\CMS\CmsUser')
->findOneBy(['username' => $this->user->username]);
$this->assertSame($this->user->getId(), $result->getId()); $this->assertSame($this->user->getId(), $result->getId());
$this->_em->clear(); $this->_em->clear();
$result = $this
->_em $result = $this->_em
->createQuery('SELECT u FROM Doctrine\Tests\Proxies\__CG__\Doctrine\Tests\Models\CMS\CmsUser u WHERE u.id = ?1') ->createQuery('SELECT u FROM Doctrine\Tests\Proxies\__CG__\Doctrine\Tests\Models\CMS\CmsUser u WHERE u.id = ?1')
->setParameter(1, $this->user->getId()) ->setParameter(1, $this->user->getId())
->getSingleResult(); ->getSingleResult();
$this->assertSame($this->user->getId(), $result->getId()); $this->assertSame($this->user->getId(), $result->getId());
$this->_em->clear(); $this->_em->clear();
} }

View File

@ -23,7 +23,7 @@ class QueryCacheTest extends OrmFunctionalTestCase
protected function setUp() protected function setUp()
{ {
$this->cacheDataReflection = new \ReflectionProperty("Doctrine\Common\Cache\ArrayCache", "data"); $this->cacheDataReflection = new \ReflectionProperty(ArrayCache::class, "data");
$this->cacheDataReflection->setAccessible(true); $this->cacheDataReflection->setAccessible(true);
$this->useModelSet('cms'); $this->useModelSet('cms');
@ -116,7 +116,7 @@ class QueryCacheTest extends OrmFunctionalTestCase
$cache $cache
->expects(self::once()) ->expects(self::once())
->method('save') ->method('save')
->with(self::isType('string'), self::isInstanceOf('Doctrine\ORM\Query\ParserResult')); ->with(self::isType('string'), self::isInstanceOf(ParserResult::class));
$query->getResult(); $query->getResult();
} }
@ -151,6 +151,7 @@ class QueryCacheTest extends OrmFunctionalTestCase
->method('doFetch') ->method('doFetch')
->with($this->isType('string')) ->with($this->isType('string'))
->will($this->returnValue($parserResultMock)); ->will($this->returnValue($parserResultMock));
$cache->expects($this->never()) $cache->expects($this->never())
->method('doSave'); ->method('doSave');

View File

@ -5,6 +5,7 @@ namespace Doctrine\Tests\ORM\Functional;
use Doctrine\Common\Collections\ArrayCollection; use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\ORM\NonUniqueResultException; use Doctrine\ORM\NonUniqueResultException;
use Doctrine\ORM\Proxy\Proxy;
use Doctrine\ORM\Query\QueryException; use Doctrine\ORM\Query\QueryException;
use Doctrine\ORM\UnexpectedResultException; use Doctrine\ORM\UnexpectedResultException;
use Doctrine\Tests\Models\CMS\CmsUser, use Doctrine\Tests\Models\CMS\CmsUser,
@ -43,7 +44,7 @@ class QueryTest extends OrmFunctionalTestCase
$result = $query->getResult(); $result = $query->getResult();
$this->assertEquals(1, count($result)); $this->assertEquals(1, count($result));
$this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsUser', $result[0][0]); $this->assertInstanceOf(CmsUser::class, $result[0][0]);
$this->assertEquals('Guilherme', $result[0][0]->name); $this->assertEquals('Guilherme', $result[0][0]->name);
$this->assertEquals('gblanco', $result[0][0]->username); $this->assertEquals('gblanco', $result[0][0]->username);
$this->assertEquals('developer', $result[0][0]->status); $this->assertEquals('developer', $result[0][0]->status);
@ -95,7 +96,7 @@ class QueryTest extends OrmFunctionalTestCase
$query = $this->_em->createQuery("select u, a from Doctrine\Tests\Models\CMS\CmsUser u join u.articles a ORDER BY a.topic"); $query = $this->_em->createQuery("select u, a from Doctrine\Tests\Models\CMS\CmsUser u join u.articles a ORDER BY a.topic");
$users = $query->getResult(); $users = $query->getResult();
$this->assertEquals(1, count($users)); $this->assertEquals(1, count($users));
$this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsUser', $users[0]); $this->assertInstanceOf(CmsUser::class, $users[0]);
$this->assertEquals(2, count($users[0]->articles)); $this->assertEquals(2, count($users[0]->articles));
$this->assertEquals('Doctrine 2', $users[0]->articles[0]->topic); $this->assertEquals('Doctrine 2', $users[0]->articles[0]->topic);
$this->assertEquals('Symfony 2', $users[0]->articles[1]->topic); $this->assertEquals('Symfony 2', $users[0]->articles[1]->topic);
@ -239,7 +240,7 @@ class QueryTest extends OrmFunctionalTestCase
$topics[] = $article->topic; $topics[] = $article->topic;
$identityMap = $this->_em->getUnitOfWork()->getIdentityMap(); $identityMap = $this->_em->getUnitOfWork()->getIdentityMap();
$identityMapCount = count($identityMap['Doctrine\Tests\Models\CMS\CmsArticle']); $identityMapCount = count($identityMap[CmsArticle::class]);
$this->assertTrue($identityMapCount>$iteratedCount); $this->assertTrue($identityMapCount>$iteratedCount);
$iteratedCount++; $iteratedCount++;
@ -417,14 +418,14 @@ class QueryTest extends OrmFunctionalTestCase
$this->_em->clear(); $this->_em->clear();
//$this->_em->getConnection()->getConfiguration()->setSQLLogger(new \Doctrine\DBAL\Logging\EchoSQLLogger); //$this->_em->getConnection()->getConfiguration()->setSQLLogger(new \Doctrine\DBAL\Logging\EchoSQLLogger);
$q = $this->_em->createQuery("select a from Doctrine\Tests\Models\CMS\CmsArticle a where a.topic = :topic and a.user = :user") $q = $this->_em->createQuery("select a from Doctrine\Tests\Models\CMS\CmsArticle a where a.topic = :topic and a.user = :user")
->setParameter("user", $this->_em->getReference('Doctrine\Tests\Models\CMS\CmsUser', $author->id)) ->setParameter("user", $this->_em->getReference(CmsUser::class, $author->id))
->setParameter("topic", "dr. dolittle"); ->setParameter("topic", "dr. dolittle");
$result = $q->getResult(); $result = $q->getResult();
$this->assertEquals(1, count($result)); $this->assertEquals(1, count($result));
$this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsArticle', $result[0]); $this->assertInstanceOf(CmsArticle::class, $result[0]);
$this->assertEquals("dr. dolittle", $result[0]->topic); $this->assertEquals("dr. dolittle", $result[0]->topic);
$this->assertInstanceOf('Doctrine\ORM\Proxy\Proxy', $result[0]->user); $this->assertInstanceOf(Proxy::class, $result[0]->user);
$this->assertFalse($result[0]->user->__isInitialized__); $this->assertFalse($result[0]->user->__isInitialized__);
} }
@ -449,12 +450,12 @@ class QueryTest extends OrmFunctionalTestCase
$this->_em->clear(); $this->_em->clear();
$articles = $this->_em->createQuery('select a from Doctrine\Tests\Models\CMS\CmsArticle a') $articles = $this->_em->createQuery('select a from Doctrine\Tests\Models\CMS\CmsArticle a')
->setFetchMode('Doctrine\Tests\Models\CMS\CmsArticle', 'user', ClassMetadata::FETCH_EAGER) ->setFetchMode(CmsArticle::class, 'user', ClassMetadata::FETCH_EAGER)
->getResult(); ->getResult();
$this->assertEquals(10, count($articles)); $this->assertEquals(10, count($articles));
foreach ($articles AS $article) { foreach ($articles AS $article) {
$this->assertNotInstanceOf('Doctrine\ORM\Proxy\Proxy', $article); $this->assertNotInstanceOf(Proxy::class, $article);
} }
} }
@ -474,7 +475,7 @@ class QueryTest extends OrmFunctionalTestCase
$query = $this->_em->createQuery("select u from Doctrine\Tests\Models\CMS\CmsUser u where u.username = 'gblanco'"); $query = $this->_em->createQuery("select u from Doctrine\Tests\Models\CMS\CmsUser u where u.username = 'gblanco'");
$fetchedUser = $query->getOneOrNullResult(); $fetchedUser = $query->getOneOrNullResult();
$this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsUser', $fetchedUser); $this->assertInstanceOf(CmsUser::class, $fetchedUser);
$this->assertEquals('gblanco', $fetchedUser->username); $this->assertEquals('gblanco', $fetchedUser->username);
$query = $this->_em->createQuery("select u.username from Doctrine\Tests\Models\CMS\CmsUser u where u.username = 'gblanco'"); $query = $this->_em->createQuery("select u.username from Doctrine\Tests\Models\CMS\CmsUser u where u.username = 'gblanco'");
@ -592,7 +593,7 @@ class QueryTest extends OrmFunctionalTestCase
{ {
$qb = $this->_em->createQueryBuilder(); $qb = $this->_em->createQueryBuilder();
$qb->select('u') $qb->select('u')
->from('Doctrine\Tests\Models\CMS\CmsUser', 'u') ->from(CmsUser::class, 'u')
->innerJoin('u.articles', 'a') ->innerJoin('u.articles', 'a')
->where('(u.id = 0) OR (u.id IS NULL)'); ->where('(u.id = 0) OR (u.id IS NULL)');
@ -661,7 +662,7 @@ class QueryTest extends OrmFunctionalTestCase
$users = $query->execute(); $users = $query->execute();
$this->assertEquals(3, count($users)); $this->assertEquals(3, count($users));
$this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsUser', $users[0]); $this->assertInstanceOf(CmsUser::class, $users[0]);
} }
/** /**
@ -724,9 +725,9 @@ class QueryTest extends OrmFunctionalTestCase
$users = $q->execute(); $users = $q->execute();
$this->assertEquals(3, count($users)); $this->assertEquals(3, count($users));
$this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsUser', $users[0]); $this->assertInstanceOf(CmsUser::class, $users[0]);
$this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsUser', $users[1]); $this->assertInstanceOf(CmsUser::class, $users[1]);
$this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsUser', $users[2]); $this->assertInstanceOf(CmsUser::class, $users[2]);
$resultUser1 = $users[0]; $resultUser1 = $users[0];
$resultUser2 = $users[1]; $resultUser2 = $users[1];
@ -802,8 +803,8 @@ class QueryTest extends OrmFunctionalTestCase
$users = $query->execute(); $users = $query->execute();
$this->assertEquals(2, count($users)); $this->assertEquals(2, count($users));
$this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsUser', $users[0]); $this->assertInstanceOf(CmsUser::class, $users[0]);
$this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsPhonenumber', $users[1]); $this->assertInstanceOf(CmsPhonenumber::class, $users[1]);
} }
public function testMultipleJoinComponentsUsingLeftJoin() public function testMultipleJoinComponentsUsingLeftJoin()
@ -835,9 +836,9 @@ class QueryTest extends OrmFunctionalTestCase
$users = $query->execute(); $users = $query->execute();
$this->assertEquals(4, count($users)); $this->assertEquals(4, count($users));
$this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsUser', $users[0]); $this->assertInstanceOf(CmsUser::class, $users[0]);
$this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsPhonenumber', $users[1]); $this->assertInstanceOf(CmsPhonenumber::class, $users[1]);
$this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsUser', $users[2]); $this->assertInstanceOf(CmsUser::class, $users[2]);
$this->assertNull($users[3]); $this->assertNull($users[3]);
} }
} }

View File

@ -1,6 +1,7 @@
<?php <?php
namespace Doctrine\Tests\ORM\Functional; namespace Doctrine\Tests\ORM\Functional;
use Doctrine\Tests\OrmFunctionalTestCase; use Doctrine\Tests\OrmFunctionalTestCase;
/** /**
@ -17,7 +18,7 @@ class ReadOnlyTest extends OrmFunctionalTestCase
try { try {
$this->_schemaTool->createSchema( $this->_schemaTool->createSchema(
[ [
$this->_em->getClassMetadata('Doctrine\Tests\ORM\Functional\ReadOnlyEntity'), $this->_em->getClassMetadata(ReadOnlyEntity::class),
] ]
); );
} catch(\Exception $e) { } catch(\Exception $e) {
@ -36,7 +37,7 @@ class ReadOnlyTest extends OrmFunctionalTestCase
$this->_em->flush(); $this->_em->flush();
$this->_em->clear(); $this->_em->clear();
$dbReadOnly = $this->_em->find('Doctrine\Tests\ORM\Functional\ReadOnlyEntity', $readOnly->id); $dbReadOnly = $this->_em->find(ReadOnlyEntity::class, $readOnly->id);
$this->assertEquals("Test1", $dbReadOnly->name); $this->assertEquals("Test1", $dbReadOnly->name);
$this->assertEquals(1234, $dbReadOnly->numericValue); $this->assertEquals(1234, $dbReadOnly->numericValue);
} }

View File

@ -2,12 +2,12 @@
namespace Doctrine\Tests\ORM\Functional; namespace Doctrine\Tests\ORM\Functional;
use Doctrine\Common\Persistence\Proxy;
use Doctrine\Common\Util\ClassUtils; use Doctrine\Common\Util\ClassUtils;
use Doctrine\ORM\Proxy\ProxyFactory; use Doctrine\ORM\Proxy\ProxyFactory;
use Doctrine\ORM\Proxy\ProxyClassGenerator; use Doctrine\Tests\Models\Company\CompanyAuction;
use Doctrine\Tests\Models\ECommerce\ECommerceProduct; use Doctrine\Tests\Models\ECommerce\ECommerceProduct;
use Doctrine\Tests\Models\ECommerce\ECommerceShipping; use Doctrine\Tests\Models\ECommerce\ECommerceShipping;
use Doctrine\Tests\Models\Company\CompanyAuction;
use Doctrine\Tests\OrmFunctionalTestCase; use Doctrine\Tests\OrmFunctionalTestCase;
/** /**
@ -57,7 +57,7 @@ class ReferenceProxyTest extends OrmFunctionalTestCase
{ {
$id = $this->createProduct(); $id = $this->createProduct();
$productProxy = $this->_em->getReference('Doctrine\Tests\Models\ECommerce\ECommerceProduct', ['id' => $id]); $productProxy = $this->_em->getReference(ECommerceProduct::class, ['id' => $id]);
$this->assertEquals('Doctrine Cookbook', $productProxy->getName()); $this->assertEquals('Doctrine Cookbook', $productProxy->getName());
} }
@ -68,10 +68,10 @@ class ReferenceProxyTest extends OrmFunctionalTestCase
{ {
$id = $this->createProduct(); $id = $this->createProduct();
$entity = $this->_em->getReference('Doctrine\Tests\Models\ECommerce\ECommerceProduct' , $id); $entity = $this->_em->getReference(ECommerceProduct::class , $id);
$class = $this->_em->getClassMetadata(get_class($entity)); $class = $this->_em->getClassMetadata(get_class($entity));
$this->assertEquals('Doctrine\Tests\Models\ECommerce\ECommerceProduct', $class->name); $this->assertEquals(ECommerceProduct::class, $class->name);
} }
/** /**
@ -81,8 +81,8 @@ class ReferenceProxyTest extends OrmFunctionalTestCase
{ {
$id = $this->createProduct(); $id = $this->createProduct();
$entity = $this->_em->getReference('Doctrine\Tests\Models\ECommerce\ECommerceProduct' , $id); $entity = $this->_em->getReference(ECommerceProduct::class , $id);
$entity2 = $this->_em->find('Doctrine\Tests\Models\ECommerce\ECommerceProduct' , $id); $entity2 = $this->_em->find(ECommerceProduct::class , $id);
$this->assertSame($entity, $entity2); $this->assertSame($entity, $entity2);
$this->assertEquals('Doctrine Cookbook', $entity2->getName()); $this->assertEquals('Doctrine Cookbook', $entity2->getName());
@ -95,10 +95,10 @@ class ReferenceProxyTest extends OrmFunctionalTestCase
{ {
$id = $this->createProduct(); $id = $this->createProduct();
/* @var $entity Doctrine\Tests\Models\ECommerce\ECommerceProduct */ /* @var $entity ECommerceProduct */
$entity = $this->_em->getReference('Doctrine\Tests\Models\ECommerce\ECommerceProduct' , $id); $entity = $this->_em->getReference(ECommerceProduct::class , $id);
/* @var $clone Doctrine\Tests\Models\ECommerce\ECommerceProduct */ /* @var $clone ECommerceProduct */
$clone = clone $entity; $clone = clone $entity;
$this->assertEquals($id, $entity->getId()); $this->assertEquals($id, $entity->getId());
@ -120,8 +120,8 @@ class ReferenceProxyTest extends OrmFunctionalTestCase
{ {
$id = $this->createProduct(); $id = $this->createProduct();
/* @var $entity Doctrine\Tests\Models\ECommerce\ECommerceProduct */ /* @var $entity ECommerceProduct */
$entity = $this->_em->getReference('Doctrine\Tests\Models\ECommerce\ECommerceProduct' , $id); $entity = $this->_em->getReference(ECommerceProduct::class , $id);
$this->assertFalse($entity->__isInitialized__, "Pre-Condition: Object is unitialized proxy."); $this->assertFalse($entity->__isInitialized__, "Pre-Condition: Object is unitialized proxy.");
$this->_em->getUnitOfWork()->initializeObject($entity); $this->_em->getUnitOfWork()->initializeObject($entity);
@ -135,14 +135,14 @@ class ReferenceProxyTest extends OrmFunctionalTestCase
{ {
$id = $this->createProduct(); $id = $this->createProduct();
/* @var $entity Doctrine\Tests\Models\ECommerce\ECommerceProduct */ /* @var $entity ECommerceProduct */
$entity = $this->_em->getReference('Doctrine\Tests\Models\ECommerce\ECommerceProduct' , $id); $entity = $this->_em->getReference(ECommerceProduct::class , $id);
$entity->setName('Doctrine 2 Cookbook'); $entity->setName('Doctrine 2 Cookbook');
$this->_em->flush(); $this->_em->flush();
$this->_em->clear(); $this->_em->clear();
$entity = $this->_em->getReference('Doctrine\Tests\Models\ECommerce\ECommerceProduct' , $id); $entity = $this->_em->getReference(ECommerceProduct::class , $id);
$this->assertEquals('Doctrine 2 Cookbook', $entity->getName()); $this->assertEquals('Doctrine 2 Cookbook', $entity->getName());
} }
@ -153,8 +153,8 @@ class ReferenceProxyTest extends OrmFunctionalTestCase
{ {
$id = $this->createProduct(); $id = $this->createProduct();
/* @var $entity Doctrine\Tests\Models\ECommerce\ECommerceProduct */ /* @var $entity ECommerceProduct */
$entity = $this->_em->getReference('Doctrine\Tests\Models\ECommerce\ECommerceProduct' , $id); $entity = $this->_em->getReference(ECommerceProduct::class , $id);
$this->assertFalse($entity->wakeUp); $this->assertFalse($entity->wakeUp);
@ -167,8 +167,8 @@ class ReferenceProxyTest extends OrmFunctionalTestCase
{ {
$id = $this->createProduct(); $id = $this->createProduct();
/* @var $entity Doctrine\Tests\Models\ECommerce\ECommerceProduct */ /* @var $entity ECommerceProduct */
$entity = $this->_em->getReference('Doctrine\Tests\Models\ECommerce\ECommerceProduct' , $id); $entity = $this->_em->getReference(ECommerceProduct::class , $id);
$this->assertFalse($entity->__isInitialized__, "Pre-Condition: Object is unitialized proxy."); $this->assertFalse($entity->__isInitialized__, "Pre-Condition: Object is unitialized proxy.");
$this->assertEquals($id, $entity->getId()); $this->assertEquals($id, $entity->getId());
@ -182,8 +182,8 @@ class ReferenceProxyTest extends OrmFunctionalTestCase
{ {
$id = $this->createAuction(); $id = $this->createAuction();
/* @var $entity Doctrine\Tests\Models\Company\CompanyAuction */ /* @var $entity CompanyAuction */
$entity = $this->_em->getReference('Doctrine\Tests\Models\Company\CompanyAuction' , $id); $entity = $this->_em->getReference(CompanyAuction::class , $id);
$this->assertFalse($entity->__isInitialized__, "Pre-Condition: Object is unitialized proxy."); $this->assertFalse($entity->__isInitialized__, "Pre-Condition: Object is unitialized proxy.");
$this->assertEquals($id, $entity->getId()); $this->assertEquals($id, $entity->getId());
@ -204,7 +204,7 @@ class ReferenceProxyTest extends OrmFunctionalTestCase
$id = $shipping->getId(); $id = $shipping->getId();
$product = $this->_em->getRepository('Doctrine\Tests\Models\ECommerce\ECommerceProduct')->find($product->getId()); $product = $this->_em->getRepository(ECommerceProduct::class)->find($product->getId());
$entity = $product->getShipping(); $entity = $product->getShipping();
$this->assertFalse($entity->__isInitialized__, "Pre-Condition: Object is unitialized proxy."); $this->assertFalse($entity->__isInitialized__, "Pre-Condition: Object is unitialized proxy.");
@ -217,8 +217,8 @@ class ReferenceProxyTest extends OrmFunctionalTestCase
{ {
$id = $this->createProduct(); $id = $this->createProduct();
/* @var $entity Doctrine\Tests\Models\ECommerce\ECommerceProduct */ /* @var $entity ECommerceProduct */
$entity = $this->_em->getReference('Doctrine\Tests\Models\ECommerce\ECommerceProduct' , $id); $entity = $this->_em->getReference(ECommerceProduct::class , $id);
$this->assertFalse($entity->__isInitialized__, "Pre-Condition: Object is unitialized proxy."); $this->assertFalse($entity->__isInitialized__, "Pre-Condition: Object is unitialized proxy.");
$this->assertEquals('Doctrine Cookbook', $entity->getName()); $this->assertEquals('Doctrine Cookbook', $entity->getName());
@ -233,12 +233,12 @@ class ReferenceProxyTest extends OrmFunctionalTestCase
$id = $this->createProduct(); $id = $this->createProduct();
/* @var $entity ECommerceProduct */ /* @var $entity ECommerceProduct */
$entity = $this->_em->getReference('Doctrine\Tests\Models\ECommerce\ECommerceProduct' , $id); $entity = $this->_em->getReference(ECommerceProduct::class , $id);
$className = ClassUtils::getClass($entity); $className = ClassUtils::getClass($entity);
$this->assertInstanceOf('Doctrine\Common\Persistence\Proxy', $entity); $this->assertInstanceOf(Proxy::class, $entity);
$this->assertFalse($entity->__isInitialized()); $this->assertFalse($entity->__isInitialized());
$this->assertEquals('Doctrine\Tests\Models\ECommerce\ECommerceProduct', $className); $this->assertEquals(ECommerceProduct::class, $className);
$restName = str_replace($this->_em->getConfiguration()->getProxyNamespace(), "", get_class($entity)); $restName = str_replace($this->_em->getConfiguration()->getProxyNamespace(), "", get_class($entity));
$restName = substr(get_class($entity), strlen($this->_em->getConfiguration()->getProxyNamespace()) +1); $restName = substr(get_class($entity), strlen($this->_em->getConfiguration()->getProxyNamespace()) +1);

View File

@ -22,7 +22,7 @@ class ResultCacheTest extends OrmFunctionalTestCase
private $cacheDataReflection; private $cacheDataReflection;
protected function setUp() { protected function setUp() {
$this->cacheDataReflection = new \ReflectionProperty("Doctrine\Common\Cache\ArrayCache", "data"); $this->cacheDataReflection = new \ReflectionProperty(ArrayCache::class, "data");
$this->cacheDataReflection->setAccessible(true); $this->cacheDataReflection->setAccessible(true);
$this->useModelSet('cms'); $this->useModelSet('cms');
parent::setUp(); parent::setUp();

View File

@ -2,26 +2,27 @@
namespace Doctrine\Tests\ORM\Functional; namespace Doctrine\Tests\ORM\Functional;
use Doctrine\Common\Cache\ArrayCache;
use Doctrine\DBAL\Connection;
use Doctrine\DBAL\Types\Type as DBALType; use Doctrine\DBAL\Types\Type as DBALType;
use Doctrine\ORM\Configuration; use Doctrine\ORM\Configuration;
use Doctrine\ORM\Query\Filter\SQLFilter; use Doctrine\ORM\EntityManager;
use Doctrine\ORM\Mapping\ClassMetadata; use Doctrine\ORM\Mapping\ClassMetadata;
use Doctrine\Common\Cache\ArrayCache;
use Doctrine\ORM\Mapping\ClassMetadataInfo; use Doctrine\ORM\Mapping\ClassMetadataInfo;
use Doctrine\ORM\Query\Filter\SQLFilter;
use Doctrine\Tests\Models\CMS\CmsUser; use Doctrine\ORM\Query\FilterCollection;
use Doctrine\Tests\Models\CMS\CmsAddress; use Doctrine\Tests\Models\CMS\CmsAddress;
use Doctrine\Tests\Models\CMS\CmsGroup;
use Doctrine\Tests\Models\CMS\CmsArticle; use Doctrine\Tests\Models\CMS\CmsArticle;
use Doctrine\Tests\Models\CMS\CmsGroup;
use Doctrine\Tests\Models\Company\CompanyPerson; use Doctrine\Tests\Models\CMS\CmsUser;
use Doctrine\Tests\Models\Company\CompanyManager;
use Doctrine\Tests\Models\Company\CompanyOrganization;
use Doctrine\Tests\Models\Company\CompanyAuction; use Doctrine\Tests\Models\Company\CompanyAuction;
use Doctrine\Tests\Models\Company\CompanyContract;
use Doctrine\Tests\Models\Company\CompanyEvent;
use Doctrine\Tests\Models\Company\CompanyFlexContract; use Doctrine\Tests\Models\Company\CompanyFlexContract;
use Doctrine\Tests\Models\Company\CompanyFlexUltraContract; use Doctrine\Tests\Models\Company\CompanyFlexUltraContract;
use Doctrine\Tests\Models\Company\CompanyManager;
use Doctrine\Tests\Models\Company\CompanyOrganization;
use Doctrine\Tests\Models\Company\CompanyPerson;
use Doctrine\Tests\OrmFunctionalTestCase; use Doctrine\Tests\OrmFunctionalTestCase;
/** /**
@ -49,7 +50,7 @@ class SQLFilterTest extends OrmFunctionalTestCase
{ {
parent::tearDown(); parent::tearDown();
$class = $this->_em->getClassMetadata('Doctrine\Tests\Models\CMS\CmsUser'); $class = $this->_em->getClassMetadata(CmsUser::class);
$class->associationMappings['groups']['fetch'] = ClassMetadataInfo::FETCH_LAZY; $class->associationMappings['groups']['fetch'] = ClassMetadataInfo::FETCH_LAZY;
$class->associationMappings['articles']['fetch'] = ClassMetadataInfo::FETCH_LAZY; $class->associationMappings['articles']['fetch'] = ClassMetadataInfo::FETCH_LAZY;
} }
@ -186,7 +187,7 @@ class SQLFilterTest extends OrmFunctionalTestCase
protected function getMockConnection() protected function getMockConnection()
{ {
// Setup connection mock // Setup connection mock
$conn = $this->getMockBuilder('Doctrine\DBAL\Connection') $conn = $this->getMockBuilder(Connection::class)
->disableOriginalConstructor() ->disableOriginalConstructor()
->getMock(); ->getMock();
@ -196,7 +197,7 @@ class SQLFilterTest extends OrmFunctionalTestCase
protected function getMockEntityManager() protected function getMockEntityManager()
{ {
// Setup connection mock // Setup connection mock
$em = $this->getMockBuilder('Doctrine\ORM\EntityManager') $em = $this->getMockBuilder(EntityManager::class)
->disableOriginalConstructor() ->disableOriginalConstructor()
->getMock(); ->getMock();
@ -205,7 +206,7 @@ class SQLFilterTest extends OrmFunctionalTestCase
protected function addMockFilterCollection($em) protected function addMockFilterCollection($em)
{ {
$filterCollection = $this->getMockBuilder('Doctrine\ORM\Query\FilterCollection') $filterCollection = $this->getMockBuilder(FilterCollection::class)
->disableOriginalConstructor() ->disableOriginalConstructor()
->getMock(); ->getMock();
@ -258,7 +259,7 @@ class SQLFilterTest extends OrmFunctionalTestCase
$filter = new MyLocaleFilter($em); $filter = new MyLocaleFilter($em);
$reflMethod = new \ReflectionMethod('Doctrine\ORM\Query\Filter\SQLFilter', 'getConnection'); $reflMethod = new \ReflectionMethod(SQLFilter::class, 'getConnection');
$reflMethod->setAccessible(true); $reflMethod->setAccessible(true);
$this->assertSame($conn, $reflMethod->invoke($filter)); $this->assertSame($conn, $reflMethod->invoke($filter));
@ -293,7 +294,7 @@ class SQLFilterTest extends OrmFunctionalTestCase
public function testSQLFilterAddConstraint() public function testSQLFilterAddConstraint()
{ {
// Set up metadata mock // Set up metadata mock
$targetEntity = $this->getMockBuilder('Doctrine\ORM\Mapping\ClassMetadata') $targetEntity = $this->getMockBuilder(ClassMetadata::class)
->disableOriginalConstructor() ->disableOriginalConstructor()
->getMock(); ->getMock();
@ -333,7 +334,7 @@ class SQLFilterTest extends OrmFunctionalTestCase
public function testQueryCache_DependsOnFilters() public function testQueryCache_DependsOnFilters()
{ {
$cacheDataReflection = new \ReflectionProperty("Doctrine\Common\Cache\ArrayCache", "data"); $cacheDataReflection = new \ReflectionProperty(ArrayCache::class, "data");
$cacheDataReflection->setAccessible(true); $cacheDataReflection->setAccessible(true);
$query = $this->_em->createQuery('select ux from Doctrine\Tests\Models\CMS\CmsUser ux'); $query = $this->_em->createQuery('select ux from Doctrine\Tests\Models\CMS\CmsUser ux');
@ -373,40 +374,40 @@ class SQLFilterTest extends OrmFunctionalTestCase
{ {
$this->loadFixtureData(); $this->loadFixtureData();
$this->assertNotNull($this->_em->getRepository('Doctrine\Tests\Models\CMS\CmsGroup')->find($this->groupId)); $this->assertNotNull($this->_em->getRepository(CmsGroup::class)->find($this->groupId));
$this->assertNotNull($this->_em->getRepository('Doctrine\Tests\Models\CMS\CmsGroup')->find($this->groupId2)); $this->assertNotNull($this->_em->getRepository(CmsGroup::class)->find($this->groupId2));
$this->useCMSGroupPrefixFilter(); $this->useCMSGroupPrefixFilter();
$this->_em->clear(); $this->_em->clear();
$this->assertNotNull($this->_em->getRepository('Doctrine\Tests\Models\CMS\CmsGroup')->find($this->groupId)); $this->assertNotNull($this->_em->getRepository(CmsGroup::class)->find($this->groupId));
$this->assertNull($this->_em->getRepository('Doctrine\Tests\Models\CMS\CmsGroup')->find($this->groupId2)); $this->assertNull($this->_em->getRepository(CmsGroup::class)->find($this->groupId2));
} }
public function testRepositoryFindAll() public function testRepositoryFindAll()
{ {
$this->loadFixtureData(); $this->loadFixtureData();
$this->assertCount(2, $this->_em->getRepository('Doctrine\Tests\Models\CMS\CmsGroup')->findAll()); $this->assertCount(2, $this->_em->getRepository(CmsGroup::class)->findAll());
$this->useCMSGroupPrefixFilter(); $this->useCMSGroupPrefixFilter();
$this->_em->clear(); $this->_em->clear();
$this->assertCount(1, $this->_em->getRepository('Doctrine\Tests\Models\CMS\CmsGroup')->findAll()); $this->assertCount(1, $this->_em->getRepository(CmsGroup::class)->findAll());
} }
public function testRepositoryFindBy() public function testRepositoryFindBy()
{ {
$this->loadFixtureData(); $this->loadFixtureData();
$this->assertCount(1, $this->_em->getRepository('Doctrine\Tests\Models\CMS\CmsGroup')->findBy( $this->assertCount(1, $this->_em->getRepository(CmsGroup::class)->findBy(
['id' => $this->groupId2] ['id' => $this->groupId2]
)); ));
$this->useCMSGroupPrefixFilter(); $this->useCMSGroupPrefixFilter();
$this->_em->clear(); $this->_em->clear();
$this->assertCount(0, $this->_em->getRepository('Doctrine\Tests\Models\CMS\CmsGroup')->findBy( $this->assertCount(0, $this->_em->getRepository(CmsGroup::class)->findBy(
['id' => $this->groupId2] ['id' => $this->groupId2]
)); ));
} }
@ -415,26 +416,26 @@ class SQLFilterTest extends OrmFunctionalTestCase
{ {
$this->loadFixtureData(); $this->loadFixtureData();
$this->assertCount(1, $this->_em->getRepository('Doctrine\Tests\Models\CMS\CmsGroup')->findById($this->groupId2)); $this->assertCount(1, $this->_em->getRepository(CmsGroup::class)->findById($this->groupId2));
$this->useCMSGroupPrefixFilter(); $this->useCMSGroupPrefixFilter();
$this->_em->clear(); $this->_em->clear();
$this->assertCount(0, $this->_em->getRepository('Doctrine\Tests\Models\CMS\CmsGroup')->findById($this->groupId2)); $this->assertCount(0, $this->_em->getRepository(CmsGroup::class)->findById($this->groupId2));
} }
public function testRepositoryFindOneBy() public function testRepositoryFindOneBy()
{ {
$this->loadFixtureData(); $this->loadFixtureData();
$this->assertNotNull($this->_em->getRepository('Doctrine\Tests\Models\CMS\CmsGroup')->findOneBy( $this->assertNotNull($this->_em->getRepository(CmsGroup::class)->findOneBy(
['id' => $this->groupId2] ['id' => $this->groupId2]
)); ));
$this->useCMSGroupPrefixFilter(); $this->useCMSGroupPrefixFilter();
$this->_em->clear(); $this->_em->clear();
$this->assertNull($this->_em->getRepository('Doctrine\Tests\Models\CMS\CmsGroup')->findOneBy( $this->assertNull($this->_em->getRepository(CmsGroup::class)->findOneBy(
['id' => $this->groupId2] ['id' => $this->groupId2]
)); ));
} }
@ -443,12 +444,12 @@ class SQLFilterTest extends OrmFunctionalTestCase
{ {
$this->loadFixtureData(); $this->loadFixtureData();
$this->assertNotNull($this->_em->getRepository('Doctrine\Tests\Models\CMS\CmsGroup')->findOneById($this->groupId2)); $this->assertNotNull($this->_em->getRepository(CmsGroup::class)->findOneById($this->groupId2));
$this->useCMSGroupPrefixFilter(); $this->useCMSGroupPrefixFilter();
$this->_em->clear(); $this->_em->clear();
$this->assertNull($this->_em->getRepository('Doctrine\Tests\Models\CMS\CmsGroup')->findOneById($this->groupId2)); $this->assertNull($this->_em->getRepository(CmsGroup::class)->findOneById($this->groupId2));
} }
public function testToOneFilter() public function testToOneFilter()
@ -521,7 +522,7 @@ class SQLFilterTest extends OrmFunctionalTestCase
private function loadLazyFixtureData() private function loadLazyFixtureData()
{ {
$class = $this->_em->getClassMetadata('Doctrine\Tests\Models\CMS\CmsUser'); $class = $this->_em->getClassMetadata(CmsUser::class);
$class->associationMappings['articles']['fetch'] = ClassMetadataInfo::FETCH_EXTRA_LAZY; $class->associationMappings['articles']['fetch'] = ClassMetadataInfo::FETCH_EXTRA_LAZY;
$class->associationMappings['groups']['fetch'] = ClassMetadataInfo::FETCH_EXTRA_LAZY; $class->associationMappings['groups']['fetch'] = ClassMetadataInfo::FETCH_EXTRA_LAZY;
$this->loadFixtureData(); $this->loadFixtureData();
@ -537,7 +538,7 @@ class SQLFilterTest extends OrmFunctionalTestCase
public function testOneToMany_ExtraLazyCountWithFilter() public function testOneToMany_ExtraLazyCountWithFilter()
{ {
$this->loadLazyFixtureData(); $this->loadLazyFixtureData();
$user = $this->_em->find('Doctrine\Tests\Models\CMS\CmsUser', $this->userId); $user = $this->_em->find(CmsUser::class, $this->userId);
$this->assertFalse($user->articles->isInitialized()); $this->assertFalse($user->articles->isInitialized());
$this->assertEquals(2, count($user->articles)); $this->assertEquals(2, count($user->articles));
@ -550,8 +551,8 @@ class SQLFilterTest extends OrmFunctionalTestCase
public function testOneToMany_ExtraLazyContainsWithFilter() public function testOneToMany_ExtraLazyContainsWithFilter()
{ {
$this->loadLazyFixtureData(); $this->loadLazyFixtureData();
$user = $this->_em->find('Doctrine\Tests\Models\CMS\CmsUser', $this->userId); $user = $this->_em->find(CmsUser::class, $this->userId);
$filteredArticle = $this->_em->find('Doctrine\Tests\Models\CMS\CmsArticle', $this->articleId2); $filteredArticle = $this->_em->find(CmsArticle::class, $this->articleId2);
$this->assertFalse($user->articles->isInitialized()); $this->assertFalse($user->articles->isInitialized());
$this->assertTrue($user->articles->contains($filteredArticle)); $this->assertTrue($user->articles->contains($filteredArticle));
@ -564,7 +565,7 @@ class SQLFilterTest extends OrmFunctionalTestCase
public function testOneToMany_ExtraLazySliceWithFilter() public function testOneToMany_ExtraLazySliceWithFilter()
{ {
$this->loadLazyFixtureData(); $this->loadLazyFixtureData();
$user = $this->_em->find('Doctrine\Tests\Models\CMS\CmsUser', $this->userId); $user = $this->_em->find(CmsUser::class, $this->userId);
$this->assertFalse($user->articles->isInitialized()); $this->assertFalse($user->articles->isInitialized());
$this->assertEquals(2, count($user->articles->slice(0,10))); $this->assertEquals(2, count($user->articles->slice(0,10)));
@ -585,7 +586,7 @@ class SQLFilterTest extends OrmFunctionalTestCase
{ {
$this->loadLazyFixtureData(); $this->loadLazyFixtureData();
$user = $this->_em->find('Doctrine\Tests\Models\CMS\CmsUser', $this->userId2); $user = $this->_em->find(CmsUser::class, $this->userId2);
$this->assertFalse($user->groups->isInitialized()); $this->assertFalse($user->groups->isInitialized());
$this->assertEquals(2, count($user->groups)); $this->assertEquals(2, count($user->groups));
@ -598,8 +599,8 @@ class SQLFilterTest extends OrmFunctionalTestCase
public function testManyToMany_ExtraLazyContainsWithFilter() public function testManyToMany_ExtraLazyContainsWithFilter()
{ {
$this->loadLazyFixtureData(); $this->loadLazyFixtureData();
$user = $this->_em->find('Doctrine\Tests\Models\CMS\CmsUser', $this->userId2); $user = $this->_em->find(CmsUser::class, $this->userId2);
$filteredArticle = $this->_em->find('Doctrine\Tests\Models\CMS\CmsGroup', $this->groupId2); $filteredArticle = $this->_em->find(CmsGroup::class, $this->groupId2);
$this->assertFalse($user->groups->isInitialized()); $this->assertFalse($user->groups->isInitialized());
$this->assertTrue($user->groups->contains($filteredArticle)); $this->assertTrue($user->groups->contains($filteredArticle));
@ -612,7 +613,7 @@ class SQLFilterTest extends OrmFunctionalTestCase
public function testManyToMany_ExtraLazySliceWithFilter() public function testManyToMany_ExtraLazySliceWithFilter()
{ {
$this->loadLazyFixtureData(); $this->loadLazyFixtureData();
$user = $this->_em->find('Doctrine\Tests\Models\CMS\CmsUser', $this->userId2); $user = $this->_em->find(CmsUser::class, $this->userId2);
$this->assertFalse($user->groups->isInitialized()); $this->assertFalse($user->groups->isInitialized());
$this->assertEquals(2, count($user->groups->slice(0,10))); $this->assertEquals(2, count($user->groups->slice(0,10)));
@ -690,14 +691,14 @@ class SQLFilterTest extends OrmFunctionalTestCase
{ {
$this->loadCompanyJoinedSubclassFixtureData(); $this->loadCompanyJoinedSubclassFixtureData();
// Persister // Persister
$this->assertEquals(2, count($this->_em->getRepository('Doctrine\Tests\Models\Company\CompanyManager')->findAll())); $this->assertEquals(2, count($this->_em->getRepository(CompanyManager::class)->findAll()));
// SQLWalker // SQLWalker
$this->assertEquals(2, count($this->_em->createQuery("SELECT cm FROM Doctrine\Tests\Models\Company\CompanyManager cm")->getResult())); $this->assertEquals(2, count($this->_em->createQuery("SELECT cm FROM Doctrine\Tests\Models\Company\CompanyManager cm")->getResult()));
// Enable the filter // Enable the filter
$this->usePersonNameFilter('Guilh%'); $this->usePersonNameFilter('Guilh%');
$managers = $this->_em->getRepository('Doctrine\Tests\Models\Company\CompanyManager')->findAll(); $managers = $this->_em->getRepository(CompanyManager::class)->findAll();
$this->assertEquals(1, count($managers)); $this->assertEquals(1, count($managers));
$this->assertEquals("Guilherme", $managers[0]->getName()); $this->assertEquals("Guilherme", $managers[0]->getName());
@ -707,13 +708,13 @@ class SQLFilterTest extends OrmFunctionalTestCase
public function testJoinSubclassPersister_FilterOnlyOnRootTableWhenFetchingRootEntity() public function testJoinSubclassPersister_FilterOnlyOnRootTableWhenFetchingRootEntity()
{ {
$this->loadCompanyJoinedSubclassFixtureData(); $this->loadCompanyJoinedSubclassFixtureData();
$this->assertEquals(3, count($this->_em->getRepository('Doctrine\Tests\Models\Company\CompanyPerson')->findAll())); $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())); $this->assertEquals(3, count($this->_em->createQuery("SELECT cp FROM Doctrine\Tests\Models\Company\CompanyPerson cp")->getResult()));
// Enable the filter // Enable the filter
$this->usePersonNameFilter('Guilh%'); $this->usePersonNameFilter('Guilh%');
$persons = $this->_em->getRepository('Doctrine\Tests\Models\Company\CompanyPerson')->findAll(); $persons = $this->_em->getRepository(CompanyPerson::class)->findAll();
$this->assertEquals(1, count($persons)); $this->assertEquals(1, count($persons));
$this->assertEquals("Guilherme", $persons[0]->getName()); $this->assertEquals("Guilherme", $persons[0]->getName());
@ -748,7 +749,7 @@ class SQLFilterTest extends OrmFunctionalTestCase
{ {
$this->loadCompanySingleTableInheritanceFixtureData(); $this->loadCompanySingleTableInheritanceFixtureData();
// Persister // Persister
$this->assertEquals(2, count($this->_em->getRepository('Doctrine\Tests\Models\Company\CompanyFlexUltraContract')->findAll())); $this->assertEquals(2, count($this->_em->getRepository(CompanyFlexUltraContract::class)->findAll()));
// SQLWalker // SQLWalker
$this->assertEquals(2, count($this->_em->createQuery("SELECT cfc FROM Doctrine\Tests\Models\Company\CompanyFlexUltraContract cfc")->getResult())); $this->assertEquals(2, count($this->_em->createQuery("SELECT cfc FROM Doctrine\Tests\Models\Company\CompanyFlexUltraContract cfc")->getResult()));
@ -759,14 +760,14 @@ class SQLFilterTest extends OrmFunctionalTestCase
->enable("completed_contract") ->enable("completed_contract")
->setParameter("completed", true, DBALType::BOOLEAN); ->setParameter("completed", true, DBALType::BOOLEAN);
$this->assertEquals(1, count($this->_em->getRepository('Doctrine\Tests\Models\Company\CompanyFlexUltraContract')->findAll())); $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())); $this->assertEquals(1, count($this->_em->createQuery("SELECT cfc FROM Doctrine\Tests\Models\Company\CompanyFlexUltraContract cfc")->getResult()));
} }
public function testSingleTableInheritance_FilterOnlyOnRootTableWhenFetchingRootEntity() public function testSingleTableInheritance_FilterOnlyOnRootTableWhenFetchingRootEntity()
{ {
$this->loadCompanySingleTableInheritanceFixtureData(); $this->loadCompanySingleTableInheritanceFixtureData();
$this->assertEquals(4, count($this->_em->getRepository('Doctrine\Tests\Models\Company\CompanyFlexContract')->findAll())); $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())); $this->assertEquals(4, count($this->_em->createQuery("SELECT cfc FROM Doctrine\Tests\Models\Company\CompanyFlexContract cfc")->getResult()));
// Enable the filter // Enable the filter
@ -776,7 +777,7 @@ class SQLFilterTest extends OrmFunctionalTestCase
->enable("completed_contract") ->enable("completed_contract")
->setParameter("completed", true, DBALType::BOOLEAN); ->setParameter("completed", true, DBALType::BOOLEAN);
$this->assertEquals(2, count($this->_em->getRepository('Doctrine\Tests\Models\Company\CompanyFlexContract')->findAll())); $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())); $this->assertEquals(2, count($this->_em->createQuery("SELECT cfc FROM Doctrine\Tests\Models\Company\CompanyFlexContract cfc")->getResult()));
} }
@ -840,7 +841,7 @@ class SQLFilterTest extends OrmFunctionalTestCase
{ {
$this->loadCompanySingleTableInheritanceFixtureData(); $this->loadCompanySingleTableInheritanceFixtureData();
$manager = $this->_em->find('Doctrine\Tests\Models\Company\CompanyManager', $this->managerId); $manager = $this->_em->find(CompanyManager::class, $this->managerId);
$this->assertFalse($manager->managedContracts->isInitialized()); $this->assertFalse($manager->managedContracts->isInitialized());
$this->assertEquals(4, count($manager->managedContracts)); $this->assertEquals(4, count($manager->managedContracts));
@ -856,9 +857,9 @@ class SQLFilterTest extends OrmFunctionalTestCase
{ {
$this->loadCompanySingleTableInheritanceFixtureData(); $this->loadCompanySingleTableInheritanceFixtureData();
$manager = $this->_em->find('Doctrine\Tests\Models\Company\CompanyManager', $this->managerId); $manager = $this->_em->find(CompanyManager::class, $this->managerId);
$contract1 = $this->_em->find('Doctrine\Tests\Models\Company\CompanyContract', $this->contractId1); $contract1 = $this->_em->find(CompanyContract::class, $this->contractId1);
$contract2 = $this->_em->find('Doctrine\Tests\Models\Company\CompanyContract', $this->contractId2); $contract2 = $this->_em->find(CompanyContract::class, $this->contractId2);
$this->assertFalse($manager->managedContracts->isInitialized()); $this->assertFalse($manager->managedContracts->isInitialized());
$this->assertTrue($manager->managedContracts->contains($contract1)); $this->assertTrue($manager->managedContracts->contains($contract1));
@ -876,7 +877,7 @@ class SQLFilterTest extends OrmFunctionalTestCase
{ {
$this->loadCompanySingleTableInheritanceFixtureData(); $this->loadCompanySingleTableInheritanceFixtureData();
$manager = $this->_em->find('Doctrine\Tests\Models\Company\CompanyManager', $this->managerId); $manager = $this->_em->find(CompanyManager::class, $this->managerId);
$this->assertFalse($manager->managedContracts->isInitialized()); $this->assertFalse($manager->managedContracts->isInitialized());
$this->assertEquals(4, count($manager->managedContracts->slice(0, 10))); $this->assertEquals(4, count($manager->managedContracts->slice(0, 10)));
@ -902,7 +903,7 @@ class SQLFilterTest extends OrmFunctionalTestCase
{ {
$this->loadCompanySingleTableInheritanceFixtureData(); $this->loadCompanySingleTableInheritanceFixtureData();
$contract = $this->_em->find('Doctrine\Tests\Models\Company\CompanyFlexUltraContract', $this->contractId1); $contract = $this->_em->find(CompanyFlexUltraContract::class, $this->contractId1);
$this->assertFalse($contract->managers->isInitialized()); $this->assertFalse($contract->managers->isInitialized());
$this->assertEquals(2, count($contract->managers)); $this->assertEquals(2, count($contract->managers));
@ -918,9 +919,9 @@ class SQLFilterTest extends OrmFunctionalTestCase
{ {
$this->loadCompanySingleTableInheritanceFixtureData(); $this->loadCompanySingleTableInheritanceFixtureData();
$contract = $this->_em->find('Doctrine\Tests\Models\Company\CompanyFlexUltraContract', $this->contractId1); $contract = $this->_em->find(CompanyFlexUltraContract::class, $this->contractId1);
$manager1 = $this->_em->find('Doctrine\Tests\Models\Company\CompanyManager', $this->managerId); $manager1 = $this->_em->find(CompanyManager::class, $this->managerId);
$manager2 = $this->_em->find('Doctrine\Tests\Models\Company\CompanyManager', $this->managerId2); $manager2 = $this->_em->find(CompanyManager::class, $this->managerId2);
$this->assertFalse($contract->managers->isInitialized()); $this->assertFalse($contract->managers->isInitialized());
$this->assertTrue($contract->managers->contains($manager1)); $this->assertTrue($contract->managers->contains($manager1));
@ -938,7 +939,7 @@ class SQLFilterTest extends OrmFunctionalTestCase
{ {
$this->loadCompanySingleTableInheritanceFixtureData(); $this->loadCompanySingleTableInheritanceFixtureData();
$contract = $this->_em->find('Doctrine\Tests\Models\Company\CompanyFlexUltraContract', $this->contractId1); $contract = $this->_em->find(CompanyFlexUltraContract::class, $this->contractId1);
$this->assertFalse($contract->managers->isInitialized()); $this->assertFalse($contract->managers->isInitialized());
$this->assertEquals(2, count($contract->managers->slice(0, 10))); $this->assertEquals(2, count($contract->managers->slice(0, 10)));
@ -954,7 +955,7 @@ class SQLFilterTest extends OrmFunctionalTestCase
{ {
$this->loadCompanySingleTableInheritanceFixtureData(); $this->loadCompanySingleTableInheritanceFixtureData();
$manager = $this->_em->find('Doctrine\Tests\Models\Company\CompanyManager', $this->managerId); $manager = $this->_em->find(CompanyManager::class, $this->managerId);
$this->assertFalse($manager->soldContracts->isInitialized()); $this->assertFalse($manager->soldContracts->isInitialized());
$this->assertEquals(2, count($manager->soldContracts)); $this->assertEquals(2, count($manager->soldContracts));
@ -970,9 +971,9 @@ class SQLFilterTest extends OrmFunctionalTestCase
{ {
$this->loadCompanySingleTableInheritanceFixtureData(); $this->loadCompanySingleTableInheritanceFixtureData();
$manager = $this->_em->find('Doctrine\Tests\Models\Company\CompanyManager', $this->managerId); $manager = $this->_em->find(CompanyManager::class, $this->managerId);
$contract1 = $this->_em->find('Doctrine\Tests\Models\Company\CompanyContract', $this->contractId1); $contract1 = $this->_em->find(CompanyContract::class, $this->contractId1);
$contract2 = $this->_em->find('Doctrine\Tests\Models\Company\CompanyContract', $this->contractId2); $contract2 = $this->_em->find(CompanyContract::class, $this->contractId2);
$this->assertFalse($manager->soldContracts->isInitialized()); $this->assertFalse($manager->soldContracts->isInitialized());
$this->assertTrue($manager->soldContracts->contains($contract1)); $this->assertTrue($manager->soldContracts->contains($contract1));
@ -991,7 +992,7 @@ class SQLFilterTest extends OrmFunctionalTestCase
$this->loadCompanySingleTableInheritanceFixtureData(); $this->loadCompanySingleTableInheritanceFixtureData();
$manager = $this->_em->find('Doctrine\Tests\Models\Company\CompanyManager', $this->managerId); $manager = $this->_em->find(CompanyManager::class, $this->managerId);
$this->assertFalse($manager->soldContracts->isInitialized()); $this->assertFalse($manager->soldContracts->isInitialized());
$this->assertEquals(2, count($manager->soldContracts->slice(0, 10))); $this->assertEquals(2, count($manager->soldContracts->slice(0, 10)));
@ -1028,7 +1029,7 @@ class SQLFilterTest extends OrmFunctionalTestCase
{ {
// Enable the filter // Enable the filter
$conf = $this->_em->getConfiguration(); $conf = $this->_em->getConfiguration();
$conf->addFilter("event_id", "\Doctrine\Tests\ORM\Functional\CompanyEventFilter"); $conf->addFilter("event_id", CompanyEventFilter::class);
$this->_em->getFilters() $this->_em->getFilters()
->enable("event_id") ->enable("event_id")
->setParameter("id", $this->eventId2); ->setParameter("id", $this->eventId2);
@ -1039,7 +1040,7 @@ class SQLFilterTest extends OrmFunctionalTestCase
{ {
$this->loadCompanyOrganizationEventJoinedSubclassFixtureData(); $this->loadCompanyOrganizationEventJoinedSubclassFixtureData();
$organization = $this->_em->find('Doctrine\Tests\Models\Company\CompanyOrganization', $this->organizationId); $organization = $this->_em->find(CompanyOrganization::class, $this->organizationId);
$this->assertFalse($organization->events->isInitialized()); $this->assertFalse($organization->events->isInitialized());
$this->assertEquals(2, count($organization->events)); $this->assertEquals(2, count($organization->events));
@ -1055,10 +1056,10 @@ class SQLFilterTest extends OrmFunctionalTestCase
{ {
$this->loadCompanyOrganizationEventJoinedSubclassFixtureData(); $this->loadCompanyOrganizationEventJoinedSubclassFixtureData();
$organization = $this->_em->find('Doctrine\Tests\Models\Company\CompanyOrganization', $this->organizationId); $organization = $this->_em->find(CompanyOrganization::class, $this->organizationId);
$event1 = $this->_em->find('Doctrine\Tests\Models\Company\CompanyEvent', $this->eventId1); $event1 = $this->_em->find(CompanyEvent::class, $this->eventId1);
$event2 = $this->_em->find('Doctrine\Tests\Models\Company\CompanyEvent', $this->eventId2); $event2 = $this->_em->find(CompanyEvent::class, $this->eventId2);
$this->assertFalse($organization->events->isInitialized()); $this->assertFalse($organization->events->isInitialized());
$this->assertTrue($organization->events->contains($event1)); $this->assertTrue($organization->events->contains($event1));
@ -1076,7 +1077,7 @@ class SQLFilterTest extends OrmFunctionalTestCase
{ {
$this->loadCompanyOrganizationEventJoinedSubclassFixtureData(); $this->loadCompanyOrganizationEventJoinedSubclassFixtureData();
$organization = $this->_em->find('Doctrine\Tests\Models\Company\CompanyOrganization', $this->organizationId); $organization = $this->_em->find(CompanyOrganization::class, $this->organizationId);
$this->assertFalse($organization->events->isInitialized()); $this->assertFalse($organization->events->isInitialized());
$this->assertEquals(2, count($organization->events->slice(0, 10))); $this->assertEquals(2, count($organization->events->slice(0, 10)));
@ -1117,7 +1118,7 @@ class CMSCountryFilter extends SQLFilter
{ {
public function addFilterConstraint(ClassMetadata $targetEntity, $targetTableAlias) public function addFilterConstraint(ClassMetadata $targetEntity, $targetTableAlias)
{ {
if ($targetEntity->name != "Doctrine\Tests\Models\CMS\CmsAddress") { if ($targetEntity->name != CmsAddress::class) {
return ""; return "";
} }
@ -1129,7 +1130,7 @@ class CMSGroupPrefixFilter extends SQLFilter
{ {
public function addFilterConstraint(ClassMetadata $targetEntity, $targetTableAlias) public function addFilterConstraint(ClassMetadata $targetEntity, $targetTableAlias)
{ {
if ($targetEntity->name != "Doctrine\Tests\Models\CMS\CmsGroup") { if ($targetEntity->name != CmsGroup::class) {
return ""; return "";
} }
@ -1141,7 +1142,7 @@ class CMSArticleTopicFilter extends SQLFilter
{ {
public function addFilterConstraint(ClassMetadata $targetEntity, $targetTableAlias) public function addFilterConstraint(ClassMetadata $targetEntity, $targetTableAlias)
{ {
if ($targetEntity->name != "Doctrine\Tests\Models\CMS\CmsArticle") { if ($targetEntity->name != CmsArticle::class) {
return ""; return "";
} }
@ -1153,7 +1154,7 @@ class CompanyPersonNameFilter extends SQLFilter
{ {
public function addFilterConstraint(ClassMetadata $targetEntity, $targetTableAlias, $targetTable = '') public function addFilterConstraint(ClassMetadata $targetEntity, $targetTableAlias, $targetTable = '')
{ {
if ($targetEntity->name != "Doctrine\Tests\Models\Company\CompanyPerson") { if ($targetEntity->name != CompanyPerson::class) {
return ""; return "";
} }
@ -1165,7 +1166,7 @@ class CompletedContractFilter extends SQLFilter
{ {
public function addFilterConstraint(ClassMetadata $targetEntity, $targetTableAlias, $targetTable = '') public function addFilterConstraint(ClassMetadata $targetEntity, $targetTableAlias, $targetTable = '')
{ {
if ($targetEntity->name != "Doctrine\Tests\Models\Company\CompanyContract") { if ($targetEntity->name != CompanyContract::class) {
return ""; return "";
} }
@ -1177,7 +1178,7 @@ class CompanyEventFilter extends SQLFilter
{ {
public function addFilterConstraint(ClassMetadata $targetEntity, $targetTableAlias, $targetTable = '') public function addFilterConstraint(ClassMetadata $targetEntity, $targetTableAlias, $targetTable = '')
{ {
if ($targetEntity->name != "Doctrine\Tests\Models\Company\CompanyEvent") { if ($targetEntity->name != CompanyEvent::class) {
return ""; return "";
} }

View File

@ -3,6 +3,7 @@
namespace Doctrine\Tests\ORM\Functional\SchemaTool; namespace Doctrine\Tests\ORM\Functional\SchemaTool;
use Doctrine\DBAL\Schema\Schema; use Doctrine\DBAL\Schema\Schema;
use Doctrine\Tests\Models\Company\CompanyManager;
use Doctrine\Tests\OrmFunctionalTestCase; use Doctrine\Tests\OrmFunctionalTestCase;
/** /**
@ -61,7 +62,7 @@ class CompanySchemaTest extends OrmFunctionalTestCase
$sql = $this->_schemaTool->getDropSchemaSQL( $sql = $this->_schemaTool->getDropSchemaSQL(
[ [
$this->_em->getClassMetadata('Doctrine\Tests\Models\Company\CompanyManager'), $this->_em->getClassMetadata(CompanyManager::class),
] ]
); );
$this->assertEquals(4, count($sql)); $this->assertEquals(4, count($sql));

View File

@ -21,7 +21,7 @@ class DBAL483Test extends OrmFunctionalTestCase
*/ */
public function testDefaultValueIsComparedCorrectly() public function testDefaultValueIsComparedCorrectly()
{ {
$class = $this->_em->getClassMetadata(__NAMESPACE__ . '\\DBAL483Default'); $class = $this->_em->getClassMetadata(DBAL483Default::class);
$this->schemaTool->createSchema([$class]); $this->schemaTool->createSchema([$class]);

View File

@ -4,6 +4,7 @@ namespace Doctrine\Tests\ORM\Functional\SchemaTool;
use Doctrine\DBAL\Schema\Comparator; use Doctrine\DBAL\Schema\Comparator;
use Doctrine\ORM\Tools; use Doctrine\ORM\Tools;
use Doctrine\Tests\Models;
use Doctrine\Tests\OrmFunctionalTestCase; use Doctrine\Tests\OrmFunctionalTestCase;
/** /**
@ -32,12 +33,12 @@ class DDC214Test extends OrmFunctionalTestCase
public function testCmsAddressModel() public function testCmsAddressModel()
{ {
$this->classes = [ $this->classes = [
'Doctrine\Tests\Models\CMS\CmsUser', Models\CMS\CmsUser::class,
'Doctrine\Tests\Models\CMS\CmsPhonenumber', Models\CMS\CmsPhonenumber::class,
'Doctrine\Tests\Models\CMS\CmsAddress', Models\CMS\CmsAddress::class,
'Doctrine\Tests\Models\CMS\CmsGroup', Models\CMS\CmsGroup::class,
'Doctrine\Tests\Models\CMS\CmsArticle', Models\CMS\CmsArticle::class,
'Doctrine\Tests\Models\CMS\CmsEmail', Models\CMS\CmsEmail::class,
]; ];
$this->assertCreatedSchemaNeedsNoUpdates($this->classes); $this->assertCreatedSchemaNeedsNoUpdates($this->classes);
@ -49,14 +50,14 @@ class DDC214Test extends OrmFunctionalTestCase
public function testCompanyModel() public function testCompanyModel()
{ {
$this->classes = [ $this->classes = [
'Doctrine\Tests\Models\Company\CompanyPerson', Models\Company\CompanyPerson::class,
'Doctrine\Tests\Models\Company\CompanyEmployee', Models\Company\CompanyEmployee::class,
'Doctrine\Tests\Models\Company\CompanyManager', Models\Company\CompanyManager::class,
'Doctrine\Tests\Models\Company\CompanyOrganization', Models\Company\CompanyOrganization::class,
'Doctrine\Tests\Models\Company\CompanyEvent', Models\Company\CompanyEvent::class,
'Doctrine\Tests\Models\Company\CompanyAuction', Models\Company\CompanyAuction::class,
'Doctrine\Tests\Models\Company\CompanyRaffle', Models\Company\CompanyRaffle::class,
'Doctrine\Tests\Models\Company\CompanyCar' Models\Company\CompanyCar::class
]; ];
$this->assertCreatedSchemaNeedsNoUpdates($this->classes); $this->assertCreatedSchemaNeedsNoUpdates($this->classes);

View File

@ -4,6 +4,7 @@ namespace Doctrine\Tests\ORM\Functional\SchemaTool;
use Doctrine\ORM\Tools\SchemaTool; use Doctrine\ORM\Tools\SchemaTool;
use Doctrine\Tests\OrmFunctionalTestCase; use Doctrine\Tests\OrmFunctionalTestCase;
use Doctrine\Tests\Models;
class MySqlSchemaToolTest extends OrmFunctionalTestCase class MySqlSchemaToolTest extends OrmFunctionalTestCase
{ {
@ -17,12 +18,12 @@ class MySqlSchemaToolTest extends OrmFunctionalTestCase
public function testGetCreateSchemaSql() public function testGetCreateSchemaSql()
{ {
$classes = [ $classes = [
$this->_em->getClassMetadata('Doctrine\Tests\Models\CMS\CmsGroup'), $this->_em->getClassMetadata(Models\CMS\CmsGroup::class),
$this->_em->getClassMetadata('Doctrine\Tests\Models\CMS\CmsUser'), $this->_em->getClassMetadata(Models\CMS\CmsUser::class),
$this->_em->getClassMetadata('Doctrine\Tests\Models\CMS\CmsTag'), $this->_em->getClassMetadata(Models\CMS\CmsTag::class),
$this->_em->getClassMetadata('Doctrine\Tests\Models\CMS\CmsAddress'), $this->_em->getClassMetadata(Models\CMS\CmsAddress::class),
$this->_em->getClassMetadata('Doctrine\Tests\Models\CMS\CmsEmail'), $this->_em->getClassMetadata(Models\CMS\CmsEmail::class),
$this->_em->getClassMetadata('Doctrine\Tests\Models\CMS\CmsPhonenumber'), $this->_em->getClassMetadata(Models\CMS\CmsPhonenumber::class),
]; ];
$tool = new SchemaTool($this->_em); $tool = new SchemaTool($this->_em);
@ -50,7 +51,7 @@ class MySqlSchemaToolTest extends OrmFunctionalTestCase
public function testGetCreateSchemaSql2() public function testGetCreateSchemaSql2()
{ {
$classes = [ $classes = [
$this->_em->getClassMetadata('Doctrine\Tests\Models\Generic\DecimalModel') $this->_em->getClassMetadata(Models\Generic\DecimalModel::class)
]; ];
$tool = new SchemaTool($this->_em); $tool = new SchemaTool($this->_em);
@ -63,7 +64,7 @@ class MySqlSchemaToolTest extends OrmFunctionalTestCase
public function testGetCreateSchemaSql3() public function testGetCreateSchemaSql3()
{ {
$classes = [ $classes = [
$this->_em->getClassMetadata('Doctrine\Tests\Models\Generic\BooleanModel') $this->_em->getClassMetadata(Models\Generic\BooleanModel::class)
]; ];
$tool = new SchemaTool($this->_em); $tool = new SchemaTool($this->_em);
@ -79,7 +80,7 @@ class MySqlSchemaToolTest extends OrmFunctionalTestCase
public function testGetCreateSchemaSql4() public function testGetCreateSchemaSql4()
{ {
$classes = [ $classes = [
$this->_em->getClassMetadata(__NAMESPACE__ . '\\MysqlSchemaNamespacedEntity') $this->_em->getClassMetadata(MysqlSchemaNamespacedEntity::class)
]; ];
$tool = new SchemaTool($this->_em); $tool = new SchemaTool($this->_em);

View File

@ -3,6 +3,7 @@
namespace Doctrine\Tests\ORM\Functional\SchemaTool; namespace Doctrine\Tests\ORM\Functional\SchemaTool;
use Doctrine\ORM\Tools\SchemaTool; use Doctrine\ORM\Tools\SchemaTool;
use Doctrine\Tests\Models;
use Doctrine\Tests\OrmFunctionalTestCase; use Doctrine\Tests\OrmFunctionalTestCase;
class PostgreSqlSchemaToolTest extends OrmFunctionalTestCase class PostgreSqlSchemaToolTest extends OrmFunctionalTestCase
@ -18,7 +19,7 @@ class PostgreSqlSchemaToolTest extends OrmFunctionalTestCase
public function testPostgresMetadataSequenceIncrementedBy10() public function testPostgresMetadataSequenceIncrementedBy10()
{ {
$address = $this->_em->getClassMetadata('Doctrine\Tests\Models\CMS\CmsAddress'); $address = $this->_em->getClassMetadata(Models\CMS\CmsAddress::class);
$this->assertEquals(1, $address->sequenceGeneratorDefinition['allocationSize']); $this->assertEquals(1, $address->sequenceGeneratorDefinition['allocationSize']);
} }
@ -26,9 +27,9 @@ class PostgreSqlSchemaToolTest extends OrmFunctionalTestCase
public function testGetCreateSchemaSql() public function testGetCreateSchemaSql()
{ {
$classes = [ $classes = [
$this->_em->getClassMetadata('Doctrine\Tests\Models\CMS\CmsAddress'), $this->_em->getClassMetadata(Models\CMS\CmsAddress::class),
$this->_em->getClassMetadata('Doctrine\Tests\Models\CMS\CmsUser'), $this->_em->getClassMetadata(Models\CMS\CmsUser::class),
$this->_em->getClassMetadata('Doctrine\Tests\Models\CMS\CmsPhonenumber'), $this->_em->getClassMetadata(Models\CMS\CmsPhonenumber::class),
]; ];
$tool = new SchemaTool($this->_em); $tool = new SchemaTool($this->_em);
@ -65,7 +66,7 @@ class PostgreSqlSchemaToolTest extends OrmFunctionalTestCase
public function testGetCreateSchemaSql2() public function testGetCreateSchemaSql2()
{ {
$classes = [ $classes = [
$this->_em->getClassMetadata('Doctrine\Tests\Models\Generic\DecimalModel') $this->_em->getClassMetadata(Models\Generic\DecimalModel::class)
]; ];
$tool = new SchemaTool($this->_em); $tool = new SchemaTool($this->_em);
@ -80,7 +81,7 @@ class PostgreSqlSchemaToolTest extends OrmFunctionalTestCase
public function testGetCreateSchemaSql3() public function testGetCreateSchemaSql3()
{ {
$classes = [ $classes = [
$this->_em->getClassMetadata('Doctrine\Tests\Models\Generic\BooleanModel') $this->_em->getClassMetadata(Models\Generic\BooleanModel::class)
]; ];
$tool = new SchemaTool($this->_em); $tool = new SchemaTool($this->_em);
@ -94,9 +95,9 @@ class PostgreSqlSchemaToolTest extends OrmFunctionalTestCase
public function testGetDropSchemaSql() public function testGetDropSchemaSql()
{ {
$classes = [ $classes = [
$this->_em->getClassMetadata('Doctrine\Tests\Models\CMS\CmsAddress'), $this->_em->getClassMetadata(Models\CMS\CmsAddress::class),
$this->_em->getClassMetadata('Doctrine\Tests\Models\CMS\CmsUser'), $this->_em->getClassMetadata(Models\CMS\CmsUser::class),
$this->_em->getClassMetadata('Doctrine\Tests\Models\CMS\CmsPhonenumber'), $this->_em->getClassMetadata(Models\CMS\CmsPhonenumber::class),
]; ];
$tool = new SchemaTool($this->_em); $tool = new SchemaTool($this->_em);
@ -120,8 +121,8 @@ class PostgreSqlSchemaToolTest extends OrmFunctionalTestCase
public function testUpdateSchemaWithPostgreSQLSchema() public function testUpdateSchemaWithPostgreSQLSchema()
{ {
$classes = [ $classes = [
$this->_em->getClassMetadata(__NAMESPACE__ . '\\DDC1657Screen'), $this->_em->getClassMetadata(DDC1657Screen::class),
$this->_em->getClassMetadata(__NAMESPACE__ . '\\DDC1657Avatar'), $this->_em->getClassMetadata(DDC1657Avatar::class),
]; ];
$tool = new SchemaTool($this->_em); $tool = new SchemaTool($this->_em);

View File

@ -21,8 +21,8 @@ class SecondLevelCacheCompositePrimaryKeyTest extends SecondLevelCacheAbstractTe
$leavingFromId = $this->cities[0]->getId(); $leavingFromId = $this->cities[0]->getId();
$goingToId = $this->cities[1]->getId(); $goingToId = $this->cities[1]->getId();
$leavingFrom = $this->_em->find(City::CLASSNAME, $leavingFromId); $leavingFrom = $this->_em->find(City::class, $leavingFromId);
$goingTo = $this->_em->find(City::CLASSNAME, $goingToId); $goingTo = $this->_em->find(City::class, $goingToId);
$flight = new Flight($leavingFrom, $goingTo); $flight = new Flight($leavingFrom, $goingTo);
$id = [ $id = [
'leavingFrom' => $leavingFromId, 'leavingFrom' => $leavingFromId,
@ -31,25 +31,25 @@ class SecondLevelCacheCompositePrimaryKeyTest extends SecondLevelCacheAbstractTe
$flight->setDeparture(new \DateTime('tomorrow')); $flight->setDeparture(new \DateTime('tomorrow'));
$this->assertTrue($this->cache->containsEntity(City::CLASSNAME, $this->cities[0]->getId())); $this->assertTrue($this->cache->containsEntity(City::class, $this->cities[0]->getId()));
$this->assertTrue($this->cache->containsEntity(City::CLASSNAME, $this->cities[1]->getId())); $this->assertTrue($this->cache->containsEntity(City::class, $this->cities[1]->getId()));
$this->_em->persist($flight); $this->_em->persist($flight);
$this->_em->flush(); $this->_em->flush();
$this->_em->clear(); $this->_em->clear();
$this->assertTrue($this->cache->containsEntity(Flight::CLASSNAME, $id)); $this->assertTrue($this->cache->containsEntity(Flight::class, $id));
$this->assertTrue($this->cache->containsEntity(City::CLASSNAME, $this->cities[0]->getId())); $this->assertTrue($this->cache->containsEntity(City::class, $this->cities[0]->getId()));
$this->assertTrue($this->cache->containsEntity(City::CLASSNAME, $this->cities[1]->getId())); $this->assertTrue($this->cache->containsEntity(City::class, $this->cities[1]->getId()));
$queryCount = $this->getCurrentQueryCount(); $queryCount = $this->getCurrentQueryCount();
$flight = $this->_em->find(Flight::CLASSNAME, $id); $flight = $this->_em->find(Flight::class, $id);
$leavingFrom = $flight->getLeavingFrom(); $leavingFrom = $flight->getLeavingFrom();
$goingTo = $flight->getGoingTo(); $goingTo = $flight->getGoingTo();
$this->assertInstanceOf(Flight::CLASSNAME, $flight); $this->assertInstanceOf(Flight::class, $flight);
$this->assertInstanceOf(City::CLASSNAME, $goingTo); $this->assertInstanceOf(City::class, $goingTo);
$this->assertInstanceOf(City::CLASSNAME, $leavingFrom); $this->assertInstanceOf(City::class, $leavingFrom);
$this->assertEquals($goingTo->getId(), $goingToId); $this->assertEquals($goingTo->getId(), $goingToId);
$this->assertEquals($leavingFrom->getId(), $leavingFromId); $this->assertEquals($leavingFrom->getId(), $leavingFromId);
@ -67,8 +67,8 @@ class SecondLevelCacheCompositePrimaryKeyTest extends SecondLevelCacheAbstractTe
$leavingFromId = $this->cities[0]->getId(); $leavingFromId = $this->cities[0]->getId();
$goingToId = $this->cities[1]->getId(); $goingToId = $this->cities[1]->getId();
$leavingFrom = $this->_em->find(City::CLASSNAME, $leavingFromId); $leavingFrom = $this->_em->find(City::class, $leavingFromId);
$goingTo = $this->_em->find(City::CLASSNAME, $goingToId); $goingTo = $this->_em->find(City::class, $goingToId);
$flight = new Flight($leavingFrom, $goingTo); $flight = new Flight($leavingFrom, $goingTo);
$id = [ $id = [
'leavingFrom' => $leavingFromId, 'leavingFrom' => $leavingFromId,
@ -77,25 +77,25 @@ class SecondLevelCacheCompositePrimaryKeyTest extends SecondLevelCacheAbstractTe
$flight->setDeparture(new \DateTime('tomorrow')); $flight->setDeparture(new \DateTime('tomorrow'));
$this->assertTrue($this->cache->containsEntity(City::CLASSNAME, $this->cities[0]->getId())); $this->assertTrue($this->cache->containsEntity(City::class, $this->cities[0]->getId()));
$this->assertTrue($this->cache->containsEntity(City::CLASSNAME, $this->cities[1]->getId())); $this->assertTrue($this->cache->containsEntity(City::class, $this->cities[1]->getId()));
$this->_em->persist($flight); $this->_em->persist($flight);
$this->_em->flush(); $this->_em->flush();
$this->assertTrue($this->cache->containsEntity(Flight::CLASSNAME, $id)); $this->assertTrue($this->cache->containsEntity(Flight::class, $id));
$this->assertTrue($this->cache->containsEntity(City::CLASSNAME, $this->cities[0]->getId())); $this->assertTrue($this->cache->containsEntity(City::class, $this->cities[0]->getId()));
$this->assertTrue($this->cache->containsEntity(City::CLASSNAME, $this->cities[1]->getId())); $this->assertTrue($this->cache->containsEntity(City::class, $this->cities[1]->getId()));
$this->_em->remove($flight); $this->_em->remove($flight);
$this->_em->flush(); $this->_em->flush();
$this->_em->clear(); $this->_em->clear();
$this->assertFalse($this->cache->containsEntity(Flight::CLASSNAME, $id)); $this->assertFalse($this->cache->containsEntity(Flight::class, $id));
$this->assertTrue($this->cache->containsEntity(City::CLASSNAME, $this->cities[0]->getId())); $this->assertTrue($this->cache->containsEntity(City::class, $this->cities[0]->getId()));
$this->assertTrue($this->cache->containsEntity(City::CLASSNAME, $this->cities[1]->getId())); $this->assertTrue($this->cache->containsEntity(City::class, $this->cities[1]->getId()));
$this->assertNull($this->_em->find(Flight::CLASSNAME, $id)); $this->assertNull($this->_em->find(Flight::class, $id));
} }
public function testUpdateCompositPrimaryKeyEntities() public function testUpdateCompositPrimaryKeyEntities()
@ -111,8 +111,8 @@ class SecondLevelCacheCompositePrimaryKeyTest extends SecondLevelCacheAbstractTe
$tomorrow = new \DateTime('tomorrow'); $tomorrow = new \DateTime('tomorrow');
$leavingFromId = $this->cities[0]->getId(); $leavingFromId = $this->cities[0]->getId();
$goingToId = $this->cities[1]->getId(); $goingToId = $this->cities[1]->getId();
$leavingFrom = $this->_em->find(City::CLASSNAME, $leavingFromId); $leavingFrom = $this->_em->find(City::class, $leavingFromId);
$goingTo = $this->_em->find(City::CLASSNAME, $goingToId); $goingTo = $this->_em->find(City::class, $goingToId);
$flight = new Flight($leavingFrom, $goingTo); $flight = new Flight($leavingFrom, $goingTo);
$id = [ $id = [
'leavingFrom' => $leavingFromId, 'leavingFrom' => $leavingFromId,
@ -121,25 +121,25 @@ class SecondLevelCacheCompositePrimaryKeyTest extends SecondLevelCacheAbstractTe
$flight->setDeparture($now); $flight->setDeparture($now);
$this->assertTrue($this->cache->containsEntity(City::CLASSNAME, $this->cities[0]->getId())); $this->assertTrue($this->cache->containsEntity(City::class, $this->cities[0]->getId()));
$this->assertTrue($this->cache->containsEntity(City::CLASSNAME, $this->cities[1]->getId())); $this->assertTrue($this->cache->containsEntity(City::class, $this->cities[1]->getId()));
$this->_em->persist($flight); $this->_em->persist($flight);
$this->_em->flush(); $this->_em->flush();
$this->_em->clear(); $this->_em->clear();
$this->assertTrue($this->cache->containsEntity(Flight::CLASSNAME, $id)); $this->assertTrue($this->cache->containsEntity(Flight::class, $id));
$this->assertTrue($this->cache->containsEntity(City::CLASSNAME, $this->cities[0]->getId())); $this->assertTrue($this->cache->containsEntity(City::class, $this->cities[0]->getId()));
$this->assertTrue($this->cache->containsEntity(City::CLASSNAME, $this->cities[1]->getId())); $this->assertTrue($this->cache->containsEntity(City::class, $this->cities[1]->getId()));
$queryCount = $this->getCurrentQueryCount(); $queryCount = $this->getCurrentQueryCount();
$flight = $this->_em->find(Flight::CLASSNAME, $id); $flight = $this->_em->find(Flight::class, $id);
$leavingFrom = $flight->getLeavingFrom(); $leavingFrom = $flight->getLeavingFrom();
$goingTo = $flight->getGoingTo(); $goingTo = $flight->getGoingTo();
$this->assertInstanceOf(Flight::CLASSNAME, $flight); $this->assertInstanceOf(Flight::class, $flight);
$this->assertInstanceOf(City::CLASSNAME, $goingTo); $this->assertInstanceOf(City::class, $goingTo);
$this->assertInstanceOf(City::CLASSNAME, $leavingFrom); $this->assertInstanceOf(City::class, $leavingFrom);
$this->assertEquals($goingTo->getId(), $goingToId); $this->assertEquals($goingTo->getId(), $goingToId);
$this->assertEquals($flight->getDeparture(), $now); $this->assertEquals($flight->getDeparture(), $now);
@ -153,18 +153,18 @@ class SecondLevelCacheCompositePrimaryKeyTest extends SecondLevelCacheAbstractTe
$this->_em->flush(); $this->_em->flush();
$this->_em->clear(); $this->_em->clear();
$this->assertTrue($this->cache->containsEntity(Flight::CLASSNAME, $id)); $this->assertTrue($this->cache->containsEntity(Flight::class, $id));
$this->assertTrue($this->cache->containsEntity(City::CLASSNAME, $this->cities[0]->getId())); $this->assertTrue($this->cache->containsEntity(City::class, $this->cities[0]->getId()));
$this->assertTrue($this->cache->containsEntity(City::CLASSNAME, $this->cities[1]->getId())); $this->assertTrue($this->cache->containsEntity(City::class, $this->cities[1]->getId()));
$queryCount = $this->getCurrentQueryCount(); $queryCount = $this->getCurrentQueryCount();
$flight = $this->_em->find(Flight::CLASSNAME, $id); $flight = $this->_em->find(Flight::class, $id);
$leavingFrom = $flight->getLeavingFrom(); $leavingFrom = $flight->getLeavingFrom();
$goingTo = $flight->getGoingTo(); $goingTo = $flight->getGoingTo();
$this->assertInstanceOf(Flight::CLASSNAME, $flight); $this->assertInstanceOf(Flight::class, $flight);
$this->assertInstanceOf(City::CLASSNAME, $goingTo); $this->assertInstanceOf(City::class, $goingTo);
$this->assertInstanceOf(City::CLASSNAME, $leavingFrom); $this->assertInstanceOf(City::class, $leavingFrom);
$this->assertEquals($goingTo->getId(), $goingToId); $this->assertEquals($goingTo->getId(), $goingToId);
$this->assertEquals($flight->getDeparture(), $tomorrow); $this->assertEquals($flight->getDeparture(), $tomorrow);

View File

@ -2,10 +2,10 @@
namespace Doctrine\Tests\ORM\Functional; namespace Doctrine\Tests\ORM\Functional;
use Doctrine\Tests\OrmFunctionalTestCase;
use Doctrine\Tests\Models\GeoNames\Country;
use Doctrine\Tests\Models\GeoNames\Admin1; use Doctrine\Tests\Models\GeoNames\Admin1;
use Doctrine\Tests\Models\GeoNames\Admin1AlternateName; use Doctrine\Tests\Models\GeoNames\Admin1AlternateName;
use Doctrine\Tests\Models\GeoNames\Country;
use Doctrine\Tests\OrmFunctionalTestCase;
class SecondLevelCacheCompositePrimaryKeyWithAssociationsTest extends OrmFunctionalTestCase class SecondLevelCacheCompositePrimaryKeyWithAssociationsTest extends OrmFunctionalTestCase
{ {
@ -51,7 +51,7 @@ class SecondLevelCacheCompositePrimaryKeyWithAssociationsTest extends OrmFunctio
public function testFindByReturnsCachedEntity() public function testFindByReturnsCachedEntity()
{ {
$admin1Repo = $this->_em->getRepository('Doctrine\Tests\Models\GeoNames\Admin1'); $admin1Repo = $this->_em->getRepository(Admin1::class);
$queries = $this->getCurrentQueryCount(); $queries = $this->getCurrentQueryCount();

View File

@ -37,19 +37,19 @@ class SecondLevelCacheConcurrentTest extends SecondLevelCacheAbstractTest
->getSecondLevelCacheConfiguration() ->getSecondLevelCacheConfiguration()
->setCacheFactory($this->cacheFactory); ->setCacheFactory($this->cacheFactory);
$this->countryMetadata = $this->_em->getClassMetadata(Country::CLASSNAME); $this->countryMetadata = $this->_em->getClassMetadata(Country::class);
$countryMetadata = clone $this->countryMetadata; $countryMetadata = clone $this->countryMetadata;
$countryMetadata->cache['usage'] = ClassMetadata::CACHE_USAGE_NONSTRICT_READ_WRITE; $countryMetadata->cache['usage'] = ClassMetadata::CACHE_USAGE_NONSTRICT_READ_WRITE;
$this->_em->getMetadataFactory()->setMetadataFor(Country::CLASSNAME, $countryMetadata); $this->_em->getMetadataFactory()->setMetadataFor(Country::class, $countryMetadata);
} }
protected function tearDown() protected function tearDown()
{ {
parent::tearDown(); parent::tearDown();
$this->_em->getMetadataFactory()->setMetadataFor(Country::CLASSNAME, $this->countryMetadata); $this->_em->getMetadataFactory()->setMetadataFor(Country::class, $this->countryMetadata);
} }
public function testBasicConcurrentEntityReadLock() public function testBasicConcurrentEntityReadLock()
@ -58,22 +58,22 @@ class SecondLevelCacheConcurrentTest extends SecondLevelCacheAbstractTest
$this->_em->clear(); $this->_em->clear();
$countryId = $this->countries[0]->getId(); $countryId = $this->countries[0]->getId();
$cacheId = new EntityCacheKey(Country::CLASSNAME, ['id'=>$countryId]); $cacheId = new EntityCacheKey(Country::class, ['id'=>$countryId]);
$region = $this->_em->getCache()->getEntityCacheRegion(Country::CLASSNAME); $region = $this->_em->getCache()->getEntityCacheRegion(Country::class);
$this->assertTrue($this->cache->containsEntity(Country::CLASSNAME, $countryId)); $this->assertTrue($this->cache->containsEntity(Country::class, $countryId));
/** @var \Doctrine\Tests\Mocks\ConcurrentRegionMock */ /** @var \Doctrine\Tests\Mocks\ConcurrentRegionMock */
$region->setLock($cacheId, Lock::createLockRead()); // another proc lock the entity cache $region->setLock($cacheId, Lock::createLockRead()); // another proc lock the entity cache
$this->assertFalse($this->cache->containsEntity(Country::CLASSNAME, $countryId)); $this->assertFalse($this->cache->containsEntity(Country::class, $countryId));
$queryCount = $this->getCurrentQueryCount(); $queryCount = $this->getCurrentQueryCount();
$country = $this->_em->find(Country::CLASSNAME, $countryId); $country = $this->_em->find(Country::class, $countryId);
$this->assertInstanceOf(Country::CLASSNAME, $country); $this->assertInstanceOf(Country::class, $country);
$this->assertEquals($queryCount + 1, $this->getCurrentQueryCount()); $this->assertEquals($queryCount + 1, $this->getCurrentQueryCount());
$this->assertFalse($this->cache->containsEntity(Country::CLASSNAME, $countryId)); $this->assertFalse($this->cache->containsEntity(Country::class, $countryId));
} }
public function testBasicConcurrentCollectionReadLock() public function testBasicConcurrentCollectionReadLock()
@ -86,10 +86,10 @@ class SecondLevelCacheConcurrentTest extends SecondLevelCacheAbstractTest
$this->evictRegions(); $this->evictRegions();
$stateId = $this->states[0]->getId(); $stateId = $this->states[0]->getId();
$state = $this->_em->find(State::CLASSNAME, $stateId); $state = $this->_em->find(State::class, $stateId);
$this->assertInstanceOf(State::CLASSNAME, $state); $this->assertInstanceOf(State::class, $state);
$this->assertInstanceOf(Country::CLASSNAME, $state->getCountry()); $this->assertInstanceOf(Country::class, $state->getCountry());
$this->assertNotNull($state->getCountry()->getName()); $this->assertNotNull($state->getCountry()->getName());
$this->assertCount(2, $state->getCities()); $this->assertCount(2, $state->getCities());
@ -97,34 +97,34 @@ class SecondLevelCacheConcurrentTest extends SecondLevelCacheAbstractTest
$this->secondLevelCacheLogger->clearStats(); $this->secondLevelCacheLogger->clearStats();
$stateId = $this->states[0]->getId(); $stateId = $this->states[0]->getId();
$cacheId = new CollectionCacheKey(State::CLASSNAME, 'cities', ['id'=>$stateId]); $cacheId = new CollectionCacheKey(State::class, 'cities', ['id'=>$stateId]);
$region = $this->_em->getCache()->getCollectionCacheRegion(State::CLASSNAME, 'cities'); $region = $this->_em->getCache()->getCollectionCacheRegion(State::class, 'cities');
$this->assertTrue($this->cache->containsCollection(State::CLASSNAME, 'cities', $stateId)); $this->assertTrue($this->cache->containsCollection(State::class, 'cities', $stateId));
/* @var $region \Doctrine\Tests\Mocks\ConcurrentRegionMock */ /* @var $region \Doctrine\Tests\Mocks\ConcurrentRegionMock */
$region->setLock($cacheId, Lock::createLockRead()); // another proc lock the entity cache $region->setLock($cacheId, Lock::createLockRead()); // another proc lock the entity cache
$this->assertFalse($this->cache->containsCollection(State::CLASSNAME, 'cities', $stateId)); $this->assertFalse($this->cache->containsCollection(State::class, 'cities', $stateId));
$queryCount = $this->getCurrentQueryCount(); $queryCount = $this->getCurrentQueryCount();
$state = $this->_em->find(State::CLASSNAME, $stateId); $state = $this->_em->find(State::class, $stateId);
$this->assertEquals(0, $this->secondLevelCacheLogger->getMissCount()); $this->assertEquals(0, $this->secondLevelCacheLogger->getMissCount());
$this->assertEquals(1, $this->secondLevelCacheLogger->getHitCount()); $this->assertEquals(1, $this->secondLevelCacheLogger->getHitCount());
$this->assertEquals(0, $this->secondLevelCacheLogger->getRegionMissCount($this->getEntityRegion(State::CLASSNAME))); $this->assertEquals(0, $this->secondLevelCacheLogger->getRegionMissCount($this->getEntityRegion(State::class)));
$this->assertEquals(1, $this->secondLevelCacheLogger->getRegionHitCount($this->getEntityRegion(State::CLASSNAME))); $this->assertEquals(1, $this->secondLevelCacheLogger->getRegionHitCount($this->getEntityRegion(State::class)));
$this->assertInstanceOf(State::CLASSNAME, $state); $this->assertInstanceOf(State::class, $state);
$this->assertCount(2, $state->getCities()); $this->assertCount(2, $state->getCities());
$this->assertEquals(1, $this->secondLevelCacheLogger->getMissCount()); $this->assertEquals(1, $this->secondLevelCacheLogger->getMissCount());
$this->assertEquals(1, $this->secondLevelCacheLogger->getHitCount()); $this->assertEquals(1, $this->secondLevelCacheLogger->getHitCount());
$this->assertEquals(1, $this->secondLevelCacheLogger->getRegionMissCount($this->getCollectionRegion(State::CLASSNAME, 'cities'))); $this->assertEquals(1, $this->secondLevelCacheLogger->getRegionMissCount($this->getCollectionRegion(State::class, 'cities')));
$this->assertEquals($queryCount + 1, $this->getCurrentQueryCount()); $this->assertEquals($queryCount + 1, $this->getCurrentQueryCount());
$this->assertFalse($this->cache->containsCollection(State::CLASSNAME, 'cities', $stateId)); $this->assertFalse($this->cache->containsCollection(State::class, 'cities', $stateId));
} }
} }

View File

@ -2,9 +2,10 @@
namespace Doctrine\Tests\ORM\Functional; namespace Doctrine\Tests\ORM\Functional;
use Doctrine\Tests\Models\Cache\State; use Doctrine\Common\Collections\Collection;
use Doctrine\Tests\Models\Cache\Country;
use Doctrine\Common\Collections\Criteria; use Doctrine\Common\Collections\Criteria;
use Doctrine\Tests\Models\Cache\Country;
use Doctrine\Tests\Models\Cache\State;
/** /**
* @group DDC-2183 * @group DDC-2183
@ -19,9 +20,9 @@ class SecondLevelCacheCriteriaTest extends SecondLevelCacheAbstractTest
$this->evictRegions(); $this->evictRegions();
$this->_em->clear(); $this->_em->clear();
$this->assertFalse($this->cache->containsEntity(Country::CLASSNAME, $this->countries[0]->getId())); $this->assertFalse($this->cache->containsEntity(Country::class, $this->countries[0]->getId()));
$repository = $this->_em->getRepository(Country::CLASSNAME); $repository = $this->_em->getRepository(Country::class);
$queryCount = $this->getCurrentQueryCount(); $queryCount = $this->getCurrentQueryCount();
$name = $this->countries[0]->getName(); $name = $this->countries[0]->getName();
$result1 = $repository->matching(new Criteria( $result1 = $repository->matching(new Criteria(
@ -35,7 +36,7 @@ class SecondLevelCacheCriteriaTest extends SecondLevelCacheAbstractTest
$this->assertEquals($this->countries[0]->getId(), $result1[0]->getId()); $this->assertEquals($this->countries[0]->getId(), $result1[0]->getId());
$this->assertEquals($this->countries[0]->getName(), $result1[0]->getName()); $this->assertEquals($this->countries[0]->getName(), $result1[0]->getName());
$this->assertTrue($this->cache->containsEntity(Country::CLASSNAME, $this->countries[0]->getId())); $this->assertTrue($this->cache->containsEntity(Country::class, $this->countries[0]->getId()));
$this->_em->clear(); $this->_em->clear();
@ -46,7 +47,7 @@ class SecondLevelCacheCriteriaTest extends SecondLevelCacheAbstractTest
$this->assertEquals($queryCount + 1, $this->getCurrentQueryCount()); $this->assertEquals($queryCount + 1, $this->getCurrentQueryCount());
$this->assertCount(1, $result2); $this->assertCount(1, $result2);
$this->assertInstanceOf('Doctrine\Tests\Models\Cache\Country', $result2[0]); $this->assertInstanceOf(Country::class, $result2[0]);
$this->assertEquals($result1[0]->getId(), $result2[0]->getId()); $this->assertEquals($result1[0]->getId(), $result2[0]->getId());
$this->assertEquals($result1[0]->getName(), $result2[0]->getName()); $this->assertEquals($result1[0]->getName(), $result2[0]->getName());
@ -59,9 +60,9 @@ class SecondLevelCacheCriteriaTest extends SecondLevelCacheAbstractTest
$this->loadFixturesCountries(); $this->loadFixturesCountries();
$this->_em->clear(); $this->_em->clear();
$this->assertTrue($this->cache->containsEntity(Country::CLASSNAME, $this->countries[0]->getId())); $this->assertTrue($this->cache->containsEntity(Country::class, $this->countries[0]->getId()));
$repository = $this->_em->getRepository(Country::CLASSNAME); $repository = $this->_em->getRepository(Country::class);
$queryCount = $this->getCurrentQueryCount(); $queryCount = $this->getCurrentQueryCount();
$result1 = $repository->matching(new Criteria( $result1 = $repository->matching(new Criteria(
Criteria::expr()->eq('name', $this->countries[0]->getName()) Criteria::expr()->eq('name', $this->countries[0]->getName())
@ -87,7 +88,7 @@ class SecondLevelCacheCriteriaTest extends SecondLevelCacheAbstractTest
$this->assertEquals($queryCount + 1, $this->getCurrentQueryCount()); $this->assertEquals($queryCount + 1, $this->getCurrentQueryCount());
$this->assertCount(1, $result2); $this->assertCount(1, $result2);
$this->assertInstanceOf('Doctrine\Tests\Models\Cache\Country', $result2[0]); $this->assertInstanceOf(Country::class, $result2[0]);
$this->assertEquals($this->countries[0]->getId(), $result2[0]->getId()); $this->assertEquals($this->countries[0]->getId(), $result2[0]->getId());
$this->assertEquals($this->countries[0]->getName(), $result2[0]->getName()); $this->assertEquals($this->countries[0]->getName(), $result2[0]->getName());
@ -102,7 +103,7 @@ class SecondLevelCacheCriteriaTest extends SecondLevelCacheAbstractTest
$this->assertEquals($queryCount + 2, $this->getCurrentQueryCount()); $this->assertEquals($queryCount + 2, $this->getCurrentQueryCount());
$this->assertCount(1, $result3); $this->assertCount(1, $result3);
$this->assertInstanceOf('Doctrine\Tests\Models\Cache\Country', $result3[0]); $this->assertInstanceOf(Country::class, $result3[0]);
$this->assertEquals($this->countries[1]->getId(), $result3[0]->getId()); $this->assertEquals($this->countries[1]->getId(), $result3[0]->getId());
$this->assertEquals($this->countries[1]->getName(), $result3[0]->getName()); $this->assertEquals($this->countries[1]->getName(), $result3[0]->getName());
@ -114,7 +115,7 @@ class SecondLevelCacheCriteriaTest extends SecondLevelCacheAbstractTest
$this->assertEquals($queryCount + 2, $this->getCurrentQueryCount()); $this->assertEquals($queryCount + 2, $this->getCurrentQueryCount());
$this->assertCount(1, $result4); $this->assertCount(1, $result4);
$this->assertInstanceOf('Doctrine\Tests\Models\Cache\Country', $result4[0]); $this->assertInstanceOf(Country::class, $result4[0]);
$this->assertEquals($this->countries[1]->getId(), $result4[0]->getId()); $this->assertEquals($this->countries[1]->getId(), $result4[0]->getId());
$this->assertEquals($this->countries[1]->getName(), $result4[0]->getName()); $this->assertEquals($this->countries[1]->getName(), $result4[0]->getName());
@ -128,7 +129,7 @@ class SecondLevelCacheCriteriaTest extends SecondLevelCacheAbstractTest
$this->_em->clear(); $this->_em->clear();
$this->secondLevelCacheLogger->clearStats(); $this->secondLevelCacheLogger->clearStats();
$entity = $this->_em->find(State::CLASSNAME, $this->states[0]->getId()); $entity = $this->_em->find(State::class, $this->states[0]->getId());
$itemName = $this->states[0]->getCities()->get(0)->getName(); $itemName = $this->states[0]->getCities()->get(0)->getName();
$queryCount = $this->getCurrentQueryCount(); $queryCount = $this->getCurrentQueryCount();
$collection = $entity->getCities(); $collection = $entity->getCities();
@ -137,12 +138,12 @@ class SecondLevelCacheCriteriaTest extends SecondLevelCacheAbstractTest
)); ));
$this->assertEquals($queryCount + 1, $this->getCurrentQueryCount()); $this->assertEquals($queryCount + 1, $this->getCurrentQueryCount());
$this->assertInstanceOf('Doctrine\Common\Collections\Collection', $matching); $this->assertInstanceOf(Collection::class, $matching);
$this->assertCount(1, $matching); $this->assertCount(1, $matching);
$this->_em->clear(); $this->_em->clear();
$entity = $this->_em->find(State::CLASSNAME, $this->states[0]->getId()); $entity = $this->_em->find(State::class, $this->states[0]->getId());
$queryCount = $this->getCurrentQueryCount(); $queryCount = $this->getCurrentQueryCount();
$collection = $entity->getCities(); $collection = $entity->getCities();
$matching = $collection->matching(new Criteria( $matching = $collection->matching(new Criteria(
@ -150,7 +151,7 @@ class SecondLevelCacheCriteriaTest extends SecondLevelCacheAbstractTest
)); ));
$this->assertEquals($queryCount, $this->getCurrentQueryCount()); $this->assertEquals($queryCount, $this->getCurrentQueryCount());
$this->assertInstanceOf('Doctrine\Common\Collections\Collection', $matching); $this->assertInstanceOf(Collection::class, $matching);
$this->assertCount(1, $matching); $this->assertCount(1, $matching);
} }

View File

@ -16,8 +16,8 @@ class SecondLevelCacheExtraLazyCollectionTest extends SecondLevelCacheAbstractTe
{ {
parent::setUp(); parent::setUp();
$sourceEntity = $this->_em->getClassMetadata(Travel::CLASSNAME); $sourceEntity = $this->_em->getClassMetadata(Travel::class);
$targetEntity = $this->_em->getClassMetadata(City::CLASSNAME); $targetEntity = $this->_em->getClassMetadata(City::class);
$sourceEntity->associationMappings['visitedCities']['fetch'] = ClassMetadata::FETCH_EXTRA_LAZY; $sourceEntity->associationMappings['visitedCities']['fetch'] = ClassMetadata::FETCH_EXTRA_LAZY;
$targetEntity->associationMappings['travels']['fetch'] = ClassMetadata::FETCH_EXTRA_LAZY; $targetEntity->associationMappings['travels']['fetch'] = ClassMetadata::FETCH_EXTRA_LAZY;
@ -27,8 +27,8 @@ class SecondLevelCacheExtraLazyCollectionTest extends SecondLevelCacheAbstractTe
{ {
parent::tearDown(); parent::tearDown();
$sourceEntity = $this->_em->getClassMetadata(Travel::CLASSNAME); $sourceEntity = $this->_em->getClassMetadata(Travel::class);
$targetEntity = $this->_em->getClassMetadata(City::CLASSNAME); $targetEntity = $this->_em->getClassMetadata(City::class);
$sourceEntity->associationMappings['visitedCities']['fetch'] = ClassMetadata::FETCH_LAZY; $sourceEntity->associationMappings['visitedCities']['fetch'] = ClassMetadata::FETCH_LAZY;
$targetEntity->associationMappings['travels']['fetch'] = ClassMetadata::FETCH_LAZY; $targetEntity->associationMappings['travels']['fetch'] = ClassMetadata::FETCH_LAZY;
@ -45,11 +45,11 @@ class SecondLevelCacheExtraLazyCollectionTest extends SecondLevelCacheAbstractTe
$this->_em->clear(); $this->_em->clear();
$ownerId = $this->travels[0]->getId(); $ownerId = $this->travels[0]->getId();
$owner = $this->_em->find(Travel::CLASSNAME, $ownerId); $owner = $this->_em->find(Travel::class, $ownerId);
$ref = $this->_em->find(State::CLASSNAME, $this->states[1]->getId()); $ref = $this->_em->find(State::class, $this->states[1]->getId());
$this->assertTrue($this->cache->containsEntity(Travel::CLASSNAME, $ownerId)); $this->assertTrue($this->cache->containsEntity(Travel::class, $ownerId));
$this->assertTrue($this->cache->containsCollection(Travel::CLASSNAME, 'visitedCities', $ownerId)); $this->assertTrue($this->cache->containsCollection(Travel::class, 'visitedCities', $ownerId));
$newItem = new City("New City", $ref); $newItem = new City("New City", $ref);
$owner->getVisitedCities()->add($newItem); $owner->getVisitedCities()->add($newItem);
@ -67,12 +67,12 @@ class SecondLevelCacheExtraLazyCollectionTest extends SecondLevelCacheAbstractTe
$this->_em->flush(); $this->_em->flush();
$this->assertFalse($owner->getVisitedCities()->isInitialized()); $this->assertFalse($owner->getVisitedCities()->isInitialized());
$this->assertFalse($this->cache->containsCollection(Travel::CLASSNAME, 'visitedCities', $ownerId)); $this->assertFalse($this->cache->containsCollection(Travel::class, 'visitedCities', $ownerId));
$this->_em->clear(); $this->_em->clear();
$queryCount = $this->getCurrentQueryCount(); $queryCount = $this->getCurrentQueryCount();
$owner = $this->_em->find(Travel::CLASSNAME, $ownerId); $owner = $this->_em->find(Travel::class, $ownerId);
$this->assertEquals(4, $owner->getVisitedCities()->count()); $this->assertEquals(4, $owner->getVisitedCities()->count());
$this->assertFalse($owner->getVisitedCities()->isInitialized()); $this->assertFalse($owner->getVisitedCities()->isInitialized());

View File

@ -2,6 +2,7 @@
namespace Doctrine\Tests\ORM\Functional; namespace Doctrine\Tests\ORM\Functional;
use Doctrine\ORM\PersistentCollection;
use Doctrine\Tests\Models\Cache\Attraction; use Doctrine\Tests\Models\Cache\Attraction;
use Doctrine\Tests\Models\Cache\AttractionContactInfo; use Doctrine\Tests\Models\Cache\AttractionContactInfo;
use Doctrine\Tests\Models\Cache\AttractionInfo; use Doctrine\Tests\Models\Cache\AttractionInfo;
@ -14,9 +15,9 @@ class SecondLevelCacheJoinTableInheritanceTest extends SecondLevelCacheAbstractT
{ {
public function testUseSameRegion() public function testUseSameRegion()
{ {
$infoRegion = $this->cache->getEntityCacheRegion(AttractionInfo::CLASSNAME); $infoRegion = $this->cache->getEntityCacheRegion(AttractionInfo::class);
$contactRegion = $this->cache->getEntityCacheRegion(AttractionContactInfo::CLASSNAME); $contactRegion = $this->cache->getEntityCacheRegion(AttractionContactInfo::class);
$locationRegion = $this->cache->getEntityCacheRegion(AttractionLocationInfo::CLASSNAME); $locationRegion = $this->cache->getEntityCacheRegion(AttractionLocationInfo::class);
$this->assertEquals($infoRegion->getName(), $contactRegion->getName()); $this->assertEquals($infoRegion->getName(), $contactRegion->getName());
$this->assertEquals($infoRegion->getName(), $locationRegion->getName()); $this->assertEquals($infoRegion->getName(), $locationRegion->getName());
@ -32,10 +33,10 @@ class SecondLevelCacheJoinTableInheritanceTest extends SecondLevelCacheAbstractT
$this->_em->clear(); $this->_em->clear();
$this->assertTrue($this->cache->containsEntity(AttractionInfo::CLASSNAME, $this->attractionsInfo[0]->getId())); $this->assertTrue($this->cache->containsEntity(AttractionInfo::class, $this->attractionsInfo[0]->getId()));
$this->assertTrue($this->cache->containsEntity(AttractionInfo::CLASSNAME, $this->attractionsInfo[1]->getId())); $this->assertTrue($this->cache->containsEntity(AttractionInfo::class, $this->attractionsInfo[1]->getId()));
$this->assertTrue($this->cache->containsEntity(AttractionInfo::CLASSNAME, $this->attractionsInfo[2]->getId())); $this->assertTrue($this->cache->containsEntity(AttractionInfo::class, $this->attractionsInfo[2]->getId()));
$this->assertTrue($this->cache->containsEntity(AttractionInfo::CLASSNAME, $this->attractionsInfo[3]->getId())); $this->assertTrue($this->cache->containsEntity(AttractionInfo::class, $this->attractionsInfo[3]->getId()));
} }
public function testJoinTableCountaisRootClass() public function testJoinTableCountaisRootClass()
@ -49,7 +50,7 @@ class SecondLevelCacheJoinTableInheritanceTest extends SecondLevelCacheAbstractT
$this->_em->clear(); $this->_em->clear();
foreach ($this->attractionsInfo as $info) { foreach ($this->attractionsInfo as $info) {
$this->assertTrue($this->cache->containsEntity(AttractionInfo::CLASSNAME, $info->getId())); $this->assertTrue($this->cache->containsEntity(AttractionInfo::class, $info->getId()));
$this->assertTrue($this->cache->containsEntity(get_class($info), $info->getId())); $this->assertTrue($this->cache->containsEntity(get_class($info), $info->getId()));
} }
} }
@ -64,32 +65,32 @@ class SecondLevelCacheJoinTableInheritanceTest extends SecondLevelCacheAbstractT
$this->_em->clear(); $this->_em->clear();
$this->cache->evictEntityRegion(AttractionInfo::CLASSNAME); $this->cache->evictEntityRegion(AttractionInfo::class);
$entityId1 = $this->attractionsInfo[0]->getId(); $entityId1 = $this->attractionsInfo[0]->getId();
$entityId2 = $this->attractionsInfo[1]->getId(); $entityId2 = $this->attractionsInfo[1]->getId();
$this->assertFalse($this->cache->containsEntity(AttractionInfo::CLASSNAME, $entityId1)); $this->assertFalse($this->cache->containsEntity(AttractionInfo::class, $entityId1));
$this->assertFalse($this->cache->containsEntity(AttractionInfo::CLASSNAME, $entityId2)); $this->assertFalse($this->cache->containsEntity(AttractionInfo::class, $entityId2));
$this->assertFalse($this->cache->containsEntity(AttractionContactInfo::CLASSNAME, $entityId1)); $this->assertFalse($this->cache->containsEntity(AttractionContactInfo::class, $entityId1));
$this->assertFalse($this->cache->containsEntity(AttractionContactInfo::CLASSNAME, $entityId2)); $this->assertFalse($this->cache->containsEntity(AttractionContactInfo::class, $entityId2));
$queryCount = $this->getCurrentQueryCount(); $queryCount = $this->getCurrentQueryCount();
$entity1 = $this->_em->find(AttractionInfo::CLASSNAME, $entityId1); $entity1 = $this->_em->find(AttractionInfo::class, $entityId1);
$entity2 = $this->_em->find(AttractionInfo::CLASSNAME, $entityId2); $entity2 = $this->_em->find(AttractionInfo::class, $entityId2);
//load entity and relation whit sub classes //load entity and relation whit sub classes
$this->assertEquals($queryCount + 4, $this->getCurrentQueryCount()); $this->assertEquals($queryCount + 4, $this->getCurrentQueryCount());
$this->assertTrue($this->cache->containsEntity(AttractionInfo::CLASSNAME, $entityId1)); $this->assertTrue($this->cache->containsEntity(AttractionInfo::class, $entityId1));
$this->assertTrue($this->cache->containsEntity(AttractionInfo::CLASSNAME, $entityId2)); $this->assertTrue($this->cache->containsEntity(AttractionInfo::class, $entityId2));
$this->assertTrue($this->cache->containsEntity(AttractionContactInfo::CLASSNAME, $entityId1)); $this->assertTrue($this->cache->containsEntity(AttractionContactInfo::class, $entityId1));
$this->assertTrue($this->cache->containsEntity(AttractionContactInfo::CLASSNAME, $entityId2)); $this->assertTrue($this->cache->containsEntity(AttractionContactInfo::class, $entityId2));
$this->assertInstanceOf(AttractionInfo::CLASSNAME, $entity1); $this->assertInstanceOf(AttractionInfo::class, $entity1);
$this->assertInstanceOf(AttractionInfo::CLASSNAME, $entity2); $this->assertInstanceOf(AttractionInfo::class, $entity2);
$this->assertInstanceOf(AttractionContactInfo::CLASSNAME, $entity1); $this->assertInstanceOf(AttractionContactInfo::class, $entity1);
$this->assertInstanceOf(AttractionContactInfo::CLASSNAME, $entity2); $this->assertInstanceOf(AttractionContactInfo::class, $entity2);
$this->assertEquals($this->attractionsInfo[0]->getId(), $entity1->getId()); $this->assertEquals($this->attractionsInfo[0]->getId(), $entity1->getId());
$this->assertEquals($this->attractionsInfo[0]->getFone(), $entity1->getFone()); $this->assertEquals($this->attractionsInfo[0]->getFone(), $entity1->getFone());
@ -100,15 +101,15 @@ class SecondLevelCacheJoinTableInheritanceTest extends SecondLevelCacheAbstractT
$this->_em->clear(); $this->_em->clear();
$queryCount = $this->getCurrentQueryCount(); $queryCount = $this->getCurrentQueryCount();
$entity3 = $this->_em->find(AttractionInfo::CLASSNAME, $entityId1); $entity3 = $this->_em->find(AttractionInfo::class, $entityId1);
$entity4 = $this->_em->find(AttractionInfo::CLASSNAME, $entityId2); $entity4 = $this->_em->find(AttractionInfo::class, $entityId2);
$this->assertEquals($queryCount, $this->getCurrentQueryCount()); $this->assertEquals($queryCount, $this->getCurrentQueryCount());
$this->assertInstanceOf(AttractionInfo::CLASSNAME, $entity3); $this->assertInstanceOf(AttractionInfo::class, $entity3);
$this->assertInstanceOf(AttractionInfo::CLASSNAME, $entity4); $this->assertInstanceOf(AttractionInfo::class, $entity4);
$this->assertInstanceOf(AttractionContactInfo::CLASSNAME, $entity3); $this->assertInstanceOf(AttractionContactInfo::class, $entity3);
$this->assertInstanceOf(AttractionContactInfo::CLASSNAME, $entity4); $this->assertInstanceOf(AttractionContactInfo::class, $entity4);
$this->assertNotSame($entity1, $entity3); $this->assertNotSame($entity1, $entity3);
$this->assertEquals($entity1->getId(), $entity3->getId()); $this->assertEquals($entity1->getId(), $entity3->getId());
@ -148,7 +149,7 @@ class SecondLevelCacheJoinTableInheritanceTest extends SecondLevelCacheAbstractT
$this->assertEquals($queryCount + 1, $this->getCurrentQueryCount()); $this->assertEquals($queryCount + 1, $this->getCurrentQueryCount());
foreach ($result2 as $entity) { foreach ($result2 as $entity) {
$this->assertInstanceOf(AttractionInfo::CLASSNAME, $entity); $this->assertInstanceOf(AttractionInfo::class, $entity);
} }
} }
@ -162,30 +163,30 @@ class SecondLevelCacheJoinTableInheritanceTest extends SecondLevelCacheAbstractT
$this->evictRegions(); $this->evictRegions();
$this->_em->clear(); $this->_em->clear();
$entity = $this->_em->find(Attraction::CLASSNAME, $this->attractions[0]->getId()); $entity = $this->_em->find(Attraction::class, $this->attractions[0]->getId());
$this->assertInstanceOf(Attraction::CLASSNAME, $entity); $this->assertInstanceOf(Attraction::class, $entity);
$this->assertInstanceOf('Doctrine\ORM\PersistentCollection', $entity->getInfos()); $this->assertInstanceOf(PersistentCollection::class, $entity->getInfos());
$this->assertCount(1, $entity->getInfos()); $this->assertCount(1, $entity->getInfos());
$ownerId = $this->attractions[0]->getId(); $ownerId = $this->attractions[0]->getId();
$queryCount = $this->getCurrentQueryCount(); $queryCount = $this->getCurrentQueryCount();
$this->assertTrue($this->cache->containsEntity(Attraction::CLASSNAME, $ownerId)); $this->assertTrue($this->cache->containsEntity(Attraction::class, $ownerId));
$this->assertTrue($this->cache->containsCollection(Attraction::CLASSNAME, 'infos', $ownerId)); $this->assertTrue($this->cache->containsCollection(Attraction::class, 'infos', $ownerId));
$this->assertInstanceOf(AttractionContactInfo::CLASSNAME, $entity->getInfos()->get(0)); $this->assertInstanceOf(AttractionContactInfo::class, $entity->getInfos()->get(0));
$this->assertEquals($this->attractionsInfo[0]->getFone(), $entity->getInfos()->get(0)->getFone()); $this->assertEquals($this->attractionsInfo[0]->getFone(), $entity->getInfos()->get(0)->getFone());
$this->_em->clear(); $this->_em->clear();
$entity = $this->_em->find(Attraction::CLASSNAME, $this->attractions[0]->getId()); $entity = $this->_em->find(Attraction::class, $this->attractions[0]->getId());
$this->assertInstanceOf(Attraction::CLASSNAME, $entity); $this->assertInstanceOf(Attraction::class, $entity);
$this->assertInstanceOf('Doctrine\ORM\PersistentCollection', $entity->getInfos()); $this->assertInstanceOf(PersistentCollection::class, $entity->getInfos());
$this->assertCount(1, $entity->getInfos()); $this->assertCount(1, $entity->getInfos());
$this->assertInstanceOf(AttractionContactInfo::CLASSNAME, $entity->getInfos()->get(0)); $this->assertInstanceOf(AttractionContactInfo::class, $entity->getInfos()->get(0));
$this->assertEquals($this->attractionsInfo[0]->getFone(), $entity->getInfos()->get(0)->getFone()); $this->assertEquals($this->attractionsInfo[0]->getFone(), $entity->getInfos()->get(0)->getFone());
} }
@ -228,7 +229,7 @@ class SecondLevelCacheJoinTableInheritanceTest extends SecondLevelCacheAbstractT
$this->assertEquals($queryCount + 6, $this->getCurrentQueryCount()); $this->assertEquals($queryCount + 6, $this->getCurrentQueryCount());
foreach ($result2 as $entity) { foreach ($result2 as $entity) {
$this->assertInstanceOf(AttractionInfo::CLASSNAME, $entity); $this->assertInstanceOf(AttractionInfo::class, $entity);
} }
} }
} }

View File

@ -23,16 +23,16 @@ class SecondLevelCacheManyToManyTest extends SecondLevelCacheAbstractTest
$this->loadFixturesTravels(); $this->loadFixturesTravels();
$this->_em->clear(); $this->_em->clear();
$this->assertTrue($this->cache->containsEntity(Travel::CLASSNAME, $this->travels[0]->getId())); $this->assertTrue($this->cache->containsEntity(Travel::class, $this->travels[0]->getId()));
$this->assertTrue($this->cache->containsEntity(Travel::CLASSNAME, $this->travels[1]->getId())); $this->assertTrue($this->cache->containsEntity(Travel::class, $this->travels[1]->getId()));
$this->assertTrue($this->cache->containsCollection(Travel::CLASSNAME, 'visitedCities', $this->travels[0]->getId())); $this->assertTrue($this->cache->containsCollection(Travel::class, 'visitedCities', $this->travels[0]->getId()));
$this->assertTrue($this->cache->containsCollection(Travel::CLASSNAME, 'visitedCities', $this->travels[1]->getId())); $this->assertTrue($this->cache->containsCollection(Travel::class, 'visitedCities', $this->travels[1]->getId()));
$this->assertTrue($this->cache->containsEntity(City::CLASSNAME, $this->cities[0]->getId())); $this->assertTrue($this->cache->containsEntity(City::class, $this->cities[0]->getId()));
$this->assertTrue($this->cache->containsEntity(City::CLASSNAME, $this->cities[1]->getId())); $this->assertTrue($this->cache->containsEntity(City::class, $this->cities[1]->getId()));
$this->assertTrue($this->cache->containsEntity(City::CLASSNAME, $this->cities[2]->getId())); $this->assertTrue($this->cache->containsEntity(City::class, $this->cities[2]->getId()));
$this->assertTrue($this->cache->containsEntity(City::CLASSNAME, $this->cities[3]->getId())); $this->assertTrue($this->cache->containsEntity(City::class, $this->cities[3]->getId()));
} }
public function testPutAndLoadManyToManyRelation() public function testPutAndLoadManyToManyRelation()
@ -46,30 +46,30 @@ class SecondLevelCacheManyToManyTest extends SecondLevelCacheAbstractTest
$this->loadFixturesTravels(); $this->loadFixturesTravels();
$this->_em->clear(); $this->_em->clear();
$this->cache->evictEntityRegion(City::CLASSNAME); $this->cache->evictEntityRegion(City::class);
$this->cache->evictEntityRegion(Travel::CLASSNAME); $this->cache->evictEntityRegion(Travel::class);
$this->cache->evictCollectionRegion(Travel::CLASSNAME, 'visitedCities'); $this->cache->evictCollectionRegion(Travel::class, 'visitedCities');
$this->secondLevelCacheLogger->clearStats(); $this->secondLevelCacheLogger->clearStats();
$this->assertFalse($this->cache->containsEntity(Travel::CLASSNAME, $this->travels[0]->getId())); $this->assertFalse($this->cache->containsEntity(Travel::class, $this->travels[0]->getId()));
$this->assertFalse($this->cache->containsEntity(Travel::CLASSNAME, $this->travels[1]->getId())); $this->assertFalse($this->cache->containsEntity(Travel::class, $this->travels[1]->getId()));
$this->assertFalse($this->cache->containsCollection(Travel::CLASSNAME, 'visitedCities', $this->travels[0]->getId())); $this->assertFalse($this->cache->containsCollection(Travel::class, 'visitedCities', $this->travels[0]->getId()));
$this->assertFalse($this->cache->containsCollection(Travel::CLASSNAME, 'visitedCities', $this->travels[1]->getId())); $this->assertFalse($this->cache->containsCollection(Travel::class, 'visitedCities', $this->travels[1]->getId()));
$this->assertFalse($this->cache->containsEntity(City::CLASSNAME, $this->cities[0]->getId())); $this->assertFalse($this->cache->containsEntity(City::class, $this->cities[0]->getId()));
$this->assertFalse($this->cache->containsEntity(City::CLASSNAME, $this->cities[1]->getId())); $this->assertFalse($this->cache->containsEntity(City::class, $this->cities[1]->getId()));
$this->assertFalse($this->cache->containsEntity(City::CLASSNAME, $this->cities[2]->getId())); $this->assertFalse($this->cache->containsEntity(City::class, $this->cities[2]->getId()));
$this->assertFalse($this->cache->containsEntity(City::CLASSNAME, $this->cities[3]->getId())); $this->assertFalse($this->cache->containsEntity(City::class, $this->cities[3]->getId()));
$t1 = $this->_em->find(Travel::CLASSNAME, $this->travels[0]->getId()); $t1 = $this->_em->find(Travel::class, $this->travels[0]->getId());
$t2 = $this->_em->find(Travel::CLASSNAME, $this->travels[1]->getId()); $t2 = $this->_em->find(Travel::class, $this->travels[1]->getId());
$this->assertEquals(2, $this->secondLevelCacheLogger->getPutCount()); $this->assertEquals(2, $this->secondLevelCacheLogger->getPutCount());
$this->assertEquals(2, $this->secondLevelCacheLogger->getMissCount()); $this->assertEquals(2, $this->secondLevelCacheLogger->getMissCount());
$this->assertEquals(2, $this->secondLevelCacheLogger->getRegionPutCount($this->getEntityRegion(Travel::CLASSNAME))); $this->assertEquals(2, $this->secondLevelCacheLogger->getRegionPutCount($this->getEntityRegion(Travel::class)));
$this->assertEquals(2, $this->secondLevelCacheLogger->getRegionMissCount($this->getEntityRegion(Travel::CLASSNAME))); $this->assertEquals(2, $this->secondLevelCacheLogger->getRegionMissCount($this->getEntityRegion(Travel::class)));
//trigger lazy load //trigger lazy load
$this->assertCount(3, $t1->getVisitedCities()); $this->assertCount(3, $t1->getVisitedCities());
@ -77,49 +77,49 @@ class SecondLevelCacheManyToManyTest extends SecondLevelCacheAbstractTest
$this->assertEquals(4, $this->secondLevelCacheLogger->getPutCount()); $this->assertEquals(4, $this->secondLevelCacheLogger->getPutCount());
$this->assertEquals(4, $this->secondLevelCacheLogger->getMissCount()); $this->assertEquals(4, $this->secondLevelCacheLogger->getMissCount());
$this->assertEquals(2, $this->secondLevelCacheLogger->getRegionPutCount($this->getCollectionRegion(Travel::CLASSNAME, 'visitedCities'))); $this->assertEquals(2, $this->secondLevelCacheLogger->getRegionPutCount($this->getCollectionRegion(Travel::class, 'visitedCities')));
$this->assertEquals(2, $this->secondLevelCacheLogger->getRegionMissCount($this->getCollectionRegion(Travel::CLASSNAME, 'visitedCities'))); $this->assertEquals(2, $this->secondLevelCacheLogger->getRegionMissCount($this->getCollectionRegion(Travel::class, 'visitedCities')));
$this->assertInstanceOf(City::CLASSNAME, $t1->getVisitedCities()->get(0)); $this->assertInstanceOf(City::class, $t1->getVisitedCities()->get(0));
$this->assertInstanceOf(City::CLASSNAME, $t1->getVisitedCities()->get(1)); $this->assertInstanceOf(City::class, $t1->getVisitedCities()->get(1));
$this->assertInstanceOf(City::CLASSNAME, $t1->getVisitedCities()->get(2)); $this->assertInstanceOf(City::class, $t1->getVisitedCities()->get(2));
$this->assertInstanceOf(City::CLASSNAME, $t2->getVisitedCities()->get(0)); $this->assertInstanceOf(City::class, $t2->getVisitedCities()->get(0));
$this->assertInstanceOf(City::CLASSNAME, $t2->getVisitedCities()->get(1)); $this->assertInstanceOf(City::class, $t2->getVisitedCities()->get(1));
$this->assertTrue($this->cache->containsEntity(Travel::CLASSNAME, $this->travels[0]->getId())); $this->assertTrue($this->cache->containsEntity(Travel::class, $this->travels[0]->getId()));
$this->assertTrue($this->cache->containsEntity(Travel::CLASSNAME, $this->travels[1]->getId())); $this->assertTrue($this->cache->containsEntity(Travel::class, $this->travels[1]->getId()));
$this->assertTrue($this->cache->containsCollection(Travel::CLASSNAME, 'visitedCities', $this->travels[0]->getId())); $this->assertTrue($this->cache->containsCollection(Travel::class, 'visitedCities', $this->travels[0]->getId()));
$this->assertTrue($this->cache->containsCollection(Travel::CLASSNAME, 'visitedCities', $this->travels[1]->getId())); $this->assertTrue($this->cache->containsCollection(Travel::class, 'visitedCities', $this->travels[1]->getId()));
$this->assertTrue($this->cache->containsEntity(City::CLASSNAME, $this->cities[0]->getId())); $this->assertTrue($this->cache->containsEntity(City::class, $this->cities[0]->getId()));
$this->assertTrue($this->cache->containsEntity(City::CLASSNAME, $this->cities[1]->getId())); $this->assertTrue($this->cache->containsEntity(City::class, $this->cities[1]->getId()));
$this->assertTrue($this->cache->containsEntity(City::CLASSNAME, $this->cities[2]->getId())); $this->assertTrue($this->cache->containsEntity(City::class, $this->cities[2]->getId()));
$this->assertTrue($this->cache->containsEntity(City::CLASSNAME, $this->cities[3]->getId())); $this->assertTrue($this->cache->containsEntity(City::class, $this->cities[3]->getId()));
$this->_em->clear(); $this->_em->clear();
$this->secondLevelCacheLogger->clearStats(); $this->secondLevelCacheLogger->clearStats();
$queryCount = $this->getCurrentQueryCount(); $queryCount = $this->getCurrentQueryCount();
$t3 = $this->_em->find(Travel::CLASSNAME, $this->travels[0]->getId()); $t3 = $this->_em->find(Travel::class, $this->travels[0]->getId());
$t4 = $this->_em->find(Travel::CLASSNAME, $this->travels[1]->getId()); $t4 = $this->_em->find(Travel::class, $this->travels[1]->getId());
//trigger lazy load from cache //trigger lazy load from cache
$this->assertCount(3, $t3->getVisitedCities()); $this->assertCount(3, $t3->getVisitedCities());
$this->assertCount(2, $t4->getVisitedCities()); $this->assertCount(2, $t4->getVisitedCities());
$this->assertInstanceOf(City::CLASSNAME, $t3->getVisitedCities()->get(0)); $this->assertInstanceOf(City::class, $t3->getVisitedCities()->get(0));
$this->assertInstanceOf(City::CLASSNAME, $t3->getVisitedCities()->get(1)); $this->assertInstanceOf(City::class, $t3->getVisitedCities()->get(1));
$this->assertInstanceOf(City::CLASSNAME, $t3->getVisitedCities()->get(2)); $this->assertInstanceOf(City::class, $t3->getVisitedCities()->get(2));
$this->assertInstanceOf(City::CLASSNAME, $t4->getVisitedCities()->get(0)); $this->assertInstanceOf(City::class, $t4->getVisitedCities()->get(0));
$this->assertInstanceOf(City::CLASSNAME, $t4->getVisitedCities()->get(1)); $this->assertInstanceOf(City::class, $t4->getVisitedCities()->get(1));
$this->assertEquals(4, $this->secondLevelCacheLogger->getHitCount()); $this->assertEquals(4, $this->secondLevelCacheLogger->getHitCount());
$this->assertEquals(2, $this->secondLevelCacheLogger->getRegionHitCount($this->getEntityRegion(Travel::CLASSNAME))); $this->assertEquals(2, $this->secondLevelCacheLogger->getRegionHitCount($this->getEntityRegion(Travel::class)));
$this->assertEquals(2, $this->secondLevelCacheLogger->getRegionHitCount($this->getCollectionRegion(Travel::CLASSNAME, 'visitedCities'))); $this->assertEquals(2, $this->secondLevelCacheLogger->getRegionHitCount($this->getCollectionRegion(Travel::class, 'visitedCities')));
$this->assertNotSame($t1->getVisitedCities()->get(0), $t3->getVisitedCities()->get(0)); $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)->getId(), $t3->getVisitedCities()->get(0)->getId());
@ -153,11 +153,11 @@ class SecondLevelCacheManyToManyTest extends SecondLevelCacheAbstractTest
$this->loadFixturesStates(); $this->loadFixturesStates();
$this->loadFixturesCities(); $this->loadFixturesCities();
$this->cache->evictEntityRegion(City::CLASSNAME); $this->cache->evictEntityRegion(City::class);
$this->cache->evictEntityRegion(Traveler::CLASSNAME); $this->cache->evictEntityRegion(Traveler::class);
$this->cache->evictEntityRegion(Travel::CLASSNAME); $this->cache->evictEntityRegion(Travel::class);
$this->cache->evictCollectionRegion(State::CLASSNAME, 'cities'); $this->cache->evictCollectionRegion(State::class, 'cities');
$this->cache->evictCollectionRegion(Traveler::CLASSNAME, 'travels'); $this->cache->evictCollectionRegion(Traveler::class, 'travels');
$traveler = new Traveler('Doctrine Bot'); $traveler = new Traveler('Doctrine Bot');
$travel = new Travel($traveler); $travel = new Travel($traveler);
@ -171,17 +171,17 @@ class SecondLevelCacheManyToManyTest extends SecondLevelCacheAbstractTest
$this->_em->flush(); $this->_em->flush();
$this->_em->clear(); $this->_em->clear();
$this->assertTrue($this->cache->containsEntity(Travel::CLASSNAME, $travel->getId())); $this->assertTrue($this->cache->containsEntity(Travel::class, $travel->getId()));
$this->assertTrue($this->cache->containsEntity(Traveler::CLASSNAME, $traveler->getId())); $this->assertTrue($this->cache->containsEntity(Traveler::class, $traveler->getId()));
$this->assertTrue($this->cache->containsEntity(City::CLASSNAME, $this->cities[0]->getId())); $this->assertTrue($this->cache->containsEntity(City::class, $this->cities[0]->getId()));
$this->assertTrue($this->cache->containsEntity(City::CLASSNAME, $this->cities[1]->getId())); $this->assertTrue($this->cache->containsEntity(City::class, $this->cities[1]->getId()));
$this->assertTrue($this->cache->containsEntity(City::CLASSNAME, $this->cities[3]->getId())); $this->assertTrue($this->cache->containsEntity(City::class, $this->cities[3]->getId()));
$this->assertTrue($this->cache->containsCollection(Travel::CLASSNAME, 'visitedCities', $travel->getId())); $this->assertTrue($this->cache->containsCollection(Travel::class, 'visitedCities', $travel->getId()));
$queryCount1 = $this->getCurrentQueryCount(); $queryCount1 = $this->getCurrentQueryCount();
$t1 = $this->_em->find(Travel::CLASSNAME, $travel->getId()); $t1 = $this->_em->find(Travel::class, $travel->getId());
$this->assertInstanceOf(Travel::CLASSNAME, $t1); $this->assertInstanceOf(Travel::class, $t1);
$this->assertCount(3, $t1->getVisitedCities()); $this->assertCount(3, $t1->getVisitedCities());
$this->assertEquals($queryCount1, $this->getCurrentQueryCount()); $this->assertEquals($queryCount1, $this->getCurrentQueryCount());
} }
@ -202,10 +202,10 @@ class SecondLevelCacheManyToManyTest extends SecondLevelCacheAbstractTest
$this->_em->clear(); $this->_em->clear();
$this->assertTrue($this->cache->containsEntity(Travel::CLASSNAME, $this->travels[0]->getId())); $this->assertTrue($this->cache->containsEntity(Travel::class, $this->travels[0]->getId()));
$this->assertTrue($this->cache->containsCollection(Travel::CLASSNAME, 'visitedCities', $this->travels[0]->getId())); $this->assertTrue($this->cache->containsCollection(Travel::class, 'visitedCities', $this->travels[0]->getId()));
$travel = $this->_em->find(Travel::CLASSNAME, $this->travels[0]->getId()); $travel = $this->_em->find(Travel::class, $this->travels[0]->getId());
$this->assertCount(3, $travel->getVisitedCities()); $this->assertCount(3, $travel->getVisitedCities());
@ -229,14 +229,14 @@ class SecondLevelCacheManyToManyTest extends SecondLevelCacheAbstractTest
$queryCount = $this->getCurrentQueryCount(); $queryCount = $this->getCurrentQueryCount();
$entitiId = $this->travels[2]->getId(); //empty travel $entitiId = $this->travels[2]->getId(); //empty travel
$entity = $this->_em->find(Travel::CLASSNAME, $entitiId); $entity = $this->_em->find(Travel::class, $entitiId);
$this->assertEquals(0, $entity->getVisitedCities()->count()); $this->assertEquals(0, $entity->getVisitedCities()->count());
$this->assertEquals($queryCount+2, $this->getCurrentQueryCount()); $this->assertEquals($queryCount+2, $this->getCurrentQueryCount());
$this->_em->clear(); $this->_em->clear();
$entity = $this->_em->find(Travel::CLASSNAME, $entitiId); $entity = $this->_em->find(Travel::class, $entitiId);
$queryCount = $this->getCurrentQueryCount(); $queryCount = $this->getCurrentQueryCount();
$this->assertEquals(0, $entity->getVisitedCities()->count()); $this->assertEquals(0, $entity->getVisitedCities()->count());

View File

@ -2,12 +2,13 @@
namespace Doctrine\Tests\ORM\Functional; namespace Doctrine\Tests\ORM\Functional;
use Doctrine\ORM\Cache\Region;
use Doctrine\Tests\Models\Cache\Action;
use Doctrine\Tests\Models\Cache\City; use Doctrine\Tests\Models\Cache\City;
use Doctrine\Tests\Models\Cache\ComplexAction; use Doctrine\Tests\Models\Cache\ComplexAction;
use Doctrine\Tests\Models\Cache\Country; use Doctrine\Tests\Models\Cache\Country;
use Doctrine\Tests\Models\Cache\State; use Doctrine\Tests\Models\Cache\State;
use Doctrine\Tests\Models\Cache\Token; use Doctrine\Tests\Models\Cache\Token;
use Doctrine\Tests\Models\Cache\Action;
/** /**
* @group DDC-2183 * @group DDC-2183
@ -20,10 +21,10 @@ class SecondLevelCacheManyToOneTest extends SecondLevelCacheAbstractTest
$this->loadFixturesStates(); $this->loadFixturesStates();
$this->_em->clear(); $this->_em->clear();
$this->assertTrue($this->cache->containsEntity(Country::CLASSNAME, $this->states[0]->getCountry()->getId())); $this->assertTrue($this->cache->containsEntity(Country::class, $this->states[0]->getCountry()->getId()));
$this->assertTrue($this->cache->containsEntity(Country::CLASSNAME, $this->states[1]->getCountry()->getId())); $this->assertTrue($this->cache->containsEntity(Country::class, $this->states[1]->getCountry()->getId()));
$this->assertTrue($this->cache->containsEntity(State::CLASSNAME, $this->states[0]->getId())); $this->assertTrue($this->cache->containsEntity(State::class, $this->states[0]->getId()));
$this->assertTrue($this->cache->containsEntity(State::CLASSNAME, $this->states[1]->getId())); $this->assertTrue($this->cache->containsEntity(State::class, $this->states[1]->getId()));
} }
public function testPutAndLoadManyToOneRelation() public function testPutAndLoadManyToOneRelation()
@ -32,30 +33,30 @@ class SecondLevelCacheManyToOneTest extends SecondLevelCacheAbstractTest
$this->loadFixturesStates(); $this->loadFixturesStates();
$this->_em->clear(); $this->_em->clear();
$this->cache->evictEntityRegion(State::CLASSNAME); $this->cache->evictEntityRegion(State::class);
$this->cache->evictEntityRegion(Country::CLASSNAME); $this->cache->evictEntityRegion(Country::class);
$this->assertFalse($this->cache->containsEntity(State::CLASSNAME, $this->states[0]->getId())); $this->assertFalse($this->cache->containsEntity(State::class, $this->states[0]->getId()));
$this->assertFalse($this->cache->containsEntity(State::CLASSNAME, $this->states[1]->getId())); $this->assertFalse($this->cache->containsEntity(State::class, $this->states[1]->getId()));
$this->assertFalse($this->cache->containsEntity(Country::CLASSNAME, $this->states[0]->getCountry()->getId())); $this->assertFalse($this->cache->containsEntity(Country::class, $this->states[0]->getCountry()->getId()));
$this->assertFalse($this->cache->containsEntity(Country::CLASSNAME, $this->states[1]->getCountry()->getId())); $this->assertFalse($this->cache->containsEntity(Country::class, $this->states[1]->getCountry()->getId()));
$c1 = $this->_em->find(State::CLASSNAME, $this->states[0]->getId()); $c1 = $this->_em->find(State::class, $this->states[0]->getId());
$c2 = $this->_em->find(State::CLASSNAME, $this->states[1]->getId()); $c2 = $this->_em->find(State::class, $this->states[1]->getId());
//trigger lazy load //trigger lazy load
$this->assertNotNull($c1->getCountry()->getName()); $this->assertNotNull($c1->getCountry()->getName());
$this->assertNotNull($c2->getCountry()->getName()); $this->assertNotNull($c2->getCountry()->getName());
$this->assertTrue($this->cache->containsEntity(Country::CLASSNAME, $this->states[0]->getCountry()->getId())); $this->assertTrue($this->cache->containsEntity(Country::class, $this->states[0]->getCountry()->getId()));
$this->assertTrue($this->cache->containsEntity(Country::CLASSNAME, $this->states[1]->getCountry()->getId())); $this->assertTrue($this->cache->containsEntity(Country::class, $this->states[1]->getCountry()->getId()));
$this->assertTrue($this->cache->containsEntity(State::CLASSNAME, $this->states[0]->getId())); $this->assertTrue($this->cache->containsEntity(State::class, $this->states[0]->getId()));
$this->assertTrue($this->cache->containsEntity(State::CLASSNAME, $this->states[1]->getId())); $this->assertTrue($this->cache->containsEntity(State::class, $this->states[1]->getId()));
$this->assertInstanceOf(State::CLASSNAME, $c1); $this->assertInstanceOf(State::class, $c1);
$this->assertInstanceOf(State::CLASSNAME, $c2); $this->assertInstanceOf(State::class, $c2);
$this->assertInstanceOf(Country::CLASSNAME, $c1->getCountry()); $this->assertInstanceOf(Country::class, $c1->getCountry());
$this->assertInstanceOf(Country::CLASSNAME, $c2->getCountry()); $this->assertInstanceOf(Country::class, $c2->getCountry());
$this->assertEquals($this->states[0]->getId(), $c1->getId()); $this->assertEquals($this->states[0]->getId(), $c1->getId());
$this->assertEquals($this->states[0]->getName(), $c1->getName()); $this->assertEquals($this->states[0]->getName(), $c1->getName());
@ -71,8 +72,8 @@ class SecondLevelCacheManyToOneTest extends SecondLevelCacheAbstractTest
$queryCount = $this->getCurrentQueryCount(); $queryCount = $this->getCurrentQueryCount();
$c3 = $this->_em->find(State::CLASSNAME, $this->states[0]->getId()); $c3 = $this->_em->find(State::class, $this->states[0]->getId());
$c4 = $this->_em->find(State::CLASSNAME, $this->states[1]->getId()); $c4 = $this->_em->find(State::class, $this->states[1]->getId());
$this->assertEquals($queryCount, $this->getCurrentQueryCount()); $this->assertEquals($queryCount, $this->getCurrentQueryCount());
@ -80,10 +81,10 @@ class SecondLevelCacheManyToOneTest extends SecondLevelCacheAbstractTest
$this->assertNotNull($c3->getCountry()->getName()); $this->assertNotNull($c3->getCountry()->getName());
$this->assertNotNull($c4->getCountry()->getName()); $this->assertNotNull($c4->getCountry()->getName());
$this->assertInstanceOf(State::CLASSNAME, $c3); $this->assertInstanceOf(State::class, $c3);
$this->assertInstanceOf(State::CLASSNAME, $c4); $this->assertInstanceOf(State::class, $c4);
$this->assertInstanceOf(Country::CLASSNAME, $c3->getCountry()); $this->assertInstanceOf(Country::class, $c3->getCountry());
$this->assertInstanceOf(Country::CLASSNAME, $c4->getCountry()); $this->assertInstanceOf(Country::class, $c4->getCountry());
$this->assertEquals($c1->getId(), $c3->getId()); $this->assertEquals($c1->getId(), $c3->getId());
$this->assertEquals($c1->getName(), $c3->getName()); $this->assertEquals($c1->getName(), $c3->getName());
@ -105,11 +106,11 @@ class SecondLevelCacheManyToOneTest extends SecondLevelCacheAbstractTest
$this->_em->clear(); $this->_em->clear();
$this->cache->evictEntityRegion(State::CLASSNAME); $this->cache->evictEntityRegion(State::class);
$this->cache->evictEntityRegion(Country::CLASSNAME); $this->cache->evictEntityRegion(Country::class);
//evict collection on add //evict collection on add
$c3 = $this->_em->find(State::CLASSNAME, $this->states[0]->getId()); $c3 = $this->_em->find(State::class, $this->states[0]->getId());
$prev = $c3->getCities(); $prev = $c3->getCities();
$count = $prev->count(); $count = $prev->count();
$city = new City("Buenos Aires", $c3); $city = new City("Buenos Aires", $c3);
@ -121,7 +122,7 @@ class SecondLevelCacheManyToOneTest extends SecondLevelCacheAbstractTest
$this->_em->flush(); $this->_em->flush();
$this->_em->clear(); $this->_em->clear();
$state = $this->_em->find(State::CLASSNAME, $c3->getId()); $state = $this->_em->find(State::class, $c3->getId());
$queryCount = $this->getCurrentQueryCount(); $queryCount = $this->getCurrentQueryCount();
// Association was cleared from EM // Association was cleared from EM
@ -144,29 +145,29 @@ class SecondLevelCacheManyToOneTest extends SecondLevelCacheAbstractTest
$countryId1 = $this->states[0]->getCountry()->getId(); $countryId1 = $this->states[0]->getCountry()->getId();
$countryId2 = $this->states[3]->getCountry()->getId(); $countryId2 = $this->states[3]->getCountry()->getId();
$this->assertTrue($this->cache->containsEntity(Country::CLASSNAME, $countryId1)); $this->assertTrue($this->cache->containsEntity(Country::class, $countryId1));
$this->assertTrue($this->cache->containsEntity(Country::CLASSNAME, $countryId2)); $this->assertTrue($this->cache->containsEntity(Country::class, $countryId2));
$this->assertTrue($this->cache->containsEntity(State::CLASSNAME, $stateId1)); $this->assertTrue($this->cache->containsEntity(State::class, $stateId1));
$this->assertTrue($this->cache->containsEntity(State::CLASSNAME, $stateId2)); $this->assertTrue($this->cache->containsEntity(State::class, $stateId2));
$this->cache->evictEntityRegion(Country::CLASSNAME); $this->cache->evictEntityRegion(Country::class);
$this->assertFalse($this->cache->containsEntity(Country::CLASSNAME, $countryId1)); $this->assertFalse($this->cache->containsEntity(Country::class, $countryId1));
$this->assertFalse($this->cache->containsEntity(Country::CLASSNAME, $countryId2)); $this->assertFalse($this->cache->containsEntity(Country::class, $countryId2));
$this->_em->clear(); $this->_em->clear();
$queryCount = $this->getCurrentQueryCount(); $queryCount = $this->getCurrentQueryCount();
$state1 = $this->_em->find(State::CLASSNAME, $stateId1); $state1 = $this->_em->find(State::class, $stateId1);
$state2 = $this->_em->find(State::CLASSNAME, $stateId2); $state2 = $this->_em->find(State::class, $stateId2);
$this->assertEquals($queryCount, $this->getCurrentQueryCount()); $this->assertEquals($queryCount, $this->getCurrentQueryCount());
$this->assertInstanceOf(State::CLASSNAME, $state1); $this->assertInstanceOf(State::class, $state1);
$this->assertInstanceOf(State::CLASSNAME, $state2); $this->assertInstanceOf(State::class, $state2);
$this->assertInstanceOf(Country::CLASSNAME, $state1->getCountry()); $this->assertInstanceOf(Country::class, $state1->getCountry());
$this->assertInstanceOf(Country::CLASSNAME, $state2->getCountry()); $this->assertInstanceOf(Country::class, $state2->getCountry());
$queryCount = $this->getCurrentQueryCount(); $queryCount = $this->getCurrentQueryCount();
@ -180,8 +181,8 @@ class SecondLevelCacheManyToOneTest extends SecondLevelCacheAbstractTest
public function testPutAndLoadNonCacheableManyToOne() public function testPutAndLoadNonCacheableManyToOne()
{ {
$this->assertNull($this->cache->getEntityCacheRegion(Action::CLASSNAME)); $this->assertNull($this->cache->getEntityCacheRegion(Action::class));
$this->assertInstanceOf('Doctrine\ORM\Cache\Region', $this->cache->getEntityCacheRegion(Token::CLASSNAME)); $this->assertInstanceOf(Region::class, $this->cache->getEntityCacheRegion(Token::class));
$token = new Token('token-hash'); $token = new Token('token-hash');
$action = new Action('exec'); $action = new Action('exec');
@ -192,16 +193,16 @@ class SecondLevelCacheManyToOneTest extends SecondLevelCacheAbstractTest
$this->_em->flush(); $this->_em->flush();
$this->_em->clear(); $this->_em->clear();
$this->assertTrue($this->cache->containsEntity(Token::CLASSNAME, $token->token)); $this->assertTrue($this->cache->containsEntity(Token::class, $token->token));
$this->assertFalse($this->cache->containsEntity(Token::CLASSNAME, $action->name)); $this->assertFalse($this->cache->containsEntity(Token::class, $action->name));
$queryCount = $this->getCurrentQueryCount(); $queryCount = $this->getCurrentQueryCount();
$entity = $this->_em->find(Token::CLASSNAME, $token->token); $entity = $this->_em->find(Token::class, $token->token);
$this->assertInstanceOf(Token::CLASSNAME, $entity); $this->assertInstanceOf(Token::class, $entity);
$this->assertEquals('token-hash', $entity->token); $this->assertEquals('token-hash', $entity->token);
$this->assertInstanceOf(Action::CLASSNAME, $entity->getAction()); $this->assertInstanceOf(Action::class, $entity->getAction());
$this->assertEquals('exec', $entity->getAction()->name); $this->assertEquals('exec', $entity->getAction()->name);
$this->assertEquals($queryCount, $this->getCurrentQueryCount()); $this->assertEquals($queryCount, $this->getCurrentQueryCount());
@ -209,9 +210,9 @@ class SecondLevelCacheManyToOneTest extends SecondLevelCacheAbstractTest
public function testPutAndLoadNonCacheableCompositeManyToOne() public function testPutAndLoadNonCacheableCompositeManyToOne()
{ {
$this->assertNull($this->cache->getEntityCacheRegion(Action::CLASSNAME)); $this->assertNull($this->cache->getEntityCacheRegion(Action::class));
$this->assertNull($this->cache->getEntityCacheRegion(ComplexAction::CLASSNAME)); $this->assertNull($this->cache->getEntityCacheRegion(ComplexAction::class));
$this->assertInstanceOf('Doctrine\ORM\Cache\Region', $this->cache->getEntityCacheRegion(Token::CLASSNAME)); $this->assertInstanceOf(Region::class, $this->cache->getEntityCacheRegion(Token::class));
$token = new Token('token-hash'); $token = new Token('token-hash');
@ -230,28 +231,28 @@ class SecondLevelCacheManyToOneTest extends SecondLevelCacheAbstractTest
$this->_em->flush(); $this->_em->flush();
$this->_em->clear(); $this->_em->clear();
$this->assertTrue($this->cache->containsEntity(Token::CLASSNAME, $token->token)); $this->assertTrue($this->cache->containsEntity(Token::class, $token->token));
$this->assertFalse($this->cache->containsEntity(Action::CLASSNAME, $action1->name)); $this->assertFalse($this->cache->containsEntity(Action::class, $action1->name));
$this->assertFalse($this->cache->containsEntity(Action::CLASSNAME, $action2->name)); $this->assertFalse($this->cache->containsEntity(Action::class, $action2->name));
$this->assertFalse($this->cache->containsEntity(Action::CLASSNAME, $action3->name)); $this->assertFalse($this->cache->containsEntity(Action::class, $action3->name));
$queryCount = $this->getCurrentQueryCount(); $queryCount = $this->getCurrentQueryCount();
/** /**
* @var $entity Token * @var $entity Token
*/ */
$entity = $this->_em->find(Token::CLASSNAME, $token->token); $entity = $this->_em->find(Token::class, $token->token);
$this->assertInstanceOf(Token::CLASSNAME, $entity); $this->assertInstanceOf(Token::class, $entity);
$this->assertEquals('token-hash', $entity->token); $this->assertEquals('token-hash', $entity->token);
$this->assertEquals($queryCount, $this->getCurrentQueryCount()); $this->assertEquals($queryCount, $this->getCurrentQueryCount());
$this->assertInstanceOf(Action::CLASSNAME, $entity->getAction()); $this->assertInstanceOf(Action::class, $entity->getAction());
$this->assertInstanceOf(ComplexAction::CLASSNAME, $entity->getComplexAction()); $this->assertInstanceOf(ComplexAction::class, $entity->getComplexAction());
$this->assertEquals($queryCount, $this->getCurrentQueryCount()); $this->assertEquals($queryCount, $this->getCurrentQueryCount());
$this->assertInstanceOf(Action::CLASSNAME, $entity->getComplexAction()->getAction1()); $this->assertInstanceOf(Action::class, $entity->getComplexAction()->getAction1());
$this->assertInstanceOf(Action::CLASSNAME, $entity->getComplexAction()->getAction2()); $this->assertInstanceOf(Action::class, $entity->getComplexAction()->getAction2());
$this->assertEquals($queryCount + 1, $this->getCurrentQueryCount()); $this->assertEquals($queryCount + 1, $this->getCurrentQueryCount());
$this->assertEquals('login', $entity->getComplexAction()->getAction1()->name); $this->assertEquals('login', $entity->getComplexAction()->getAction1()->name);

View File

@ -2,6 +2,7 @@
namespace Doctrine\Tests\ORM\Functional; namespace Doctrine\Tests\ORM\Functional;
use Doctrine\ORM\Cache\Region;
use Doctrine\Tests\Models\Cache\City; use Doctrine\Tests\Models\Cache\City;
use Doctrine\Tests\Models\Cache\Login; use Doctrine\Tests\Models\Cache\Login;
use Doctrine\Tests\Models\Cache\State; use Doctrine\Tests\Models\Cache\State;
@ -22,10 +23,10 @@ class SecondLevelCacheOneToManyTest extends SecondLevelCacheAbstractTest
$this->_em->clear(); $this->_em->clear();
$this->assertTrue($this->cache->containsEntity(State::CLASSNAME, $this->states[0]->getId())); $this->assertTrue($this->cache->containsEntity(State::class, $this->states[0]->getId()));
$this->assertTrue($this->cache->containsEntity(State::CLASSNAME, $this->states[1]->getId())); $this->assertTrue($this->cache->containsEntity(State::class, $this->states[1]->getId()));
$this->assertTrue($this->cache->containsCollection(State::CLASSNAME, 'cities', $this->states[0]->getId())); $this->assertTrue($this->cache->containsCollection(State::class, 'cities', $this->states[0]->getId()));
$this->assertTrue($this->cache->containsCollection(State::CLASSNAME, 'cities', $this->states[1]->getId())); $this->assertTrue($this->cache->containsCollection(State::class, 'cities', $this->states[1]->getId()));
} }
public function testPutAndLoadOneToManyRelation() public function testPutAndLoadOneToManyRelation()
@ -36,28 +37,28 @@ class SecondLevelCacheOneToManyTest extends SecondLevelCacheAbstractTest
$this->_em->clear(); $this->_em->clear();
$this->secondLevelCacheLogger->clearStats(); $this->secondLevelCacheLogger->clearStats();
$this->cache->evictEntityRegion(State::CLASSNAME); $this->cache->evictEntityRegion(State::class);
$this->cache->evictEntityRegion(City::CLASSNAME); $this->cache->evictEntityRegion(City::class);
$this->cache->evictCollectionRegion(State::CLASSNAME, 'cities'); $this->cache->evictCollectionRegion(State::class, 'cities');
$this->assertFalse($this->cache->containsEntity(State::CLASSNAME, $this->states[0]->getId())); $this->assertFalse($this->cache->containsEntity(State::class, $this->states[0]->getId()));
$this->assertFalse($this->cache->containsEntity(State::CLASSNAME, $this->states[1]->getId())); $this->assertFalse($this->cache->containsEntity(State::class, $this->states[1]->getId()));
$this->assertFalse($this->cache->containsCollection(State::CLASSNAME, 'cities', $this->states[0]->getId())); $this->assertFalse($this->cache->containsCollection(State::class, 'cities', $this->states[0]->getId()));
$this->assertFalse($this->cache->containsCollection(State::CLASSNAME, 'cities', $this->states[1]->getId())); $this->assertFalse($this->cache->containsCollection(State::class, 'cities', $this->states[1]->getId()));
$this->assertFalse($this->cache->containsEntity(City::CLASSNAME, $this->states[0]->getCities()->get(0)->getId())); $this->assertFalse($this->cache->containsEntity(City::class, $this->states[0]->getCities()->get(0)->getId()));
$this->assertFalse($this->cache->containsEntity(City::CLASSNAME, $this->states[0]->getCities()->get(1)->getId())); $this->assertFalse($this->cache->containsEntity(City::class, $this->states[0]->getCities()->get(1)->getId()));
$this->assertFalse($this->cache->containsEntity(City::CLASSNAME, $this->states[1]->getCities()->get(0)->getId())); $this->assertFalse($this->cache->containsEntity(City::class, $this->states[1]->getCities()->get(0)->getId()));
$this->assertFalse($this->cache->containsEntity(City::CLASSNAME, $this->states[1]->getCities()->get(1)->getId())); $this->assertFalse($this->cache->containsEntity(City::class, $this->states[1]->getCities()->get(1)->getId()));
$s1 = $this->_em->find(State::CLASSNAME, $this->states[0]->getId()); $s1 = $this->_em->find(State::class, $this->states[0]->getId());
$s2 = $this->_em->find(State::CLASSNAME, $this->states[1]->getId()); $s2 = $this->_em->find(State::class, $this->states[1]->getId());
$this->assertEquals(2, $this->secondLevelCacheLogger->getPutCount()); $this->assertEquals(2, $this->secondLevelCacheLogger->getPutCount());
$this->assertEquals(2, $this->secondLevelCacheLogger->getMissCount()); $this->assertEquals(2, $this->secondLevelCacheLogger->getMissCount());
$this->assertEquals(2, $this->secondLevelCacheLogger->getRegionPutCount($this->getEntityRegion(State::CLASSNAME))); $this->assertEquals(2, $this->secondLevelCacheLogger->getRegionPutCount($this->getEntityRegion(State::class)));
$this->assertEquals(2, $this->secondLevelCacheLogger->getRegionMissCount($this->getEntityRegion(State::CLASSNAME))); $this->assertEquals(2, $this->secondLevelCacheLogger->getRegionMissCount($this->getEntityRegion(State::class)));
//trigger lazy load //trigger lazy load
$this->assertCount(2, $s1->getCities()); $this->assertCount(2, $s1->getCities());
@ -65,46 +66,46 @@ class SecondLevelCacheOneToManyTest extends SecondLevelCacheAbstractTest
$this->assertEquals(4, $this->secondLevelCacheLogger->getPutCount()); $this->assertEquals(4, $this->secondLevelCacheLogger->getPutCount());
$this->assertEquals(4, $this->secondLevelCacheLogger->getMissCount()); $this->assertEquals(4, $this->secondLevelCacheLogger->getMissCount());
$this->assertEquals(2, $this->secondLevelCacheLogger->getRegionPutCount($this->getCollectionRegion(State::CLASSNAME, 'cities'))); $this->assertEquals(2, $this->secondLevelCacheLogger->getRegionPutCount($this->getCollectionRegion(State::class, 'cities')));
$this->assertEquals(2, $this->secondLevelCacheLogger->getRegionMissCount($this->getCollectionRegion(State::CLASSNAME, 'cities'))); $this->assertEquals(2, $this->secondLevelCacheLogger->getRegionMissCount($this->getCollectionRegion(State::class, 'cities')));
$this->assertInstanceOf(City::CLASSNAME, $s1->getCities()->get(0)); $this->assertInstanceOf(City::class, $s1->getCities()->get(0));
$this->assertInstanceOf(City::CLASSNAME, $s1->getCities()->get(1)); $this->assertInstanceOf(City::class, $s1->getCities()->get(1));
$this->assertInstanceOf(City::CLASSNAME, $s2->getCities()->get(0)); $this->assertInstanceOf(City::class, $s2->getCities()->get(0));
$this->assertInstanceOf(City::CLASSNAME, $s2->getCities()->get(1)); $this->assertInstanceOf(City::class, $s2->getCities()->get(1));
$this->assertTrue($this->cache->containsEntity(State::CLASSNAME, $this->states[0]->getId())); $this->assertTrue($this->cache->containsEntity(State::class, $this->states[0]->getId()));
$this->assertTrue($this->cache->containsEntity(State::CLASSNAME, $this->states[1]->getId())); $this->assertTrue($this->cache->containsEntity(State::class, $this->states[1]->getId()));
$this->assertTrue($this->cache->containsCollection(State::CLASSNAME, 'cities', $this->states[0]->getId())); $this->assertTrue($this->cache->containsCollection(State::class, 'cities', $this->states[0]->getId()));
$this->assertTrue($this->cache->containsCollection(State::CLASSNAME, 'cities', $this->states[1]->getId())); $this->assertTrue($this->cache->containsCollection(State::class, 'cities', $this->states[1]->getId()));
$this->assertTrue($this->cache->containsEntity(City::CLASSNAME, $this->states[0]->getCities()->get(0)->getId())); $this->assertTrue($this->cache->containsEntity(City::class, $this->states[0]->getCities()->get(0)->getId()));
$this->assertTrue($this->cache->containsEntity(City::CLASSNAME, $this->states[0]->getCities()->get(1)->getId())); $this->assertTrue($this->cache->containsEntity(City::class, $this->states[0]->getCities()->get(1)->getId()));
$this->assertTrue($this->cache->containsEntity(City::CLASSNAME, $this->states[1]->getCities()->get(0)->getId())); $this->assertTrue($this->cache->containsEntity(City::class, $this->states[1]->getCities()->get(0)->getId()));
$this->assertTrue($this->cache->containsEntity(City::CLASSNAME, $this->states[1]->getCities()->get(1)->getId())); $this->assertTrue($this->cache->containsEntity(City::class, $this->states[1]->getCities()->get(1)->getId()));
$this->_em->clear(); $this->_em->clear();
$this->secondLevelCacheLogger->clearStats(); $this->secondLevelCacheLogger->clearStats();
$queryCount = $this->getCurrentQueryCount(); $queryCount = $this->getCurrentQueryCount();
$s3 = $this->_em->find(State::CLASSNAME, $this->states[0]->getId()); $s3 = $this->_em->find(State::class, $this->states[0]->getId());
$s4 = $this->_em->find(State::CLASSNAME, $this->states[1]->getId()); $s4 = $this->_em->find(State::class, $this->states[1]->getId());
//trigger lazy load from cache //trigger lazy load from cache
$this->assertCount(2, $s3->getCities()); $this->assertCount(2, $s3->getCities());
$this->assertCount(2, $s4->getCities()); $this->assertCount(2, $s4->getCities());
$this->assertEquals(4, $this->secondLevelCacheLogger->getHitCount()); $this->assertEquals(4, $this->secondLevelCacheLogger->getHitCount());
$this->assertEquals(2, $this->secondLevelCacheLogger->getRegionHitCount($this->getEntityRegion(State::CLASSNAME))); $this->assertEquals(2, $this->secondLevelCacheLogger->getRegionHitCount($this->getEntityRegion(State::class)));
$this->assertEquals(2, $this->secondLevelCacheLogger->getRegionHitCount($this->getCollectionRegion(State::CLASSNAME, 'cities'))); $this->assertEquals(2, $this->secondLevelCacheLogger->getRegionHitCount($this->getCollectionRegion(State::class, 'cities')));
$this->assertInstanceOf(City::CLASSNAME, $s3->getCities()->get(0)); $this->assertInstanceOf(City::class, $s3->getCities()->get(0));
$this->assertInstanceOf(City::CLASSNAME, $s3->getCities()->get(1)); $this->assertInstanceOf(City::class, $s3->getCities()->get(1));
$this->assertInstanceOf(City::CLASSNAME, $s4->getCities()->get(0)); $this->assertInstanceOf(City::class, $s4->getCities()->get(0));
$this->assertInstanceOf(City::CLASSNAME, $s4->getCities()->get(1)); $this->assertInstanceOf(City::class, $s4->getCities()->get(1));
$this->assertNotSame($s1->getCities()->get(0), $s3->getCities()->get(0)); $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)->getId(), $s3->getCities()->get(0)->getId());
@ -134,32 +135,32 @@ class SecondLevelCacheOneToManyTest extends SecondLevelCacheAbstractTest
$this->_em->clear(); $this->_em->clear();
//trigger lazy load from database //trigger lazy load from database
$this->assertCount(2, $this->_em->find(State::CLASSNAME, $this->states[0]->getId())->getCities()); $this->assertCount(2, $this->_em->find(State::class, $this->states[0]->getId())->getCities());
$this->assertTrue($this->cache->containsEntity(State::CLASSNAME, $this->states[0]->getId())); $this->assertTrue($this->cache->containsEntity(State::class, $this->states[0]->getId()));
$this->assertTrue($this->cache->containsCollection(State::CLASSNAME, 'cities', $this->states[0]->getId())); $this->assertTrue($this->cache->containsCollection(State::class, 'cities', $this->states[0]->getId()));
$this->assertTrue($this->cache->containsEntity(City::CLASSNAME, $this->states[0]->getCities()->get(0)->getId())); $this->assertTrue($this->cache->containsEntity(City::class, $this->states[0]->getCities()->get(0)->getId()));
$this->assertTrue($this->cache->containsEntity(City::CLASSNAME, $this->states[0]->getCities()->get(1)->getId())); $this->assertTrue($this->cache->containsEntity(City::class, $this->states[0]->getCities()->get(1)->getId()));
$queryCount = $this->getCurrentQueryCount(); $queryCount = $this->getCurrentQueryCount();
$stateId = $this->states[0]->getId(); $stateId = $this->states[0]->getId();
$state = $this->_em->find(State::CLASSNAME, $stateId); $state = $this->_em->find(State::class, $stateId);
$cityId = $this->states[0]->getCities()->get(1)->getId(); $cityId = $this->states[0]->getCities()->get(1)->getId();
//trigger lazy load from cache //trigger lazy load from cache
$this->assertCount(2, $state->getCities()); $this->assertCount(2, $state->getCities());
$this->assertEquals($queryCount, $this->getCurrentQueryCount()); $this->assertEquals($queryCount, $this->getCurrentQueryCount());
$this->assertTrue($this->cache->containsEntity(City::CLASSNAME, $cityId)); $this->assertTrue($this->cache->containsEntity(City::class, $cityId));
$this->cache->evictEntity(City::CLASSNAME, $cityId); $this->cache->evictEntity(City::class, $cityId);
$this->assertFalse($this->cache->containsEntity(City::CLASSNAME, $cityId)); $this->assertFalse($this->cache->containsEntity(City::class, $cityId));
$this->assertTrue($this->cache->containsEntity(State::CLASSNAME, $stateId)); $this->assertTrue($this->cache->containsEntity(State::class, $stateId));
$this->assertTrue($this->cache->containsCollection(State::CLASSNAME, 'cities', $stateId)); $this->assertTrue($this->cache->containsCollection(State::class, 'cities', $stateId));
$this->_em->clear(); $this->_em->clear();
$state = $this->_em->find(State::CLASSNAME, $stateId); $state = $this->_em->find(State::class, $stateId);
//trigger lazy load from database //trigger lazy load from database
$this->assertCount(2, $state->getCities()); $this->assertCount(2, $state->getCities());
@ -178,8 +179,8 @@ class SecondLevelCacheOneToManyTest extends SecondLevelCacheAbstractTest
$this->_em->flush(); $this->_em->flush();
$this->_em->clear(); $this->_em->clear();
$this->assertTrue($this->cache->containsEntity(State::CLASSNAME, $state->getId())); $this->assertTrue($this->cache->containsEntity(State::class, $state->getId()));
$this->assertFalse($this->cache->containsCollection(State::CLASSNAME, 'cities', $state->getId())); $this->assertFalse($this->cache->containsCollection(State::class, 'cities', $state->getId()));
} }
public function testOneToManyRemove() public function testOneToManyRemove()
@ -191,51 +192,51 @@ class SecondLevelCacheOneToManyTest extends SecondLevelCacheAbstractTest
$this->_em->clear(); $this->_em->clear();
$this->secondLevelCacheLogger->clearStats(); $this->secondLevelCacheLogger->clearStats();
$this->cache->evictEntityRegion(State::CLASSNAME); $this->cache->evictEntityRegion(State::class);
$this->cache->evictEntityRegion(City::CLASSNAME); $this->cache->evictEntityRegion(City::class);
$this->cache->evictCollectionRegion(State::CLASSNAME, 'cities'); $this->cache->evictCollectionRegion(State::class, 'cities');
$this->assertFalse($this->cache->containsEntity(State::CLASSNAME, $this->states[0]->getId())); $this->assertFalse($this->cache->containsEntity(State::class, $this->states[0]->getId()));
$this->assertFalse($this->cache->containsCollection(State::CLASSNAME, 'cities', $this->states[0]->getId())); $this->assertFalse($this->cache->containsCollection(State::class, 'cities', $this->states[0]->getId()));
$this->assertFalse($this->cache->containsEntity(City::CLASSNAME, $this->states[0]->getCities()->get(0)->getId())); $this->assertFalse($this->cache->containsEntity(City::class, $this->states[0]->getCities()->get(0)->getId()));
$this->assertFalse($this->cache->containsEntity(City::CLASSNAME, $this->states[0]->getCities()->get(1)->getId())); $this->assertFalse($this->cache->containsEntity(City::class, $this->states[0]->getCities()->get(1)->getId()));
$entity = $this->_em->find(State::CLASSNAME, $this->states[0]->getId()); $entity = $this->_em->find(State::class, $this->states[0]->getId());
$this->assertEquals(1, $this->secondLevelCacheLogger->getPutCount()); $this->assertEquals(1, $this->secondLevelCacheLogger->getPutCount());
$this->assertEquals(1, $this->secondLevelCacheLogger->getMissCount()); $this->assertEquals(1, $this->secondLevelCacheLogger->getMissCount());
$this->assertEquals(1, $this->secondLevelCacheLogger->getRegionPutCount($this->getEntityRegion(State::CLASSNAME))); $this->assertEquals(1, $this->secondLevelCacheLogger->getRegionPutCount($this->getEntityRegion(State::class)));
$this->assertEquals(1, $this->secondLevelCacheLogger->getRegionMissCount($this->getEntityRegion(State::CLASSNAME))); $this->assertEquals(1, $this->secondLevelCacheLogger->getRegionMissCount($this->getEntityRegion(State::class)));
//trigger lazy load //trigger lazy load
$this->assertCount(2, $entity->getCities()); $this->assertCount(2, $entity->getCities());
$this->assertEquals(2, $this->secondLevelCacheLogger->getPutCount()); $this->assertEquals(2, $this->secondLevelCacheLogger->getPutCount());
$this->assertEquals(2, $this->secondLevelCacheLogger->getMissCount()); $this->assertEquals(2, $this->secondLevelCacheLogger->getMissCount());
$this->assertEquals(1, $this->secondLevelCacheLogger->getRegionPutCount($this->getCollectionRegion(State::CLASSNAME, 'cities'))); $this->assertEquals(1, $this->secondLevelCacheLogger->getRegionPutCount($this->getCollectionRegion(State::class, 'cities')));
$this->assertEquals(1, $this->secondLevelCacheLogger->getRegionMissCount($this->getCollectionRegion(State::CLASSNAME, 'cities'))); $this->assertEquals(1, $this->secondLevelCacheLogger->getRegionMissCount($this->getCollectionRegion(State::class, 'cities')));
$this->assertInstanceOf(City::CLASSNAME, $entity->getCities()->get(0)); $this->assertInstanceOf(City::class, $entity->getCities()->get(0));
$this->assertInstanceOf(City::CLASSNAME, $entity->getCities()->get(1)); $this->assertInstanceOf(City::class, $entity->getCities()->get(1));
$this->_em->clear(); $this->_em->clear();
$this->secondLevelCacheLogger->clearStats(); $this->secondLevelCacheLogger->clearStats();
$queryCount = $this->getCurrentQueryCount(); $queryCount = $this->getCurrentQueryCount();
$state = $this->_em->find(State::CLASSNAME, $this->states[0]->getId()); $state = $this->_em->find(State::class, $this->states[0]->getId());
//trigger lazy load from cache //trigger lazy load from cache
$this->assertCount(2, $state->getCities()); $this->assertCount(2, $state->getCities());
$this->assertEquals(2, $this->secondLevelCacheLogger->getHitCount()); $this->assertEquals(2, $this->secondLevelCacheLogger->getHitCount());
$this->assertEquals(1, $this->secondLevelCacheLogger->getRegionHitCount($this->getEntityRegion(State::CLASSNAME))); $this->assertEquals(1, $this->secondLevelCacheLogger->getRegionHitCount($this->getEntityRegion(State::class)));
$this->assertEquals(1, $this->secondLevelCacheLogger->getRegionHitCount($this->getCollectionRegion(State::CLASSNAME, 'cities'))); $this->assertEquals(1, $this->secondLevelCacheLogger->getRegionHitCount($this->getCollectionRegion(State::class, 'cities')));
$city0 = $state->getCities()->get(0); $city0 = $state->getCities()->get(0);
$city1 = $state->getCities()->get(1); $city1 = $state->getCities()->get(1);
$this->assertInstanceOf(City::CLASSNAME, $city0); $this->assertInstanceOf(City::class, $city0);
$this->assertInstanceOf(City::CLASSNAME, $city1); $this->assertInstanceOf(City::class, $city1);
$this->assertEquals($entity->getCities()->get(0)->getName(), $city0->getName()); $this->assertEquals($entity->getCities()->get(0)->getName(), $city0->getName());
$this->assertEquals($entity->getCities()->get(1)->getName(), $city1->getName()); $this->assertEquals($entity->getCities()->get(1)->getName(), $city1->getName());
@ -253,18 +254,18 @@ class SecondLevelCacheOneToManyTest extends SecondLevelCacheAbstractTest
$this->secondLevelCacheLogger->clearStats(); $this->secondLevelCacheLogger->clearStats();
$queryCount = $this->getCurrentQueryCount(); $queryCount = $this->getCurrentQueryCount();
$state = $this->_em->find(State::CLASSNAME, $this->states[0]->getId()); $state = $this->_em->find(State::class, $this->states[0]->getId());
//trigger lazy load from cache //trigger lazy load from cache
$this->assertCount(1, $state->getCities()); $this->assertCount(1, $state->getCities());
$city1 = $state->getCities()->get(0); $city1 = $state->getCities()->get(0);
$this->assertInstanceOf(City::CLASSNAME, $city1); $this->assertInstanceOf(City::class, $city1);
$this->assertEquals($entity->getCities()->get(1)->getName(), $city1->getName()); $this->assertEquals($entity->getCities()->get(1)->getName(), $city1->getName());
$this->assertEquals(2, $this->secondLevelCacheLogger->getHitCount()); $this->assertEquals(2, $this->secondLevelCacheLogger->getHitCount());
$this->assertEquals(1, $this->secondLevelCacheLogger->getRegionHitCount($this->getEntityRegion(State::CLASSNAME))); $this->assertEquals(1, $this->secondLevelCacheLogger->getRegionHitCount($this->getEntityRegion(State::class)));
$this->assertEquals(1, $this->secondLevelCacheLogger->getRegionHitCount($this->getCollectionRegion(State::CLASSNAME, 'cities'))); $this->assertEquals(1, $this->secondLevelCacheLogger->getRegionHitCount($this->getCollectionRegion(State::class, 'cities')));
$this->assertEquals($queryCount, $this->getCurrentQueryCount()); $this->assertEquals($queryCount, $this->getCurrentQueryCount());
@ -278,13 +279,13 @@ class SecondLevelCacheOneToManyTest extends SecondLevelCacheAbstractTest
$this->secondLevelCacheLogger->clearStats(); $this->secondLevelCacheLogger->clearStats();
$queryCount = $this->getCurrentQueryCount(); $queryCount = $this->getCurrentQueryCount();
$state = $this->_em->find(State::CLASSNAME, $this->states[0]->getId()); $state = $this->_em->find(State::class, $this->states[0]->getId());
$this->assertCount(0, $state->getCities()); $this->assertCount(0, $state->getCities());
$this->assertEquals(2, $this->secondLevelCacheLogger->getHitCount()); $this->assertEquals(2, $this->secondLevelCacheLogger->getHitCount());
$this->assertEquals(1, $this->secondLevelCacheLogger->getRegionHitCount($this->getEntityRegion(State::CLASSNAME))); $this->assertEquals(1, $this->secondLevelCacheLogger->getRegionHitCount($this->getEntityRegion(State::class)));
$this->assertEquals(1, $this->secondLevelCacheLogger->getRegionHitCount($this->getCollectionRegion(State::CLASSNAME, 'cities'))); $this->assertEquals(1, $this->secondLevelCacheLogger->getRegionHitCount($this->getCollectionRegion(State::class, 'cities')));
} }
public function testOneToManyWithEmptyRelation() public function testOneToManyWithEmptyRelation()
@ -294,14 +295,14 @@ class SecondLevelCacheOneToManyTest extends SecondLevelCacheAbstractTest
$this->loadFixturesCities(); $this->loadFixturesCities();
$this->secondLevelCacheLogger->clearStats(); $this->secondLevelCacheLogger->clearStats();
$this->cache->evictEntityRegion(City::CLASSNAME); $this->cache->evictEntityRegion(City::class);
$this->cache->evictEntityRegion(State::CLASSNAME); $this->cache->evictEntityRegion(State::class);
$this->cache->evictCollectionRegion(State::CLASSNAME, 'cities'); $this->cache->evictCollectionRegion(State::class, 'cities');
$this->_em->clear(); $this->_em->clear();
$entitiId = $this->states[2]->getId(); // bavaria (cities count = 0) $entitiId = $this->states[2]->getId(); // bavaria (cities count = 0)
$queryCount = $this->getCurrentQueryCount(); $queryCount = $this->getCurrentQueryCount();
$entity = $this->_em->find(State::CLASSNAME, $entitiId); $entity = $this->_em->find(State::class, $entitiId);
$this->assertEquals(0, $entity->getCities()->count()); $this->assertEquals(0, $entity->getCities()->count());
$this->assertEquals($queryCount + 2, $this->getCurrentQueryCount()); $this->assertEquals($queryCount + 2, $this->getCurrentQueryCount());
@ -309,7 +310,7 @@ class SecondLevelCacheOneToManyTest extends SecondLevelCacheAbstractTest
$this->_em->clear(); $this->_em->clear();
$queryCount = $this->getCurrentQueryCount(); $queryCount = $this->getCurrentQueryCount();
$entity = $this->_em->find(State::CLASSNAME, $entitiId); $entity = $this->_em->find(State::class, $entitiId);
$this->assertEquals(0, $entity->getCities()->count()); $this->assertEquals(0, $entity->getCities()->count());
$this->assertEquals($queryCount, $this->getCurrentQueryCount()); $this->assertEquals($queryCount, $this->getCurrentQueryCount());
@ -323,14 +324,14 @@ class SecondLevelCacheOneToManyTest extends SecondLevelCacheAbstractTest
$this->loadFixturesCities(); $this->loadFixturesCities();
$this->secondLevelCacheLogger->clearStats(); $this->secondLevelCacheLogger->clearStats();
$this->cache->evictEntityRegion(City::CLASSNAME); $this->cache->evictEntityRegion(City::class);
$this->cache->evictEntityRegion(State::CLASSNAME); $this->cache->evictEntityRegion(State::class);
$this->cache->evictCollectionRegion(State::CLASSNAME, 'cities'); $this->cache->evictCollectionRegion(State::class, 'cities');
$this->_em->clear(); $this->_em->clear();
$entityId = $this->states[0]->getId(); $entityId = $this->states[0]->getId();
$queryCount = $this->getCurrentQueryCount(); $queryCount = $this->getCurrentQueryCount();
$entity = $this->_em->find(State::CLASSNAME, $entityId); $entity = $this->_em->find(State::class, $entityId);
$this->assertEquals(2, $entity->getCities()->count()); $this->assertEquals(2, $entity->getCities()->count());
$this->assertEquals($queryCount + 2, $this->getCurrentQueryCount()); $this->assertEquals($queryCount + 2, $this->getCurrentQueryCount());
@ -338,7 +339,7 @@ class SecondLevelCacheOneToManyTest extends SecondLevelCacheAbstractTest
$this->_em->clear(); $this->_em->clear();
$queryCount = $this->getCurrentQueryCount(); $queryCount = $this->getCurrentQueryCount();
$entity = $this->_em->find(State::CLASSNAME, $entityId); $entity = $this->_em->find(State::class, $entityId);
$this->assertEquals(2, $entity->getCities()->count()); $this->assertEquals(2, $entity->getCities()->count());
$this->assertEquals($queryCount, $this->getCurrentQueryCount()); $this->assertEquals($queryCount, $this->getCurrentQueryCount());
@ -364,7 +365,7 @@ class SecondLevelCacheOneToManyTest extends SecondLevelCacheAbstractTest
$travelerId = $traveler->getId(); $travelerId = $traveler->getId();
$queryCount = $this->getCurrentQueryCount(); $queryCount = $this->getCurrentQueryCount();
$entity = $this->_em->find(Traveler::CLASSNAME, $travelerId); $entity = $this->_em->find(Traveler::class, $travelerId);
$this->assertEquals($queryCount, $this->getCurrentQueryCount()); $this->assertEquals($queryCount, $this->getCurrentQueryCount());
$this->assertFalse($entity->getTravels()->isInitialized()); $this->assertFalse($entity->getTravels()->isInitialized());
@ -388,8 +389,8 @@ class SecondLevelCacheOneToManyTest extends SecondLevelCacheAbstractTest
public function testPutAndLoadNonCacheableOneToMany() public function testPutAndLoadNonCacheableOneToMany()
{ {
$this->assertNull($this->cache->getEntityCacheRegion(Login::CLASSNAME)); $this->assertNull($this->cache->getEntityCacheRegion(Login::class));
$this->assertInstanceOf('Doctrine\ORM\Cache\Region', $this->cache->getEntityCacheRegion(Token::CLASSNAME)); $this->assertInstanceOf(Region::class, $this->cache->getEntityCacheRegion(Token::class));
$l1 = new Login('session1'); $l1 = new Login('session1');
$l2 = new Login('session2'); $l2 = new Login('session2');
@ -401,13 +402,13 @@ class SecondLevelCacheOneToManyTest extends SecondLevelCacheAbstractTest
$this->_em->flush(); $this->_em->flush();
$this->_em->clear(); $this->_em->clear();
$this->assertTrue($this->cache->containsEntity(Token::CLASSNAME, $token->token)); $this->assertTrue($this->cache->containsEntity(Token::class, $token->token));
$queryCount = $this->getCurrentQueryCount(); $queryCount = $this->getCurrentQueryCount();
$entity = $this->_em->find(Token::CLASSNAME, $token->token); $entity = $this->_em->find(Token::class, $token->token);
$this->assertInstanceOf(Token::CLASSNAME, $entity); $this->assertInstanceOf(Token::class, $entity);
$this->assertEquals('token-hash', $entity->token); $this->assertEquals('token-hash', $entity->token);
$this->assertEquals($queryCount, $this->getCurrentQueryCount()); $this->assertEquals($queryCount, $this->getCurrentQueryCount());

View File

@ -2,6 +2,7 @@
namespace Doctrine\Tests\ORM\Functional; namespace Doctrine\Tests\ORM\Functional;
use Doctrine\ORM\Cache\Region;
use Doctrine\Tests\Models\Cache\Address; use Doctrine\Tests\Models\Cache\Address;
use Doctrine\Tests\Models\Cache\Client; use Doctrine\Tests\Models\Cache\Client;
use Doctrine\Tests\Models\Cache\Person; use Doctrine\Tests\Models\Cache\Person;
@ -27,10 +28,10 @@ class SecondLevelCacheOneToOneTest extends SecondLevelCacheAbstractTest
$entity1 = $this->travelersWithProfile[0]; $entity1 = $this->travelersWithProfile[0];
$entity2 = $this->travelersWithProfile[1]; $entity2 = $this->travelersWithProfile[1];
$this->assertTrue($this->cache->containsEntity(Traveler::CLASSNAME, $entity1->getId())); $this->assertTrue($this->cache->containsEntity(Traveler::class, $entity1->getId()));
$this->assertTrue($this->cache->containsEntity(Traveler::CLASSNAME, $entity2->getId())); $this->assertTrue($this->cache->containsEntity(Traveler::class, $entity2->getId()));
$this->assertTrue($this->cache->containsEntity(TravelerProfile::CLASSNAME, $entity1->getProfile()->getId())); $this->assertTrue($this->cache->containsEntity(TravelerProfile::class, $entity1->getProfile()->getId()));
$this->assertTrue($this->cache->containsEntity(TravelerProfile::CLASSNAME, $entity2->getProfile()->getId())); $this->assertTrue($this->cache->containsEntity(TravelerProfile::class, $entity2->getProfile()->getId()));
} }
public function testPutOneToOneOnBidirectionalPersist() public function testPutOneToOneOnBidirectionalPersist()
@ -46,12 +47,12 @@ class SecondLevelCacheOneToOneTest extends SecondLevelCacheAbstractTest
$entity1 = $this->travelersWithProfile[0]; $entity1 = $this->travelersWithProfile[0];
$entity2 = $this->travelersWithProfile[1]; $entity2 = $this->travelersWithProfile[1];
$this->assertTrue($this->cache->containsEntity(Traveler::CLASSNAME, $entity1->getId())); $this->assertTrue($this->cache->containsEntity(Traveler::class, $entity1->getId()));
$this->assertTrue($this->cache->containsEntity(Traveler::CLASSNAME, $entity2->getId())); $this->assertTrue($this->cache->containsEntity(Traveler::class, $entity2->getId()));
$this->assertTrue($this->cache->containsEntity(TravelerProfile::CLASSNAME, $entity1->getProfile()->getId())); $this->assertTrue($this->cache->containsEntity(TravelerProfile::class, $entity1->getProfile()->getId()));
$this->assertTrue($this->cache->containsEntity(TravelerProfile::CLASSNAME, $entity2->getProfile()->getId())); $this->assertTrue($this->cache->containsEntity(TravelerProfile::class, $entity2->getProfile()->getId()));
$this->assertTrue($this->cache->containsEntity(TravelerProfileInfo::CLASSNAME, $entity1->getProfile()->getInfo()->getId())); $this->assertTrue($this->cache->containsEntity(TravelerProfileInfo::class, $entity1->getProfile()->getInfo()->getId()));
$this->assertTrue($this->cache->containsEntity(TravelerProfileInfo::CLASSNAME, $entity2->getProfile()->getInfo()->getId())); $this->assertTrue($this->cache->containsEntity(TravelerProfileInfo::class, $entity2->getProfile()->getInfo()->getId()));
} }
public function testPutAndLoadOneToOneUnidirectionalRelation() public function testPutAndLoadOneToOneUnidirectionalRelation()
@ -64,30 +65,30 @@ class SecondLevelCacheOneToOneTest extends SecondLevelCacheAbstractTest
$this->_em->clear(); $this->_em->clear();
$this->cache->evictEntityRegion(Traveler::CLASSNAME); $this->cache->evictEntityRegion(Traveler::class);
$this->cache->evictEntityRegion(TravelerProfile::CLASSNAME); $this->cache->evictEntityRegion(TravelerProfile::class);
$entity1 = $this->travelersWithProfile[0]; $entity1 = $this->travelersWithProfile[0];
$entity2 = $this->travelersWithProfile[1]; $entity2 = $this->travelersWithProfile[1];
$this->assertFalse($this->cache->containsEntity(Traveler::CLASSNAME, $entity1->getId())); $this->assertFalse($this->cache->containsEntity(Traveler::class, $entity1->getId()));
$this->assertFalse($this->cache->containsEntity(Traveler::CLASSNAME, $entity2->getId())); $this->assertFalse($this->cache->containsEntity(Traveler::class, $entity2->getId()));
$this->assertFalse($this->cache->containsEntity(TravelerProfile::CLASSNAME, $entity1->getProfile()->getId())); $this->assertFalse($this->cache->containsEntity(TravelerProfile::class, $entity1->getProfile()->getId()));
$this->assertFalse($this->cache->containsEntity(TravelerProfile::CLASSNAME, $entity2->getProfile()->getId())); $this->assertFalse($this->cache->containsEntity(TravelerProfile::class, $entity2->getProfile()->getId()));
$t1 = $this->_em->find(Traveler::CLASSNAME, $entity1->getId()); $t1 = $this->_em->find(Traveler::class, $entity1->getId());
$t2 = $this->_em->find(Traveler::CLASSNAME, $entity2->getId()); $t2 = $this->_em->find(Traveler::class, $entity2->getId());
$this->assertTrue($this->cache->containsEntity(Traveler::CLASSNAME, $entity1->getId())); $this->assertTrue($this->cache->containsEntity(Traveler::class, $entity1->getId()));
$this->assertTrue($this->cache->containsEntity(Traveler::CLASSNAME, $entity2->getId())); $this->assertTrue($this->cache->containsEntity(Traveler::class, $entity2->getId()));
// The inverse side its not cached // The inverse side its not cached
$this->assertFalse($this->cache->containsEntity(TravelerProfile::CLASSNAME, $entity1->getProfile()->getId())); $this->assertFalse($this->cache->containsEntity(TravelerProfile::class, $entity1->getProfile()->getId()));
$this->assertFalse($this->cache->containsEntity(TravelerProfile::CLASSNAME, $entity2->getProfile()->getId())); $this->assertFalse($this->cache->containsEntity(TravelerProfile::class, $entity2->getProfile()->getId()));
$this->assertInstanceOf(Traveler::CLASSNAME, $t1); $this->assertInstanceOf(Traveler::class, $t1);
$this->assertInstanceOf(Traveler::CLASSNAME, $t2); $this->assertInstanceOf(Traveler::class, $t2);
$this->assertInstanceOf(TravelerProfile::CLASSNAME, $t1->getProfile()); $this->assertInstanceOf(TravelerProfile::class, $t1->getProfile());
$this->assertInstanceOf(TravelerProfile::CLASSNAME, $t2->getProfile()); $this->assertInstanceOf(TravelerProfile::class, $t2->getProfile());
$this->assertEquals($entity1->getId(), $t1->getId()); $this->assertEquals($entity1->getId(), $t1->getId());
$this->assertEquals($entity1->getName(), $t1->getName()); $this->assertEquals($entity1->getName(), $t1->getName());
@ -100,22 +101,22 @@ class SecondLevelCacheOneToOneTest extends SecondLevelCacheAbstractTest
$this->assertEquals($entity2->getProfile()->getName(), $t2->getProfile()->getName()); $this->assertEquals($entity2->getProfile()->getName(), $t2->getProfile()->getName());
// its all cached now // its all cached now
$this->assertTrue($this->cache->containsEntity(Traveler::CLASSNAME, $entity1->getId())); $this->assertTrue($this->cache->containsEntity(Traveler::class, $entity1->getId()));
$this->assertTrue($this->cache->containsEntity(Traveler::CLASSNAME, $entity2->getId())); $this->assertTrue($this->cache->containsEntity(Traveler::class, $entity2->getId()));
$this->assertTrue($this->cache->containsEntity(TravelerProfile::CLASSNAME, $entity1->getProfile()->getId())); $this->assertTrue($this->cache->containsEntity(TravelerProfile::class, $entity1->getProfile()->getId()));
$this->assertTrue($this->cache->containsEntity(TravelerProfile::CLASSNAME, $entity1->getProfile()->getId())); $this->assertTrue($this->cache->containsEntity(TravelerProfile::class, $entity1->getProfile()->getId()));
$this->_em->clear(); $this->_em->clear();
$queryCount = $this->getCurrentQueryCount(); $queryCount = $this->getCurrentQueryCount();
// load from cache // load from cache
$t3 = $this->_em->find(Traveler::CLASSNAME, $entity1->getId()); $t3 = $this->_em->find(Traveler::class, $entity1->getId());
$t4 = $this->_em->find(Traveler::CLASSNAME, $entity2->getId()); $t4 = $this->_em->find(Traveler::class, $entity2->getId());
$this->assertInstanceOf(Traveler::CLASSNAME, $t3); $this->assertInstanceOf(Traveler::class, $t3);
$this->assertInstanceOf(Traveler::CLASSNAME, $t4); $this->assertInstanceOf(Traveler::class, $t4);
$this->assertInstanceOf(TravelerProfile::CLASSNAME, $t3->getProfile()); $this->assertInstanceOf(TravelerProfile::class, $t3->getProfile());
$this->assertInstanceOf(TravelerProfile::CLASSNAME, $t4->getProfile()); $this->assertInstanceOf(TravelerProfile::class, $t4->getProfile());
$this->assertEquals($entity1->getProfile()->getId(), $t3->getProfile()->getId()); $this->assertEquals($entity1->getProfile()->getId(), $t3->getProfile()->getId());
$this->assertEquals($entity2->getProfile()->getId(), $t4->getProfile()->getId()); $this->assertEquals($entity2->getProfile()->getId(), $t4->getProfile()->getId());
@ -136,20 +137,20 @@ class SecondLevelCacheOneToOneTest extends SecondLevelCacheAbstractTest
$this->_em->clear(); $this->_em->clear();
$this->cache->evictEntityRegion(Traveler::CLASSNAME); $this->cache->evictEntityRegion(Traveler::class);
$this->cache->evictEntityRegion(TravelerProfile::CLASSNAME); $this->cache->evictEntityRegion(TravelerProfile::class);
$this->cache->evictEntityRegion(TravelerProfileInfo::CLASSNAME); $this->cache->evictEntityRegion(TravelerProfileInfo::class);
$entity1 = $this->travelersWithProfile[0]->getProfile(); $entity1 = $this->travelersWithProfile[0]->getProfile();
$entity2 = $this->travelersWithProfile[1]->getProfile(); $entity2 = $this->travelersWithProfile[1]->getProfile();
$this->assertFalse($this->cache->containsEntity(TravelerProfile::CLASSNAME, $entity1->getId())); $this->assertFalse($this->cache->containsEntity(TravelerProfile::class, $entity1->getId()));
$this->assertFalse($this->cache->containsEntity(TravelerProfile::CLASSNAME, $entity2->getId())); $this->assertFalse($this->cache->containsEntity(TravelerProfile::class, $entity2->getId()));
$this->assertFalse($this->cache->containsEntity(TravelerProfileInfo::CLASSNAME, $entity1->getInfo()->getId())); $this->assertFalse($this->cache->containsEntity(TravelerProfileInfo::class, $entity1->getInfo()->getId()));
$this->assertFalse($this->cache->containsEntity(TravelerProfileInfo::CLASSNAME, $entity2->getInfo()->getId())); $this->assertFalse($this->cache->containsEntity(TravelerProfileInfo::class, $entity2->getInfo()->getId()));
$p1 = $this->_em->find(TravelerProfile::CLASSNAME, $entity1->getId()); $p1 = $this->_em->find(TravelerProfile::class, $entity1->getId());
$p2 = $this->_em->find(TravelerProfile::CLASSNAME, $entity2->getId()); $p2 = $this->_em->find(TravelerProfile::class, $entity2->getId());
$this->assertEquals($entity1->getId(), $p1->getId()); $this->assertEquals($entity1->getId(), $p1->getId());
$this->assertEquals($entity1->getName(), $p1->getName()); $this->assertEquals($entity1->getName(), $p1->getName());
@ -161,22 +162,22 @@ class SecondLevelCacheOneToOneTest extends SecondLevelCacheAbstractTest
$this->assertEquals($entity2->getInfo()->getId(), $p2->getInfo()->getId()); $this->assertEquals($entity2->getInfo()->getId(), $p2->getInfo()->getId());
$this->assertEquals($entity2->getInfo()->getDescription(), $p2->getInfo()->getDescription()); $this->assertEquals($entity2->getInfo()->getDescription(), $p2->getInfo()->getDescription());
$this->assertTrue($this->cache->containsEntity(TravelerProfile::CLASSNAME, $entity1->getId())); $this->assertTrue($this->cache->containsEntity(TravelerProfile::class, $entity1->getId()));
$this->assertTrue($this->cache->containsEntity(TravelerProfile::CLASSNAME, $entity2->getId())); $this->assertTrue($this->cache->containsEntity(TravelerProfile::class, $entity2->getId()));
$this->assertTrue($this->cache->containsEntity(TravelerProfileInfo::CLASSNAME, $entity1->getInfo()->getId())); $this->assertTrue($this->cache->containsEntity(TravelerProfileInfo::class, $entity1->getInfo()->getId()));
$this->assertTrue($this->cache->containsEntity(TravelerProfileInfo::CLASSNAME, $entity2->getInfo()->getId())); $this->assertTrue($this->cache->containsEntity(TravelerProfileInfo::class, $entity2->getInfo()->getId()));
$this->_em->clear(); $this->_em->clear();
$queryCount = $this->getCurrentQueryCount(); $queryCount = $this->getCurrentQueryCount();
$p3 = $this->_em->find(TravelerProfile::CLASSNAME, $entity1->getId()); $p3 = $this->_em->find(TravelerProfile::class, $entity1->getId());
$p4 = $this->_em->find(TravelerProfile::CLASSNAME, $entity2->getId()); $p4 = $this->_em->find(TravelerProfile::class, $entity2->getId());
$this->assertInstanceOf(TravelerProfile::CLASSNAME, $p3); $this->assertInstanceOf(TravelerProfile::class, $p3);
$this->assertInstanceOf(TravelerProfile::CLASSNAME, $p4); $this->assertInstanceOf(TravelerProfile::class, $p4);
$this->assertInstanceOf(TravelerProfileInfo::CLASSNAME, $p3->getInfo()); $this->assertInstanceOf(TravelerProfileInfo::class, $p3->getInfo());
$this->assertInstanceOf(TravelerProfileInfo::CLASSNAME, $p4->getInfo()); $this->assertInstanceOf(TravelerProfileInfo::class, $p4->getInfo());
$this->assertEquals($entity1->getId(), $p3->getId()); $this->assertEquals($entity1->getId(), $p3->getId());
$this->assertEquals($entity1->getName(), $p3->getName()); $this->assertEquals($entity1->getName(), $p3->getName());
@ -197,19 +198,19 @@ class SecondLevelCacheOneToOneTest extends SecondLevelCacheAbstractTest
$this->_em->clear(); $this->_em->clear();
$this->cache->evictEntityRegion(Person::CLASSNAME); $this->cache->evictEntityRegion(Person::class);
$this->cache->evictEntityRegion(Address::CLASSNAME); $this->cache->evictEntityRegion(Address::class);
$entity1 = $this->addresses[0]->person; $entity1 = $this->addresses[0]->person;
$entity2 = $this->addresses[1]->person; $entity2 = $this->addresses[1]->person;
$this->assertFalse($this->cache->containsEntity(Person::CLASSNAME, $entity1->id)); $this->assertFalse($this->cache->containsEntity(Person::class, $entity1->id));
$this->assertFalse($this->cache->containsEntity(Person::CLASSNAME, $entity2->id)); $this->assertFalse($this->cache->containsEntity(Person::class, $entity2->id));
$this->assertFalse($this->cache->containsEntity(Address::CLASSNAME, $entity1->address->id)); $this->assertFalse($this->cache->containsEntity(Address::class, $entity1->address->id));
$this->assertFalse($this->cache->containsEntity(Address::CLASSNAME, $entity2->address->id)); $this->assertFalse($this->cache->containsEntity(Address::class, $entity2->address->id));
$p1 = $this->_em->find(Person::CLASSNAME, $entity1->id); $p1 = $this->_em->find(Person::class, $entity1->id);
$p2 = $this->_em->find(Person::CLASSNAME, $entity2->id); $p2 = $this->_em->find(Person::class, $entity2->id);
$this->assertEquals($entity1->id, $p1->id); $this->assertEquals($entity1->id, $p1->id);
$this->assertEquals($entity1->name, $p1->name); $this->assertEquals($entity1->name, $p1->name);
@ -221,23 +222,23 @@ class SecondLevelCacheOneToOneTest extends SecondLevelCacheAbstractTest
$this->assertEquals($entity2->address->id, $p2->address->id); $this->assertEquals($entity2->address->id, $p2->address->id);
$this->assertEquals($entity2->address->location, $p2->address->location); $this->assertEquals($entity2->address->location, $p2->address->location);
$this->assertTrue($this->cache->containsEntity(Person::CLASSNAME, $entity1->id)); $this->assertTrue($this->cache->containsEntity(Person::class, $entity1->id));
$this->assertTrue($this->cache->containsEntity(Person::CLASSNAME, $entity2->id)); $this->assertTrue($this->cache->containsEntity(Person::class, $entity2->id));
// The inverse side its not cached // The inverse side its not cached
$this->assertFalse($this->cache->containsEntity(Address::CLASSNAME, $entity1->address->id)); $this->assertFalse($this->cache->containsEntity(Address::class, $entity1->address->id));
$this->assertFalse($this->cache->containsEntity(Address::CLASSNAME, $entity2->address->id)); $this->assertFalse($this->cache->containsEntity(Address::class, $entity2->address->id));
$this->_em->clear(); $this->_em->clear();
$queryCount = $this->getCurrentQueryCount(); $queryCount = $this->getCurrentQueryCount();
$p3 = $this->_em->find(Person::CLASSNAME, $entity1->id); $p3 = $this->_em->find(Person::class, $entity1->id);
$p4 = $this->_em->find(Person::CLASSNAME, $entity2->id); $p4 = $this->_em->find(Person::class, $entity2->id);
$this->assertInstanceOf(Person::CLASSNAME, $p3); $this->assertInstanceOf(Person::class, $p3);
$this->assertInstanceOf(Person::CLASSNAME, $p4); $this->assertInstanceOf(Person::class, $p4);
$this->assertInstanceOf(Address::CLASSNAME, $p3->address); $this->assertInstanceOf(Address::class, $p3->address);
$this->assertInstanceOf(Address::CLASSNAME, $p4->address); $this->assertInstanceOf(Address::class, $p4->address);
$this->assertEquals($entity1->id, $p3->id); $this->assertEquals($entity1->id, $p3->id);
$this->assertEquals($entity1->name, $p3->name); $this->assertEquals($entity1->name, $p3->name);
@ -254,8 +255,8 @@ class SecondLevelCacheOneToOneTest extends SecondLevelCacheAbstractTest
public function testPutAndLoadNonCacheableOneToOne() public function testPutAndLoadNonCacheableOneToOne()
{ {
$this->assertNull($this->cache->getEntityCacheRegion(Client::CLASSNAME)); $this->assertNull($this->cache->getEntityCacheRegion(Client::class));
$this->assertInstanceOf('Doctrine\ORM\Cache\Region', $this->cache->getEntityCacheRegion(Token::CLASSNAME)); $this->assertInstanceOf(Region::class, $this->cache->getEntityCacheRegion(Token::class));
$client = new Client('FabioBatSilva'); $client = new Client('FabioBatSilva');
$token = new Token('token-hash', $client); $token = new Token('token-hash', $client);
@ -267,13 +268,13 @@ class SecondLevelCacheOneToOneTest extends SecondLevelCacheAbstractTest
$queryCount = $this->getCurrentQueryCount(); $queryCount = $this->getCurrentQueryCount();
$this->assertTrue($this->cache->containsEntity(Token::CLASSNAME, $token->token)); $this->assertTrue($this->cache->containsEntity(Token::class, $token->token));
$this->assertFalse($this->cache->containsEntity(Client::CLASSNAME, $client->id)); $this->assertFalse($this->cache->containsEntity(Client::class, $client->id));
$entity = $this->_em->find(Token::CLASSNAME, $token->token); $entity = $this->_em->find(Token::class, $token->token);
$this->assertInstanceOf(Token::CLASSNAME, $entity); $this->assertInstanceOf(Token::class, $entity);
$this->assertInstanceOf(Client::CLASSNAME, $entity->getClient()); $this->assertInstanceOf(Client::class, $entity->getClient());
$this->assertEquals('token-hash', $entity->token); $this->assertEquals('token-hash', $entity->token);
$this->assertEquals($queryCount, $this->getCurrentQueryCount()); $this->assertEquals($queryCount, $this->getCurrentQueryCount());

View File

@ -3,16 +3,17 @@
namespace Doctrine\Tests\ORM\Functional; namespace Doctrine\Tests\ORM\Functional;
use Doctrine\ORM\AbstractQuery; use Doctrine\ORM\AbstractQuery;
use Doctrine\ORM\Query\ResultSetMapping;
use Doctrine\Tests\Models\Cache\City;
use Doctrine\Tests\Models\Cache\State;
use Doctrine\Tests\Models\Cache\Country;
use Doctrine\Tests\Models\Cache\Attraction;
use Doctrine\ORM\Cache\QueryCacheKey;
use Doctrine\ORM\Cache\EntityCacheKey;
use Doctrine\ORM\Cache\EntityCacheEntry;
use Doctrine\ORM\Query;
use Doctrine\ORM\Cache; use Doctrine\ORM\Cache;
use Doctrine\ORM\Cache\EntityCacheEntry;
use Doctrine\ORM\Cache\EntityCacheKey;
use Doctrine\ORM\Cache\QueryCacheKey;
use Doctrine\ORM\Proxy\Proxy;
use Doctrine\ORM\Query;
use Doctrine\ORM\Query\ResultSetMapping;
use Doctrine\Tests\Models\Cache\Attraction;
use Doctrine\Tests\Models\Cache\City;
use Doctrine\Tests\Models\Cache\Country;
use Doctrine\Tests\Models\Cache\State;
/** /**
* @group DDC-2183 * @group DDC-2183
@ -27,8 +28,8 @@ class SecondLevelCacheQueryCacheTest extends SecondLevelCacheAbstractTest
$this->secondLevelCacheLogger->clearStats(); $this->secondLevelCacheLogger->clearStats();
$this->_em->clear(); $this->_em->clear();
$this->assertTrue($this->cache->containsEntity(Country::CLASSNAME, $this->countries[0]->getId())); $this->assertTrue($this->cache->containsEntity(Country::class, $this->countries[0]->getId()));
$this->assertTrue($this->cache->containsEntity(Country::CLASSNAME, $this->countries[1]->getId())); $this->assertTrue($this->cache->containsEntity(Country::class, $this->countries[1]->getId()));
$queryCount = $this->getCurrentQueryCount(); $queryCount = $this->getCurrentQueryCount();
$dql = 'SELECT c FROM Doctrine\Tests\Models\Cache\Country c'; $dql = 'SELECT c FROM Doctrine\Tests\Models\Cache\Country c';
@ -63,8 +64,8 @@ class SecondLevelCacheQueryCacheTest extends SecondLevelCacheAbstractTest
$this->assertEquals(1, $this->secondLevelCacheLogger->getRegionHitCount($this->getDefaultQueryRegionName())); $this->assertEquals(1, $this->secondLevelCacheLogger->getRegionHitCount($this->getDefaultQueryRegionName()));
$this->assertEquals(1, $this->secondLevelCacheLogger->getRegionMissCount($this->getDefaultQueryRegionName())); $this->assertEquals(1, $this->secondLevelCacheLogger->getRegionMissCount($this->getDefaultQueryRegionName()));
$this->assertInstanceOf('Doctrine\Tests\Models\Cache\Country', $result2[0]); $this->assertInstanceOf(Country::class, $result2[0]);
$this->assertInstanceOf('Doctrine\Tests\Models\Cache\Country', $result2[1]); $this->assertInstanceOf(Country::class, $result2[1]);
$this->assertEquals($result1[0]->getId(), $result2[0]->getId()); $this->assertEquals($result1[0]->getId(), $result2[0]->getId());
$this->assertEquals($result1[1]->getId(), $result2[1]->getId()); $this->assertEquals($result1[1]->getId(), $result2[1]->getId());
@ -90,8 +91,8 @@ class SecondLevelCacheQueryCacheTest extends SecondLevelCacheAbstractTest
$this->secondLevelCacheLogger->clearStats(); $this->secondLevelCacheLogger->clearStats();
$this->_em->clear(); $this->_em->clear();
$this->assertFalse($this->cache->containsEntity(Country::CLASSNAME, $this->countries[0]->getId())); $this->assertFalse($this->cache->containsEntity(Country::class, $this->countries[0]->getId()));
$this->assertFalse($this->cache->containsEntity(Country::CLASSNAME, $this->countries[1]->getId())); $this->assertFalse($this->cache->containsEntity(Country::class, $this->countries[1]->getId()));
$queryCount = $this->getCurrentQueryCount(); $queryCount = $this->getCurrentQueryCount();
$dql = 'SELECT c FROM Doctrine\Tests\Models\Cache\Country c'; $dql = 'SELECT c FROM Doctrine\Tests\Models\Cache\Country c';
@ -113,8 +114,8 @@ class SecondLevelCacheQueryCacheTest extends SecondLevelCacheAbstractTest
$this->assertCount(2, $result); $this->assertCount(2, $result);
$this->assertEquals($queryCount + 3, $this->getCurrentQueryCount()); $this->assertEquals($queryCount + 3, $this->getCurrentQueryCount());
$this->assertTrue($this->cache->containsEntity(Country::CLASSNAME, $this->countries[0]->getId())); $this->assertTrue($this->cache->containsEntity(Country::class, $this->countries[0]->getId()));
$this->assertTrue($this->cache->containsEntity(Country::CLASSNAME, $this->countries[1]->getId())); $this->assertTrue($this->cache->containsEntity(Country::class, $this->countries[1]->getId()));
// MODE_GET should read items if exists. // MODE_GET should read items if exists.
$this->assertCount(2, $queryGet->getResult()); $this->assertCount(2, $queryGet->getResult());
@ -130,8 +131,8 @@ class SecondLevelCacheQueryCacheTest extends SecondLevelCacheAbstractTest
$this->secondLevelCacheLogger->clearStats(); $this->secondLevelCacheLogger->clearStats();
$this->_em->clear(); $this->_em->clear();
$this->assertFalse($this->cache->containsEntity(Country::CLASSNAME, $this->countries[0]->getId())); $this->assertFalse($this->cache->containsEntity(Country::class, $this->countries[0]->getId()));
$this->assertFalse($this->cache->containsEntity(Country::CLASSNAME, $this->countries[1]->getId())); $this->assertFalse($this->cache->containsEntity(Country::class, $this->countries[1]->getId()));
$queryCount = $this->getCurrentQueryCount(); $queryCount = $this->getCurrentQueryCount();
$dql = 'SELECT c FROM Doctrine\Tests\Models\Cache\Country c'; $dql = 'SELECT c FROM Doctrine\Tests\Models\Cache\Country c';
@ -139,8 +140,8 @@ class SecondLevelCacheQueryCacheTest extends SecondLevelCacheAbstractTest
->setCacheable(true) ->setCacheable(true)
->getResult(); ->getResult();
$this->assertTrue($this->cache->containsEntity(Country::CLASSNAME, $this->countries[0]->getId())); $this->assertTrue($this->cache->containsEntity(Country::class, $this->countries[0]->getId()));
$this->assertTrue($this->cache->containsEntity(Country::CLASSNAME, $this->countries[1]->getId())); $this->assertTrue($this->cache->containsEntity(Country::class, $this->countries[1]->getId()));
$this->assertCount(2, $result); $this->assertCount(2, $result);
$this->assertEquals($queryCount + 1, $this->getCurrentQueryCount()); $this->assertEquals($queryCount + 1, $this->getCurrentQueryCount());
@ -152,13 +153,13 @@ class SecondLevelCacheQueryCacheTest extends SecondLevelCacheAbstractTest
// MODE_PUT should never read itens from cache. // MODE_PUT should never read itens from cache.
$this->assertCount(2, $queryPut->getResult()); $this->assertCount(2, $queryPut->getResult());
$this->assertEquals($queryCount + 2, $this->getCurrentQueryCount()); $this->assertEquals($queryCount + 2, $this->getCurrentQueryCount());
$this->assertTrue($this->cache->containsEntity(Country::CLASSNAME, $this->countries[0]->getId())); $this->assertTrue($this->cache->containsEntity(Country::class, $this->countries[0]->getId()));
$this->assertTrue($this->cache->containsEntity(Country::CLASSNAME, $this->countries[1]->getId())); $this->assertTrue($this->cache->containsEntity(Country::class, $this->countries[1]->getId()));
$this->assertCount(2, $queryPut->getResult()); $this->assertCount(2, $queryPut->getResult());
$this->assertEquals($queryCount + 3, $this->getCurrentQueryCount()); $this->assertEquals($queryCount + 3, $this->getCurrentQueryCount());
$this->assertTrue($this->cache->containsEntity(Country::CLASSNAME, $this->countries[0]->getId())); $this->assertTrue($this->cache->containsEntity(Country::class, $this->countries[0]->getId()));
$this->assertTrue($this->cache->containsEntity(Country::CLASSNAME, $this->countries[1]->getId())); $this->assertTrue($this->cache->containsEntity(Country::class, $this->countries[1]->getId()));
} }
public function testQueryCacheModeRefresh() public function testQueryCacheModeRefresh()
@ -170,18 +171,18 @@ class SecondLevelCacheQueryCacheTest extends SecondLevelCacheAbstractTest
$this->secondLevelCacheLogger->clearStats(); $this->secondLevelCacheLogger->clearStats();
$this->_em->clear(); $this->_em->clear();
$this->assertFalse($this->cache->containsEntity(Country::CLASSNAME, $this->countries[0]->getId())); $this->assertFalse($this->cache->containsEntity(Country::class, $this->countries[0]->getId()));
$this->assertFalse($this->cache->containsEntity(Country::CLASSNAME, $this->countries[1]->getId())); $this->assertFalse($this->cache->containsEntity(Country::class, $this->countries[1]->getId()));
$region = $this->cache->getEntityCacheRegion(Country::CLASSNAME); $region = $this->cache->getEntityCacheRegion(Country::class);
$queryCount = $this->getCurrentQueryCount(); $queryCount = $this->getCurrentQueryCount();
$dql = 'SELECT c FROM Doctrine\Tests\Models\Cache\Country c'; $dql = 'SELECT c FROM Doctrine\Tests\Models\Cache\Country c';
$result = $this->_em->createQuery($dql) $result = $this->_em->createQuery($dql)
->setCacheable(true) ->setCacheable(true)
->getResult(); ->getResult();
$this->assertTrue($this->cache->containsEntity(Country::CLASSNAME, $this->countries[0]->getId())); $this->assertTrue($this->cache->containsEntity(Country::class, $this->countries[0]->getId()));
$this->assertTrue($this->cache->containsEntity(Country::CLASSNAME, $this->countries[1]->getId())); $this->assertTrue($this->cache->containsEntity(Country::class, $this->countries[1]->getId()));
$this->assertCount(2, $result); $this->assertCount(2, $result);
$this->assertEquals($queryCount + 1, $this->getCurrentQueryCount()); $this->assertEquals($queryCount + 1, $this->getCurrentQueryCount());
@ -191,10 +192,10 @@ class SecondLevelCacheQueryCacheTest extends SecondLevelCacheAbstractTest
$countryName1 = $this->countries[0]->getName(); $countryName1 = $this->countries[0]->getName();
$countryName2 = $this->countries[1]->getName(); $countryName2 = $this->countries[1]->getName();
$key1 = new EntityCacheKey(Country::CLASSNAME, ['id'=>$countryId1]); $key1 = new EntityCacheKey(Country::class, ['id'=>$countryId1]);
$key2 = new EntityCacheKey(Country::CLASSNAME, ['id'=>$countryId2]); $key2 = new EntityCacheKey(Country::class, ['id'=>$countryId2]);
$entry1 = new EntityCacheEntry(Country::CLASSNAME, ['id'=>$countryId1, 'name'=>'outdated']); $entry1 = new EntityCacheEntry(Country::class, ['id'=>$countryId1, 'name'=>'outdated']);
$entry2 = new EntityCacheEntry(Country::CLASSNAME, ['id'=>$countryId2, 'name'=>'outdated']); $entry2 = new EntityCacheEntry(Country::class, ['id'=>$countryId2, 'name'=>'outdated']);
$region->put($key1, $entry1); $region->put($key1, $entry1);
$region->put($key2, $entry2); $region->put($key2, $entry2);
@ -240,14 +241,14 @@ class SecondLevelCacheQueryCacheTest extends SecondLevelCacheAbstractTest
$this->assertEquals($this->countries[0]->getName(), $result1[0]->getName()); $this->assertEquals($this->countries[0]->getName(), $result1[0]->getName());
$this->assertEquals($this->countries[1]->getName(), $result1[1]->getName()); $this->assertEquals($this->countries[1]->getName(), $result1[1]->getName());
$this->assertTrue($this->cache->containsEntity(Country::CLASSNAME, $this->countries[0]->getId())); $this->assertTrue($this->cache->containsEntity(Country::class, $this->countries[0]->getId()));
$this->assertTrue($this->cache->containsEntity(Country::CLASSNAME, $this->countries[1]->getId())); $this->assertTrue($this->cache->containsEntity(Country::class, $this->countries[1]->getId()));
$this->assertEquals(3, $this->secondLevelCacheLogger->getPutCount()); $this->assertEquals(3, $this->secondLevelCacheLogger->getPutCount());
$this->assertEquals(1, $this->secondLevelCacheLogger->getMissCount()); $this->assertEquals(1, $this->secondLevelCacheLogger->getMissCount());
$this->assertEquals(1, $this->secondLevelCacheLogger->getRegionPutCount($this->getDefaultQueryRegionName())); $this->assertEquals(1, $this->secondLevelCacheLogger->getRegionPutCount($this->getDefaultQueryRegionName()));
$this->assertEquals(1, $this->secondLevelCacheLogger->getRegionMissCount($this->getDefaultQueryRegionName())); $this->assertEquals(1, $this->secondLevelCacheLogger->getRegionMissCount($this->getDefaultQueryRegionName()));
$this->assertEquals(2, $this->secondLevelCacheLogger->getRegionPutCount($this->getEntityRegion(Country::CLASSNAME))); $this->assertEquals(2, $this->secondLevelCacheLogger->getRegionPutCount($this->getEntityRegion(Country::class)));
$this->_em->clear(); $this->_em->clear();
@ -266,8 +267,8 @@ class SecondLevelCacheQueryCacheTest extends SecondLevelCacheAbstractTest
$this->assertEquals(1, $this->secondLevelCacheLogger->getRegionHitCount($this->getDefaultQueryRegionName())); $this->assertEquals(1, $this->secondLevelCacheLogger->getRegionHitCount($this->getDefaultQueryRegionName()));
$this->assertEquals(1, $this->secondLevelCacheLogger->getRegionMissCount($this->getDefaultQueryRegionName())); $this->assertEquals(1, $this->secondLevelCacheLogger->getRegionMissCount($this->getDefaultQueryRegionName()));
$this->assertInstanceOf('Doctrine\Tests\Models\Cache\Country', $result2[0]); $this->assertInstanceOf(Country::class, $result2[0]);
$this->assertInstanceOf('Doctrine\Tests\Models\Cache\Country', $result2[1]); $this->assertInstanceOf(Country::class, $result2[1]);
$this->assertEquals($result1[0]->getId(), $result2[0]->getId()); $this->assertEquals($result1[0]->getId(), $result2[0]->getId());
$this->assertEquals($result1[1]->getId(), $result2[1]->getId()); $this->assertEquals($result1[1]->getId(), $result2[1]->getId());
@ -295,9 +296,9 @@ class SecondLevelCacheQueryCacheTest extends SecondLevelCacheAbstractTest
$this->loadFixturesAttractions(); $this->loadFixturesAttractions();
$queryRegionName = $this->getDefaultQueryRegionName(); $queryRegionName = $this->getDefaultQueryRegionName();
$cityRegionName = $this->getEntityRegion(City::CLASSNAME); $cityRegionName = $this->getEntityRegion(City::class);
$stateRegionName = $this->getEntityRegion(State::CLASSNAME); $stateRegionName = $this->getEntityRegion(State::class);
$attractionRegionName = $this->getEntityRegion(Attraction::CLASSNAME); $attractionRegionName = $this->getEntityRegion(Attraction::class);
$this->secondLevelCacheLogger->clearStats(); $this->secondLevelCacheLogger->clearStats();
$this->evictRegions(); $this->evictRegions();
@ -312,29 +313,29 @@ class SecondLevelCacheQueryCacheTest extends SecondLevelCacheAbstractTest
$this->assertCount(2, $result1); $this->assertCount(2, $result1);
$this->assertEquals($queryCount + 1, $this->getCurrentQueryCount()); $this->assertEquals($queryCount + 1, $this->getCurrentQueryCount());
$this->assertTrue($this->cache->containsEntity(State::CLASSNAME, $this->states[0]->getId())); $this->assertTrue($this->cache->containsEntity(State::class, $this->states[0]->getId()));
$this->assertTrue($this->cache->containsEntity(State::CLASSNAME, $this->states[1]->getId())); $this->assertTrue($this->cache->containsEntity(State::class, $this->states[1]->getId()));
$this->assertTrue($this->cache->containsEntity(City::CLASSNAME, $this->cities[0]->getId())); $this->assertTrue($this->cache->containsEntity(City::class, $this->cities[0]->getId()));
$this->assertTrue($this->cache->containsEntity(City::CLASSNAME, $this->cities[1]->getId())); $this->assertTrue($this->cache->containsEntity(City::class, $this->cities[1]->getId()));
$this->assertTrue($this->cache->containsEntity(City::CLASSNAME, $this->cities[2]->getId())); $this->assertTrue($this->cache->containsEntity(City::class, $this->cities[2]->getId()));
$this->assertTrue($this->cache->containsEntity(City::CLASSNAME, $this->cities[3]->getId())); $this->assertTrue($this->cache->containsEntity(City::class, $this->cities[3]->getId()));
$this->assertTrue($this->cache->containsEntity(Attraction::CLASSNAME, $this->attractions[0]->getId())); $this->assertTrue($this->cache->containsEntity(Attraction::class, $this->attractions[0]->getId()));
$this->assertTrue($this->cache->containsEntity(Attraction::CLASSNAME, $this->attractions[1]->getId())); $this->assertTrue($this->cache->containsEntity(Attraction::class, $this->attractions[1]->getId()));
$this->assertTrue($this->cache->containsEntity(Attraction::CLASSNAME, $this->attractions[2]->getId())); $this->assertTrue($this->cache->containsEntity(Attraction::class, $this->attractions[2]->getId()));
$this->assertTrue($this->cache->containsEntity(Attraction::CLASSNAME, $this->attractions[3]->getId())); $this->assertTrue($this->cache->containsEntity(Attraction::class, $this->attractions[3]->getId()));
$this->assertInstanceOf(State::CLASSNAME, $result1[0]); $this->assertInstanceOf(State::class, $result1[0]);
$this->assertInstanceOf(State::CLASSNAME, $result1[1]); $this->assertInstanceOf(State::class, $result1[1]);
$this->assertCount(2, $result1[0]->getCities()); $this->assertCount(2, $result1[0]->getCities());
$this->assertCount(2, $result1[1]->getCities()); $this->assertCount(2, $result1[1]->getCities());
$this->assertInstanceOf(City::CLASSNAME, $result1[0]->getCities()->get(0)); $this->assertInstanceOf(City::class, $result1[0]->getCities()->get(0));
$this->assertInstanceOf(City::CLASSNAME, $result1[0]->getCities()->get(1)); $this->assertInstanceOf(City::class, $result1[0]->getCities()->get(1));
$this->assertInstanceOf(City::CLASSNAME, $result1[1]->getCities()->get(0)); $this->assertInstanceOf(City::class, $result1[1]->getCities()->get(0));
$this->assertInstanceOf(City::CLASSNAME, $result1[1]->getCities()->get(1)); $this->assertInstanceOf(City::class, $result1[1]->getCities()->get(1));
$this->assertCount(2, $result1[0]->getCities()->get(0)->getAttractions()); $this->assertCount(2, $result1[0]->getCities()->get(0)->getAttractions());
$this->assertCount(2, $result1[0]->getCities()->get(1)->getAttractions()); $this->assertCount(2, $result1[0]->getCities()->get(1)->getAttractions());
@ -350,16 +351,16 @@ class SecondLevelCacheQueryCacheTest extends SecondLevelCacheAbstractTest
$this->assertCount(2, $result2); $this->assertCount(2, $result2);
$this->assertEquals($queryCount + 1, $this->getCurrentQueryCount()); $this->assertEquals($queryCount + 1, $this->getCurrentQueryCount());
$this->assertInstanceOf(State::CLASSNAME, $result2[0]); $this->assertInstanceOf(State::class, $result2[0]);
$this->assertInstanceOf(State::CLASSNAME, $result2[1]); $this->assertInstanceOf(State::class, $result2[1]);
$this->assertCount(2, $result2[0]->getCities()); $this->assertCount(2, $result2[0]->getCities());
$this->assertCount(2, $result2[1]->getCities()); $this->assertCount(2, $result2[1]->getCities());
$this->assertInstanceOf(City::CLASSNAME, $result2[0]->getCities()->get(0)); $this->assertInstanceOf(City::class, $result2[0]->getCities()->get(0));
$this->assertInstanceOf(City::CLASSNAME, $result2[0]->getCities()->get(1)); $this->assertInstanceOf(City::class, $result2[0]->getCities()->get(1));
$this->assertInstanceOf(City::CLASSNAME, $result2[1]->getCities()->get(0)); $this->assertInstanceOf(City::class, $result2[1]->getCities()->get(0));
$this->assertInstanceOf(City::CLASSNAME, $result2[1]->getCities()->get(1)); $this->assertInstanceOf(City::class, $result2[1]->getCities()->get(1));
$this->assertCount(2, $result2[0]->getCities()->get(0)->getAttractions()); $this->assertCount(2, $result2[0]->getCities()->get(0)->getAttractions());
$this->assertCount(2, $result2[0]->getCities()->get(1)->getAttractions()); $this->assertCount(2, $result2[0]->getCities()->get(1)->getAttractions());
@ -374,8 +375,8 @@ class SecondLevelCacheQueryCacheTest extends SecondLevelCacheAbstractTest
$this->loadFixturesCountries(); $this->loadFixturesCountries();
$this->_em->clear(); $this->_em->clear();
$this->assertTrue($this->cache->containsEntity(Country::CLASSNAME, $this->countries[0]->getId())); $this->assertTrue($this->cache->containsEntity(Country::class, $this->countries[0]->getId()));
$this->assertTrue($this->cache->containsEntity(Country::CLASSNAME, $this->countries[1]->getId())); $this->assertTrue($this->cache->containsEntity(Country::class, $this->countries[1]->getId()));
$queryCount = $this->getCurrentQueryCount(); $queryCount = $this->getCurrentQueryCount();
$name = $this->countries[0]->getName(); $name = $this->countries[0]->getName();
@ -398,7 +399,7 @@ class SecondLevelCacheQueryCacheTest extends SecondLevelCacheAbstractTest
$this->assertEquals($queryCount + 1, $this->getCurrentQueryCount()); $this->assertEquals($queryCount + 1, $this->getCurrentQueryCount());
$this->assertCount(1, $result2); $this->assertCount(1, $result2);
$this->assertInstanceOf('Doctrine\Tests\Models\Cache\Country', $result2[0]); $this->assertInstanceOf(Country::class, $result2[0]);
$this->assertEquals($result1[0]->getId(), $result2[0]->getId()); $this->assertEquals($result1[0]->getId(), $result2[0]->getId());
$this->assertEquals($result1[0]->getName(), $result2[0]->getName()); $this->assertEquals($result1[0]->getName(), $result2[0]->getName());
@ -411,8 +412,8 @@ class SecondLevelCacheQueryCacheTest extends SecondLevelCacheAbstractTest
$this->loadFixturesCountries(); $this->loadFixturesCountries();
$this->_em->clear(); $this->_em->clear();
$this->assertTrue($this->cache->containsEntity(Country::CLASSNAME, $this->countries[0]->getId())); $this->assertTrue($this->cache->containsEntity(Country::class, $this->countries[0]->getId()));
$this->assertTrue($this->cache->containsEntity(Country::CLASSNAME, $this->countries[1]->getId())); $this->assertTrue($this->cache->containsEntity(Country::class, $this->countries[1]->getId()));
$queryCount = $this->getCurrentQueryCount(); $queryCount = $this->getCurrentQueryCount();
$dql = 'SELECT c FROM Doctrine\Tests\Models\Cache\Country c'; $dql = 'SELECT c FROM Doctrine\Tests\Models\Cache\Country c';
@ -430,8 +431,8 @@ class SecondLevelCacheQueryCacheTest extends SecondLevelCacheAbstractTest
$this->assertEquals(1, $this->secondLevelCacheLogger->getRegionPutCount($this->getDefaultQueryRegionName())); $this->assertEquals(1, $this->secondLevelCacheLogger->getRegionPutCount($this->getDefaultQueryRegionName()));
$this->assertEquals(1, $this->secondLevelCacheLogger->getRegionMissCount($this->getDefaultQueryRegionName())); $this->assertEquals(1, $this->secondLevelCacheLogger->getRegionMissCount($this->getDefaultQueryRegionName()));
$this->cache->evictEntity(Country::CLASSNAME, $result1[0]->getId()); $this->cache->evictEntity(Country::class, $result1[0]->getId());
$this->assertFalse($this->cache->containsEntity(Country::CLASSNAME, $result1[0]->getId())); $this->assertFalse($this->cache->containsEntity(Country::class, $result1[0]->getId()));
$this->_em->clear(); $this->_em->clear();
@ -447,8 +448,8 @@ class SecondLevelCacheQueryCacheTest extends SecondLevelCacheAbstractTest
$this->assertEquals(2, $this->secondLevelCacheLogger->getRegionPutCount($this->getDefaultQueryRegionName())); $this->assertEquals(2, $this->secondLevelCacheLogger->getRegionPutCount($this->getDefaultQueryRegionName()));
$this->assertEquals(2, $this->secondLevelCacheLogger->getRegionMissCount($this->getDefaultQueryRegionName())); $this->assertEquals(2, $this->secondLevelCacheLogger->getRegionMissCount($this->getDefaultQueryRegionName()));
$this->assertInstanceOf('Doctrine\Tests\Models\Cache\Country', $result2[0]); $this->assertInstanceOf(Country::class, $result2[0]);
$this->assertInstanceOf('Doctrine\Tests\Models\Cache\Country', $result2[1]); $this->assertInstanceOf(Country::class, $result2[1]);
$this->assertEquals($result1[0]->getId(), $result2[0]->getId()); $this->assertEquals($result1[0]->getId(), $result2[0]->getId());
$this->assertEquals($result1[1]->getId(), $result2[1]->getId()); $this->assertEquals($result1[1]->getId(), $result2[1]->getId());
@ -475,15 +476,15 @@ class SecondLevelCacheQueryCacheTest extends SecondLevelCacheAbstractTest
->getResult(); ->getResult();
$this->assertEquals($queryCount + 1, $this->getCurrentQueryCount()); $this->assertEquals($queryCount + 1, $this->getCurrentQueryCount());
$this->assertInstanceOf(State::CLASSNAME, $result1[0]); $this->assertInstanceOf(State::class, $result1[0]);
$this->assertInstanceOf(State::CLASSNAME, $result1[1]); $this->assertInstanceOf(State::class, $result1[1]);
$this->assertCount(2, $result1[0]->getCities()); $this->assertCount(2, $result1[0]->getCities());
$this->assertCount(2, $result1[1]->getCities()); $this->assertCount(2, $result1[1]->getCities());
$this->assertInstanceOf(City::CLASSNAME, $result1[0]->getCities()->get(0)); $this->assertInstanceOf(City::class, $result1[0]->getCities()->get(0));
$this->assertInstanceOf(City::CLASSNAME, $result1[0]->getCities()->get(1)); $this->assertInstanceOf(City::class, $result1[0]->getCities()->get(1));
$this->assertInstanceOf(City::CLASSNAME, $result1[1]->getCities()->get(0)); $this->assertInstanceOf(City::class, $result1[1]->getCities()->get(0));
$this->assertInstanceOf(City::CLASSNAME, $result1[1]->getCities()->get(1)); $this->assertInstanceOf(City::class, $result1[1]->getCities()->get(1));
$this->assertNotNull($result1[0]->getCities()->get(0)->getId()); $this->assertNotNull($result1[0]->getCities()->get(0)->getId());
$this->assertNotNull($result1[0]->getCities()->get(1)->getId()); $this->assertNotNull($result1[0]->getCities()->get(1)->getId());
@ -501,15 +502,15 @@ class SecondLevelCacheQueryCacheTest extends SecondLevelCacheAbstractTest
->setCacheable(true) ->setCacheable(true)
->getResult(); ->getResult();
$this->assertInstanceOf(State::CLASSNAME, $result2[0]); $this->assertInstanceOf(State::class, $result2[0]);
$this->assertInstanceOf(State::CLASSNAME, $result2[1]); $this->assertInstanceOf(State::class, $result2[1]);
$this->assertCount(2, $result2[0]->getCities()); $this->assertCount(2, $result2[0]->getCities());
$this->assertCount(2, $result2[1]->getCities()); $this->assertCount(2, $result2[1]->getCities());
$this->assertInstanceOf(City::CLASSNAME, $result2[0]->getCities()->get(0)); $this->assertInstanceOf(City::class, $result2[0]->getCities()->get(0));
$this->assertInstanceOf(City::CLASSNAME, $result2[0]->getCities()->get(1)); $this->assertInstanceOf(City::class, $result2[0]->getCities()->get(1));
$this->assertInstanceOf(City::CLASSNAME, $result2[1]->getCities()->get(0)); $this->assertInstanceOf(City::class, $result2[1]->getCities()->get(0));
$this->assertInstanceOf(City::CLASSNAME, $result2[1]->getCities()->get(1)); $this->assertInstanceOf(City::class, $result2[1]->getCities()->get(1));
$this->assertNotNull($result2[0]->getCities()->get(0)->getId()); $this->assertNotNull($result2[0]->getCities()->get(0)->getId());
$this->assertNotNull($result2[0]->getCities()->get(1)->getId()); $this->assertNotNull($result2[0]->getCities()->get(1)->getId());
@ -541,22 +542,22 @@ class SecondLevelCacheQueryCacheTest extends SecondLevelCacheAbstractTest
->getResult(); ->getResult();
$this->assertCount(4, $result1); $this->assertCount(4, $result1);
$this->assertInstanceOf(City::CLASSNAME, $result1[0]); $this->assertInstanceOf(City::class, $result1[0]);
$this->assertInstanceOf(City::CLASSNAME, $result1[1]); $this->assertInstanceOf(City::class, $result1[1]);
$this->assertInstanceOf(State::CLASSNAME, $result1[0]->getState()); $this->assertInstanceOf(State::class, $result1[0]->getState());
$this->assertInstanceOf(State::CLASSNAME, $result1[1]->getState()); $this->assertInstanceOf(State::class, $result1[1]->getState());
$this->assertTrue($this->cache->containsEntity(City::CLASSNAME, $result1[0]->getId())); $this->assertTrue($this->cache->containsEntity(City::class, $result1[0]->getId()));
$this->assertTrue($this->cache->containsEntity(City::CLASSNAME, $result1[1]->getId())); $this->assertTrue($this->cache->containsEntity(City::class, $result1[1]->getId()));
$this->assertTrue($this->cache->containsEntity(State::CLASSNAME, $result1[0]->getState()->getId())); $this->assertTrue($this->cache->containsEntity(State::class, $result1[0]->getState()->getId()));
$this->assertTrue($this->cache->containsEntity(State::CLASSNAME, $result1[1]->getState()->getId())); $this->assertTrue($this->cache->containsEntity(State::class, $result1[1]->getState()->getId()));
$this->assertEquals(7, $this->secondLevelCacheLogger->getPutCount()); $this->assertEquals(7, $this->secondLevelCacheLogger->getPutCount());
$this->assertEquals(1, $this->secondLevelCacheLogger->getMissCount()); $this->assertEquals(1, $this->secondLevelCacheLogger->getMissCount());
$this->assertEquals(1, $this->secondLevelCacheLogger->getRegionPutCount($this->getDefaultQueryRegionName())); $this->assertEquals(1, $this->secondLevelCacheLogger->getRegionPutCount($this->getDefaultQueryRegionName()));
$this->assertEquals(1, $this->secondLevelCacheLogger->getRegionMissCount($this->getDefaultQueryRegionName())); $this->assertEquals(1, $this->secondLevelCacheLogger->getRegionMissCount($this->getDefaultQueryRegionName()));
$this->assertEquals(2, $this->secondLevelCacheLogger->getRegionPutCount($this->getEntityRegion(State::CLASSNAME))); $this->assertEquals(2, $this->secondLevelCacheLogger->getRegionPutCount($this->getEntityRegion(State::class)));
$this->assertEquals(4, $this->secondLevelCacheLogger->getRegionPutCount($this->getEntityRegion(City::CLASSNAME))); $this->assertEquals(4, $this->secondLevelCacheLogger->getRegionPutCount($this->getEntityRegion(City::class)));
$this->assertEquals($queryCount + 1, $this->getCurrentQueryCount()); $this->assertEquals($queryCount + 1, $this->getCurrentQueryCount());
@ -568,10 +569,10 @@ class SecondLevelCacheQueryCacheTest extends SecondLevelCacheAbstractTest
->getResult(); ->getResult();
$this->assertCount(4, $result1); $this->assertCount(4, $result1);
$this->assertInstanceOf(City::CLASSNAME, $result2[0]); $this->assertInstanceOf(City::class, $result2[0]);
$this->assertInstanceOf(City::CLASSNAME, $result2[1]); $this->assertInstanceOf(City::class, $result2[1]);
$this->assertInstanceOf(State::CLASSNAME, $result2[0]->getState()); $this->assertInstanceOf(State::class, $result2[0]->getState());
$this->assertInstanceOf(State::CLASSNAME, $result2[1]->getState()); $this->assertInstanceOf(State::class, $result2[1]->getState());
$this->assertNotNull($result2[0]->getId()); $this->assertNotNull($result2[0]->getId());
$this->assertNotNull($result2[0]->getId()); $this->assertNotNull($result2[0]->getId());
@ -608,30 +609,30 @@ class SecondLevelCacheQueryCacheTest extends SecondLevelCacheAbstractTest
->getResult(); ->getResult();
$this->assertCount(4, $result1); $this->assertCount(4, $result1);
$this->assertInstanceOf(City::CLASSNAME, $result1[0]); $this->assertInstanceOf(City::class, $result1[0]);
$this->assertInstanceOf(City::CLASSNAME, $result1[1]); $this->assertInstanceOf(City::class, $result1[1]);
$this->assertInstanceOf(State::CLASSNAME, $result1[0]->getState()); $this->assertInstanceOf(State::class, $result1[0]->getState());
$this->assertInstanceOf(State::CLASSNAME, $result1[1]->getState()); $this->assertInstanceOf(State::class, $result1[1]->getState());
$this->assertTrue($this->cache->containsEntity(City::CLASSNAME, $result1[0]->getId())); $this->assertTrue($this->cache->containsEntity(City::class, $result1[0]->getId()));
$this->assertTrue($this->cache->containsEntity(City::CLASSNAME, $result1[1]->getId())); $this->assertTrue($this->cache->containsEntity(City::class, $result1[1]->getId()));
$this->assertTrue($this->cache->containsEntity(State::CLASSNAME, $result1[0]->getState()->getId())); $this->assertTrue($this->cache->containsEntity(State::class, $result1[0]->getState()->getId()));
$this->assertTrue($this->cache->containsEntity(State::CLASSNAME, $result1[1]->getState()->getId())); $this->assertTrue($this->cache->containsEntity(State::class, $result1[1]->getState()->getId()));
$this->assertEquals($queryCount + 1, $this->getCurrentQueryCount()); $this->assertEquals($queryCount + 1, $this->getCurrentQueryCount());
$this->_em->clear(); $this->_em->clear();
$this->cache->evictEntityRegion(State::CLASSNAME); $this->cache->evictEntityRegion(State::class);
$result2 = $this->_em->createQuery($dql) $result2 = $this->_em->createQuery($dql)
->setCacheable(true) ->setCacheable(true)
->getResult(); ->getResult();
$this->assertCount(4, $result1); $this->assertCount(4, $result1);
$this->assertInstanceOf(City::CLASSNAME, $result2[0]); $this->assertInstanceOf(City::class, $result2[0]);
$this->assertInstanceOf(City::CLASSNAME, $result2[1]); $this->assertInstanceOf(City::class, $result2[1]);
$this->assertInstanceOf(State::CLASSNAME, $result2[0]->getState()); $this->assertInstanceOf(State::class, $result2[0]->getState());
$this->assertInstanceOf(State::CLASSNAME, $result2[1]->getState()); $this->assertInstanceOf(State::class, $result2[1]->getState());
$this->assertEquals($queryCount + 2, $this->getCurrentQueryCount()); $this->assertEquals($queryCount + 2, $this->getCurrentQueryCount());
} }
@ -652,33 +653,33 @@ class SecondLevelCacheQueryCacheTest extends SecondLevelCacheAbstractTest
->getResult(); ->getResult();
$this->assertEquals($queryCount + 1, $this->getCurrentQueryCount()); $this->assertEquals($queryCount + 1, $this->getCurrentQueryCount());
$this->assertInstanceOf(State::CLASSNAME, $result1[0]); $this->assertInstanceOf(State::class, $result1[0]);
$this->assertInstanceOf(State::CLASSNAME, $result1[1]); $this->assertInstanceOf(State::class, $result1[1]);
$this->assertCount(2, $result1[0]->getCities()); $this->assertCount(2, $result1[0]->getCities());
$this->assertCount(2, $result1[1]->getCities()); $this->assertCount(2, $result1[1]->getCities());
$this->assertInstanceOf(City::CLASSNAME, $result1[0]->getCities()->get(0)); $this->assertInstanceOf(City::class, $result1[0]->getCities()->get(0));
$this->assertInstanceOf(City::CLASSNAME, $result1[0]->getCities()->get(1)); $this->assertInstanceOf(City::class, $result1[0]->getCities()->get(1));
$this->assertInstanceOf(City::CLASSNAME, $result1[1]->getCities()->get(0)); $this->assertInstanceOf(City::class, $result1[1]->getCities()->get(0));
$this->assertInstanceOf(City::CLASSNAME, $result1[1]->getCities()->get(1)); $this->assertInstanceOf(City::class, $result1[1]->getCities()->get(1));
$this->_em->clear(); $this->_em->clear();
$this->cache->evictEntityRegion(City::CLASSNAME); $this->cache->evictEntityRegion(City::class);
$result2 = $this->_em->createQuery($dql) $result2 = $this->_em->createQuery($dql)
->setCacheable(true) ->setCacheable(true)
->getResult(); ->getResult();
$this->assertInstanceOf(State::CLASSNAME, $result2[0]); $this->assertInstanceOf(State::class, $result2[0]);
$this->assertInstanceOf(State::CLASSNAME, $result2[1]); $this->assertInstanceOf(State::class, $result2[1]);
$this->assertCount(2, $result2[0]->getCities()); $this->assertCount(2, $result2[0]->getCities());
$this->assertCount(2, $result2[1]->getCities()); $this->assertCount(2, $result2[1]->getCities());
$this->assertInstanceOf(City::CLASSNAME, $result2[0]->getCities()->get(0)); $this->assertInstanceOf(City::class, $result2[0]->getCities()->get(0));
$this->assertInstanceOf(City::CLASSNAME, $result2[0]->getCities()->get(1)); $this->assertInstanceOf(City::class, $result2[0]->getCities()->get(1));
$this->assertInstanceOf(City::CLASSNAME, $result2[1]->getCities()->get(0)); $this->assertInstanceOf(City::class, $result2[1]->getCities()->get(0));
$this->assertInstanceOf(City::CLASSNAME, $result2[1]->getCities()->get(1)); $this->assertInstanceOf(City::class, $result2[1]->getCities()->get(1));
$this->assertEquals($queryCount + 2, $this->getCurrentQueryCount()); $this->assertEquals($queryCount + 2, $this->getCurrentQueryCount());
} }
@ -691,11 +692,11 @@ class SecondLevelCacheQueryCacheTest extends SecondLevelCacheAbstractTest
$this->secondLevelCacheLogger->clearStats(); $this->secondLevelCacheLogger->clearStats();
$this->_em->clear(); $this->_em->clear();
$this->assertTrue($this->cache->containsEntity(Country::CLASSNAME, $this->countries[0]->getId())); $this->assertTrue($this->cache->containsEntity(Country::class, $this->countries[0]->getId()));
$this->assertTrue($this->cache->containsEntity(Country::CLASSNAME, $this->countries[1]->getId())); $this->assertTrue($this->cache->containsEntity(Country::class, $this->countries[1]->getId()));
$rsm = new ResultSetMapping; $rsm = new ResultSetMapping;
$rsm->addEntityResult(Country::CLASSNAME, 'c'); $rsm->addEntityResult(Country::class, 'c');
$rsm->addFieldResult('c', 'name', 'name'); $rsm->addFieldResult('c', 'name', 'name');
$rsm->addFieldResult('c', 'id', 'id'); $rsm->addFieldResult('c', 'id', 'id');
@ -732,8 +733,8 @@ class SecondLevelCacheQueryCacheTest extends SecondLevelCacheAbstractTest
$this->assertEquals(1, $this->secondLevelCacheLogger->getRegionHitCount($this->getDefaultQueryRegionName())); $this->assertEquals(1, $this->secondLevelCacheLogger->getRegionHitCount($this->getDefaultQueryRegionName()));
$this->assertEquals(1, $this->secondLevelCacheLogger->getRegionMissCount($this->getDefaultQueryRegionName())); $this->assertEquals(1, $this->secondLevelCacheLogger->getRegionMissCount($this->getDefaultQueryRegionName()));
$this->assertInstanceOf('Doctrine\Tests\Models\Cache\Country', $result2[0]); $this->assertInstanceOf(Country::class, $result2[0]);
$this->assertInstanceOf('Doctrine\Tests\Models\Cache\Country', $result2[1]); $this->assertInstanceOf(Country::class, $result2[1]);
$this->assertEquals($result1[0]->getId(), $result2[0]->getId()); $this->assertEquals($result1[0]->getId(), $result2[0]->getId());
$this->assertEquals($result1[1]->getId(), $result2[1]->getId()); $this->assertEquals($result1[1]->getId(), $result2[1]->getId());
@ -827,7 +828,7 @@ class SecondLevelCacheQueryCacheTest extends SecondLevelCacheAbstractTest
->getRegion() ->getRegion()
->get($key); ->get($key);
$this->assertInstanceOf('Doctrine\ORM\Cache\QueryCacheEntry', $entry); $this->assertInstanceOf(Cache\QueryCacheEntry::class, $entry);
$entry->time = $entry->time / 2; $entry->time = $entry->time / 2;
$this->cache->getQueryCache() $this->cache->getQueryCache()
@ -936,8 +937,8 @@ class SecondLevelCacheQueryCacheTest extends SecondLevelCacheAbstractTest
$this->assertNotNull($state1); $this->assertNotNull($state1);
$this->assertNotNull($state1->getCountry()); $this->assertNotNull($state1->getCountry());
$this->assertEquals($queryCount + 1, $this->getCurrentQueryCount()); $this->assertEquals($queryCount + 1, $this->getCurrentQueryCount());
$this->assertInstanceOf('Doctrine\Tests\Models\Cache\State', $state1); $this->assertInstanceOf(State::class, $state1);
$this->assertInstanceOf('Doctrine\ORM\Proxy\Proxy', $state1->getCountry()); $this->assertInstanceOf(Proxy::class, $state1->getCountry());
$this->assertEquals($countryName, $state1->getCountry()->getName()); $this->assertEquals($countryName, $state1->getCountry()->getName());
$this->assertEquals($stateId, $state1->getId()); $this->assertEquals($stateId, $state1->getId());
@ -954,8 +955,8 @@ class SecondLevelCacheQueryCacheTest extends SecondLevelCacheAbstractTest
$this->assertNotNull($state2); $this->assertNotNull($state2);
$this->assertNotNull($state2->getCountry()); $this->assertNotNull($state2->getCountry());
$this->assertEquals($queryCount, $this->getCurrentQueryCount()); $this->assertEquals($queryCount, $this->getCurrentQueryCount());
$this->assertInstanceOf('Doctrine\Tests\Models\Cache\State', $state2); $this->assertInstanceOf(State::class, $state2);
$this->assertInstanceOf('Doctrine\ORM\Proxy\Proxy', $state2->getCountry()); $this->assertInstanceOf(Proxy::class, $state2->getCountry());
$this->assertEquals($countryName, $state2->getCountry()->getName()); $this->assertEquals($countryName, $state2->getCountry()->getName());
$this->assertEquals($stateId, $state2->getId()); $this->assertEquals($stateId, $state2->getId());
} }
@ -983,10 +984,10 @@ class SecondLevelCacheQueryCacheTest extends SecondLevelCacheAbstractTest
->getSingleResult(); ->getSingleResult();
$this->assertEquals($queryCount + 1, $this->getCurrentQueryCount()); $this->assertEquals($queryCount + 1, $this->getCurrentQueryCount());
$this->assertInstanceOf('Doctrine\Tests\Models\Cache\City', $city1); $this->assertInstanceOf(City::class, $city1);
$this->assertInstanceOf('Doctrine\Tests\Models\Cache\State', $city1->getState()); $this->assertInstanceOf(State::class, $city1->getState());
$this->assertInstanceOf('Doctrine\Tests\Models\Cache\City', $city1->getState()->getCities()->get(0)); $this->assertInstanceOf(City::class, $city1->getState()->getCities()->get(0));
$this->assertInstanceOf('Doctrine\Tests\Models\Cache\State', $city1->getState()->getCities()->get(0)->getState()); $this->assertInstanceOf(State::class, $city1->getState()->getCities()->get(0)->getState());
$this->_em->clear(); $this->_em->clear();
@ -999,10 +1000,10 @@ class SecondLevelCacheQueryCacheTest extends SecondLevelCacheAbstractTest
->getSingleResult(); ->getSingleResult();
$this->assertEquals($queryCount, $this->getCurrentQueryCount()); $this->assertEquals($queryCount, $this->getCurrentQueryCount());
$this->assertInstanceOf('Doctrine\Tests\Models\Cache\City', $city2); $this->assertInstanceOf(City::class, $city2);
$this->assertInstanceOf('Doctrine\Tests\Models\Cache\State', $city2->getState()); $this->assertInstanceOf(State::class, $city2->getState());
$this->assertInstanceOf('Doctrine\Tests\Models\Cache\City', $city2->getState()->getCities()->get(0)); $this->assertInstanceOf(City::class, $city2->getState()->getCities()->get(0));
$this->assertInstanceOf('Doctrine\Tests\Models\Cache\State', $city2->getState()->getCities()->get(0)->getState()); $this->assertInstanceOf(State::class, $city2->getState()->getCities()->get(0)->getState());
} }
public function testResolveToManyAssociationCacheEntry() public function testResolveToManyAssociationCacheEntry()
@ -1028,10 +1029,10 @@ class SecondLevelCacheQueryCacheTest extends SecondLevelCacheAbstractTest
->getSingleResult(); ->getSingleResult();
$this->assertEquals($queryCount + 1, $this->getCurrentQueryCount()); $this->assertEquals($queryCount + 1, $this->getCurrentQueryCount());
$this->assertInstanceOf('Doctrine\Tests\Models\Cache\State', $state1); $this->assertInstanceOf(State::class, $state1);
$this->assertInstanceOf('Doctrine\ORM\Proxy\Proxy', $state1->getCountry()); $this->assertInstanceOf(Proxy::class, $state1->getCountry());
$this->assertInstanceOf('Doctrine\Tests\Models\Cache\City', $state1->getCities()->get(0)); $this->assertInstanceOf(City::class, $state1->getCities()->get(0));
$this->assertInstanceOf('Doctrine\Tests\Models\Cache\State', $state1->getCities()->get(0)->getState()); $this->assertInstanceOf(State::class, $state1->getCities()->get(0)->getState());
$this->assertSame($state1, $state1->getCities()->get(0)->getState()); $this->assertSame($state1, $state1->getCities()->get(0)->getState());
$this->_em->clear(); $this->_em->clear();
@ -1045,10 +1046,10 @@ class SecondLevelCacheQueryCacheTest extends SecondLevelCacheAbstractTest
->getSingleResult(); ->getSingleResult();
$this->assertEquals($queryCount, $this->getCurrentQueryCount()); $this->assertEquals($queryCount, $this->getCurrentQueryCount());
$this->assertInstanceOf('Doctrine\Tests\Models\Cache\State', $state2); $this->assertInstanceOf(State::class, $state2);
$this->assertInstanceOf('Doctrine\ORM\Proxy\Proxy', $state2->getCountry()); $this->assertInstanceOf(Proxy::class, $state2->getCountry());
$this->assertInstanceOf('Doctrine\Tests\Models\Cache\City', $state2->getCities()->get(0)); $this->assertInstanceOf(City::class, $state2->getCities()->get(0));
$this->assertInstanceOf('Doctrine\Tests\Models\Cache\State', $state2->getCities()->get(0)->getState()); $this->assertInstanceOf(State::class, $state2->getCities()->get(0)->getState());
$this->assertSame($state2, $state2->getCities()->get(0)->getState()); $this->assertSame($state2, $state2->getCities()->get(0)->getState());
} }
@ -1057,15 +1058,15 @@ class SecondLevelCacheQueryCacheTest extends SecondLevelCacheAbstractTest
$this->evictRegions(); $this->evictRegions();
$this->loadFixturesCountries(); $this->loadFixturesCountries();
$this->assertTrue($this->cache->containsEntity('Doctrine\Tests\Models\Cache\Country', $this->countries[0]->getId())); $this->assertTrue($this->cache->containsEntity(Country::class, $this->countries[0]->getId()));
$this->assertTrue($this->cache->containsEntity('Doctrine\Tests\Models\Cache\Country', $this->countries[1]->getId())); $this->assertTrue($this->cache->containsEntity(Country::class, $this->countries[1]->getId()));
$this->_em->createQuery('DELETE Doctrine\Tests\Models\Cache\Country u WHERE u.id = 4') $this->_em->createQuery('DELETE Doctrine\Tests\Models\Cache\Country u WHERE u.id = 4')
->setHint(Query::HINT_CACHE_EVICT, true) ->setHint(Query::HINT_CACHE_EVICT, true)
->execute(); ->execute();
$this->assertFalse($this->cache->containsEntity('Doctrine\Tests\Models\Cache\Country', $this->countries[0]->getId())); $this->assertFalse($this->cache->containsEntity(Country::class, $this->countries[0]->getId()));
$this->assertFalse($this->cache->containsEntity('Doctrine\Tests\Models\Cache\Country', $this->countries[1]->getId())); $this->assertFalse($this->cache->containsEntity(Country::class, $this->countries[1]->getId()));
} }
public function testHintClearEntityRegionDeleteStatement() public function testHintClearEntityRegionDeleteStatement()
@ -1073,15 +1074,15 @@ class SecondLevelCacheQueryCacheTest extends SecondLevelCacheAbstractTest
$this->evictRegions(); $this->evictRegions();
$this->loadFixturesCountries(); $this->loadFixturesCountries();
$this->assertTrue($this->cache->containsEntity('Doctrine\Tests\Models\Cache\Country', $this->countries[0]->getId())); $this->assertTrue($this->cache->containsEntity(Country::class, $this->countries[0]->getId()));
$this->assertTrue($this->cache->containsEntity('Doctrine\Tests\Models\Cache\Country', $this->countries[1]->getId())); $this->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") $this->_em->createQuery("UPDATE Doctrine\Tests\Models\Cache\Country u SET u.name = 'foo' WHERE u.id = 1")
->setHint(Query::HINT_CACHE_EVICT, true) ->setHint(Query::HINT_CACHE_EVICT, true)
->execute(); ->execute();
$this->assertFalse($this->cache->containsEntity('Doctrine\Tests\Models\Cache\Country', $this->countries[0]->getId())); $this->assertFalse($this->cache->containsEntity(Country::class, $this->countries[0]->getId()));
$this->assertFalse($this->cache->containsEntity('Doctrine\Tests\Models\Cache\Country', $this->countries[1]->getId())); $this->assertFalse($this->cache->containsEntity(Country::class, $this->countries[1]->getId()));
} }
/** /**
@ -1150,7 +1151,7 @@ class SecondLevelCacheQueryCacheTest extends SecondLevelCacheAbstractTest
$this->assertEquals($queryCount + 1, $this->getCurrentQueryCount()); $this->assertEquals($queryCount + 1, $this->getCurrentQueryCount());
foreach ($result2 as $entity) { foreach ($result2 as $entity) {
$this->assertInstanceOf(Country::CLASSNAME, $entity); $this->assertInstanceOf(Country::class, $entity);
} }
} }
} }

View File

@ -2,6 +2,7 @@
namespace Doctrine\Tests\ORM\Functional; namespace Doctrine\Tests\ORM\Functional;
use Doctrine\ORM\Proxy\Proxy;
use Doctrine\Tests\Models\Cache\Country; use Doctrine\Tests\Models\Cache\Country;
use Doctrine\Tests\Models\Cache\State; use Doctrine\Tests\Models\Cache\State;
@ -18,22 +19,22 @@ class SecondLevelCacheRepositoryTest extends SecondLevelCacheAbstractTest
$this->secondLevelCacheLogger->clearStats(); $this->secondLevelCacheLogger->clearStats();
$this->_em->clear(); $this->_em->clear();
$this->assertTrue($this->cache->containsEntity(Country::CLASSNAME, $this->countries[0]->getId())); $this->assertTrue($this->cache->containsEntity(Country::class, $this->countries[0]->getId()));
$this->assertTrue($this->cache->containsEntity(Country::CLASSNAME, $this->countries[1]->getId())); $this->assertTrue($this->cache->containsEntity(Country::class, $this->countries[1]->getId()));
$queryCount = $this->getCurrentQueryCount(); $queryCount = $this->getCurrentQueryCount();
$repository = $this->_em->getRepository(Country::CLASSNAME); $repository = $this->_em->getRepository(Country::class);
$country1 = $repository->find($this->countries[0]->getId()); $country1 = $repository->find($this->countries[0]->getId());
$country2 = $repository->find($this->countries[1]->getId()); $country2 = $repository->find($this->countries[1]->getId());
$this->assertEquals($queryCount, $this->getCurrentQueryCount()); $this->assertEquals($queryCount, $this->getCurrentQueryCount());
$this->assertInstanceOf(Country::CLASSNAME, $country1); $this->assertInstanceOf(Country::class, $country1);
$this->assertInstanceOf(Country::CLASSNAME, $country2); $this->assertInstanceOf(Country::class, $country2);
$this->assertEquals(2, $this->secondLevelCacheLogger->getHitCount()); $this->assertEquals(2, $this->secondLevelCacheLogger->getHitCount());
$this->assertEquals(0, $this->secondLevelCacheLogger->getMissCount()); $this->assertEquals(0, $this->secondLevelCacheLogger->getMissCount());
$this->assertEquals(2, $this->secondLevelCacheLogger->getRegionHitCount($this->getEntityRegion(Country::CLASSNAME))); $this->assertEquals(2, $this->secondLevelCacheLogger->getRegionHitCount($this->getEntityRegion(Country::class)));
} }
@ -44,10 +45,10 @@ class SecondLevelCacheRepositoryTest extends SecondLevelCacheAbstractTest
$this->secondLevelCacheLogger->clearStats(); $this->secondLevelCacheLogger->clearStats();
$this->_em->clear(); $this->_em->clear();
$this->assertFalse($this->cache->containsEntity(Country::CLASSNAME, $this->countries[0]->getId())); $this->assertFalse($this->cache->containsEntity(Country::class, $this->countries[0]->getId()));
$this->assertFalse($this->cache->containsEntity(Country::CLASSNAME, $this->countries[1]->getId())); $this->assertFalse($this->cache->containsEntity(Country::class, $this->countries[1]->getId()));
$repository = $this->_em->getRepository(Country::CLASSNAME); $repository = $this->_em->getRepository(Country::class);
$queryCount = $this->getCurrentQueryCount(); $queryCount = $this->getCurrentQueryCount();
$this->assertCount(2, $repository->findAll()); $this->assertCount(2, $repository->findAll());
@ -58,14 +59,14 @@ class SecondLevelCacheRepositoryTest extends SecondLevelCacheAbstractTest
$this->assertEquals($queryCount, $this->getCurrentQueryCount()); $this->assertEquals($queryCount, $this->getCurrentQueryCount());
$this->assertInstanceOf(Country::CLASSNAME, $countries[0]); $this->assertInstanceOf(Country::class, $countries[0]);
$this->assertInstanceOf(Country::CLASSNAME, $countries[1]); $this->assertInstanceOf(Country::class, $countries[1]);
$this->assertEquals(3, $this->secondLevelCacheLogger->getHitCount()); $this->assertEquals(3, $this->secondLevelCacheLogger->getHitCount());
$this->assertEquals(1, $this->secondLevelCacheLogger->getMissCount()); $this->assertEquals(1, $this->secondLevelCacheLogger->getMissCount());
$this->assertTrue($this->cache->containsEntity(Country::CLASSNAME, $this->countries[0]->getId())); $this->assertTrue($this->cache->containsEntity(Country::class, $this->countries[0]->getId()));
$this->assertTrue($this->cache->containsEntity(Country::CLASSNAME, $this->countries[1]->getId())); $this->assertTrue($this->cache->containsEntity(Country::class, $this->countries[1]->getId()));
} }
public function testRepositoryCacheFindAllInvalidation() public function testRepositoryCacheFindAllInvalidation()
@ -75,10 +76,10 @@ class SecondLevelCacheRepositoryTest extends SecondLevelCacheAbstractTest
$this->secondLevelCacheLogger->clearStats(); $this->secondLevelCacheLogger->clearStats();
$this->_em->clear(); $this->_em->clear();
$this->assertFalse($this->cache->containsEntity(Country::CLASSNAME, $this->countries[0]->getId())); $this->assertFalse($this->cache->containsEntity(Country::class, $this->countries[0]->getId()));
$this->assertFalse($this->cache->containsEntity(Country::CLASSNAME, $this->countries[1]->getId())); $this->assertFalse($this->cache->containsEntity(Country::class, $this->countries[1]->getId()));
$repository = $this->_em->getRepository(Country::CLASSNAME); $repository = $this->_em->getRepository(Country::class);
$queryCount = $this->getCurrentQueryCount(); $queryCount = $this->getCurrentQueryCount();
$this->assertCount(2, $repository->findAll()); $this->assertCount(2, $repository->findAll());
@ -90,8 +91,8 @@ class SecondLevelCacheRepositoryTest extends SecondLevelCacheAbstractTest
$this->assertEquals($queryCount, $this->getCurrentQueryCount()); $this->assertEquals($queryCount, $this->getCurrentQueryCount());
$this->assertCount(2, $countries); $this->assertCount(2, $countries);
$this->assertInstanceOf(Country::CLASSNAME, $countries[0]); $this->assertInstanceOf(Country::class, $countries[0]);
$this->assertInstanceOf(Country::CLASSNAME, $countries[1]); $this->assertInstanceOf(Country::class, $countries[1]);
$country = new Country('foo'); $country = new Country('foo');
@ -123,10 +124,10 @@ class SecondLevelCacheRepositoryTest extends SecondLevelCacheAbstractTest
$this->secondLevelCacheLogger->clearStats(); $this->secondLevelCacheLogger->clearStats();
$this->_em->clear(); $this->_em->clear();
$this->assertFalse($this->cache->containsEntity(Country::CLASSNAME, $this->countries[0]->getId())); $this->assertFalse($this->cache->containsEntity(Country::class, $this->countries[0]->getId()));
$criteria = ['name'=>$this->countries[0]->getName()]; $criteria = ['name'=>$this->countries[0]->getName()];
$repository = $this->_em->getRepository(Country::CLASSNAME); $repository = $this->_em->getRepository(Country::class);
$queryCount = $this->getCurrentQueryCount(); $queryCount = $this->getCurrentQueryCount();
$this->assertCount(1, $repository->findBy($criteria)); $this->assertCount(1, $repository->findBy($criteria));
@ -138,12 +139,12 @@ class SecondLevelCacheRepositoryTest extends SecondLevelCacheAbstractTest
$this->assertEquals($queryCount, $this->getCurrentQueryCount()); $this->assertEquals($queryCount, $this->getCurrentQueryCount());
$this->assertCount(1, $countries); $this->assertCount(1, $countries);
$this->assertInstanceOf(Country::CLASSNAME, $countries[0]); $this->assertInstanceOf(Country::class, $countries[0]);
$this->assertEquals(2, $this->secondLevelCacheLogger->getHitCount()); $this->assertEquals(2, $this->secondLevelCacheLogger->getHitCount());
$this->assertEquals(1, $this->secondLevelCacheLogger->getMissCount()); $this->assertEquals(1, $this->secondLevelCacheLogger->getMissCount());
$this->assertTrue($this->cache->containsEntity(Country::CLASSNAME, $this->countries[0]->getId())); $this->assertTrue($this->cache->containsEntity(Country::class, $this->countries[0]->getId()));
} }
public function testRepositoryCacheFindOneBy() public function testRepositoryCacheFindOneBy()
@ -153,10 +154,10 @@ class SecondLevelCacheRepositoryTest extends SecondLevelCacheAbstractTest
$this->secondLevelCacheLogger->clearStats(); $this->secondLevelCacheLogger->clearStats();
$this->_em->clear(); $this->_em->clear();
$this->assertFalse($this->cache->containsEntity(Country::CLASSNAME, $this->countries[0]->getId())); $this->assertFalse($this->cache->containsEntity(Country::class, $this->countries[0]->getId()));
$criteria = ['name'=>$this->countries[0]->getName()]; $criteria = ['name'=>$this->countries[0]->getName()];
$repository = $this->_em->getRepository(Country::CLASSNAME); $repository = $this->_em->getRepository(Country::class);
$queryCount = $this->getCurrentQueryCount(); $queryCount = $this->getCurrentQueryCount();
$this->assertNotNull($repository->findOneBy($criteria)); $this->assertNotNull($repository->findOneBy($criteria));
@ -167,12 +168,12 @@ class SecondLevelCacheRepositoryTest extends SecondLevelCacheAbstractTest
$this->assertEquals($queryCount, $this->getCurrentQueryCount()); $this->assertEquals($queryCount, $this->getCurrentQueryCount());
$this->assertInstanceOf(Country::CLASSNAME, $country); $this->assertInstanceOf(Country::class, $country);
$this->assertEquals(2, $this->secondLevelCacheLogger->getHitCount()); $this->assertEquals(2, $this->secondLevelCacheLogger->getHitCount());
$this->assertEquals(1, $this->secondLevelCacheLogger->getMissCount()); $this->assertEquals(1, $this->secondLevelCacheLogger->getMissCount());
$this->assertTrue($this->cache->containsEntity(Country::CLASSNAME, $this->countries[0]->getId())); $this->assertTrue($this->cache->containsEntity(Country::class, $this->countries[0]->getId()));
} }
public function testRepositoryCacheFindAllToOneAssociation() public function testRepositoryCacheFindAllToOneAssociation()
@ -186,19 +187,19 @@ class SecondLevelCacheRepositoryTest extends SecondLevelCacheAbstractTest
$this->_em->clear(); $this->_em->clear();
// load from database // load from database
$repository = $this->_em->getRepository(State::CLASSNAME); $repository = $this->_em->getRepository(State::class);
$queryCount = $this->getCurrentQueryCount(); $queryCount = $this->getCurrentQueryCount();
$entities = $repository->findAll(); $entities = $repository->findAll();
$this->assertCount(4, $entities); $this->assertCount(4, $entities);
$this->assertEquals($queryCount + 1, $this->getCurrentQueryCount()); $this->assertEquals($queryCount + 1, $this->getCurrentQueryCount());
$this->assertInstanceOf(State::CLASSNAME, $entities[0]); $this->assertInstanceOf(State::class, $entities[0]);
$this->assertInstanceOf(State::CLASSNAME, $entities[1]); $this->assertInstanceOf(State::class, $entities[1]);
$this->assertInstanceOf(Country::CLASSNAME, $entities[0]->getCountry()); $this->assertInstanceOf(Country::class, $entities[0]->getCountry());
$this->assertInstanceOf(Country::CLASSNAME, $entities[0]->getCountry()); $this->assertInstanceOf(Country::class, $entities[0]->getCountry());
$this->assertInstanceOf('Doctrine\ORM\Proxy\Proxy', $entities[0]->getCountry()); $this->assertInstanceOf(Proxy::class, $entities[0]->getCountry());
$this->assertInstanceOf('Doctrine\ORM\Proxy\Proxy', $entities[1]->getCountry()); $this->assertInstanceOf(Proxy::class, $entities[1]->getCountry());
// load from cache // load from cache
$queryCount = $this->getCurrentQueryCount(); $queryCount = $this->getCurrentQueryCount();
@ -207,15 +208,15 @@ class SecondLevelCacheRepositoryTest extends SecondLevelCacheAbstractTest
$this->assertCount(4, $entities); $this->assertCount(4, $entities);
$this->assertEquals($queryCount, $this->getCurrentQueryCount()); $this->assertEquals($queryCount, $this->getCurrentQueryCount());
$this->assertInstanceOf(State::CLASSNAME, $entities[0]); $this->assertInstanceOf(State::class, $entities[0]);
$this->assertInstanceOf(State::CLASSNAME, $entities[1]); $this->assertInstanceOf(State::class, $entities[1]);
$this->assertInstanceOf(Country::CLASSNAME, $entities[0]->getCountry()); $this->assertInstanceOf(Country::class, $entities[0]->getCountry());
$this->assertInstanceOf(Country::CLASSNAME, $entities[1]->getCountry()); $this->assertInstanceOf(Country::class, $entities[1]->getCountry());
$this->assertInstanceOf('Doctrine\ORM\Proxy\Proxy', $entities[0]->getCountry()); $this->assertInstanceOf(Proxy::class, $entities[0]->getCountry());
$this->assertInstanceOf('Doctrine\ORM\Proxy\Proxy', $entities[1]->getCountry()); $this->assertInstanceOf(Proxy::class, $entities[1]->getCountry());
// invalidate cache // invalidate cache
$this->_em->persist(new State('foo', $this->_em->find(Country::CLASSNAME, $this->countries[0]->getId()))); $this->_em->persist(new State('foo', $this->_em->find(Country::class, $this->countries[0]->getId())));
$this->_em->flush(); $this->_em->flush();
$this->_em->clear(); $this->_em->clear();
@ -226,12 +227,12 @@ class SecondLevelCacheRepositoryTest extends SecondLevelCacheAbstractTest
$this->assertCount(5, $entities); $this->assertCount(5, $entities);
$this->assertEquals($queryCount + 1, $this->getCurrentQueryCount()); $this->assertEquals($queryCount + 1, $this->getCurrentQueryCount());
$this->assertInstanceOf(State::CLASSNAME, $entities[0]); $this->assertInstanceOf(State::class, $entities[0]);
$this->assertInstanceOf(State::CLASSNAME, $entities[1]); $this->assertInstanceOf(State::class, $entities[1]);
$this->assertInstanceOf(Country::CLASSNAME, $entities[0]->getCountry()); $this->assertInstanceOf(Country::class, $entities[0]->getCountry());
$this->assertInstanceOf(Country::CLASSNAME, $entities[1]->getCountry()); $this->assertInstanceOf(Country::class, $entities[1]->getCountry());
$this->assertInstanceOf('Doctrine\ORM\Proxy\Proxy', $entities[0]->getCountry()); $this->assertInstanceOf(Proxy::class, $entities[0]->getCountry());
$this->assertInstanceOf('Doctrine\ORM\Proxy\Proxy', $entities[1]->getCountry()); $this->assertInstanceOf(Proxy::class, $entities[1]->getCountry());
// load from cache // load from cache
$queryCount = $this->getCurrentQueryCount(); $queryCount = $this->getCurrentQueryCount();
@ -240,11 +241,11 @@ class SecondLevelCacheRepositoryTest extends SecondLevelCacheAbstractTest
$this->assertCount(5, $entities); $this->assertCount(5, $entities);
$this->assertEquals($queryCount, $this->getCurrentQueryCount()); $this->assertEquals($queryCount, $this->getCurrentQueryCount());
$this->assertInstanceOf(State::CLASSNAME, $entities[0]); $this->assertInstanceOf(State::class, $entities[0]);
$this->assertInstanceOf(State::CLASSNAME, $entities[1]); $this->assertInstanceOf(State::class, $entities[1]);
$this->assertInstanceOf(Country::CLASSNAME, $entities[0]->getCountry()); $this->assertInstanceOf(Country::class, $entities[0]->getCountry());
$this->assertInstanceOf(Country::CLASSNAME, $entities[1]->getCountry()); $this->assertInstanceOf(Country::class, $entities[1]->getCountry());
$this->assertInstanceOf('Doctrine\ORM\Proxy\Proxy', $entities[0]->getCountry()); $this->assertInstanceOf(Proxy::class, $entities[0]->getCountry());
$this->assertInstanceOf('Doctrine\ORM\Proxy\Proxy', $entities[1]->getCountry()); $this->assertInstanceOf(Proxy::class, $entities[1]->getCountry());
} }
} }

View File

@ -2,11 +2,12 @@
namespace Doctrine\Tests\ORM\Functional; namespace Doctrine\Tests\ORM\Functional;
use Doctrine\ORM\PersistentCollection;
use Doctrine\Tests\Models\Cache\Attraction; use Doctrine\Tests\Models\Cache\Attraction;
use Doctrine\Tests\Models\Cache\Restaurant; use Doctrine\Tests\Models\Cache\Bar;
use Doctrine\Tests\Models\Cache\Beach; use Doctrine\Tests\Models\Cache\Beach;
use Doctrine\Tests\Models\Cache\City; use Doctrine\Tests\Models\Cache\City;
use Doctrine\Tests\Models\Cache\Bar; use Doctrine\Tests\Models\Cache\Restaurant;
/** /**
* @group DDC-2183 * @group DDC-2183
@ -15,10 +16,10 @@ class SecondLevelCacheSingleTableInheritanceTest extends SecondLevelCacheAbstrac
{ {
public function testUseSameRegion() public function testUseSameRegion()
{ {
$attractionRegion = $this->cache->getEntityCacheRegion(Attraction::CLASSNAME); $attractionRegion = $this->cache->getEntityCacheRegion(Attraction::class);
$restaurantRegion = $this->cache->getEntityCacheRegion(Restaurant::CLASSNAME); $restaurantRegion = $this->cache->getEntityCacheRegion(Restaurant::class);
$beachRegion = $this->cache->getEntityCacheRegion(Beach::CLASSNAME); $beachRegion = $this->cache->getEntityCacheRegion(Beach::class);
$barRegion = $this->cache->getEntityCacheRegion(Bar::CLASSNAME); $barRegion = $this->cache->getEntityCacheRegion(Bar::class);
$this->assertEquals($attractionRegion->getName(), $restaurantRegion->getName()); $this->assertEquals($attractionRegion->getName(), $restaurantRegion->getName());
$this->assertEquals($attractionRegion->getName(), $beachRegion->getName()); $this->assertEquals($attractionRegion->getName(), $beachRegion->getName());
@ -34,8 +35,8 @@ class SecondLevelCacheSingleTableInheritanceTest extends SecondLevelCacheAbstrac
$this->_em->clear(); $this->_em->clear();
$this->assertTrue($this->cache->containsEntity(Bar::CLASSNAME, $this->attractions[0]->getId())); $this->assertTrue($this->cache->containsEntity(Bar::class, $this->attractions[0]->getId()));
$this->assertTrue($this->cache->containsEntity(Bar::CLASSNAME, $this->attractions[1]->getId())); $this->assertTrue($this->cache->containsEntity(Bar::class, $this->attractions[1]->getId()));
} }
public function testCountaisRootClass() public function testCountaisRootClass()
@ -48,7 +49,7 @@ class SecondLevelCacheSingleTableInheritanceTest extends SecondLevelCacheAbstrac
$this->_em->clear(); $this->_em->clear();
foreach ($this->attractions as $attraction) { foreach ($this->attractions as $attraction) {
$this->assertTrue($this->cache->containsEntity(Attraction::CLASSNAME, $attraction->getId())); $this->assertTrue($this->cache->containsEntity(Attraction::class, $attraction->getId()));
$this->assertTrue($this->cache->containsEntity(get_class($attraction), $attraction->getId())); $this->assertTrue($this->cache->containsEntity(get_class($attraction), $attraction->getId()));
} }
} }
@ -62,28 +63,28 @@ class SecondLevelCacheSingleTableInheritanceTest extends SecondLevelCacheAbstrac
$this->_em->clear(); $this->_em->clear();
$this->cache->evictEntityRegion(Attraction::CLASSNAME); $this->cache->evictEntityRegion(Attraction::class);
$entityId1 = $this->attractions[0]->getId(); $entityId1 = $this->attractions[0]->getId();
$entityId2 = $this->attractions[1]->getId(); $entityId2 = $this->attractions[1]->getId();
$this->assertFalse($this->cache->containsEntity(Attraction::CLASSNAME, $entityId1)); $this->assertFalse($this->cache->containsEntity(Attraction::class, $entityId1));
$this->assertFalse($this->cache->containsEntity(Attraction::CLASSNAME, $entityId2)); $this->assertFalse($this->cache->containsEntity(Attraction::class, $entityId2));
$this->assertFalse($this->cache->containsEntity(Bar::CLASSNAME, $entityId1)); $this->assertFalse($this->cache->containsEntity(Bar::class, $entityId1));
$this->assertFalse($this->cache->containsEntity(Bar::CLASSNAME, $entityId2)); $this->assertFalse($this->cache->containsEntity(Bar::class, $entityId2));
$entity1 = $this->_em->find(Attraction::CLASSNAME, $entityId1); $entity1 = $this->_em->find(Attraction::class, $entityId1);
$entity2 = $this->_em->find(Attraction::CLASSNAME, $entityId2); $entity2 = $this->_em->find(Attraction::class, $entityId2);
$this->assertTrue($this->cache->containsEntity(Attraction::CLASSNAME, $entityId1)); $this->assertTrue($this->cache->containsEntity(Attraction::class, $entityId1));
$this->assertTrue($this->cache->containsEntity(Attraction::CLASSNAME, $entityId2)); $this->assertTrue($this->cache->containsEntity(Attraction::class, $entityId2));
$this->assertTrue($this->cache->containsEntity(Bar::CLASSNAME, $entityId1)); $this->assertTrue($this->cache->containsEntity(Bar::class, $entityId1));
$this->assertTrue($this->cache->containsEntity(Bar::CLASSNAME, $entityId2)); $this->assertTrue($this->cache->containsEntity(Bar::class, $entityId2));
$this->assertInstanceOf(Attraction::CLASSNAME, $entity1); $this->assertInstanceOf(Attraction::class, $entity1);
$this->assertInstanceOf(Attraction::CLASSNAME, $entity2); $this->assertInstanceOf(Attraction::class, $entity2);
$this->assertInstanceOf(Bar::CLASSNAME, $entity1); $this->assertInstanceOf(Bar::class, $entity1);
$this->assertInstanceOf(Bar::CLASSNAME, $entity2); $this->assertInstanceOf(Bar::class, $entity2);
$this->assertEquals($this->attractions[0]->getId(), $entity1->getId()); $this->assertEquals($this->attractions[0]->getId(), $entity1->getId());
$this->assertEquals($this->attractions[0]->getName(), $entity1->getName()); $this->assertEquals($this->attractions[0]->getName(), $entity1->getName());
@ -95,15 +96,15 @@ class SecondLevelCacheSingleTableInheritanceTest extends SecondLevelCacheAbstrac
$queryCount = $this->getCurrentQueryCount(); $queryCount = $this->getCurrentQueryCount();
$entity3 = $this->_em->find(Attraction::CLASSNAME, $entityId1); $entity3 = $this->_em->find(Attraction::class, $entityId1);
$entity4 = $this->_em->find(Attraction::CLASSNAME, $entityId2); $entity4 = $this->_em->find(Attraction::class, $entityId2);
$this->assertEquals($queryCount, $this->getCurrentQueryCount()); $this->assertEquals($queryCount, $this->getCurrentQueryCount());
$this->assertInstanceOf(Attraction::CLASSNAME, $entity3); $this->assertInstanceOf(Attraction::class, $entity3);
$this->assertInstanceOf(Attraction::CLASSNAME, $entity4); $this->assertInstanceOf(Attraction::class, $entity4);
$this->assertInstanceOf(Bar::CLASSNAME, $entity3); $this->assertInstanceOf(Bar::class, $entity3);
$this->assertInstanceOf(Bar::CLASSNAME, $entity4); $this->assertInstanceOf(Bar::class, $entity4);
$this->assertNotSame($entity1, $entity3); $this->assertNotSame($entity1, $entity3);
$this->assertEquals($entity1->getId(), $entity3->getId()); $this->assertEquals($entity1->getId(), $entity3->getId());
@ -142,7 +143,7 @@ class SecondLevelCacheSingleTableInheritanceTest extends SecondLevelCacheAbstrac
$this->assertEquals($queryCount + 1, $this->getCurrentQueryCount()); $this->assertEquals($queryCount + 1, $this->getCurrentQueryCount());
foreach ($result2 as $entity) { foreach ($result2 as $entity) {
$this->assertInstanceOf(Attraction::CLASSNAME, $entity); $this->assertInstanceOf(Attraction::class, $entity);
} }
} }
@ -156,12 +157,12 @@ class SecondLevelCacheSingleTableInheritanceTest extends SecondLevelCacheAbstrac
$this->_em->clear(); $this->_em->clear();
foreach ($this->cities as $city) { foreach ($this->cities as $city) {
$this->assertTrue($this->cache->containsEntity(City::CLASSNAME, $city->getId())); $this->assertTrue($this->cache->containsEntity(City::class, $city->getId()));
$this->assertFalse($this->cache->containsCollection(City::CLASSNAME, 'attractions', $city->getId())); $this->assertFalse($this->cache->containsCollection(City::class, 'attractions', $city->getId()));
} }
foreach ($this->attractions as $attraction) { foreach ($this->attractions as $attraction) {
$this->assertTrue($this->cache->containsEntity(Attraction::CLASSNAME, $attraction->getId())); $this->assertTrue($this->cache->containsEntity(Attraction::class, $attraction->getId()));
} }
} }
@ -172,41 +173,41 @@ class SecondLevelCacheSingleTableInheritanceTest extends SecondLevelCacheAbstrac
$this->loadFixturesCities(); $this->loadFixturesCities();
$this->loadFixturesAttractions(); $this->loadFixturesAttractions();
$this->cache->evictEntityRegion(City::CLASSNAME); $this->cache->evictEntityRegion(City::class);
$this->cache->evictEntityRegion(Attraction::CLASSNAME); $this->cache->evictEntityRegion(Attraction::class);
$this->cache->evictCollectionRegion(City::CLASSNAME, 'attractions'); $this->cache->evictCollectionRegion(City::class, 'attractions');
$this->_em->clear(); $this->_em->clear();
$entity = $this->_em->find(City::CLASSNAME, $this->cities[0]->getId()); $entity = $this->_em->find(City::class, $this->cities[0]->getId());
$this->assertInstanceOf(City::CLASSNAME, $entity); $this->assertInstanceOf(City::class, $entity);
$this->assertInstanceOf('Doctrine\ORM\PersistentCollection', $entity->getAttractions()); $this->assertInstanceOf(PersistentCollection::class, $entity->getAttractions());
$this->assertCount(2, $entity->getAttractions()); $this->assertCount(2, $entity->getAttractions());
$ownerId = $this->cities[0]->getId(); $ownerId = $this->cities[0]->getId();
$queryCount = $this->getCurrentQueryCount(); $queryCount = $this->getCurrentQueryCount();
$this->assertTrue($this->cache->containsEntity(City::CLASSNAME, $ownerId)); $this->assertTrue($this->cache->containsEntity(City::class, $ownerId));
$this->assertTrue($this->cache->containsCollection(City::CLASSNAME, 'attractions', $ownerId)); $this->assertTrue($this->cache->containsCollection(City::class, 'attractions', $ownerId));
$this->assertInstanceOf(Bar::CLASSNAME, $entity->getAttractions()->get(0)); $this->assertInstanceOf(Bar::class, $entity->getAttractions()->get(0));
$this->assertInstanceOf(Bar::CLASSNAME, $entity->getAttractions()->get(1)); $this->assertInstanceOf(Bar::class, $entity->getAttractions()->get(1));
$this->assertEquals($this->attractions[0]->getName(), $entity->getAttractions()->get(0)->getName()); $this->assertEquals($this->attractions[0]->getName(), $entity->getAttractions()->get(0)->getName());
$this->assertEquals($this->attractions[1]->getName(), $entity->getAttractions()->get(1)->getName()); $this->assertEquals($this->attractions[1]->getName(), $entity->getAttractions()->get(1)->getName());
$this->_em->clear(); $this->_em->clear();
$entity = $this->_em->find(City::CLASSNAME, $ownerId); $entity = $this->_em->find(City::class, $ownerId);
$this->assertInstanceOf(City::CLASSNAME, $entity); $this->assertInstanceOf(City::class, $entity);
$this->assertInstanceOf('Doctrine\ORM\PersistentCollection', $entity->getAttractions()); $this->assertInstanceOf(PersistentCollection::class, $entity->getAttractions());
$this->assertCount(2, $entity->getAttractions()); $this->assertCount(2, $entity->getAttractions());
$this->assertEquals($queryCount, $this->getCurrentQueryCount()); $this->assertEquals($queryCount, $this->getCurrentQueryCount());
$this->assertInstanceOf(Bar::CLASSNAME, $entity->getAttractions()->get(0)); $this->assertInstanceOf(Bar::class, $entity->getAttractions()->get(0));
$this->assertInstanceOf(Bar::CLASSNAME, $entity->getAttractions()->get(1)); $this->assertInstanceOf(Bar::class, $entity->getAttractions()->get(1));
$this->assertEquals($this->attractions[0]->getName(), $entity->getAttractions()->get(0)->getName()); $this->assertEquals($this->attractions[0]->getName(), $entity->getAttractions()->get(0)->getName());
$this->assertEquals($this->attractions[1]->getName(), $entity->getAttractions()->get(1)->getName()); $this->assertEquals($this->attractions[1]->getName(), $entity->getAttractions()->get(1)->getName());
} }
@ -248,7 +249,7 @@ class SecondLevelCacheSingleTableInheritanceTest extends SecondLevelCacheAbstrac
$this->assertEquals($queryCount + 1, $this->getCurrentQueryCount()); $this->assertEquals($queryCount + 1, $this->getCurrentQueryCount());
foreach ($result2 as $entity) { foreach ($result2 as $entity) {
$this->assertInstanceOf(Attraction::CLASSNAME, $entity); $this->assertInstanceOf(Attraction::class, $entity);
} }
} }
} }

View File

@ -16,10 +16,10 @@ class SecondLevelCacheTest extends SecondLevelCacheAbstractTest
$this->loadFixturesCountries(); $this->loadFixturesCountries();
$this->_em->clear(); $this->_em->clear();
$this->assertTrue($this->cache->containsEntity(Country::CLASSNAME, $this->countries[0]->getId())); $this->assertTrue($this->cache->containsEntity(Country::class, $this->countries[0]->getId()));
$this->assertTrue($this->cache->containsEntity(Country::CLASSNAME, $this->countries[1]->getId())); $this->assertTrue($this->cache->containsEntity(Country::class, $this->countries[1]->getId()));
$this->assertEquals(2, $this->secondLevelCacheLogger->getPutCount()); $this->assertEquals(2, $this->secondLevelCacheLogger->getPutCount());
$this->assertEquals(2, $this->secondLevelCacheLogger->getRegionPutCount($this->getEntityRegion(Country::CLASSNAME))); $this->assertEquals(2, $this->secondLevelCacheLogger->getRegionPutCount($this->getEntityRegion(Country::class)));
} }
public function testPutAndLoadEntities() public function testPutAndLoadEntities()
@ -28,21 +28,21 @@ class SecondLevelCacheTest extends SecondLevelCacheAbstractTest
$this->_em->clear(); $this->_em->clear();
$this->assertEquals(2, $this->secondLevelCacheLogger->getPutCount()); $this->assertEquals(2, $this->secondLevelCacheLogger->getPutCount());
$this->assertEquals(2, $this->secondLevelCacheLogger->getRegionPutCount($this->getEntityRegion(Country::CLASSNAME))); $this->assertEquals(2, $this->secondLevelCacheLogger->getRegionPutCount($this->getEntityRegion(Country::class)));
$this->cache->evictEntityRegion(Country::CLASSNAME); $this->cache->evictEntityRegion(Country::class);
$this->assertFalse($this->cache->containsEntity(Country::CLASSNAME, $this->countries[0]->getId())); $this->assertFalse($this->cache->containsEntity(Country::class, $this->countries[0]->getId()));
$this->assertFalse($this->cache->containsEntity(Country::CLASSNAME, $this->countries[1]->getId())); $this->assertFalse($this->cache->containsEntity(Country::class, $this->countries[1]->getId()));
$c1 = $this->_em->find(Country::CLASSNAME, $this->countries[0]->getId()); $c1 = $this->_em->find(Country::class, $this->countries[0]->getId());
$c2 = $this->_em->find(Country::CLASSNAME, $this->countries[1]->getId()); $c2 = $this->_em->find(Country::class, $this->countries[1]->getId());
$this->assertTrue($this->cache->containsEntity(Country::CLASSNAME, $this->countries[0]->getId())); $this->assertTrue($this->cache->containsEntity(Country::class, $this->countries[0]->getId()));
$this->assertTrue($this->cache->containsEntity(Country::CLASSNAME, $this->countries[1]->getId())); $this->assertTrue($this->cache->containsEntity(Country::class, $this->countries[1]->getId()));
$this->assertInstanceOf(Country::CLASSNAME, $c1); $this->assertInstanceOf(Country::class, $c1);
$this->assertInstanceOf(Country::CLASSNAME, $c2); $this->assertInstanceOf(Country::class, $c2);
$this->assertEquals($this->countries[0]->getId(), $c1->getId()); $this->assertEquals($this->countries[0]->getId(), $c1->getId());
$this->assertEquals($this->countries[0]->getName(), $c1->getName()); $this->assertEquals($this->countries[0]->getName(), $c1->getName());
@ -54,15 +54,15 @@ class SecondLevelCacheTest extends SecondLevelCacheAbstractTest
$queryCount = $this->getCurrentQueryCount(); $queryCount = $this->getCurrentQueryCount();
$c3 = $this->_em->find(Country::CLASSNAME, $this->countries[0]->getId()); $c3 = $this->_em->find(Country::class, $this->countries[0]->getId());
$c4 = $this->_em->find(Country::CLASSNAME, $this->countries[1]->getId()); $c4 = $this->_em->find(Country::class, $this->countries[1]->getId());
$this->assertEquals($queryCount, $this->getCurrentQueryCount()); $this->assertEquals($queryCount, $this->getCurrentQueryCount());
$this->assertEquals(2, $this->secondLevelCacheLogger->getHitCount()); $this->assertEquals(2, $this->secondLevelCacheLogger->getHitCount());
$this->assertEquals(2, $this->secondLevelCacheLogger->getRegionHitCount($this->getEntityRegion(Country::CLASSNAME))); $this->assertEquals(2, $this->secondLevelCacheLogger->getRegionHitCount($this->getEntityRegion(Country::class)));
$this->assertInstanceOf(Country::CLASSNAME, $c3); $this->assertInstanceOf(Country::class, $c3);
$this->assertInstanceOf(Country::CLASSNAME, $c4); $this->assertInstanceOf(Country::class, $c4);
$this->assertEquals($c1->getId(), $c3->getId()); $this->assertEquals($c1->getId(), $c3->getId());
$this->assertEquals($c1->getName(), $c3->getName()); $this->assertEquals($c1->getName(), $c3->getName());
@ -78,23 +78,23 @@ class SecondLevelCacheTest extends SecondLevelCacheAbstractTest
$this->assertEquals(2, $this->secondLevelCacheLogger->getPutCount()); $this->assertEquals(2, $this->secondLevelCacheLogger->getPutCount());
$this->cache->evictEntityRegion(Country::CLASSNAME); $this->cache->evictEntityRegion(Country::class);
$this->secondLevelCacheLogger->clearRegionStats($this->getEntityRegion(Country::CLASSNAME)); $this->secondLevelCacheLogger->clearRegionStats($this->getEntityRegion(Country::class));
$this->assertFalse($this->cache->containsEntity(Country::CLASSNAME, $this->countries[0]->getId())); $this->assertFalse($this->cache->containsEntity(Country::class, $this->countries[0]->getId()));
$this->assertFalse($this->cache->containsEntity(Country::CLASSNAME, $this->countries[1]->getId())); $this->assertFalse($this->cache->containsEntity(Country::class, $this->countries[1]->getId()));
$c1 = $this->_em->find(Country::CLASSNAME, $this->countries[0]->getId()); $c1 = $this->_em->find(Country::class, $this->countries[0]->getId());
$c2 = $this->_em->find(Country::CLASSNAME, $this->countries[1]->getId()); $c2 = $this->_em->find(Country::class, $this->countries[1]->getId());
$this->assertEquals(2, $this->secondLevelCacheLogger->getPutCount()); $this->assertEquals(2, $this->secondLevelCacheLogger->getPutCount());
$this->assertEquals(2, $this->secondLevelCacheLogger->getMissCount()); $this->assertEquals(2, $this->secondLevelCacheLogger->getMissCount());
$this->assertTrue($this->cache->containsEntity(Country::CLASSNAME, $this->countries[0]->getId())); $this->assertTrue($this->cache->containsEntity(Country::class, $this->countries[0]->getId()));
$this->assertTrue($this->cache->containsEntity(Country::CLASSNAME, $this->countries[1]->getId())); $this->assertTrue($this->cache->containsEntity(Country::class, $this->countries[1]->getId()));
$this->assertInstanceOf(Country::CLASSNAME, $c1); $this->assertInstanceOf(Country::class, $c1);
$this->assertInstanceOf(Country::CLASSNAME, $c2); $this->assertInstanceOf(Country::class, $c2);
$this->assertEquals($this->countries[0]->getId(), $c1->getId()); $this->assertEquals($this->countries[0]->getId(), $c1->getId());
$this->assertEquals($this->countries[0]->getName(), $c1->getName()); $this->assertEquals($this->countries[0]->getName(), $c1->getName());
@ -107,11 +107,11 @@ class SecondLevelCacheTest extends SecondLevelCacheAbstractTest
$this->_em->flush(); $this->_em->flush();
$this->_em->clear(); $this->_em->clear();
$this->assertFalse($this->cache->containsEntity(Country::CLASSNAME, $this->countries[0]->getId())); $this->assertFalse($this->cache->containsEntity(Country::class, $this->countries[0]->getId()));
$this->assertFalse($this->cache->containsEntity(Country::CLASSNAME, $this->countries[1]->getId())); $this->assertFalse($this->cache->containsEntity(Country::class, $this->countries[1]->getId()));
$this->assertNull($this->_em->find(Country::CLASSNAME, $this->countries[0]->getId())); $this->assertNull($this->_em->find(Country::class, $this->countries[0]->getId()));
$this->assertNull($this->_em->find(Country::CLASSNAME, $this->countries[1]->getId())); $this->assertNull($this->_em->find(Country::class, $this->countries[1]->getId()));
$this->assertEquals(2, $this->secondLevelCacheLogger->getPutCount()); $this->assertEquals(2, $this->secondLevelCacheLogger->getPutCount());
$this->assertEquals(2, $this->secondLevelCacheLogger->getMissCount()); $this->assertEquals(2, $this->secondLevelCacheLogger->getMissCount());
@ -124,27 +124,27 @@ class SecondLevelCacheTest extends SecondLevelCacheAbstractTest
$this->_em->clear(); $this->_em->clear();
$this->assertEquals(6, $this->secondLevelCacheLogger->getPutCount()); $this->assertEquals(6, $this->secondLevelCacheLogger->getPutCount());
$this->assertEquals(2, $this->secondLevelCacheLogger->getRegionPutCount($this->getEntityRegion(Country::CLASSNAME))); $this->assertEquals(2, $this->secondLevelCacheLogger->getRegionPutCount($this->getEntityRegion(Country::class)));
$this->assertEquals(4, $this->secondLevelCacheLogger->getRegionPutCount($this->getEntityRegion(State::CLASSNAME))); $this->assertEquals(4, $this->secondLevelCacheLogger->getRegionPutCount($this->getEntityRegion(State::class)));
$this->cache->evictEntityRegion(State::CLASSNAME); $this->cache->evictEntityRegion(State::class);
$this->secondLevelCacheLogger->clearRegionStats($this->getEntityRegion(State::CLASSNAME)); $this->secondLevelCacheLogger->clearRegionStats($this->getEntityRegion(State::class));
$this->assertFalse($this->cache->containsEntity(State::CLASSNAME, $this->states[0]->getId())); $this->assertFalse($this->cache->containsEntity(State::class, $this->states[0]->getId()));
$this->assertFalse($this->cache->containsEntity(State::CLASSNAME, $this->states[1]->getId())); $this->assertFalse($this->cache->containsEntity(State::class, $this->states[1]->getId()));
$s1 = $this->_em->find(State::CLASSNAME, $this->states[0]->getId()); $s1 = $this->_em->find(State::class, $this->states[0]->getId());
$s2 = $this->_em->find(State::CLASSNAME, $this->states[1]->getId()); $s2 = $this->_em->find(State::class, $this->states[1]->getId());
$this->assertEquals(4, $this->secondLevelCacheLogger->getPutCount()); $this->assertEquals(4, $this->secondLevelCacheLogger->getPutCount());
$this->assertEquals(2, $this->secondLevelCacheLogger->getRegionPutCount($this->getEntityRegion(Country::CLASSNAME))); $this->assertEquals(2, $this->secondLevelCacheLogger->getRegionPutCount($this->getEntityRegion(Country::class)));
$this->assertEquals(2, $this->secondLevelCacheLogger->getRegionPutCount($this->getEntityRegion(State::CLASSNAME))); $this->assertEquals(2, $this->secondLevelCacheLogger->getRegionPutCount($this->getEntityRegion(State::class)));
$this->assertTrue($this->cache->containsEntity(State::CLASSNAME, $this->states[0]->getId())); $this->assertTrue($this->cache->containsEntity(State::class, $this->states[0]->getId()));
$this->assertTrue($this->cache->containsEntity(State::CLASSNAME, $this->states[1]->getId())); $this->assertTrue($this->cache->containsEntity(State::class, $this->states[1]->getId()));
$this->assertInstanceOf(State::CLASSNAME, $s1); $this->assertInstanceOf(State::class, $s1);
$this->assertInstanceOf(State::CLASSNAME, $s2); $this->assertInstanceOf(State::class, $s2);
$this->assertEquals($this->states[0]->getId(), $s1->getId()); $this->assertEquals($this->states[0]->getId(), $s1->getId());
$this->assertEquals($this->states[0]->getName(), $s1->getName()); $this->assertEquals($this->states[0]->getName(), $s1->getName());
@ -160,28 +160,28 @@ class SecondLevelCacheTest extends SecondLevelCacheAbstractTest
$this->_em->flush(); $this->_em->flush();
$this->_em->clear(); $this->_em->clear();
$this->assertTrue($this->cache->containsEntity(State::CLASSNAME, $this->states[0]->getId())); $this->assertTrue($this->cache->containsEntity(State::class, $this->states[0]->getId()));
$this->assertTrue($this->cache->containsEntity(State::CLASSNAME, $this->states[1]->getId())); $this->assertTrue($this->cache->containsEntity(State::class, $this->states[1]->getId()));
$this->assertEquals(6, $this->secondLevelCacheLogger->getPutCount()); $this->assertEquals(6, $this->secondLevelCacheLogger->getPutCount());
$this->assertEquals(2, $this->secondLevelCacheLogger->getRegionPutCount($this->getEntityRegion(Country::CLASSNAME))); $this->assertEquals(2, $this->secondLevelCacheLogger->getRegionPutCount($this->getEntityRegion(Country::class)));
$this->assertEquals(4, $this->secondLevelCacheLogger->getRegionPutCount($this->getEntityRegion(State::CLASSNAME))); $this->assertEquals(4, $this->secondLevelCacheLogger->getRegionPutCount($this->getEntityRegion(State::class)));
$queryCount = $this->getCurrentQueryCount(); $queryCount = $this->getCurrentQueryCount();
$c3 = $this->_em->find(State::CLASSNAME, $this->states[0]->getId()); $c3 = $this->_em->find(State::class, $this->states[0]->getId());
$c4 = $this->_em->find(State::CLASSNAME, $this->states[1]->getId()); $c4 = $this->_em->find(State::class, $this->states[1]->getId());
$this->assertEquals(2, $this->secondLevelCacheLogger->getHitCount()); $this->assertEquals(2, $this->secondLevelCacheLogger->getHitCount());
$this->assertEquals(2, $this->secondLevelCacheLogger->getRegionHitCount($this->getEntityRegion(State::CLASSNAME))); $this->assertEquals(2, $this->secondLevelCacheLogger->getRegionHitCount($this->getEntityRegion(State::class)));
$this->assertEquals($queryCount, $this->getCurrentQueryCount()); $this->assertEquals($queryCount, $this->getCurrentQueryCount());
$this->assertTrue($this->cache->containsEntity(State::CLASSNAME, $this->states[0]->getId())); $this->assertTrue($this->cache->containsEntity(State::class, $this->states[0]->getId()));
$this->assertTrue($this->cache->containsEntity(State::CLASSNAME, $this->states[1]->getId())); $this->assertTrue($this->cache->containsEntity(State::class, $this->states[1]->getId()));
$this->assertInstanceOf(State::CLASSNAME, $c3); $this->assertInstanceOf(State::class, $c3);
$this->assertInstanceOf(State::CLASSNAME, $c4); $this->assertInstanceOf(State::class, $c4);
$this->assertEquals($s1->getId(), $c3->getId()); $this->assertEquals($s1->getId(), $c3->getId());
$this->assertEquals("NEW NAME 1", $c3->getName()); $this->assertEquals("NEW NAME 1", $c3->getName());
@ -190,7 +190,7 @@ class SecondLevelCacheTest extends SecondLevelCacheAbstractTest
$this->assertEquals("NEW NAME 2", $c4->getName()); $this->assertEquals("NEW NAME 2", $c4->getName());
$this->assertEquals(2, $this->secondLevelCacheLogger->getHitCount()); $this->assertEquals(2, $this->secondLevelCacheLogger->getHitCount());
$this->assertEquals(2, $this->secondLevelCacheLogger->getRegionHitCount($this->getEntityRegion(State::CLASSNAME))); $this->assertEquals(2, $this->secondLevelCacheLogger->getRegionHitCount($this->getEntityRegion(State::class)));
} }
public function testPostFlushFailure() public function testPostFlushFailure()
@ -208,7 +208,7 @@ class SecondLevelCacheTest extends SecondLevelCacheAbstractTest
$country = new Country("Brazil"); $country = new Country("Brazil");
$this->cache->evictEntityRegion(Country::CLASSNAME); $this->cache->evictEntityRegion(Country::class);
try { try {
@ -219,7 +219,7 @@ class SecondLevelCacheTest extends SecondLevelCacheAbstractTest
} catch (\RuntimeException $exc) { } catch (\RuntimeException $exc) {
$this->assertNotNull($country->getId()); $this->assertNotNull($country->getId());
$this->assertEquals('post flush failure', $exc->getMessage()); $this->assertEquals('post flush failure', $exc->getMessage());
$this->assertTrue($this->cache->containsEntity(Country::CLASSNAME, $country->getId())); $this->assertTrue($this->cache->containsEntity(Country::class, $country->getId()));
} }
} }
@ -240,14 +240,14 @@ class SecondLevelCacheTest extends SecondLevelCacheAbstractTest
$this->_em->getEventManager() $this->_em->getEventManager()
->addEventListener(Events::postUpdate, $listener); ->addEventListener(Events::postUpdate, $listener);
$this->cache->evictEntityRegion(State::CLASSNAME); $this->cache->evictEntityRegion(State::class);
$stateId = $this->states[0]->getId(); $stateId = $this->states[0]->getId();
$stateName = $this->states[0]->getName(); $stateName = $this->states[0]->getName();
$state = $this->_em->find(State::CLASSNAME, $stateId); $state = $this->_em->find(State::class, $stateId);
$this->assertTrue($this->cache->containsEntity(State::CLASSNAME, $stateId)); $this->assertTrue($this->cache->containsEntity(State::class, $stateId));
$this->assertInstanceOf(State::CLASSNAME, $state); $this->assertInstanceOf(State::class, $state);
$this->assertEquals($stateName, $state->getName()); $this->assertEquals($stateName, $state->getName());
$state->setName($stateName . uniqid()); $state->setName($stateName . uniqid());
@ -264,11 +264,11 @@ class SecondLevelCacheTest extends SecondLevelCacheAbstractTest
$this->_em->clear(); $this->_em->clear();
$this->assertTrue($this->cache->containsEntity(State::CLASSNAME, $stateId)); $this->assertTrue($this->cache->containsEntity(State::class, $stateId));
$state = $this->_em->find(State::CLASSNAME, $stateId); $state = $this->_em->find(State::class, $stateId);
$this->assertInstanceOf(State::CLASSNAME, $state); $this->assertInstanceOf(State::class, $state);
$this->assertEquals($stateName, $state->getName()); $this->assertEquals($stateName, $state->getName());
} }
@ -288,13 +288,13 @@ class SecondLevelCacheTest extends SecondLevelCacheAbstractTest
$this->_em->getEventManager() $this->_em->getEventManager()
->addEventListener(Events::postRemove, $listener); ->addEventListener(Events::postRemove, $listener);
$this->cache->evictEntityRegion(Country::CLASSNAME); $this->cache->evictEntityRegion(Country::class);
$countryId = $this->countries[0]->getId(); $countryId = $this->countries[0]->getId();
$country = $this->_em->find(Country::CLASSNAME, $countryId); $country = $this->_em->find(Country::class, $countryId);
$this->assertTrue($this->cache->containsEntity(Country::CLASSNAME, $countryId)); $this->assertTrue($this->cache->containsEntity(Country::class, $countryId));
$this->assertInstanceOf(Country::CLASSNAME, $country); $this->assertInstanceOf(Country::class, $country);
$this->_em->remove($country); $this->_em->remove($country);
@ -309,18 +309,18 @@ class SecondLevelCacheTest extends SecondLevelCacheAbstractTest
$this->_em->clear(); $this->_em->clear();
$this->assertFalse( $this->assertFalse(
$this->cache->containsEntity(Country::CLASSNAME, $countryId), $this->cache->containsEntity(Country::class, $countryId),
'Removal attempts should clear the cache entry corresponding to the entity' 'Removal attempts should clear the cache entry corresponding to the entity'
); );
$this->assertInstanceOf(Country::CLASSNAME, $this->_em->find(Country::CLASSNAME, $countryId)); $this->assertInstanceOf(Country::class, $this->_em->find(Country::class, $countryId));
} }
public function testCachedNewEntityExists() public function testCachedNewEntityExists()
{ {
$this->loadFixturesCountries(); $this->loadFixturesCountries();
$persister = $this->_em->getUnitOfWork()->getEntityPersister(Country::CLASSNAME); $persister = $this->_em->getUnitOfWork()->getEntityPersister(Country::class);
$queryCount = $this->getCurrentQueryCount(); $queryCount = $this->getCurrentQueryCount();
$this->assertTrue($persister->exists($this->countries[0])); $this->assertTrue($persister->exists($this->countries[0]));

View File

@ -21,7 +21,7 @@ class SequenceEmulatedIdentityStrategyTest extends OrmFunctionalTestCase
} else { } else {
try { try {
$this->_schemaTool->createSchema( $this->_schemaTool->createSchema(
[$this->_em->getClassMetadata('Doctrine\Tests\ORM\Functional\SequenceEmulatedIdentityEntity')] [$this->_em->getClassMetadata(SequenceEmulatedIdentityEntity::class)]
); );
} catch (\Exception $e) { } catch (\Exception $e) {
// Swallow all exceptions. We do not test the schema tool here. // Swallow all exceptions. We do not test the schema tool here.

View File

@ -21,7 +21,7 @@ class SequenceGeneratorTest extends OrmFunctionalTestCase
try { try {
$this->_schemaTool->createSchema( $this->_schemaTool->createSchema(
[ [
$this->_em->getClassMetadata(__NAMESPACE__ . '\SequenceEntity'), $this->_em->getClassMetadata(SequenceEntity::class),
] ]
); );
} catch(\Exception $e) { } catch(\Exception $e) {

View File

@ -1,8 +1,9 @@
<?php <?php
namespace Doctrine\Tests\ORM\Functional; namespace Doctrine\Tests\ORM\Functional;
use Doctrine\Tests\OrmFunctionalTestCase;
use Doctrine\Tests\Models\CompositeKeyInheritance\SingleChildClass; use Doctrine\Tests\Models\CompositeKeyInheritance\SingleChildClass;
use Doctrine\Tests\Models\CompositeKeyInheritance\SingleRootClass;
use Doctrine\Tests\OrmFunctionalTestCase;
class SingleTableCompositeKeyTest extends OrmFunctionalTestCase class SingleTableCompositeKeyTest extends OrmFunctionalTestCase
{ {
@ -56,9 +57,6 @@ class SingleTableCompositeKeyTest extends OrmFunctionalTestCase
*/ */
private function findEntity() private function findEntity()
{ {
return $this->_em->find( return $this->_em->find(SingleRootClass::class, ['keyPart1' => 'part-1', 'keyPart2' => 'part-2']);
'Doctrine\Tests\Models\CompositeKeyInheritance\SingleRootClass',
['keyPart1' => 'part-1', 'keyPart2' => 'part-2']
);
} }
} }

View File

@ -2,9 +2,11 @@
namespace Doctrine\Tests\ORM\Functional; namespace Doctrine\Tests\ORM\Functional;
use Doctrine\ORM\Mapping\ClassMetadata;
use Doctrine\Common\Collections\Criteria; use Doctrine\Common\Collections\Criteria;
use Doctrine\ORM\Mapping\ClassMetadata;
use Doctrine\ORM\Persisters\PersisterException; use Doctrine\ORM\Persisters\PersisterException;
use Doctrine\ORM\Proxy\Proxy;
use Doctrine\Tests\Models\Company\CompanyContract;
use Doctrine\Tests\Models\Company\CompanyEmployee; use Doctrine\Tests\Models\Company\CompanyEmployee;
use Doctrine\Tests\Models\Company\CompanyFixContract; use Doctrine\Tests\Models\Company\CompanyFixContract;
use Doctrine\Tests\Models\Company\CompanyFlexContract; use Doctrine\Tests\Models\Company\CompanyFlexContract;
@ -110,9 +112,9 @@ class SingleTableInheritanceTest extends OrmFunctionalTestCase
$this->_em->flush(); $this->_em->flush();
$this->_em->clear(); $this->_em->clear();
$contract = $this->_em->find('Doctrine\Tests\Models\Company\CompanyFixContract', $fixContract->getId()); $contract = $this->_em->find(CompanyFixContract::class, $fixContract->getId());
$this->assertInstanceOf('Doctrine\Tests\Models\Company\CompanyFixContract', $contract); $this->assertInstanceOf(CompanyFixContract::class, $contract);
$this->assertEquals(1000, $contract->getFixPrice()); $this->assertEquals(1000, $contract->getFixPrice());
$this->assertEquals($this->salesPerson->getId(), $contract->getSalesPerson()->getId()); $this->assertEquals($this->salesPerson->getId(), $contract->getSalesPerson()->getId());
} }
@ -131,9 +133,9 @@ class SingleTableInheritanceTest extends OrmFunctionalTestCase
$this->_em->flush(); $this->_em->flush();
$this->_em->clear(); $this->_em->clear();
$contract = $this->_em->find('Doctrine\Tests\Models\Company\CompanyFlexUltraContract', $ultraContract->getId()); $contract = $this->_em->find(CompanyFlexUltraContract::class, $ultraContract->getId());
$this->assertInstanceOf('Doctrine\Tests\Models\Company\CompanyFlexUltraContract', $contract); $this->assertInstanceOf(CompanyFlexUltraContract::class, $contract);
$this->assertEquals(7000, $contract->getMaxPrice()); $this->assertEquals(7000, $contract->getMaxPrice());
$this->assertEquals(100, $contract->getHoursWorked()); $this->assertEquals(100, $contract->getHoursWorked());
$this->assertEquals(50, $contract->getPricePerHour()); $this->assertEquals(50, $contract->getPricePerHour());
@ -143,13 +145,13 @@ class SingleTableInheritanceTest extends OrmFunctionalTestCase
{ {
$this->loadFullFixture(); $this->loadFullFixture();
$fix = $this->_em->find('Doctrine\Tests\Models\Company\CompanyContract', $this->fix->getId()); $fix = $this->_em->find(CompanyContract::class, $this->fix->getId());
$fix->setFixPrice(2500); $fix->setFixPrice(2500);
$this->_em->flush(); $this->_em->flush();
$this->_em->clear(); $this->_em->clear();
$newFix = $this->_em->find('Doctrine\Tests\Models\Company\CompanyContract', $this->fix->getId()); $newFix = $this->_em->find(CompanyContract::class, $this->fix->getId());
$this->assertEquals(2500, $newFix->getFixPrice()); $this->assertEquals(2500, $newFix->getFixPrice());
} }
@ -157,38 +159,38 @@ class SingleTableInheritanceTest extends OrmFunctionalTestCase
{ {
$this->loadFullFixture(); $this->loadFullFixture();
$fix = $this->_em->find('Doctrine\Tests\Models\Company\CompanyContract', $this->fix->getId()); $fix = $this->_em->find(CompanyContract::class, $this->fix->getId());
$this->_em->remove($fix); $this->_em->remove($fix);
$this->_em->flush(); $this->_em->flush();
$this->assertNull($this->_em->find('Doctrine\Tests\Models\Company\CompanyContract', $this->fix->getId())); $this->assertNull($this->_em->find(CompanyContract::class, $this->fix->getId()));
} }
public function testFindAllForAbstractBaseClass() public function testFindAllForAbstractBaseClass()
{ {
$this->loadFullFixture(); $this->loadFullFixture();
$contracts = $this->_em->getRepository('Doctrine\Tests\Models\Company\CompanyContract')->findAll(); $contracts = $this->_em->getRepository(CompanyContract::class)->findAll();
$this->assertEquals(3, count($contracts)); $this->assertEquals(3, count($contracts));
$this->assertContainsOnly('Doctrine\Tests\Models\Company\CompanyContract', $contracts); $this->assertContainsOnly(CompanyContract::class, $contracts);
} }
public function testFindAllForChildClass() public function testFindAllForChildClass()
{ {
$this->loadFullFixture(); $this->loadFullFixture();
$this->assertEquals(1, count($this->_em->getRepository('Doctrine\Tests\Models\Company\CompanyFixContract')->findAll())); $this->assertEquals(1, count($this->_em->getRepository(CompanyFixContract::class)->findAll()));
$this->assertEquals(2, count($this->_em->getRepository('Doctrine\Tests\Models\Company\CompanyFlexContract')->findAll())); $this->assertEquals(2, count($this->_em->getRepository(CompanyFlexContract::class)->findAll()));
$this->assertEquals(1, count($this->_em->getRepository('Doctrine\Tests\Models\Company\CompanyFlexUltraContract')->findAll())); $this->assertEquals(1, count($this->_em->getRepository(CompanyFlexUltraContract::class)->findAll()));
} }
public function testFindForAbstractBaseClass() public function testFindForAbstractBaseClass()
{ {
$this->loadFullFixture(); $this->loadFullFixture();
$contract = $this->_em->find('Doctrine\Tests\Models\Company\CompanyContract', $this->fix->getId()); $contract = $this->_em->find(CompanyContract::class, $this->fix->getId());
$this->assertInstanceOf('Doctrine\Tests\Models\Company\CompanyFixContract', $contract); $this->assertInstanceOf(CompanyFixContract::class, $contract);
$this->assertEquals(1000, $contract->getFixPrice()); $this->assertEquals(1000, $contract->getFixPrice());
} }
@ -199,7 +201,7 @@ class SingleTableInheritanceTest extends OrmFunctionalTestCase
$contracts = $this->_em->createQuery('SELECT c FROM Doctrine\Tests\Models\Company\CompanyContract c')->getResult(); $contracts = $this->_em->createQuery('SELECT c FROM Doctrine\Tests\Models\Company\CompanyContract c')->getResult();
$this->assertEquals(3, count($contracts)); $this->assertEquals(3, count($contracts));
$this->assertContainsOnly('Doctrine\Tests\Models\Company\CompanyContract', $contracts); $this->assertContainsOnly(CompanyContract::class, $contracts);
} }
public function testQueryForChildClass() public function testQueryForChildClass()
@ -217,7 +219,7 @@ class SingleTableInheritanceTest extends OrmFunctionalTestCase
$contracts = $this->_em->createQuery('SELECT c, p FROM Doctrine\Tests\Models\Company\CompanyContract c JOIN c.salesPerson p')->getResult(); $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->assertEquals(3, count($contracts));
$this->assertContainsOnly('Doctrine\Tests\Models\Company\CompanyContract', $contracts); $this->assertContainsOnly(CompanyContract::class, $contracts);
} }
public function testQueryScalarWithDiscriminatorValue() public function testQueryScalarWithDiscriminatorValue()
@ -242,7 +244,7 @@ class SingleTableInheritanceTest extends OrmFunctionalTestCase
$dql = 'SELECT c FROM Doctrine\Tests\Models\Company\CompanyFixContract c WHERE c.fixPrice = ?1'; $dql = 'SELECT c FROM Doctrine\Tests\Models\Company\CompanyFixContract c WHERE c.fixPrice = ?1';
$contract = $this->_em->createQuery($dql)->setParameter(1, 1000)->getSingleResult(); $contract = $this->_em->createQuery($dql)->setParameter(1, 1000)->getSingleResult();
$this->assertInstanceOf('Doctrine\Tests\Models\Company\CompanyFixContract', $contract); $this->assertInstanceOf(CompanyFixContract::class, $contract);
$this->assertEquals(1000, $contract->getFixPrice()); $this->assertEquals(1000, $contract->getFixPrice());
} }
@ -258,8 +260,8 @@ class SingleTableInheritanceTest extends OrmFunctionalTestCase
$this->assertEquals(1, $affected); $this->assertEquals(1, $affected);
$flexContract = $this->_em->find('Doctrine\Tests\Models\Company\CompanyContract', $this->flex->getId()); $flexContract = $this->_em->find(CompanyContract::class, $this->flex->getId());
$ultraContract = $this->_em->find('Doctrine\Tests\Models\Company\CompanyContract', $this->ultra->getId()); $ultraContract = $this->_em->find(CompanyContract::class, $this->ultra->getId());
$this->assertEquals(300, $ultraContract->getHoursWorked()); $this->assertEquals(300, $ultraContract->getHoursWorked());
$this->assertEquals(100, $flexContract->getHoursWorked()); $this->assertEquals(100, $flexContract->getHoursWorked());
@ -326,19 +328,19 @@ class SingleTableInheritanceTest extends OrmFunctionalTestCase
{ {
$this->loadFullFixture(); $this->loadFullFixture();
$repos = $this->_em->getRepository("Doctrine\Tests\Models\Company\CompanyContract"); $repos = $this->_em->getRepository(CompanyContract::class);
$contracts = $repos->findBy(['salesPerson' => $this->salesPerson->getId()]); $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'"); $this->assertEquals(3, count($contracts), "There should be 3 entities related to " . $this->salesPerson->getId() . " for 'Doctrine\Tests\Models\Company\CompanyContract'");
$repos = $this->_em->getRepository("Doctrine\Tests\Models\Company\CompanyFixContract"); $repos = $this->_em->getRepository(CompanyFixContract::class);
$contracts = $repos->findBy(['salesPerson' => $this->salesPerson->getId()]); $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'"); $this->assertEquals(1, count($contracts), "There should be 1 entities related to " . $this->salesPerson->getId() . " for 'Doctrine\Tests\Models\Company\CompanyFixContract'");
$repos = $this->_em->getRepository("Doctrine\Tests\Models\Company\CompanyFlexContract"); $repos = $this->_em->getRepository(CompanyFlexContract::class);
$contracts = $repos->findBy(['salesPerson' => $this->salesPerson->getId()]); $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'"); $this->assertEquals(2, count($contracts), "There should be 2 entities related to " . $this->salesPerson->getId() . " for 'Doctrine\Tests\Models\Company\CompanyFlexContract'");
$repos = $this->_em->getRepository("Doctrine\Tests\Models\Company\CompanyFlexUltraContract"); $repos = $this->_em->getRepository(CompanyFlexUltraContract::class);
$contracts = $repos->findBy(['salesPerson' => $this->salesPerson->getId()]); $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'"); $this->assertEquals(1, count($contracts), "There should be 1 entities related to " . $this->salesPerson->getId() . " for 'Doctrine\Tests\Models\Company\CompanyFlexUltraContract'");
} }
@ -350,13 +352,13 @@ class SingleTableInheritanceTest extends OrmFunctionalTestCase
{ {
$this->loadFullFixture(); $this->loadFullFixture();
$repository = $this->_em->getRepository("Doctrine\Tests\Models\Company\CompanyContract"); $repository = $this->_em->getRepository(CompanyContract::class);
$contracts = $repository->matching(new Criteria( $contracts = $repository->matching(new Criteria(
Criteria::expr()->eq('salesPerson', $this->salesPerson) Criteria::expr()->eq('salesPerson', $this->salesPerson)
)); ));
$this->assertEquals(3, count($contracts)); $this->assertEquals(3, count($contracts));
$repository = $this->_em->getRepository("Doctrine\Tests\Models\Company\CompanyFixContract"); $repository = $this->_em->getRepository(CompanyFixContract::class);
$contracts = $repository->matching(new Criteria( $contracts = $repository->matching(new Criteria(
Criteria::expr()->eq('salesPerson', $this->salesPerson) Criteria::expr()->eq('salesPerson', $this->salesPerson)
)); ));
@ -370,7 +372,7 @@ class SingleTableInheritanceTest extends OrmFunctionalTestCase
{ {
$this->loadFullFixture(); $this->loadFullFixture();
$repository = $this->_em->getRepository("Doctrine\Tests\Models\Company\CompanyContract"); $repository = $this->_em->getRepository(CompanyContract::class);
$this->expectException(PersisterException::class); $this->expectException(PersisterException::class);
$this->expectExceptionMessage('annot match on Doctrine\Tests\Models\Company\CompanyContract::salesPerson with a non-object value.'); $this->expectExceptionMessage('annot match on Doctrine\Tests\Models\Company\CompanyContract::salesPerson with a non-object value.');
@ -390,14 +392,14 @@ class SingleTableInheritanceTest extends OrmFunctionalTestCase
{ {
$this->loadFullFixture(); $this->loadFullFixture();
$ref = $this->_em->getReference('Doctrine\Tests\Models\Company\CompanyContract', $this->fix->getId()); $ref = $this->_em->getReference(CompanyContract::class, $this->fix->getId());
$this->assertNotInstanceOf('Doctrine\ORM\Proxy\Proxy', $ref, "Cannot Request a proxy from a class that has subclasses."); $this->assertNotInstanceOf(Proxy::class, $ref, "Cannot Request a proxy from a class that has subclasses.");
$this->assertInstanceOf('Doctrine\Tests\Models\Company\CompanyContract', $ref); $this->assertInstanceOf(CompanyContract::class, $ref);
$this->assertInstanceOf('Doctrine\Tests\Models\Company\CompanyFixContract', $ref, "Direct fetch of the reference has to load the child class Employee directly."); $this->assertInstanceOf(CompanyFixContract::class, $ref, "Direct fetch of the reference has to load the child class Employee directly.");
$this->_em->clear(); $this->_em->clear();
$ref = $this->_em->getReference('Doctrine\Tests\Models\Company\CompanyFixContract', $this->fix->getId()); $ref = $this->_em->getReference(CompanyFixContract::class, $this->fix->getId());
$this->assertInstanceOf('Doctrine\ORM\Proxy\Proxy', $ref, "A proxy can be generated only if no subclasses exists for the requested reference."); $this->assertInstanceOf(Proxy::class, $ref, "A proxy can be generated only if no subclasses exists for the requested reference.");
} }
/** /**
@ -409,10 +411,10 @@ class SingleTableInheritanceTest extends OrmFunctionalTestCase
$dql = 'SELECT f FROM Doctrine\Tests\Models\Company\CompanyFixContract f WHERE f.id = ?1'; $dql = 'SELECT f FROM Doctrine\Tests\Models\Company\CompanyFixContract f WHERE f.id = ?1';
$contract = $this->_em->createQuery($dql) $contract = $this->_em->createQuery($dql)
->setFetchMode('Doctrine\Tests\Models\Company\CompanyFixContract', 'salesPerson', ClassMetadata::FETCH_EAGER) ->setFetchMode(CompanyFixContract::class, 'salesPerson', ClassMetadata::FETCH_EAGER)
->setParameter(1, $this->fix->getId()) ->setParameter(1, $this->fix->getId())
->getSingleResult(); ->getSingleResult();
$this->assertNotInstanceOf('Doctrine\ORM\Proxy\Proxy', $contract->getSalesPerson()); $this->assertNotInstanceOf(Proxy::class, $contract->getSalesPerson());
} }
} }

View File

@ -2,12 +2,11 @@
namespace Doctrine\Tests\ORM\Functional; namespace Doctrine\Tests\ORM\Functional;
use Doctrine\Tests\Models\ECommerce\ECommerceCart, use Doctrine\ORM\PersistentCollection;
Doctrine\Tests\Models\ECommerce\ECommerceFeature, use Doctrine\Tests\Models\ECommerce\ECommerceCart;
Doctrine\Tests\Models\ECommerce\ECommerceCustomer, use Doctrine\Tests\Models\ECommerce\ECommerceCustomer;
Doctrine\Tests\Models\ECommerce\ECommerceProduct; use Doctrine\Tests\Models\ECommerce\ECommerceFeature;
use Doctrine\Tests\Models\ECommerce\ECommerceProduct;
use Doctrine\ORM\Mapping\AssociationMapping;
use Doctrine\Tests\OrmFunctionalTestCase; use Doctrine\Tests\OrmFunctionalTestCase;
/** /**
@ -35,9 +34,9 @@ class StandardEntityPersisterTest extends OrmFunctionalTestCase
$cardId = $cart->getId(); $cardId = $cart->getId();
unset($cart); unset($cart);
$class = $this->_em->getClassMetadata('Doctrine\Tests\Models\ECommerce\ECommerceCart'); $class = $this->_em->getClassMetadata(ECommerceCart::class);
$persister = $this->_em->getUnitOfWork()->getEntityPersister('Doctrine\Tests\Models\ECommerce\ECommerceCart'); $persister = $this->_em->getUnitOfWork()->getEntityPersister(ECommerceCart::class);
$newCart = new ECommerceCart(); $newCart = new ECommerceCart();
$this->_em->getUnitOfWork()->registerManaged($newCart, ['id' => $cardId], []); $this->_em->getUnitOfWork()->registerManaged($newCart, ['id' => $cardId], []);
$persister->load(['customer_id' => $customer->getId()], $newCart, $class->associationMappings['customer']); $persister->load(['customer_id' => $customer->getId()], $newCart, $class->associationMappings['customer']);
@ -63,7 +62,7 @@ class StandardEntityPersisterTest extends OrmFunctionalTestCase
$this->_em->flush(); $this->_em->flush();
$this->assertEquals(2, count($p->getFeatures())); $this->assertEquals(2, count($p->getFeatures()));
$this->assertInstanceOf('Doctrine\ORM\PersistentCollection', $p->getFeatures()); $this->assertInstanceOf(PersistentCollection::class, $p->getFeatures());
$q = $this->_em->createQuery( $q = $this->_em->createQuery(
'SELECT p, f 'SELECT p, f
@ -74,7 +73,7 @@ class StandardEntityPersisterTest extends OrmFunctionalTestCase
$res = $q->getResult(); $res = $q->getResult();
$this->assertEquals(2, count($p->getFeatures())); $this->assertEquals(2, count($p->getFeatures()));
$this->assertInstanceOf('Doctrine\ORM\PersistentCollection', $p->getFeatures()); $this->assertInstanceOf(PersistentCollection::class, $p->getFeatures());
// Check that the features are the same instances still // Check that the features are the same instances still
foreach ($p->getFeatures() as $feature) { foreach ($p->getFeatures() as $feature) {

Some files were not shown because too many files have changed in this diff Show More