7 * This source file is subject to the new BSD license that is bundled
8 * with this package in the file LICENSE.txt.
9 * It is also available through the world-wide-web at this URL:
10 * http://framework.zend.com/license/new-bsd
11 * If you did not receive a copy of the license and are unable to
12 * obtain it through the world-wide-web, please send an email
13 * to license@zend.com so we can send you a copy immediately.
16 * @package Zend_Navigation
17 * @subpackage UnitTests
18 * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
19 * @license http://framework.zend.com/license/new-bsd New BSD License
23 if (!defined('PHPUnit_MAIN_METHOD')) {
24 define('PHPUnit_MAIN_METHOD', 'Zend_NavigationTest::main');
27 require_once dirname(__FILE__
) . '/../TestHelper.php';
32 require_once 'Zend/Navigation.php';
36 * @package Zend_Navigation
37 * @subpackage UnitTests
38 * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
39 * @license http://framework.zend.com/license/new-bsd New BSD License
40 * @group Zend_Navigation
42 class Zend_NavigationTest
extends PHPUnit_Framework_TestCase
45 * @var Zend_Navigation
49 protected function setUp()
52 $this->_navigation
= new Zend_Navigation();
55 protected function tearDown()
57 $this->_navigation
= null;
61 * Runs the test methods of this class.
65 public static function main()
67 $suite = new PHPUnit_Framework_TestSuite("Zend_NavigationTest");
68 $result = PHPUnit_TextUI_TestRunner
::run($suite);
72 * Testing that navigation order is done correctly
77 public function testNavigationArraySortsCorrectly()
79 require_once 'Zend/Navigation/Page/Uri.php';
80 $page1 = new Zend_Navigation_Page_Uri(array('uri' => 'page1'));
81 $page2 = new Zend_Navigation_Page_Uri(array('uri' => 'page2'));
82 $page3 = new Zend_Navigation_Page_Uri(array('uri' => 'page3'));
84 $this->_navigation
->setPages(array($page1, $page2, $page3));
90 $pages = $this->_navigation
->toArray();
91 $this->assertSame(3, count($pages));
92 $this->assertEquals('page3', $pages[0]['uri']);
93 $this->assertEquals('page1', $pages[1]['uri']);
94 $this->assertEquals('page2', $pages[2]['uri']);