|
@@ -13,14 +13,27 @@ namespace Symfony\Bundle\FrameworkBundle\Tests\Controller;
|
|
|
|
|
|
use Symfony\Bundle\FrameworkBundle\Tests\TestCase;
|
|
|
use Symfony\Bundle\FrameworkBundle\Controller\ControllerNameParser;
|
|
|
-use Symfony\Bundle\FrameworkBundle\Tests\Logger;
|
|
|
-use Symfony\Bundle\FrameworkBundle\Tests\Kernel;
|
|
|
-
|
|
|
-require_once __DIR__.'/../Kernel.php';
|
|
|
-require_once __DIR__.'/../Logger.php';
|
|
|
+use Symfony\Component\ClassLoader\UniversalClassLoader;
|
|
|
|
|
|
class ControllerNameParserTest extends TestCase
|
|
|
{
|
|
|
+ protected $loader;
|
|
|
+
|
|
|
+ public function setUp()
|
|
|
+ {
|
|
|
+ $this->loader = new UniversalClassLoader();
|
|
|
+ $this->loader->registerNamespaces(array(
|
|
|
+ 'TestBundle' => __DIR__.'/../Fixtures',
|
|
|
+ 'TestApplication' => __DIR__.'/../Fixtures',
|
|
|
+ ));
|
|
|
+ $this->loader->register();
|
|
|
+ }
|
|
|
+
|
|
|
+ public function tearDown()
|
|
|
+ {
|
|
|
+ spl_autoload_unregister(array($this->loader, 'loadClass'));
|
|
|
+ }
|
|
|
+
|
|
|
public function testParse()
|
|
|
{
|
|
|
$parser = $this->createParser();
|
|
@@ -63,10 +76,31 @@ class ControllerNameParserTest extends TestCase
|
|
|
|
|
|
private function createParser()
|
|
|
{
|
|
|
- $kernel = new Kernel();
|
|
|
- $kernel->boot();
|
|
|
- $logger = new Logger();
|
|
|
+ $bundles = array(
|
|
|
+ 'SensioFooBundle' => array($this->getBundle('TestBundle\Fabpot\FooBundle', 'FabpotFooBundle'), $this->getBundle('TestBundle\Sensio\FooBundle', 'SensioFooBundle')),
|
|
|
+ 'SensioCmsFooBundle' => array($this->getBundle('TestBundle\Sensio\Cms\FooBundle', 'SensioCmsFooBundle')),
|
|
|
+ 'FooBundle' => array($this->getBundle('TestBundle\FooBundle', 'FooBundle')),
|
|
|
+ 'FabpotFooBundle' => array($this->getBundle('TestBundle\Fabpot\FooBundle', 'FabpotFooBundle'), $this->getBundle('TestBundle\Sensio\FooBundle', 'SensioFooBundle')),
|
|
|
+ );
|
|
|
+
|
|
|
+ $kernel = $this->getMock('Symfony\Component\HttpKernel\KernelInterface');
|
|
|
+ $kernel
|
|
|
+ ->expects($this->any())
|
|
|
+ ->method('getBundle')
|
|
|
+ ->will($this->returnCallback(function ($bundle) use ($bundles) {
|
|
|
+ return $bundles[$bundle];
|
|
|
+ }))
|
|
|
+ ;
|
|
|
+
|
|
|
+ return new ControllerNameParser($kernel);
|
|
|
+ }
|
|
|
+
|
|
|
+ private function getBundle($namespace, $name)
|
|
|
+ {
|
|
|
+ $bundle = $this->getMock('Symfony\Component\HttpKernel\Bundle\BundleInterface');
|
|
|
+ $bundle->expects($this->any())->method('getName')->will($this->returnValue($name));
|
|
|
+ $bundle->expects($this->any())->method('getNamespace')->will($this->returnValue($namespace));
|
|
|
|
|
|
- return new ControllerNameParser($kernel, $logger);
|
|
|
+ return $bundle;
|
|
|
}
|
|
|
}
|