Skip to content

Instantly share code, notes, and snippets.

@rich97
Created May 25, 2011 09:10
Show Gist options
  • Save rich97/990640 to your computer and use it in GitHub Desktop.
Save rich97/990640 to your computer and use it in GitHub Desktop.
<?php
// ...
class AuthRbacTest extends \lithium\test\Unit {
// ...
public function testParseMatch() {
$request = new Request(array('library' => 'test_library', 'controller' => 'test_controller', 'action' => 'test_action'));
$match = array('library' => 'test_library', 'controller' => 'test_controller', 'action' => 'test_action');
$this->assertTrue(Access::adapter('test_simple_check')->parseMatch($match, $request));
$match = array('controller' => 'test_controller', 'action' => 'test_action');
$this->assertTrue(Access::adapter('test_simple_check')->parseMatch($match, $request));
$match = array('library' => 'test_library', 'action' => 'test_action');
$this->assertTrue(Access::adapter('test_simple_check')->parseMatch($match, $request));
$match = array('library' => 'test_library', 'controller' => 'test_controller');
$this->assertTrue(Access::adapter('test_simple_check')->parseMatch($match, $request));
$match = array('library' => 'test_no_match', 'controller' => 'test_controller', 'action' => 'test_action');
$this->assertFalse(Access::adapter('test_simple_check')->parseMatch($match, $request));
$match = 'TestControllers::test_action';
$this->assertTrue(Access::adapter('test_simple_check')->parseMatch($match, $request));
$match = 'TestControllers::*';
$this->assertTrue(Access::adapter('test_simple_check')->parseMatch($match, $request));
$match = '*::test_action';
$this->assertTrue(Access::adapter('test_simple_check')->parseMatch($match, $request));
$match = '*::*';
$this->assertTrue(Access::adapter('test_simple_check')->parseMatch($match, $request));
$match = array('library' => 'test_library', '*::*');
$this->assertTrue(Access::adapter('test_simple_check')->parseMatch($match, $request));
$match = array('library' => 'test_no_match', '*::*');
$this->assertFalse(Access::adapter('test_simple_check')->parseMatch($match, $request));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment