From dd063dfcbd3e5df8224b91febd1d213909f2f37e Mon Sep 17 00:00:00 2001 From: mark_story Date: Thu, 18 Aug 2016 17:43:54 -0400 Subject: [PATCH] Add integration test for issue in #9266 --- .../Routing/DispatcherFactoryTest.php | 31 +++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/tests/TestCase/Routing/DispatcherFactoryTest.php b/tests/TestCase/Routing/DispatcherFactoryTest.php index 2f174bae73e..ec7d936e498 100644 --- a/tests/TestCase/Routing/DispatcherFactoryTest.php +++ b/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 @@ public function testCreate() $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()); + } }