|
@@ -1,96 +0,0 @@
|
|
|
-<?php
|
|
|
-
|
|
|
-/*
|
|
|
- * This file is part of the Symfony package.
|
|
|
- *
|
|
|
- * (c) Fabien Potencier <fabien@symfony.com>
|
|
|
- *
|
|
|
- * For the full copyright and license information, please view the LICENSE
|
|
|
- * file that was distributed with this source code.
|
|
|
- */
|
|
|
-
|
|
|
-namespace Symfony\Bundle\DoctrineBundle\Tests\CacheWarmer;
|
|
|
-
|
|
|
-use Symfony\Bundle\DoctrineBundle\CacheWarmer\ProxyCacheWarmer;
|
|
|
-
|
|
|
-class ProxyCacheWarmerTest extends \Symfony\Bundle\DoctrineBundle\Tests\TestCase
|
|
|
-{
|
|
|
- /**
|
|
|
- * This is not necessarily a good test, it doesn't generate any proxies
|
|
|
- * because there are none in the AnnotationsBundle. However that is
|
|
|
- * rather a task of doctrine to test. We touch the lines here and
|
|
|
- * verify that the container is called correctly for the relevant information.
|
|
|
- *
|
|
|
- * @group DoctrineORMProxy
|
|
|
- */
|
|
|
- public function testWarmCache()
|
|
|
- {
|
|
|
- $testManager = $this->createTestEntityManager(array(
|
|
|
- __DIR__ . "/../DependencyInjection/Fixtures/Bundles/AnnotationsBundle/Entity")
|
|
|
- );
|
|
|
-
|
|
|
- $registry = $this->getMockBuilder('Symfony\Bundle\DoctrineBundle\Registry')->disableOriginalConstructor()->getMock();
|
|
|
- $registry->expects($this->at(0))
|
|
|
- ->method('getEntityManagerNames')
|
|
|
- ->will($this->returnValue(array('default' => 'doctrine.orm.default_entity_manager', 'foo' => 'doctrine.orm.foo_entity_manager')));
|
|
|
-
|
|
|
- $container = $this->getMock('Symfony\Component\DependencyInjection\Container');
|
|
|
- $container->expects($this->at(0))
|
|
|
- ->method('getParameter')
|
|
|
- ->with($this->equalTo('doctrine.orm.proxy_dir'))
|
|
|
- ->will($this->returnValue(sys_get_temp_dir()));
|
|
|
- $container->expects($this->at(1))
|
|
|
- ->method('getParameter')
|
|
|
- ->with($this->equalTo('doctrine.orm.auto_generate_proxy_classes'))
|
|
|
- ->will($this->returnValue(false));
|
|
|
- $container->expects($this->at(2))
|
|
|
- ->method('get')
|
|
|
- ->with($this->equalTo('doctrine'))
|
|
|
- ->will($this->returnValue($registry));
|
|
|
- $container->expects($this->at(3))
|
|
|
- ->method('get')
|
|
|
- ->with($this->equalTo('doctrine.orm.default_entity_manager'))
|
|
|
- ->will($this->returnValue($testManager));
|
|
|
- $container->expects($this->at(4))
|
|
|
- ->method('get')
|
|
|
- ->with($this->equalTo('doctrine.orm.foo_entity_manager'))
|
|
|
- ->will($this->returnValue($testManager));
|
|
|
-
|
|
|
- $cacheWarmer = new ProxyCacheWarmer($container);
|
|
|
- $cacheWarmer->warmUp(sys_get_temp_dir());
|
|
|
- }
|
|
|
-
|
|
|
- public function testSkipWhenProxiesAreAutoGenerated()
|
|
|
- {
|
|
|
- $testManager = $this->createTestEntityManager(array(
|
|
|
- __DIR__ . "/../DependencyInjection/Fixtures/Bundles/AnnotationsBundle/Entity")
|
|
|
- );
|
|
|
-
|
|
|
- $container = $this->getMock('Symfony\Component\DependencyInjection\Container');
|
|
|
- $container->expects($this->at(0))
|
|
|
- ->method('getParameter')
|
|
|
- ->with($this->equalTo('doctrine.orm.proxy_dir'))
|
|
|
- ->will($this->returnValue(sys_get_temp_dir()));
|
|
|
- $container->expects($this->at(1))
|
|
|
- ->method('getParameter')
|
|
|
- ->with($this->equalTo('doctrine.orm.auto_generate_proxy_classes'))
|
|
|
- ->will($this->returnValue(true));
|
|
|
- $container->expects($this->at(2))
|
|
|
- ->method('getParameter')
|
|
|
- ->with($this->equalTo('assertion'))
|
|
|
- ->will($this->returnValue(true));
|
|
|
-
|
|
|
- $cacheWarmer = new ProxyCacheWarmer($container);
|
|
|
- $cacheWarmer->warmUp(sys_get_temp_dir());
|
|
|
-
|
|
|
- $container->getParameter('assertion'); // check that the assertion is really the third call.
|
|
|
- }
|
|
|
-
|
|
|
- public function testProxyCacheWarmingIsNotOptional()
|
|
|
- {
|
|
|
- $container = $this->getMock('Symfony\Component\DependencyInjection\Container');
|
|
|
- $cacheWarmer = new ProxyCacheWarmer($container);
|
|
|
-
|
|
|
- $this->assertFalse($cacheWarmer->isOptional());
|
|
|
- }
|
|
|
-}
|