2
0

UriTest.php 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. <?php
  2. /**
  3. * Zend Framework
  4. *
  5. * LICENSE
  6. *
  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.
  14. *
  15. * @category Zend
  16. * @package Zend_Navigation
  17. * @subpackage UnitTests
  18. * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
  19. * @license http://framework.zend.com/license/new-bsd New BSD License
  20. * @version $Id$
  21. */
  22. require_once 'PHPUnit/Framework/TestCase.php';
  23. require_once 'Zend/Navigation/Page/Uri.php';
  24. /**
  25. * Tests the class Zend_Navigation_Page_Uri
  26. *
  27. * @category Zend
  28. * @package Zend_Navigation
  29. * @subpackage UnitTests
  30. * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
  31. * @license http://framework.zend.com/license/new-bsd New BSD License
  32. * @group Zend_Navigation
  33. */
  34. class Zend_Navigation_Page_UriTest extends PHPUnit_Framework_TestCase
  35. {
  36. public function testUriOptionAsString()
  37. {
  38. $page = new Zend_Navigation_Page_Uri(array(
  39. 'label' => 'foo',
  40. 'uri' => '#'
  41. ));
  42. $this->assertEquals('#', $page->getUri());
  43. }
  44. public function testUriOptionAsNull()
  45. {
  46. $page = new Zend_Navigation_Page_Uri(array(
  47. 'label' => 'foo',
  48. 'uri' => null
  49. ));
  50. $this->assertNull($page->getUri(), 'getUri() should return null');
  51. }
  52. public function testUriOptionAsInteger()
  53. {
  54. try {
  55. $page = new Zend_Navigation_Page_Uri(array('uri' => 1337));
  56. $this->fail('An invalid \'uri\' was given, but ' .
  57. 'a Zend_Navigation_Exception was not thrown');
  58. } catch (Zend_Navigation_Exception $e) {
  59. }
  60. }
  61. public function testUriOptionAsObject()
  62. {
  63. try {
  64. $uri = new stdClass();
  65. $uri->foo = 'bar';
  66. $page = new Zend_Navigation_Page_Uri(array('uri' => $uri));
  67. $this->fail('An invalid \'uri\' was given, but ' .
  68. 'a Zend_Navigation_Exception was not thrown');
  69. } catch (Zend_Navigation_Exception $e) {
  70. }
  71. }
  72. public function testSetAndGetUri()
  73. {
  74. $page = new Zend_Navigation_Page_Uri(array(
  75. 'label' => 'foo',
  76. 'uri' => '#'
  77. ));
  78. $page->setUri('http://www.example.com/')->setUri('about:blank');
  79. $this->assertEquals('about:blank', $page->getUri());
  80. }
  81. public function testGetHref()
  82. {
  83. $uri = 'spotify:album:4YzcWwBUSzibRsqD9Sgu4A';
  84. $page = new Zend_Navigation_Page_Uri();
  85. $page->setUri($uri);
  86. $this->assertEquals($uri, $page->getHref());
  87. }
  88. }