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

https://github.com/gnomeontherun/joomla-cms · PHP · 288 lines · 270 code · 12 blank · 6 comment · 1 complexity · bfce3dedc6a55b9d62ad0d2cf9092092 MD5 · raw file

  1. <?php
  2. /**
  3. * @package Joomla.SystemTest
  4. * @copyright Copyright (C) 2005 - 2012 Open Source Matters, Inc. All rights reserved.
  5. * @license GNU General Public License version 2 or later; see LICENSE.txt
  6. * Creates test group and assigns priviledges with the ACL.
  7. */
  8. require_once 'SeleniumJoomlaTestCase.php';
  9. class Acl0001Test extends SeleniumJoomlaTestCase
  10. {
  11. function testAclGroupCreation()
  12. {
  13. $this->setUp();
  14. $this->gotoAdmin();
  15. $this->doAdminLogin();
  16. echo "Check starting condition as Super Admin user\n";
  17. try
  18. {
  19. $this->assertTrue($this->isElementPresent("//ul[@id='menu-com-users-users']"), 'User manager should be visible');
  20. }
  21. catch (PHPUnit_Framework_AssertionFailedError $e)
  22. {
  23. array_push($this->verificationErrors, $this->getTraceFiles($e));
  24. }
  25. try
  26. {
  27. $this->assertTrue($this->isElementPresent("//ul[@id='menu-com-users-groups']"), 'Groups should be visible');
  28. }
  29. catch (PHPUnit_Framework_AssertionFailedError $e)
  30. {
  31. array_push($this->verificationErrors, $this->getTraceFiles($e));
  32. }
  33. try
  34. {
  35. $this->assertTrue($this->isElementPresent("//ul[@id='menu-com-menus-menus']"), 'Menus should be visible');
  36. }
  37. catch (PHPUnit_Framework_AssertionFailedError $e)
  38. {
  39. array_push($this->verificationErrors, $this->getTraceFiles($e));
  40. }
  41. try
  42. {
  43. $this->assertTrue($this->isElementPresent("//ul[@id='menu-com-banners']"), 'Banners should be visible');
  44. }
  45. catch (PHPUnit_Framework_AssertionFailedError $e)
  46. {
  47. array_push($this->verificationErrors, $this->getTraceFiles($e));
  48. }
  49. try
  50. {
  51. $this->assertTrue($this->isElementPresent("//ul[@id='menu-com-contact']"), 'Contacts should be visible');
  52. }
  53. catch (PHPUnit_Framework_AssertionFailedError $e)
  54. {
  55. array_push($this->verificationErrors, $this->getTraceFiles($e));
  56. }
  57. try
  58. {
  59. $this->assertTrue($this->isElementPresent("//ul[@id='menu-com-messages']"), 'Messaging should be visible');
  60. }
  61. catch (PHPUnit_Framework_AssertionFailedError $e)
  62. {
  63. array_push($this->verificationErrors, $this->getTraceFiles($e));
  64. }
  65. try
  66. {
  67. $this->assertTrue($this->isElementPresent("//ul[@id='menu-com-newsfeeds']"), 'Newsfeeds should be visible');
  68. }
  69. catch (PHPUnit_Framework_AssertionFailedError $e)
  70. {
  71. array_push($this->verificationErrors, $this->getTraceFiles($e));
  72. }
  73. try
  74. {
  75. $this->assertTrue($this->isElementPresent("//a[@href='index.php?option=com_search']"), 'Search should be visible');
  76. }
  77. catch (PHPUnit_Framework_AssertionFailedError $e)
  78. {
  79. array_push($this->verificationErrors, $this->getTraceFiles($e));
  80. }
  81. try
  82. {
  83. $this->assertTrue($this->isElementPresent("//ul[@id='menu-com-weblinks']"), 'Weblinks should be visible');
  84. }
  85. catch (PHPUnit_Framework_AssertionFailedError $e)
  86. {
  87. array_push($this->verificationErrors, $this->getTraceFiles($e));
  88. }
  89. try
  90. {
  91. $this->assertTrue($this->isElementPresent("//a[@href='index.php?option=com_redirect']"), 'Redirect should be visible');
  92. }
  93. catch (PHPUnit_Framework_AssertionFailedError $e)
  94. {
  95. array_push($this->verificationErrors, $this->getTraceFiles($e));
  96. }
  97. try
  98. {
  99. $this->assertTrue($this->isElementPresent("//a[@href='index.php?option=com_installer']"), 'Extensions should be visible');
  100. }
  101. catch (PHPUnit_Framework_AssertionFailedError $e)
  102. {
  103. array_push($this->verificationErrors, $this->getTraceFiles($e));
  104. }
  105. try
  106. {
  107. $this->assertTrue($this->isElementPresent("//ul[@id='menu-com-menus-menus']"), 'Menu Manager should not be visible');
  108. }
  109. catch (PHPUnit_Framework_AssertionFailedError $e)
  110. {
  111. array_push($this->verificationErrors, $this->getTraceFiles($e));
  112. }
  113. try
  114. {
  115. $this->assertTrue($this->isElementPresent("//a[@href='index.php?option=com_modules']"), 'Module Manager should not be visible');
  116. }
  117. catch (PHPUnit_Framework_AssertionFailedError $e)
  118. {
  119. array_push($this->verificationErrors, $this->getTraceFiles($e));
  120. }
  121. $saltGroup = mt_rand();
  122. $groupName = 'Test Administrator Group'.$saltGroup;
  123. $groupParent = 'Registered';
  124. $this->createGroup($groupName, $groupParent);
  125. $levelName = 'Special';
  126. $this->changeAccessLevel($levelName,$groupName);
  127. echo "Change " . $groupName . " article permissions.\n";
  128. echo "Grant allow for all actions in article manager\n";
  129. $actions = array('Configure', 'Access Component', 'Create', 'Delete', 'Edit', 'Edit State');
  130. $permissions = array('Allowed', 'Allowed', 'Allowed', 'Allowed', 'Allowed', 'Allowed');
  131. $this->setPermissions('Article Manager', $groupName, $actions, $permissions);
  132. sleep(3); // Needed for google chrome
  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. }