UriTest.php 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. <?php
  2. require_once 'PHPUnit/Framework/TestCase.php';
  3. require_once 'Zend/Navigation/Page/Uri.php';
  4. /**
  5. * Tests the class Zend_Navigation_Page_Uri
  6. *
  7. */
  8. class Zend_Navigation_Page_UriTest extends PHPUnit_Framework_TestCase
  9. {
  10. public function testUriOptionAsString()
  11. {
  12. $page = new Zend_Navigation_Page_Uri(array(
  13. 'label' => 'foo',
  14. 'uri' => '#'
  15. ));
  16. $this->assertEquals('#', $page->getUri());
  17. }
  18. public function testUriOptionAsNull()
  19. {
  20. $page = new Zend_Navigation_Page_Uri(array(
  21. 'label' => 'foo',
  22. 'uri' => null
  23. ));
  24. $this->assertNull($page->getUri(), 'getUri() should return null');
  25. }
  26. public function testUriOptionAsInteger()
  27. {
  28. try {
  29. $page = new Zend_Navigation_Page_Uri(array('uri' => 1337));
  30. $this->fail('An invalid \'uri\' was given, but ' .
  31. 'a Zend_Navigation_Exception was not thrown');
  32. } catch (Zend_Navigation_Exception $e) {
  33. }
  34. }
  35. public function testUriOptionAsObject()
  36. {
  37. try {
  38. $uri = new stdClass();
  39. $uri->foo = 'bar';
  40. $page = new Zend_Navigation_Page_Uri(array('uri' => $uri));
  41. $this->fail('An invalid \'uri\' was given, but ' .
  42. 'a Zend_Navigation_Exception was not thrown');
  43. } catch (Zend_Navigation_Exception $e) {
  44. }
  45. }
  46. public function testSetAndGetUri()
  47. {
  48. $page = new Zend_Navigation_Page_Uri(array(
  49. 'label' => 'foo',
  50. 'uri' => '#'
  51. ));
  52. $page->setUri('http://www.example.com/')->setUri('about:blank');
  53. $this->assertEquals('about:blank', $page->getUri());
  54. }
  55. public function testGetHref()
  56. {
  57. $uri = 'spotify:album:4YzcWwBUSzibRsqD9Sgu4A';
  58. $page = new Zend_Navigation_Page_Uri();
  59. $page->setUri($uri);
  60. $this->assertEquals($uri, $page->getHref());
  61. }
  62. }