/tests/system/suite/menus/menu0002Test.php

https://github.com/mathc/joomla-cms · PHP · 227 lines · 186 code · 32 blank · 9 comment · 18 complexity · e98e590f2171c2a5c60583a87dbc69f4 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 Menu0002 extends SeleniumJoomlaTestCase
  11. {
  12. public function testSelectTypeWithoutSave()
  13. {
  14. // get logged in
  15. $this->setUp();
  16. $this->gotoAdmin();
  17. echo "starting testSelectTypeWithoutSave\n";
  18. $this->doAdminLogin();
  19. echo "Add new menu item to User Menu\n";
  20. $this->click("link=User Menu");
  21. $this->waitForPageToLoad("30000");
  22. $this->click("//li[@id='toolbar-new']/a/span");
  23. $this->waitForPageToLoad("30000");
  24. echo "Enter the Title\n";
  25. $this->type("jform_title", "Test Menu Item");
  26. echo "Select the menu item type\n";
  27. $this->click("//input[@value='Select']");
  28. for ($second = 0;; $second++)
  29. {
  30. if ($second >= 15) $this->fail("timeout");
  31. try
  32. {
  33. if ($this->isElementPresent("//div[@id='sbox-content']")) break;
  34. }
  35. catch (Exception $e)
  36. {
  37. }
  38. sleep(1);
  39. }
  40. echo "Select External URL\n";
  41. $this->click("Link=External URL");
  42. $this->waitForPageToLoad("60000");
  43. echo "Check that name is still there\n";
  44. $this->assertEquals("Test Menu Item", $this->getValue("jform_title"));
  45. echo "Save the menu item\n";
  46. $this->click("//li[@id='toolbar-apply']/a/span");
  47. $this->waitForPageToLoad("30000");
  48. echo "Change the title\n";
  49. $this->type("jform_title", "Test Menu Item - Edit");
  50. echo "Change the menu item type\n";
  51. $this->click("//input[@value='Select']");
  52. for ($second = 0;; $second++)
  53. {
  54. if ($second >= 15) $this->fail("timeout");
  55. try
  56. {
  57. if ($this->isElementPresent("//div[@id='sbox-content']")) break;
  58. }
  59. catch (Exception $e)
  60. {
  61. }
  62. sleep(1);
  63. }
  64. $this->click("Link=Menu Item Alias");
  65. $this->waitForPageToLoad("60000");
  66. echo "Check that new name is still there\n";
  67. $this->assertEquals("Test Menu Item - Edit", $this->getValue("jform_title"));
  68. echo "Change the title again\n";
  69. $this->type("jform_title", "Test Menu Item - Edit Again");
  70. $this->click("//input[@value='Select']");
  71. for ($second = 0;; $second++)
  72. {
  73. if ($second >= 15) $this->fail("timeout");
  74. try
  75. {
  76. if ($this->isElementPresent("//div[@id='sbox-content']")) break;
  77. }
  78. catch (Exception $e)
  79. {
  80. }
  81. sleep(1);
  82. }
  83. $this->click("Link=Text Separator");
  84. $this->waitForPageToLoad("30000");
  85. $this->assertEquals("Test Menu Item - Edit Again", $this->getValue("jform_title"));
  86. $this->click("//li[@id='toolbar-cancel']/a/span");
  87. $this->waitForPageToLoad("30000");
  88. $this->type("filter_search", "Test Menu Item");
  89. $this->click("//button[@type='submit']");
  90. $this->waitForPageToLoad("30000");
  91. $this->click("//button[@type='submit']");
  92. $this->waitForPageToLoad("30000");
  93. $this->click("cb0");
  94. $this->click("//li[@id='toolbar-trash']/a/span");
  95. $this->waitForPageToLoad("30000");
  96. $this->select("filter_published", "label=Trashed");
  97. $this->waitForPageToLoad("30000");
  98. $this->click("cb0");
  99. $this->click("//li[@id='toolbar-delete']/a/span");
  100. $this->waitForPageToLoad("30000");
  101. $this->doAdminLogout();
  102. echo "finishing testSelectTypeWithoutSave\n";
  103. $this->deleteAllVisibleCookies();
  104. }
  105. public function testSelectAndSave()
  106. {
  107. // get logged in
  108. echo "starting testSelectAndSave\n";
  109. $this->setUp();
  110. $this->gotoAdmin();
  111. $this->doAdminLogin();
  112. echo "Add new menu item to User Menu\n";
  113. $this->click("link=User Menu");
  114. $this->waitForPageToLoad("30000");
  115. $this->click("//li[@id='toolbar-new']/a/span");
  116. $this->waitForPageToLoad("30000");
  117. $saltGroup = mt_rand();
  118. $this->type("jform_title", "Test Menu Item" . $saltGroup);
  119. $this->click("//input[@value='Select']");
  120. for ($second = 0;; $second++)
  121. {
  122. if ($second >= 15) $this->fail("timeout");
  123. try
  124. {
  125. if ($this->isElementPresent("//div[@id='sbox-content']")) break;
  126. }
  127. catch (Exception $e)
  128. {
  129. }
  130. sleep(1);
  131. }
  132. echo "Select a menu item type\n";
  133. $this->click("link=List All News Feed Categories");
  134. $this->waitForPageToLoad("60000");
  135. echo "Make sure our changes were kept\n";
  136. $this->assertEquals("Test Menu Item" . $saltGroup, $this->getValue("jform_title"), 'Our title edits were not retained.');
  137. $this->click("//li[@id='toolbar-apply']/a/span");
  138. $this->waitForPageToLoad("30000");
  139. echo "Edit the title again and select a different type\n";
  140. $this->type("jform_title", "Test Menu Item - Edit");
  141. $this->click("//input[@value='Select']");
  142. for ($second = 0;; $second++)
  143. {
  144. if ($second >= 15) $this->fail("timeout");
  145. try
  146. {
  147. if ($this->isElementPresent("//div[@id='sbox-content']")) break;
  148. }
  149. catch (Exception $e)
  150. {
  151. }
  152. sleep(1);
  153. }
  154. $this->click("Link=Single Contact");
  155. $this->waitForPageToLoad("30000");
  156. $this->assertEquals("Test Menu Item - Edit", $this->getValue("jform_title"), 'Our title edits were not retained.');
  157. $this->type("jform_title", "Test Menu Item - Edit Again");
  158. $this->click("//input[@value='Select']");
  159. for ($second = 0;; $second++)
  160. {
  161. if ($second >= 15) $this->fail("timeout");
  162. try
  163. {
  164. if ($this->isElementPresent("//div[@id='sbox-content']")) break;
  165. }
  166. catch (Exception $e)
  167. {
  168. }
  169. sleep(1);
  170. }
  171. $this->click("link=External URL");
  172. $this->waitForPageToLoad("30000");
  173. $this->assertEquals("Test Menu Item - Edit Again", $this->getValue("jform_title"), 'Our title edits were not retained.');
  174. $this->click("//li[@id='toolbar-cancel']/a/span");
  175. $this->waitForPageToLoad("30000");
  176. echo "Clean up - we trash and delete our item and then log out\n";
  177. $this->type("filter_search", "Test Menu Item" . $saltGroup);
  178. $this->click("//button[@type='submit']");
  179. $this->waitForPageToLoad("30000");
  180. $this->click("//button[@type='submit']");
  181. $this->waitForPageToLoad("30000");
  182. $this->click("cb0");
  183. $this->click("//li[@id='toolbar-trash']/a/span");
  184. $this->waitForPageToLoad("30000");
  185. $this->select("filter_published", "label=Trashed");
  186. $this->waitForPageToLoad("30000");
  187. $this->click("cb0");
  188. $this->click("//li[@id='toolbar-delete']/a/span");
  189. $this->waitForPageToLoad("30000");
  190. $this->gotoAdmin();
  191. $this->doAdminLogout();
  192. echo "finishing testSelectAndSave\n";
  193. $this->deleteAllVisibleCookies();
  194. }
  195. }