| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121 |
- <?php
- /**
- * Zend Framework
- *
- * LICENSE
- *
- * This source file is subject to the new BSD license that is bundled
- * with this package in the file LICENSE.txt.
- * It is also available through the world-wide-web at this URL:
- * http://framework.zend.com/license/new-bsd
- * If you did not receive a copy of the license and are unable to
- * obtain it through the world-wide-web, please send an email
- * to license@zend.com so we can send you a copy immediately.
- *
- * @category Zend
- * @package Zend_Navigation
- * @subpackage UnitTests
- * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
- * @license http://framework.zend.com/license/new-bsd New BSD License
- * @version $Id$
- */
- require_once 'Zend/Navigation/Page/Uri.php';
- /**
- * Tests the class Zend_Navigation_Page_Uri
- *
- * @category Zend
- * @package Zend_Navigation
- * @subpackage UnitTests
- * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
- * @license http://framework.zend.com/license/new-bsd New BSD License
- * @group Zend_Navigation
- */
- class Zend_Navigation_Page_UriTest extends PHPUnit_Framework_TestCase
- {
- public function testUriOptionAsString()
- {
- $page = new Zend_Navigation_Page_Uri(array(
- 'label' => 'foo',
- 'uri' => '#'
- ));
- $this->assertEquals('#', $page->getUri());
- }
- public function testUriOptionAsNull()
- {
- $page = new Zend_Navigation_Page_Uri(array(
- 'label' => 'foo',
- 'uri' => null
- ));
- $this->assertNull($page->getUri(), 'getUri() should return null');
- }
- public function testUriOptionAsInteger()
- {
- try {
- $page = new Zend_Navigation_Page_Uri(array('uri' => 1337));
- $this->fail('An invalid \'uri\' was given, but ' .
- 'a Zend_Navigation_Exception was not thrown');
- } catch (Zend_Navigation_Exception $e) {
- }
- }
- public function testUriOptionAsObject()
- {
- try {
- $uri = new stdClass();
- $uri->foo = 'bar';
- $page = new Zend_Navigation_Page_Uri(array('uri' => $uri));
- $this->fail('An invalid \'uri\' was given, but ' .
- 'a Zend_Navigation_Exception was not thrown');
- } catch (Zend_Navigation_Exception $e) {
- }
- }
- public function testSetAndGetUri()
- {
- $page = new Zend_Navigation_Page_Uri(array(
- 'label' => 'foo',
- 'uri' => '#'
- ));
- $page->setUri('http://www.example.com/')->setUri('about:blank');
- $this->assertEquals('about:blank', $page->getUri());
- }
- public function testGetHref()
- {
- $uri = 'spotify:album:4YzcWwBUSzibRsqD9Sgu4A';
- $page = new Zend_Navigation_Page_Uri();
- $page->setUri($uri);
- $this->assertEquals($uri, $page->getHref());
- }
- /**
- * @group ZF-8922
- */
- public function testGetHrefWithFragmentIdentifier()
- {
- $uri = 'http://www.example.com/foo.html';
-
- $page = new Zend_Navigation_Page_Uri();
- $page->setUri($uri);
- $page->setFragment('bar');
-
- $this->assertEquals($uri . '#bar', $page->getHref());
-
- $page->setUri('#');
-
- $this->assertEquals('#bar', $page->getHref());
- }
- }
|