瀏覽代碼

[Framework] added some more test to demonstrate how template and controller name work with a vendor and a category in the namespace

Fabien Potencier 14 年之前
父節點
當前提交
5b61cb5a8d

+ 2 - 0
src/Symfony/Bundle/FrameworkBundle/Tests/Controller/ControllerNameConverterTest.php

@@ -29,6 +29,7 @@ class ControllerNameConverterTest extends TestCase
 
         $this->assertEquals('FooBundle:Default:index', $converter->toShortNotation('TestBundle\FooBundle\Controller\DefaultController::indexAction'), '->toShortNotation() converts a class::method string to the short a:b:c notation');
         $this->assertEquals('SensioFooBundle:Default:index', $converter->toShortNotation('TestBundle\Sensio\FooBundle\Controller\DefaultController::indexAction'), '->toShortNotation() converts a class::method string to the short a:b:c notation');
+        $this->assertEquals('SensioCmsFooBundle:Default:index', $converter->toShortNotation('TestBundle\Sensio\Cms\FooBundle\Controller\DefaultController::indexAction'), '->toShortNotation() converts a class::method string to the short a:b:c notation');
 
         try {
             $converter->toShortNotation('foo');
@@ -68,6 +69,7 @@ class ControllerNameConverterTest extends TestCase
 
         $this->assertEquals('TestBundle\FooBundle\Controller\DefaultController::indexAction', $converter->fromShortNotation('FooBundle:Default:index'), '->fromShortNotation() converts a short a:b:c notation string to a class::method string');
         $this->assertEquals('TestBundle\Sensio\FooBundle\Controller\DefaultController::indexAction', $converter->fromShortNotation('SensioFooBundle:Default:index'), '->fromShortNotation() converts a short a:b:c notation string to a class::method string');
+        $this->assertEquals('TestBundle\Sensio\Cms\FooBundle\Controller\DefaultController::indexAction', $converter->fromShortNotation('SensioCmsFooBundle:Default:index'), '->fromShortNotation() converts a short a:b:c notation string to a class::method string');
 
         try {
             $converter->fromShortNotation('foo:');

+ 21 - 0
src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/TestBundle/Sensio/Cms/FooBundle/Controller/DefaultController.php

@@ -0,0 +1,21 @@
+<?php
+
+namespace TestBundle\Sensio\Cms\FooBundle\Controller;
+
+/*
+ * This file is part of the Symfony framework.
+ *
+ * (c) Fabien Potencier <fabien.potencier@symfony-project.com>
+ *
+ * This source file is subject to the MIT license that is bundled
+ * with this source code in the file LICENSE.
+ */
+
+/**
+ * DefaultController.
+ *
+ * @author Fabien Potencier <fabien.potencier@symfony-project.com>
+ */
+class DefaultController
+{
+}

+ 23 - 0
src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/TestBundle/Sensio/Cms/FooBundle/SensioCmsFooBundle.php

@@ -0,0 +1,23 @@
+<?php
+
+namespace TestBundle\Sensio\Cms\FooBundle;
+
+use Symfony\Component\HttpKernel\Bundle\Bundle;
+
+/*
+ * This file is part of the Symfony framework.
+ *
+ * (c) Fabien Potencier <fabien.potencier@symfony-project.com>
+ *
+ * This source file is subject to the MIT license that is bundled
+ * with this source code in the file LICENSE.
+ */
+
+/**
+ * Bundle.
+ *
+ * @author Fabien Potencier <fabien.potencier@symfony-project.com>
+ */
+class SensioCmsFooBundle extends Bundle
+{
+}

+ 1 - 0
src/Symfony/Bundle/FrameworkBundle/Tests/Kernel.php

@@ -55,6 +55,7 @@ class Kernel extends BaseKernel
             new \Symfony\Bundle\FrameworkBundle\FrameworkBundle(),
             new \TestBundle\FooBundle\FooBundle(),
             new \TestBundle\Sensio\FooBundle\SensioFooBundle(),
+            new \TestBundle\Sensio\Cms\FooBundle\SensioCmsFooBundle(),
         );
     }
 

+ 1 - 0
src/Symfony/Bundle/FrameworkBundle/Tests/Templating/TemplateNameParserTest.php

@@ -36,6 +36,7 @@ class TemplateNameParserTest extends TestCase
             array('FooBundle:Post:index.twig.html', array('index', array('bundle' => 'FooBundle', 'controller' => 'Post', 'renderer' => 'twig', 'format' => 'html'))),
             array('FooBundle:Post:index.php.xml', array('index', array('bundle' => 'FooBundle', 'controller' => 'Post', 'renderer' => 'php', 'format' => 'xml'))),
             array('SensioFooBundle:Post:index.php.html', array('index', array('bundle' => 'Sensio\\FooBundle', 'controller' => 'Post', 'renderer' => 'php', 'format' => 'html'))),
+            array('SensioCmsFooBundle:Post:index.php.html', array('index', array('bundle' => 'Sensio\\Cms\\FooBundle', 'controller' => 'Post', 'renderer' => 'php', 'format' => 'html'))),
             array(':Post:index.php.html', array('index', array('bundle' => '', 'controller' => 'Post', 'renderer' => 'php', 'format' => 'html'))),
             array('::index.php.html', array('index', array('bundle' => '', 'controller' => '', 'renderer' => 'php', 'format' => 'html'))),
         );