From 5770459bfce9485c8c9ed1eb463590b19e2e93b7 Mon Sep 17 00:00:00 2001 From: Marco Pivetta Date: Fri, 18 Aug 2017 04:44:17 +0200 Subject: [PATCH] #6441 moving expected exception annotations into explicit method calls --- .../ORM/Cache/DefaultCacheFactoryTest.php | 36 ++++++++++--------- 1 file changed, 20 insertions(+), 16 deletions(-) diff --git a/tests/Doctrine/Tests/ORM/Cache/DefaultCacheFactoryTest.php b/tests/Doctrine/Tests/ORM/Cache/DefaultCacheFactoryTest.php index 54fd59e37..4ff2edc1c 100644 --- a/tests/Doctrine/Tests/ORM/Cache/DefaultCacheFactoryTest.php +++ b/tests/Doctrine/Tests/ORM/Cache/DefaultCacheFactoryTest.php @@ -228,10 +228,6 @@ class DefaultCacheFactoryTest extends OrmTestCase $this->assertNotSame($cachedPersister1->getCacheRegion(), $cachedPersister2->getCacheRegion()); } - /** - * @expectedException InvalidArgumentException - * @expectedExceptionMessage Unrecognized access strategy type [-1] - */ public function testBuildCachedEntityPersisterNonStrictException() { $em = $this->em; @@ -240,13 +236,12 @@ class DefaultCacheFactoryTest extends OrmTestCase $metadata->cache['usage'] = -1; + $this->expectException(\InvalidArgumentException::class); + $this->expectExceptionMessage('Unrecognized access strategy type [-1]'); + $this->factory->buildCachedEntityPersister($em, $persister, $metadata); } - /** - * @expectedException InvalidArgumentException - * @expectedExceptionMessage Unrecognized access strategy type [-1] - */ public function testBuildCachedCollectionPersisterException() { $em = $this->em; @@ -256,17 +251,23 @@ class DefaultCacheFactoryTest extends OrmTestCase $mapping['cache']['usage'] = -1; + $this->expectException(\InvalidArgumentException::class); + $this->expectExceptionMessage('Unrecognized access strategy type [-1]'); + $this->factory->buildCachedCollectionPersister($em, $persister, $mapping); } - /** - * @expectedException LogicException - * @expectedExceptionMessage If you want to use a "READ_WRITE" cache an implementation of "Doctrine\ORM\Cache\ConcurrentRegion" is required, The default implementation provided by doctrine is "Doctrine\ORM\Cache\Region\FileLockRegion" if you want to use it please provide a valid directory - */ public function testInvalidFileLockRegionDirectoryException() { $factory = new DefaultCacheFactory($this->regionsConfig, $this->getSharedSecondLevelCacheDriverImpl()); + $this->expectException(\LogicException::class); + $this->expectExceptionMessage( + 'If you want to use a "READ_WRITE" cache an implementation of "Doctrine\ORM\Cache\ConcurrentRegion" ' + . 'is required, The default implementation provided by doctrine is ' + . '"Doctrine\ORM\Cache\Region\FileLockRegion" if you want to use it please provide a valid directory' + ); + $factory->getRegion( [ 'usage' => ClassMetadata::CACHE_USAGE_READ_WRITE, @@ -275,16 +276,19 @@ class DefaultCacheFactoryTest extends OrmTestCase ); } - /** - * @expectedException LogicException - * @expectedExceptionMessage If you want to use a "READ_WRITE" cache an implementation of "Doctrine\ORM\Cache\ConcurrentRegion" is required, The default implementation provided by doctrine is "Doctrine\ORM\Cache\Region\FileLockRegion" if you want to use it please provide a valid directory - */ public function testInvalidFileLockRegionDirectoryExceptionWithEmptyString() { $factory = new DefaultCacheFactory($this->regionsConfig, $this->getSharedSecondLevelCacheDriverImpl()); $factory->setFileLockRegionDirectory(''); + $this->expectException(\LogicException::class); + $this->expectExceptionMessage( + 'If you want to use a "READ_WRITE" cache an implementation of "Doctrine\ORM\Cache\ConcurrentRegion" ' + . 'is required, The default implementation provided by doctrine is ' + . '"Doctrine\ORM\Cache\Region\FileLockRegion" if you want to use it please provide a valid directory' + ); + $factory->getRegion( [ 'usage' => ClassMetadata::CACHE_USAGE_READ_WRITE,