Browse Source

Add integration test for issue in #9266

mark_story 9 years ago
parent
commit
dd063dfcbd
1 changed files with 31 additions and 0 deletions
  1. 31 0
      tests/TestCase/Routing/DispatcherFactoryTest.php

+ 31 - 0
tests/TestCase/Routing/DispatcherFactoryTest.php

@@ -14,6 +14,8 @@
  */
 namespace Cake\Test\TestCase\Routing;
 
+use Cake\Core\Configure;
+use Cake\Network\Request;
 use Cake\Routing\DispatcherFactory;
 use Cake\TestSuite\TestCase;
 
@@ -31,6 +33,7 @@ class DispatcherFactoryTest extends TestCase
     public function setUp()
     {
         parent::setUp();
+        Configure::write('App.namespace', 'TestApp');
         DispatcherFactory::clear();
     }
 
@@ -99,4 +102,32 @@ class DispatcherFactoryTest extends TestCase
         $this->assertInstanceOf('Cake\Routing\Dispatcher', $result);
         $this->assertCount(1, $result->filters());
     }
+
+    /**
+     * test create() -> dispatch() -> response flow.
+     *
+     * @return void
+     */
+    public function testCreateDispatchWithFilters()
+    {
+        $url = new Request([
+            'url' => 'posts',
+            'params' => [
+                'controller' => 'Posts',
+                'action' => 'index',
+                'pass' => [],
+                'bare' => true,
+            ]
+        ]);
+        $response = $this->getMockBuilder('Cake\Network\Response')
+            ->setMethods(['send'])
+            ->getMock();
+        DispatcherFactory::add('ControllerFactory');
+        DispatcherFactory::add('Append');
+
+        $dispatcher = DispatcherFactory::create();
+        $result = $dispatcher->dispatch($url, $response);
+        $this->assertNull($result);
+        $this->assertEquals('posts index appended content', $response->body());
+    }
 }