Index: tests/Zend/Navigation/PageFactoryTest.php =================================================================== --- tests/Zend/Navigation/PageFactoryTest.php (revision 24879) +++ tests/Zend/Navigation/PageFactoryTest.php (working copy) @@ -57,21 +57,27 @@ { $pages = array( Zend_Navigation_Page::factory(array( - 'label' => 'MVC Page', + 'label' => 'MVC Page', 'action' => 'index' )), Zend_Navigation_Page::factory(array( - 'label' => 'MVC Page', + 'label' => 'MVC Page', 'controller' => 'index' )), Zend_Navigation_Page::factory(array( - 'label' => 'MVC Page', + 'label' => 'MVC Page', 'module' => 'index' )), Zend_Navigation_Page::factory(array( 'label' => 'MVC Page', 'route' => 'home' - )) + )), + Zend_Navigation_Page::factory(array( + 'label' => 'MVC Page', + 'params' => array( + 'foo' => 'bar', + ), + )), ); $this->assertContainsOnly('Zend_Navigation_Page_Mvc', $pages); @@ -81,62 +87,50 @@ { $page = Zend_Navigation_Page::factory(array( 'label' => 'URI Page', - 'uri' => '#' + 'uri' => '#' )); - $this->assertType('Zend_Navigation_Page_Uri', $page); + $this->assertTrue($page instanceof Zend_Navigation_Page_Uri); } - public function testMvcShouldHaveDetectionPrecedence() - { - $page = Zend_Navigation_Page::factory(array( - 'label' => 'MVC Page', - 'action' => 'index', - 'controller' => 'index', - 'uri' => '#' - )); - - $this->assertType('Zend_Navigation_Page_Mvc', $page); - } - public function testSupportsMvcShorthand() { $mvcPage = Zend_Navigation_Page::factory(array( - 'type' => 'mvc', - 'label' => 'MVC Page', - 'action' => 'index', + 'type' => 'mvc', + 'label' => 'MVC Page', + 'action' => 'index', 'controller' => 'index' )); - $this->assertType('Zend_Navigation_Page_Mvc', $mvcPage); + $this->assertTrue($mvcPage instanceof Zend_Navigation_Page_Mvc); } public function testSupportsUriShorthand() { $uriPage = Zend_Navigation_Page::factory(array( - 'type' => 'uri', + 'type' => 'uri', 'label' => 'URI Page', - 'uri' => 'http://www.example.com/' + 'uri' => 'http://www.example.com/' )); - $this->assertType('Zend_Navigation_Page_Uri', $uriPage); + $this->assertTrue($uriPage instanceof Zend_Navigation_Page_Uri); } public function testSupportsCustomPageTypes() { $page = Zend_Navigation_Page::factory(array( - 'type' => 'My_Page', + 'type' => 'My_Page', 'label' => 'My Custom Page' )); - return $this->assertType('My_Page', $page); + return $this->assertTrue($page instanceof My_Page); } public function testShouldFailForInvalidType() { try { $page = Zend_Navigation_Page::factory(array( - 'type' => 'My_InvalidPage', + 'type' => 'My_InvalidPage', 'label' => 'My Invalid Page' )); } catch(Zend_Navigation_Exception $e) { @@ -149,18 +143,23 @@ public function testShouldFailForNonExistantType() { $pageConfig = array( - 'type' => 'My_NonExistant_Page', + 'type' => 'My_NonExistant_Page', 'label' => 'My non-existant Page' ); try { $page = Zend_Navigation_Page::factory($pageConfig); + + $this->fail( + 'A Zend_Exception has not been thrown for non-existant class' + ); } catch(Zend_Exception $e) { - return; + $this->assertEquals( + 'File "My/NonExistant/Page.php" does not exist or class ' + . '"My_NonExistant_Page" was not found in the file', + $e->getMessage() + ); } - - $msg = 'A Zend_Exception has not been thrown for non-existant class'; - $this->fail($msg); } public function testShouldFailIfUnableToDetermineType() @@ -169,10 +168,40 @@ $page = Zend_Navigation_Page::factory(array( 'label' => 'My Invalid Page' )); + + $this->fail( + 'An exception has not been thrown for invalid page type' + ); } catch(Zend_Navigation_Exception $e) { - return; + $this->assertEquals( + 'Invalid argument: Unable to determine class to instantiate ' + . '(Page label: My Invalid Page)', + $e->getMessage() + ); } + } - $this->fail('An exception has not been thrown for invalid page type'); + /** + * @group ZF-10048 + */ + public function testMvcShouldFailIfOptionsContainsUriAndMvcProperties() + { + try { + $page = Zend_Navigation_Page::factory(array( + 'label' => 'MVC Page', + 'action' => 'index', + 'controller' => 'index', + 'uri' => '#' + )); + $this->fail( + 'An exception has not been thrown for invalid properties' + ); + } catch(Zend_Navigation_Exception $e) { + $this->assertEquals( + 'Invalid argument: Unable to determine class to instantiate ' + . '(Page label: MVC Page)', + $e->getMessage() + ); + } } }