You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

62 lines
2.4 KiB

  1. <?php
  2. /*
  3. * @copyright NetMonsters <team@netmonsters.ru>
  4. * @link http://netmonsters.ru
  5. * @package Majestic
  6. * @subpackage UnitTests
  7. * @since 2011-10-11
  8. *
  9. * Unit tests for PHPView class
  10. */
  11. require_once dirname(__FILE__) . '/../../../Registry.php';
  12. require_once dirname(__FILE__) . '/../../../view/helpers/ViewHelper.php';
  13. require_once dirname(__FILE__) . '/../../../view/helpers/BreadcrumbViewHelper.php';
  14. class BreadcrumbViewHelperTest extends PHPUnit_Framework_TestCase
  15. {
  16. /**
  17. * @var BreadcrumbViewHelper
  18. */
  19. public $helper;
  20. public function setUp()
  21. {
  22. Registry::set('BreadcrumbViewHelper', array());
  23. $this->helper = new BreadcrumbViewHelper(new PHPView('any'));
  24. }
  25. public function testTitle()
  26. {
  27. $this->helper->breadcrumb('Guest page', 'guest.php');
  28. $result = Registry::get('BreadcrumbViewHelper');
  29. $this->assertSame(array('Guest page' => 'guest.php'), Registry::get('BreadcrumbViewHelper'));
  30. $this->helper->prepend('Leave message', 'feedback.php');
  31. $this->assertSame(array('Leave message' => 'feedback.php', 'Guest page' => 'guest.php'), Registry::get('BreadcrumbViewHelper'));
  32. $this->helper->append('Home page', 'home.php');
  33. $this->assertSame(array('Leave message' => 'feedback.php', 'Guest page' => 'guest.php', 'Home page' => 'home.php'), Registry::get('BreadcrumbViewHelper'));
  34. }
  35. public function testToString()
  36. {
  37. $this->helper->prepend('Home page', 'home.php');
  38. $this->helper->breadcrumb('Guest page', 'guest.php');
  39. $this->helper->append('Leave message', 'feedback.php');
  40. $this->assertSame(array('Home page' => 'home.php', 'Guest page' => 'guest.php', 'Leave message' => 'feedback.php'), Registry::get('BreadcrumbViewHelper'));
  41. $result = $this->helper->__toString();
  42. $this->assertSame('<a href="home.php">Home page</a> &gt; <a href="guest.php">Guest page</a> &gt; <a href="feedback.php">Leave message</a>', $result);
  43. $this->helper->setSeparator('-');
  44. $result = $this->helper->__toString();
  45. $this->assertSame('<a href="home.php">Home page</a>-<a href="guest.php">Guest page</a>-<a href="feedback.php">Leave message</a>', $result);
  46. $this->helper->append('Last page', '');
  47. $result = $this->helper->__toString();
  48. $this->assertSame('<a href="home.php">Home page</a>-<a href="guest.php">Guest page</a>-<a href="feedback.php">Leave message</a>-Last page', $result);
  49. }
  50. }