Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Increased test coverage

  • Loading branch information...
commit c4eb97eabf08d28430191ee2a842823f86d5b77c 1 parent 0a4404c
@josegonzalez authored
Showing with 32 additions and 0 deletions.
  1. +32 −0 tests/cases/controllers/components/permit.test.php
View
32 tests/cases/controllers/components/permit.test.php
@@ -326,6 +326,9 @@ function setup() {
}
function testSingleParse() {
+ $testRoute = array();
+ $this->assertFalse($this->Controller->Permit->_parse($testRoute));
+
$testRoute = array('controller' => 'posts');
$this->assertTrue($this->Controller->Permit->_parse($testRoute));
@@ -385,6 +388,11 @@ function testDenyAccess() {
$this->Controller->Permit->settings['path'] = 'MockAuthTest.User';
$this->Controller->Permit->settings['check'] = 'id';
+ $testRoute = array('rules' => array());
+ $this->assertNull($this->Controller->Permit->executed);
+ $this->assertFalse($this->Controller->Permit->_execute($testRoute));
+ $this->Controller->Permit->executed = null;
+
$testRoute = array('rules' => array('deny' => true));
$this->assertNull($this->Controller->Permit->executed);
$this->assertTrue($this->Controller->Permit->_execute($testRoute));
@@ -508,6 +516,19 @@ function testAuthMultidimensionalExecute() {
$testRoute = array('rules' => array('auth' => array('/Group/name' => 'something-else')));
$this->assertTrue($this->Controller->Permit->_execute($testRoute));
$this->assertEqual($this->Controller->Permit->executed, $testRoute);
+
+ $testRoute = array('rules' => array('auth' => array('Group.name' => 'admin')));
+ $this->assertFalse($this->Controller->Permit->_execute($testRoute));
+ $this->assertEqual($this->Controller->Permit->executed, $testRoute);
+ $testRoute = array('rules' => array('auth' => array('Group.name' => 'editors')));
+ $this->assertFalse($this->Controller->Permit->_execute($testRoute));
+ $this->assertEqual($this->Controller->Permit->executed, $testRoute);
+ $testRoute = array('rules' => array('auth' => array('Group.description' => 'HABTM association')));
+ $this->assertFalse($this->Controller->Permit->_execute($testRoute));
+ $this->assertEqual($this->Controller->Permit->executed, $testRoute);
+ $testRoute = array('rules' => array('auth' => array('Group.name' => 'something-else')));
+ $this->assertTrue($this->Controller->Permit->_execute($testRoute));
+ $this->assertEqual($this->Controller->Permit->executed, $testRoute);
}
function testStartup() {
@@ -627,6 +648,17 @@ function testRedirect() {
$this->assertEqual(count($session['flash']['params']), 0);
}
+ function testReferer() {
+ $this->Controller->Session->write('Sanction.referer', array());
+ $this->assertEqual('/', $this->Controller->Permit->referer());
+
+ $this->Controller->Session->write('Sanction.referer', null);
+ $this->assertFalse($this->Controller->Permit->referer());
+
+ $this->Controller->Session->write('Sanction.referer', array('controller' => 'users', 'action' => 'login'));
+ $this->assertEqual('/users/login', $this->Controller->Permit->referer());
+ }
+
function testPermitObject() {
$Permit = PermitComponent::getInstance();
$Permit->routes = array();
Please sign in to comment.
Something went wrong with that request. Please try again.