コード例 #1
0
ファイル: db_testcase.php プロジェクト: niekbosch/BeeHub
 /**
  * Mocks BeeHub_Auth to make it show as if a certain user is logged in
  *
  * @param   string  $path  The path to the user
  * @return  void
  */
 protected function setCurrentUser($path)
 {
     $user = new \BeeHub_User($path);
     $auth = $this->getMock('\\BeeHub\\tests\\BeeHub_Auth', array('current_user'), array(new \SimpleSAML_Auth_Simple('BeeHub')));
     $auth->expects($this->any())->method('current_user')->will($this->returnValue($user));
     \BeeHub::setAuth($auth);
 }
コード例 #2
0
ファイル: bootstrap.php プロジェクト: niekbosch/BeeHub
/**
 * Because we can't be sure we're using PHP 5.4 or higher, we can't use traits.
 * Instead, we use this global function to do the general setup for tests
 *
 * @return  void
 */
function setUp()
{
    reset_SERVER();
    \DAV::$REGISTRY = new \BeeHub_Registry();
    \DAV::$LOCKPROVIDER = new \BeeHub_Lock_Provider();
    \DAV::$ACLPROVIDER = new \BeeHub_ACL_Provider();
    \BeeHub::setAuth(new BeeHub_Auth(new \SimpleSAML_Auth_Simple('BeeHub')));
}
コード例 #3
0
 public function testMethod_HEAD()
 {
     $user = new \BeeHub_User('/system/users/john');
     $auth = $this->getMock('\\BeeHub\\tests\\BeeHub_Auth', array('current_user'), array(new \SimpleSAML_Auth_Simple('BeeHub')));
     $auth->expects($this->any())->method('current_user')->will($this->returnValue($user));
     \BeeHub::setAuth($auth);
     $headers = $this->obj->method_HEAD();
     $this->assertSame('no-cache', $headers['Cache-Control']);
 }
コード例 #4
0
 public function testUser_prop_current_user_principal()
 {
     $authJohn = $this->getMock('\\BeeHub\\tests\\BeeHub_Auth', array('is_authenticated', 'current_user'), array(new \SimpleSAML_Auth_Simple('BeeHub')));
     $authJohn->expects($this->any())->method('is_authenticated')->will($this->returnValue(true));
     $authJohn->expects($this->any())->method('current_user')->will($this->returnValue(new \DAV_Resource('/system/users/john')));
     \BeeHub::setAuth($authJohn);
     $obj = new \BeeHub_ACL_Provider();
     $this->assertSame('/system/users/john', $obj->user_prop_current_user_principal(), 'BeeHub_ACL_Provider::user_prop_current_user_principal() should return a string with the path to the current user');
     $authNull = $this->getMock('\\BeeHub\\tests\\BeeHub_Auth', array('is_authenticated', 'current_user'), array(new \SimpleSAML_Auth_Simple('BeeHub')));
     $authNull->expects($this->any())->method('is_authenticated')->will($this->returnValue(false));
     $authNull->expects($this->any())->method('current_user')->will($this->returnValue(null));
     \BeeHub::setAuth($authNull);
     $this->assertSame(null, $obj->user_prop_current_user_principal(), 'BeeHub_ACL_Provider::user_prop_current_user_principal() should return null when no user is logged in');
 }