Permalink
Browse files

Merge pull request #150 from D4nte/master

unit test for the previous push
  • Loading branch information...
2 parents 1cd4ebb + 17ee7bd commit 684ca0635f7182a733b9ef58a185cb53aaa0067c @thibaud-rohmer committed Apr 19, 2012
Showing with 28 additions and 7 deletions.
  1. +14 −0 src/tests/GuestTokenTest.php
  2. +14 −7 src/tests/TestUnit.php
@@ -82,5 +82,19 @@ public function test_toHTML()
$guest_token->toHTML();
}
+ /**
+ * Verify toHTML gives an output when there is not token file
+ * @test
+ */
+ public function test_toHTML_no_tokens_file()
+ {
+ self::login_as_admin();
+ self::delete_tokens_file();
+
+ $this->expectOutputString("");
+ $guest_token = new GuestToken();
+ $guest_token->toHTML();
+ }
+
}
?>
View
@@ -85,7 +85,7 @@ function __construct()
* @author Franck Royer
*/
- static public function include_all()
+ public static function include_all()
{
$toinclude = array(
realpath(dirname(__FILE__)."/../classes/HTMLObject.php"),
@@ -148,7 +148,7 @@ public static function prepare_files(){
/**
* prepare test accounts
*/
- public function create_accounts(){
+ public static function create_accounts(){
// Create admin account
// First account is always admin
@@ -207,11 +207,9 @@ public function create_token($path=NULL){
}
// do we already have a token ?
- if (file_exists(CurrentUser::$tokens_file)){
- $tokens = GuestToken::find_for_path(File::a2r($path), true);
- if (!empty($tokens)){
- return $tokens[0]['key'];
- }
+ $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
@@ -222,5 +220,14 @@ public function create_token($path=NULL){
return $key;
}
+
+ /**
+ * Delete the token file
+ */
+ public static function delete_tokens_file(){
+ if (file_exists(CurrentUser::$tokens_file)){
+ unlink(CurrentUser::$tokens_file);
+ }
+ }
}
?>

0 comments on commit 684ca06

Please sign in to comment.