From 9d57a35b94f31ca13f50b2d3c1d5fc048eb39930 Mon Sep 17 00:00:00 2001 From: Greg Bowler Date: Sun, 31 Aug 2014 13:15:07 +0100 Subject: [PATCH] Test dispatcher builds all common logic objects in tree hierarchy. --- test/Unit/Dispatcher/PageDispatcher.test.php | 6 +++++- test/Unit/Logic/LogicFactory.test.php | 11 +++++++---- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/test/Unit/Dispatcher/PageDispatcher.test.php b/test/Unit/Dispatcher/PageDispatcher.test.php index f4108a96..e7a27d14 100644 --- a/test/Unit/Dispatcher/PageDispatcher.test.php +++ b/test/Unit/Dispatcher/PageDispatcher.test.php @@ -24,9 +24,13 @@ public function setUp() { $cfg = new \Gt\Core\ConfigObj(); - $this->request = $this->getMock("\Gt\Request\Request", null, [ + $this->request = $this->getMock("\Gt\Request\Request", ["getType"], [ "/", $cfg, ]); + $this->request->expects($this->any()) + ->method("getType") + ->will($this->returnValue(\Gt\Request\Request::TYPE_PAGE) + ); $this->response = $this->getMock("\Gt\Response\Reponse", null); $this->apiFactory = $this->getMock("\Gt\Api\ApiFactory", null, [ $cfg diff --git a/test/Unit/Logic/LogicFactory.test.php b/test/Unit/Logic/LogicFactory.test.php index 4c683eae..c76504d6 100644 --- a/test/Unit/Logic/LogicFactory.test.php +++ b/test/Unit/Logic/LogicFactory.test.php @@ -58,10 +58,13 @@ public function testGetLogicFileArrayGivesCommons($uri) { $topPath ); - $directory = dirname($topPath . $uri); - $commonPath = $directory . "/_common.php"; - - $this->assertContains($commonPath, $logicFileArray); + // Check each directory in the tree. + $directory = $topPath . $uri; + do { + $directory = dirname($directory); + $commonPath = $directory . "/_common.php"; + $this->assertContains($commonPath, $logicFileArray); + } while(strstr($directory, $path)); } /**