[ Index ] |
|
Code source de LifeType 1.2.4 |
1 <?php 2 3 lt_include( PLOG_CLASS_PATH."class/test/helpers/lifetypetestcase.class.php" ); 4 lt_include( PLOG_CLASS_PATH."class/test/helpers/testtools.class.php" ); 5 lt_include( PLOG_CLASS_PATH."class/dao/permissions.class.php" ); 6 7 /** 8 * \ingroup Test 9 */ 10 class PermissionsUI_Test extends LifeTypeTestCase 11 { 12 var $user; 13 var $blog; 14 15 function setUp() 16 { 17 $this->user = TestTools::createAdminUser(); 18 $this->blog = TestTools::createBlog( $this->user->getId()); 19 } 20 21 function tearDown() 22 { 23 TestTools::deleteDaoTestData( Array( $this->user, $this->blog )); 24 } 25 26 /** 27 * Test that core permissions cannot be deleted via the user interface 28 */ 29 function testCorePermissions() 30 { 31 $permName = "perm_".TestTools::getRandomWord( 20 ); 32 33 // login 34 $this->assertUIScript( 35 Array( 36 "login" => Array( 37 "url" => $this->getAdminUrl(), 38 "type" => "post", 39 "params" => Array( 40 "userName" => $this->user->getUserName(), 41 "userPassword" => "password", 42 "op" => "Login" 43 ), 44 "expected" => "Dashboard", 45 "message" => "The dashboard did not appear when logging in" 46 ), 47 "select_blog" => Array( 48 "url" => $this->getAdminUrl(), 49 "type" => "get", 50 "params" => Array( 51 "op" => "blogSelect", 52 "blogId" => $this->blog->getId() 53 ), 54 "expected" => "New Post", 55 "message" => "The blog could not be selected after the dashboard" 56 ) 57 ) 58 ); 59 60 // go the "new permission" page and add a new one 61 $this->assertUIScript( 62 Array( 63 "new_permission" => Array( 64 "url" => $this->getAdminUrl(), 65 "type" => "get", 66 "params" => Array( "op" => "newPermission" ), 67 "expected" => "Unique name for the new permission", 68 "message" => "The form to input a new permission was not successfully displayed" 69 ), 70 "create_permission" => Array( 71 "url" => $this->getAdminUrl(), 72 "type" => "post", 73 "params" => Array( "permissionName" => $permName, "permissionDescription" => "$permName description", "corePermission" => "1", "op" => "addPermission" ), 74 "expected" => "Permission added", 75 "message" => "The test permission was not successully added" 76 ) 77 ) 78 ); 79 80 // find the category in the db... 81 $perms = new Permissions(); 82 $perm = $perms->getPermissionByName( $permName ); 83 84 if( !$perm ) { 85 die("FATAL: The permission was not successfully added and the test cannot continue" ); 86 } 87 88 // ...and delete it via the UI 89 $this->assertUIScript( 90 Array( 91 "delete_permission" => Array( 92 "url" => $this->getAdminUrl(), 93 "type" => "get", 94 "params" => Array( "permId" => $perm->getId(), "op" => "deletePermission" ), 95 "expected" => "Permission \"".$perm->getName()."\" cannot be deleted", 96 "message" => "The user interface allowed to delete a core permission!" 97 ) 98 ) 99 ); 100 101 // delete the permission via the API 102 $perms->deletePermission( $perm->getId()); 103 } 104 105 /** 106 * Test permissions 107 */ 108 function testPermissions() 109 { 110 $permName = "perm_".TestTools::getRandomWord( 20 ); 111 112 // login 113 $this->assertUIScript( 114 Array( 115 "login" => Array( 116 "url" => $this->getAdminUrl(), 117 "type" => "post", 118 "params" => Array( 119 "userName" => $this->user->getUserName(), 120 "userPassword" => "password", 121 "op" => "Login" 122 ), 123 "expected" => "Dashboard", 124 "message" => "The dashboard did not appear when logging in" 125 ), 126 "select_blog" => Array( 127 "url" => $this->getAdminUrl(), 128 "type" => "get", 129 "params" => Array( 130 "op" => "blogSelect", 131 "blogId" => $this->blog->getId() 132 ), 133 "expected" => "New Post", 134 "message" => "The blog could not be selected after the dashboard" 135 ) 136 ) 137 ); 138 139 // go the "new permission" page and add a new one 140 $this->assertUIScript( 141 Array( 142 "new_permission" => Array( 143 "url" => $this->getAdminUrl(), 144 "type" => "get", 145 "params" => Array( "op" => "newPermission" ), 146 "expected" => "Unique name for the new permission", 147 "message" => "The form to input a new permission was not successfully displayed" 148 ), 149 "create_permission" => Array( 150 "url" => $this->getAdminUrl(), 151 "type" => "post", 152 "params" => Array( "permissionName" => $permName, "permissionDescription" => "$permName description", "adminOnlyPermission" => "1", "op" => "addPermission" ), 153 "expected" => "Permission added", 154 "message" => "The test permission was not successully added" 155 ) 156 ) 157 ); 158 159 // find the category in the db... 160 $perms = new Permissions(); 161 $perm = $perms->getPermissionByName( $permName ); 162 163 if( !$perm ) { 164 die("FATAL: The permission was not successfully added and the test cannot continue" ); 165 } 166 167 // ...and delete it via the UI 168 $this->assertUIScript( 169 Array( 170 "delete_permission" => Array( 171 "url" => $this->getAdminUrl(), 172 "type" => "get", 173 "params" => Array( "permId" => $perm->getId(), "op" => "deletePermission" ), 174 "expected" => "Permission \"".$perm->getName()."\" was deleted", 175 "message" => "The permission was not deleted!" 176 ), 177 "delete_permission_again" => Array( 178 "url" => $this->getAdminUrl(), 179 "type" => "get", 180 "params" => Array( "permId" => $perm->getId(), "op" => "deletePermission" ), 181 "expected" => "There was an error deleting permission", 182 "message" => "The user interface allowed to delete the test permission twice" 183 ) 184 ) 185 ); 186 } 187 } 188 ?>
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Mon Nov 26 21:04:15 2007 | par Balluche grâce à PHPXref 0.7 |
![]() |