|
13 | 13 |
|
14 | 14 | namespace Liip\FunctionalTestBundle\Tests\Test; |
15 | 15 |
|
| 16 | +use Doctrine\Common\Annotations\Annotation\IgnoreAnnotation; |
| 17 | +use Liip\FunctionalTestBundle\Annotations\DisableDatabaseCache; |
16 | 18 | use Liip\FunctionalTestBundle\Annotations\QueryCount; |
17 | 19 | use Liip\FunctionalTestBundle\Test\WebTestCase; |
18 | 20 | use Liip\FunctionalTestBundle\Tests\AppConfig\AppConfigKernel; |
@@ -246,6 +248,42 @@ public function testLoadFixturesFilesWithCustomProvider(): void |
246 | 248 | ); |
247 | 249 | } |
248 | 250 |
|
| 251 | + /** |
| 252 | + * @DisableDatabaseCache() |
| 253 | + */ |
| 254 | + public function testCacheCanBeDisabled(): void |
| 255 | + { |
| 256 | + // MD5 hash corresponding to these fixtures files. |
| 257 | + $md5 = '0ded9d8daaeaeca1056b18b9d0d433b2'; |
| 258 | + $databaseFilePath = $this->getContainer()->getParameter('kernel.cache_dir').'/test_sqlite_'.$md5.'.db'; |
| 259 | + |
| 260 | + $fixtures = [ |
| 261 | + 'Liip\FunctionalTestBundle\Tests\App\DataFixtures\ORM\LoadDependentUserData', |
| 262 | + ]; |
| 263 | + |
| 264 | + $this->loadFixtures($fixtures); |
| 265 | + |
| 266 | + // Load data from database |
| 267 | + $em = $this->getContainer()->get('doctrine.orm.entity_manager'); |
| 268 | + |
| 269 | + /** @var \Liip\FunctionalTestBundle\Tests\App\Entity\User $user1 */ |
| 270 | + $user1 = $em->getRepository('LiipFunctionalTestBundle:User')->findOneBy(['id' => 1]); |
| 271 | + |
| 272 | + // Store random data, in order to check it after reloading fixtures. |
| 273 | + $user1Salt = $user1->getSalt(); |
| 274 | + |
| 275 | + sleep(2); |
| 276 | + |
| 277 | + // Reload the fixtures. |
| 278 | + $this->loadFixtures($fixtures); |
| 279 | + |
| 280 | + /** @var \Liip\FunctionalTestBundle\Tests\App\Entity\User $user1 */ |
| 281 | + $user1 = $em->getRepository('LiipFunctionalTestBundle:User')->findOneBy(['id' => 1]); |
| 282 | + |
| 283 | + //The salt are not the same because cache were not used |
| 284 | + $this->assertNotSame($user1Salt, $user1->getSalt()); |
| 285 | + } |
| 286 | + |
249 | 287 | /** |
250 | 288 | * Update a fixture file and check that the cache will be refreshed. |
251 | 289 | */ |
|
0 commit comments