|
@ -16,45 +16,47 @@ require_once dirname(__FILE__) . '/../../../view/helpers/BreadcrumbViewHelper.ph |
|
|
|
|
|
|
|
|
class BreadcrumbViewHelperTest extends PHPUnit_Framework_TestCase |
|
|
class BreadcrumbViewHelperTest extends PHPUnit_Framework_TestCase |
|
|
{ |
|
|
{ |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
* @var BreadcrumbViewHelper |
|
|
|
|
|
*/ |
|
|
public $helper; |
|
|
public $helper; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public function setUp() |
|
|
public function setUp() |
|
|
{ |
|
|
{ |
|
|
Registry::set('BreadcrumbViewHelper', array()); |
|
|
Registry::set('BreadcrumbViewHelper', array()); |
|
|
$this->helper = new BreadcrumbViewHelper(new PHPView('any')); |
|
|
$this->helper = new BreadcrumbViewHelper(new PHPView('any')); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public function testTitle() |
|
|
public function testTitle() |
|
|
{ |
|
|
{ |
|
|
$this->helper->breadcrumb('Guest page', 'guest.php'); |
|
|
|
|
|
|
|
|
$this->helper->breadcrumb('Guest page', 'guest.php'); |
|
|
$result = Registry::get('BreadcrumbViewHelper'); |
|
|
$result = Registry::get('BreadcrumbViewHelper'); |
|
|
$this->assertSame(array('Guest page' => 'guest.php'), Registry::get('BreadcrumbViewHelper')); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$this->assertSame(array('Guest page' => 'guest.php'), Registry::get('BreadcrumbViewHelper')); |
|
|
|
|
|
|
|
|
$this->helper->prepend('Leave message', 'feedback.php'); |
|
|
$this->helper->prepend('Leave message', 'feedback.php'); |
|
|
$this->assertSame(array('Leave message' => 'feedback.php', 'Guest page' => 'guest.php'), Registry::get('BreadcrumbViewHelper')); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$this->assertSame(array('Leave message' => 'feedback.php', 'Guest page' => 'guest.php'), Registry::get('BreadcrumbViewHelper')); |
|
|
|
|
|
|
|
|
$this->helper->append('Home page', 'home.php'); |
|
|
$this->helper->append('Home page', 'home.php'); |
|
|
$this->assertSame(array('Leave message' => 'feedback.php', 'Guest page' => 'guest.php', 'Home page' => 'home.php'), Registry::get('BreadcrumbViewHelper')); |
|
|
|
|
|
|
|
|
$this->assertSame(array('Leave message' => 'feedback.php', 'Guest page' => 'guest.php', 'Home page' => 'home.php'), Registry::get('BreadcrumbViewHelper')); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public function testToString() |
|
|
public function testToString() |
|
|
{ |
|
|
{ |
|
|
$this->helper->prepend('Home page', 'home.php'); |
|
|
$this->helper->prepend('Home page', 'home.php'); |
|
|
$this->helper->breadcrumb('Guest page', 'guest.php'); |
|
|
|
|
|
|
|
|
$this->helper->breadcrumb('Guest page', 'guest.php'); |
|
|
$this->helper->append('Leave message', 'feedback.php'); |
|
|
$this->helper->append('Leave message', 'feedback.php'); |
|
|
$this->assertSame(array('Home page' => 'home.php', 'Guest page' => 'guest.php', 'Leave message'=> 'feedback.php'), Registry::get('BreadcrumbViewHelper')); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$this->assertSame(array('Home page' => 'home.php', 'Guest page' => 'guest.php', 'Leave message' => 'feedback.php'), Registry::get('BreadcrumbViewHelper')); |
|
|
|
|
|
|
|
|
$result = $this->helper->__toString(); |
|
|
$result = $this->helper->__toString(); |
|
|
$this->assertSame('<a href="home.php">Home page</a> > <a href="guest.php">Guest page</a> > <a href="feedback.php">Leave message</a>', $result); |
|
|
$this->assertSame('<a href="home.php">Home page</a> > <a href="guest.php">Guest page</a> > <a href="feedback.php">Leave message</a>', $result); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$this->helper->setSeparator('-'); |
|
|
$this->helper->setSeparator('-'); |
|
|
$result = $this->helper->__toString(); |
|
|
$result = $this->helper->__toString(); |
|
|
$this->assertSame('<a href="home.php">Home page</a>-<a href="guest.php">Guest page</a>-<a href="feedback.php">Leave message</a>', $result); |
|
|
$this->assertSame('<a href="home.php">Home page</a>-<a href="guest.php">Guest page</a>-<a href="feedback.php">Leave message</a>', $result); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$this->helper->append('Last page', ''); |
|
|
$this->helper->append('Last page', ''); |
|
|
$result = $this->helper->__toString(); |
|
|
$result = $this->helper->__toString(); |
|
|
$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); |
|
|
$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); |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |