예제 #1
0
파일: DBTest.php 프로젝트: jasny/Q
 /**
  * Init test
  */
 public function setUp()
 {
     try {
         $this->conn = DB::connect('mysql', "localhost", "qtest");
     } catch (Exception $e) {
         $this->markTestSkipped("Failed to connect to database. Please create a user 'qtest' with all privileges to database 'qtest'. " . $e->getMessage());
     }
     $this->createTestSchema();
     $this->Auth = Auth::with('db');
     $this->Auth->query = $this->conn->prepare("SELECT id, fullname, username, '%', password, VALUES (SELECT `group` FROM `user_group` ORDER BY `group` CASCADE ON `user_group`.`user_id`=`user`.`id`) AS `groups`, `status` != 'PASSIVE' AS `active`, IF(`status` = 'NEW', 1, NULL) AS `expire` FROM `user`");
     $this->Auth->onLoginQuery = $this->conn->prepare("SET @auth_uid = :id, @auth_username = :username, @auth_fullname = :fullname");
     $this->Auth->onLogoutQuery = $this->conn->prepare("SET @auth_uid = NULL, @auth_username = NULL, @auth_fullname = NULL");
     parent::setUp();
 }
예제 #2
0
파일: MainTest.php 프로젝트: jasny/Q
 /**
  * Tests Auth->authz() with multiple getRoles() where authorization fails
  */
 public function testAuthz_Roles_FailMultiple()
 {
     $this->Auth->login('monkey', 'mark');
     $this->setExpectedException('Q\\Authz_Exception', "User 'monkey' is not in roles 'ape', 'pretty'.");
     $this->Auth->authz('primate', 'ape', 'pretty');
 }
예제 #3
0
파일: ManualTest.php 프로젝트: jasny/Q
 /**
  * Prepares the environment before running a test.
  */
 protected function setUp()
 {
     $this->Auth = Auth::with('manual');
     $this->Auth->users = array((object) array('id' => 1, 'fullname' => "Mark Monkey", 'username' => 'monkey', 'password' => md5('mark'), 'roles' => 'primate', 'active' => true, 'expires' => null), (object) array('id' => 2, 'fullname' => "Ben Baboon", 'username' => 'baboon', 'password' => md5('ben'), 'roles' => array('ape', 'primate'), 'active' => false, 'expires' => null), (object) array('id' => 3, 'fullname' => "George Gorilla", 'username' => 'gorilla', 'password' => md5('george'), 'roles' => array('ape', 'primate'), 'active' => true, 'expires' => 1));
     parent::setUp();
 }