Skip to content
This repository has been archived by the owner on Jan 30, 2020. It is now read-only.

Commit

Permalink
Merge branch 'hotfix/52'
Browse files Browse the repository at this point in the history
Close #52
  • Loading branch information
weierophinney committed Mar 22, 2017
2 parents 1bdb9fe + ac10968 commit fb90dad
Show file tree
Hide file tree
Showing 2 changed files with 80 additions and 2 deletions.
8 changes: 8 additions & 0 deletions test/Page/PageFactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -158,4 +158,12 @@ public function testShouldFailIfUnableToDetermineType()

$this->fail('An exception has not been thrown for invalid page type');
}

/**
* @expectedException \Zend\Navigation\Exception\InvalidArgumentException
*/
public function testShouldThrowExceptionOnInvalidMethodArgument()
{
AbstractPage::factory('');
}
}
74 changes: 72 additions & 2 deletions test/Page/PageTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,12 @@

namespace ZendTest\Navigation\Page;

use Zend\Config;
use Zend\Navigation;
use Zend\Navigation\Exception;
use Zend\Navigation\Page\AbstractPage;
use Zend\Navigation\Page\Mvc;
use Zend\Navigation\Page\Uri;
use Zend\Navigation;
use Zend\Config;

/**
* Tests the class Zend_Navigation_Page
Expand Down Expand Up @@ -104,6 +105,46 @@ public function testSetShouldNotMapToSetConfigToPreventRecursion()
$this->assertEquals($options, $page->get('config'));
}

public function testSetShouldThrowExceptionIfPropertyIsNotString()
{
$page = AbstractPage::factory([
'type' => 'uri',
]);

$this->setExpectedException(Exception\InvalidArgumentException::class);
$page->set([], true);
}

public function testSetShouldThrowExceptionIfPropertyIsEmpty()
{
$page = AbstractPage::factory([
'type' => 'uri',
]);

$this->setExpectedException(Exception\InvalidArgumentException::class);
$page->set('', true);
}

public function testGetShouldThrowExceptionIfPropertyIsNotString()
{
$page = AbstractPage::factory([
'type' => 'uri',
]);

$this->setExpectedException(Exception\InvalidArgumentException::class);
$page->get([]);
}

public function testGetShouldThrowExceptionIfPropertyIsEmpty()
{
$page = AbstractPage::factory([
'type' => 'uri',
]);

$this->setExpectedException(Exception\InvalidArgumentException::class);
$page->get('');
}

public function testSetAndGetLabel()
{
$page = AbstractPage::factory([
Expand Down Expand Up @@ -325,6 +366,17 @@ public function testConstructingWithRelationsInConfig()
$this->assertEquals($expected, $actual);
}

public function testConstructingWithTraversableOptions()
{
$options = ['label' => 'bar'];

$page = new Uri(new Config\Config($options));

$actual = ['label' => $page->getLabel()];

$this->assertEquals($options, $actual);
}

public function testGettingSpecificRelations()
{
$page = AbstractPage::factory([
Expand Down Expand Up @@ -509,6 +561,12 @@ public function testIsActiveOnNewlyConstructedPageShouldReturnFalse()
$this->assertFalse($page->isActive());
}

public function testIsActiveRecursiveOnNewlyConstructedPageShouldReturnFalse()
{
$page = new Uri();
$this->assertFalse($page->isActive(true));
}

public function testGetActiveShouldReturnTrueIfPageIsActive()
{
$page = new Uri(['active' => true]);
Expand Down Expand Up @@ -1168,4 +1226,16 @@ public function testSetObjectPermission()
$this->assertInstanceOf('stdClass', $page->getPermission());
$this->assertEquals('my_permission', $page->getPermission()->name);
}

public function testSetParentShouldThrowExceptionIfPageItselfIsParent()
{
$page = AbstractPage::factory(
[
'type' => 'uri',
]
);

$this->setExpectedException(Exception\InvalidArgumentException::class);
$page->setParent($page);
}
}

0 comments on commit fb90dad

Please sign in to comment.