コード例 #1
0
 /**
  * test delete
  * @test
  * @depends test_create
  * @depends test_generate_key
  * @depends test_exist
  */
 public function test_delete()
 {
     self::login_as_admin();
     self::delete_tokens_file();
     $key = Guesttoken::generate_key();
     $path = Settings::$photos_dir . "/tokenfolder";
     $key2 = Guesttoken::generate_key();
     $path2 = Settings::$photos_dir . "/subfolder";
     GuestToken::create($path, $key);
     GuestToken::create($path2, $key2);
     $this->assertFalse(GuestToken::delete(GuestToken::generate_key()));
     $this->assertCount(2, GuestToken::findAll());
     $this->assertTrue(GuestToken::delete($key));
     $this->assertCount(1, GuestToken::findAll());
     $this->assertFalse(GuestToken::exist($key));
     $this->assertTrue(GuestToken::exist($key2));
 }
コード例 #2
0
ファイル: TestUnit.php プロジェクト: inscriptionweb/PhotoShow
 /**
  * create a token and give you the ouput
  * actually it's a bit of cheating
  * if a token already exist for the given path we return it
  * otherwise, we create a new one
  */
 public function create_token($path = NULL)
 {
     // default path is the token folder
     if (!isset($path)) {
         $path = Settings::$photos_dir . "/tokenfolder";
     }
     // do we already have a token ?
     $tokens = GuestToken::find_for_path(File::a2r($path), true);
     if (!empty($tokens)) {
         return $tokens[0]['key'];
     }
     // No token found, Creating a token to allow guest view for the given path
     $key = Guesttoken::generate_key();
     if (!GuestToken::create($path, $key)) {
         throw new Exception("Cannot create token for path " . $path . "\n");
     }
     return $key;
 }