/tests/system/suite/acl/acl0001Test.php

https://github.com/chdemko/joomla-cms · PHP · 288 lines · 269 code · 12 blank · 7 comment · 1 complexity · 3752104ad9e2225835e3bea5b653a1e9 MD5 · raw file

  1. <?php
  2. /**
  3. * @version $Id$
  4. * @package Joomla.SystemTest
  5. * @copyright Copyright (C) 2005 - 2011 Open Source Matters, Inc. All rights reserved.
  6. * @license GNU General Public License version 2 or later; see LICENSE.txt
  7. * Creates test group and assigns priviledges with the ACL.
  8. */
  9. require_once 'SeleniumJoomlaTestCase.php';
  10. class Acl0001Test extends SeleniumJoomlaTestCase
  11. {
  12. function testAclGroupCreation()
  13. {
  14. $this->setUp();
  15. $this->gotoAdmin();
  16. $this->doAdminLogin();
  17. echo "Check starting condition as Super Admin user\n";
  18. try
  19. {
  20. $this->assertTrue($this->isElementPresent("//ul[@id='menu-com-users-users']"), 'User manager should be visible');
  21. }
  22. catch (PHPUnit_Framework_AssertionFailedError $e)
  23. {
  24. array_push($this->verificationErrors, $this->getTraceFiles($e));
  25. }
  26. try
  27. {
  28. $this->assertTrue($this->isElementPresent("//ul[@id='menu-com-users-groups']"), 'Groups should be visible');
  29. }
  30. catch (PHPUnit_Framework_AssertionFailedError $e)
  31. {
  32. array_push($this->verificationErrors, $this->getTraceFiles($e));
  33. }
  34. try
  35. {
  36. $this->assertTrue($this->isElementPresent("//ul[@id='menu-com-menus-menus']"), 'Menus should be visible');
  37. }
  38. catch (PHPUnit_Framework_AssertionFailedError $e)
  39. {
  40. array_push($this->verificationErrors, $this->getTraceFiles($e));
  41. }
  42. try
  43. {
  44. $this->assertTrue($this->isElementPresent("//ul[@id='menu-com-banners']"), 'Banners should be visible');
  45. }
  46. catch (PHPUnit_Framework_AssertionFailedError $e)
  47. {
  48. array_push($this->verificationErrors, $this->getTraceFiles($e));
  49. }
  50. try
  51. {
  52. $this->assertTrue($this->isElementPresent("//ul[@id='menu-com-contact']"), 'Contacts should be visible');
  53. }
  54. catch (PHPUnit_Framework_AssertionFailedError $e)
  55. {
  56. array_push($this->verificationErrors, $this->getTraceFiles($e));
  57. }
  58. try
  59. {
  60. $this->assertTrue($this->isElementPresent("//ul[@id='menu-com-messages']"), 'Messaging should be visible');
  61. }
  62. catch (PHPUnit_Framework_AssertionFailedError $e)
  63. {
  64. array_push($this->verificationErrors, $this->getTraceFiles($e));
  65. }
  66. try
  67. {
  68. $this->assertTrue($this->isElementPresent("//ul[@id='menu-com-newsfeeds']"), 'Newsfeeds should be visible');
  69. }
  70. catch (PHPUnit_Framework_AssertionFailedError $e)
  71. {
  72. array_push($this->verificationErrors, $this->getTraceFiles($e));
  73. }
  74. try
  75. {
  76. $this->assertTrue($this->isElementPresent("//a[@href='index.php?option=com_search']"), 'Search should be visible');
  77. }
  78. catch (PHPUnit_Framework_AssertionFailedError $e)
  79. {
  80. array_push($this->verificationErrors, $this->getTraceFiles($e));
  81. }
  82. try
  83. {
  84. $this->assertTrue($this->isElementPresent("//ul[@id='menu-com-weblinks']"), 'Weblinks should be visible');
  85. }
  86. catch (PHPUnit_Framework_AssertionFailedError $e)
  87. {
  88. array_push($this->verificationErrors, $this->getTraceFiles($e));
  89. }
  90. try
  91. {
  92. $this->assertTrue($this->isElementPresent("//a[@href='index.php?option=com_redirect']"), 'Redirect should be visible');
  93. }
  94. catch (PHPUnit_Framework_AssertionFailedError $e)
  95. {
  96. array_push($this->verificationErrors, $this->getTraceFiles($e));
  97. }
  98. try
  99. {
  100. $this->assertTrue($this->isElementPresent("//a[@href='index.php?option=com_installer']"), 'Extensions should be visible');
  101. }
  102. catch (PHPUnit_Framework_AssertionFailedError $e)
  103. {
  104. array_push($this->verificationErrors, $this->getTraceFiles($e));
  105. }
  106. try
  107. {
  108. $this->assertTrue($this->isElementPresent("//ul[@id='menu-com-menus-menus']"), 'Menu Manager should not be visible');
  109. }
  110. catch (PHPUnit_Framework_AssertionFailedError $e)
  111. {
  112. array_push($this->verificationErrors, $this->getTraceFiles($e));
  113. }
  114. try
  115. {
  116. $this->assertTrue($this->isElementPresent("//a[@href='index.php?option=com_modules']"), 'Module Manager should not be visible');
  117. }
  118. catch (PHPUnit_Framework_AssertionFailedError $e)
  119. {
  120. array_push($this->verificationErrors, $this->getTraceFiles($e));
  121. }
  122. $saltGroup = mt_rand();
  123. $groupName = 'Test Administrator Group'.$saltGroup;
  124. $groupParent = 'Registered';
  125. $this->createGroup($groupName, $groupParent);
  126. $levelName = 'Special';
  127. $this->changeAccessLevel($levelName,$groupName);
  128. echo "Change " . $groupName . " article permissions.\n";
  129. echo "Grant allow for all actions in article manager\n";
  130. $actions = array('Configure', 'Access Component', 'Create', 'Delete', 'Edit', 'Edit State');
  131. $permissions = array('Allowed', 'Allowed', 'Allowed', 'Allowed', 'Allowed', 'Allowed');
  132. $this->setPermissions('Article Manager', $groupName, $actions, $permissions);
  133. echo "Allow" . $groupName . " back end access, deny admin access\n";
  134. $actions = array('Site Login', 'Admin Login', 'Configure', 'Access Component', 'Create', 'Delete', 'Edit', 'Edit State');
  135. $permissions = array('Inherited', 'Allowed', 'Denied', 'Inherited', 'Inherited', 'Inherited', 'Inherited', 'Inherited');
  136. $this->setPermissions('Global Configuration', $groupName, $actions, $permissions);
  137. $group = $groupName;
  138. $username = 'Test User' . $saltGroup;
  139. $login = 'TestUser' . $saltGroup;
  140. $email = $login . '@test.com';
  141. $this->createUser($username, $login, 'password' , $email, $group);
  142. $this->gotoAdmin();
  143. $this->doAdminLogout();
  144. sleep(3);
  145. echo("Log in to back end as " . $username . ".\n");
  146. $this->type("mod-login-username", $login);
  147. $this->type("mod-login-password", 'password');
  148. $this->click("link=Log in");
  149. $this->waitForPageToLoad("30000");
  150. echo("Testing " . $username . " access.\n");
  151. try
  152. {
  153. $this->assertFalse($this->isElementPresent("//a[@class=''][@href='#'][contains(text(), 'Users')]"), 'Users menu should not be visible');
  154. }
  155. catch (PHPUnit_Framework_AssertionFailedError $e)
  156. {
  157. array_push($this->verificationErrors, $this->getTraceFiles($e));
  158. }
  159. try
  160. {
  161. $this->assertFalse($this->isElementPresent("//ul[@id='menu-com-users-groups']"), 'Groups should not be visible');
  162. }
  163. catch (PHPUnit_Framework_AssertionFailedError $e)
  164. {
  165. array_push($this->verificationErrors, $this->getTraceFiles($e));
  166. }
  167. try
  168. {
  169. $this->assertFalse($this->isElementPresent("//ul[@id='menu-com-menus-menus']"), 'Menus option should not be visible');
  170. }
  171. catch (PHPUnit_Framework_AssertionFailedError $e)
  172. {
  173. array_push($this->verificationErrors, $this->getTraceFiles($e));
  174. }
  175. try
  176. {
  177. $this->assertFalse($this->isElementPresent("//ul[@id='menu-com-banners']"), 'Banners should not be visible');
  178. }
  179. catch (PHPUnit_Framework_AssertionFailedError $e)
  180. {
  181. array_push($this->verificationErrors, $this->getTraceFiles($e));
  182. }
  183. try
  184. {
  185. $this->assertFalse($this->isElementPresent("//ul[@id='menu-com-contact']"), 'Contacts should not be visible');
  186. }
  187. catch (PHPUnit_Framework_AssertionFailedError $e)
  188. {
  189. array_push($this->verificationErrors, $this->getTraceFiles($e));
  190. }
  191. try
  192. {
  193. $this->assertFalse($this->isElementPresent("//ul[@id='menu-com-messages']"), 'Messaging should not be visible');
  194. }
  195. catch (PHPUnit_Framework_AssertionFailedError $e)
  196. {
  197. array_push($this->verificationErrors, $this->getTraceFiles($e));
  198. }
  199. try
  200. {
  201. $this->assertFalse($this->isElementPresent("//ul[@id='menu-com-newsfeeds']"), 'Newsfeeds should not be visible');
  202. }
  203. catch (PHPUnit_Framework_AssertionFailedError $e)
  204. {
  205. array_push($this->verificationErrors, $this->getTraceFiles($e));
  206. }
  207. try
  208. {
  209. $this->assertFalse($this->isElementPresent("//a[@href='index.php?option=com_search']"), 'Search should not be visible');
  210. }
  211. catch (PHPUnit_Framework_AssertionFailedError $e)
  212. {
  213. array_push($this->verificationErrors, $this->getTraceFiles($e));
  214. }
  215. try
  216. {
  217. $this->assertFalse($this->isElementPresent("//ul[@id='menu-com-weblinks']"), 'Weblinks should not be visible');
  218. }
  219. catch (PHPUnit_Framework_AssertionFailedError $e)
  220. {
  221. array_push($this->verificationErrors, $this->getTraceFiles($e));
  222. }
  223. try
  224. {
  225. $this->assertFalse($this->isElementPresent("//a[@href='index.php?option=com_redirect']"), 'Redirect should not be visible');
  226. }
  227. catch (PHPUnit_Framework_AssertionFailedError $e)
  228. {
  229. array_push($this->verificationErrors, $this->getTraceFiles($e));
  230. }
  231. try
  232. {
  233. $this->assertFalse($this->isElementPresent("//a[@href='index.php?option=com_installer']"), 'Extensions should not be visible');
  234. }
  235. catch (PHPUnit_Framework_AssertionFailedError $e)
  236. {
  237. array_push($this->verificationErrors, $this->getTraceFiles($e));
  238. }
  239. try
  240. {
  241. $this->assertFalse($this->isElementPresent("//ul[@id='menu-com-menus-menus']"), 'Menu Manager should not be visible');
  242. }
  243. catch (PHPUnit_Framework_AssertionFailedError $e)
  244. {
  245. array_push($this->verificationErrors, $this->getTraceFiles($e));
  246. }
  247. try
  248. {
  249. $this->assertFalse($this->isElementPresent("//a[@href='index.php?option=com_modules']"), 'Module Manager should not be visible');
  250. }
  251. catch (PHPUnit_Framework_AssertionFailedError $e)
  252. {
  253. array_push($this->verificationErrors, $this->getTraceFiles($e));
  254. }
  255. $this->click("link=Control Panel");
  256. $this->waitForPageToLoad("30000");
  257. $this->click("link=Article Manager");
  258. $this->waitForPageToLoad("30000");
  259. try
  260. {
  261. $this->assertTrue($this->isTextPresent("Article Manager: Articles"), 'Article Manager not shown when it should be, Acl0001Test line 182');
  262. }
  263. catch (PHPUnit_Framework_AssertionFailedError $e)
  264. {
  265. array_push($this->verificationErrors, $this->getTraceFiles($e));
  266. }
  267. $this->doAdminLogout();
  268. $this->doAdminLogin();
  269. $this->deleteTestUsers();
  270. $this->gotoAdmin();
  271. $this->deleteGroup();
  272. $this->doAdminLogout();
  273. $this->countErrors();
  274. $this->deleteAllVisibleCookies();
  275. }
  276. }