浏览代码

[FrameworkBundle] removed the need to boot a Kernel in a unit test file

Fabien Potencier 14 年之前
父节点
当前提交
4dc5b8ec78
共有 1 个文件被更改,包括 12 次插入4 次删除
  1. 12 4
      src/Symfony/Bundle/FrameworkBundle/Tests/Templating/TemplateNameParserTest.php

+ 12 - 4
src/Symfony/Bundle/FrameworkBundle/Tests/Templating/TemplateNameParserTest.php

@@ -12,7 +12,6 @@
 namespace Symfony\Bundle\FrameworkBundle\Tests\Templating;
 
 use Symfony\Bundle\FrameworkBundle\Tests\TestCase;
-use Symfony\Bundle\FrameworkBundle\Tests\Kernel;
 use Symfony\Bundle\FrameworkBundle\Templating\TemplateNameParser;
 use Symfony\Bundle\FrameworkBundle\Templating\TemplateReference;
 
@@ -22,9 +21,18 @@ class TemplateNameParserTest extends TestCase
 
     protected function  setUp()
     {
-        $kernel = new Kernel();
-        $kernel->boot();
-
+        $kernel = $this->getMock('Symfony\Component\HttpKernel\KernelInterface');
+        $kernel
+            ->expects($this->any())
+            ->method('getBundle')
+            ->will($this->returnCallback(function ($bundle) {
+                if (in_array($bundle, array('SensioFooBundle', 'SensioCmsFooBundle', 'FooBundle'))) {
+                    return true;
+                }
+
+                throw new \InvalidArgumentException();
+            }))
+        ;
         $this->parser = new TemplateNameParser($kernel);
     }