Skip to content

Commit 98a690a

Browse files
committed
Fix up doc blocks as example for Webdriver page classes and tests.
1 parent a0385e4 commit 98a690a

File tree

3 files changed

+82
-10
lines changed

3 files changed

+82
-10
lines changed

tests/CHANGELOG

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@ $ -> Language fix or change
2626
- -> Removed
2727
! -> Note
2828

29+
2-May-2013 Mark Dexter
30+
# Fix up doc blocks as example for Webdriver page classes and tests.
31+
2932
30-Apr-2013 Mark Dexter
3033
# Fix system tests for clearfix class in front end
3134

tests/system/webdriver/Pages/Menus/MenuItemsManagerPage.php

Lines changed: 53 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,44 @@
88
use SeleniumClient\WebElement;
99

1010
/**
11-
* Class for the back-end control panel screen.
11+
* @package Joomla.Test
12+
* @subpackage Webdriver
1213
*
14+
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
15+
* @license GNU General Public License version 2 or later; see LICENSE
16+
*/
17+
18+
/**
19+
* Page class for the back-end menu items manager screen.
20+
*
21+
* @package Joomla.Test
22+
* @subpackage Webdriver
23+
* @since 3.0
1324
*/
1425
class MenuItemsManagerPage extends AdminManagerPage
1526
{
27+
/**
28+
* XPath string used to uniquely identify this page
29+
*
30+
* @var string
31+
* @since 3.0
32+
*/
1633
protected $waitForXpath = "//ul/li/a[@href='index.php?option=com_menus&view=items']";
34+
35+
/**
36+
* URL used to uniquely identify this page
37+
*
38+
* @var string
39+
* @since 3.0
40+
*/
1741
protected $url = 'administrator/index.php?option=com_menus&view=items';
1842

43+
/**
44+
* Array of filter id values for this page
45+
*
46+
* @var array
47+
* @since 3.0
48+
*/
1949
public $filters = array(
2050
'Menu' => 'menutype',
2151
'Max Levels' => 'filter_level',
@@ -24,6 +54,12 @@ class MenuItemsManagerPage extends AdminManagerPage
2454
'Language' => 'filter_language',
2555
);
2656

57+
/**
58+
* Array of toolbar id values for this page
59+
*
60+
* @var array
61+
* @since 3.0
62+
*/
2763
public $toolbar = array (
2864
'New' => 'toolbar-new',
2965
'Edit' => 'toolbar-edit',
@@ -38,23 +74,29 @@ class MenuItemsManagerPage extends AdminManagerPage
3874
'Help' => 'toolbar-help',
3975
);
4076

77+
/**
78+
* Array of submenu links used for this page
79+
*
80+
* @var array
81+
* @since 3.0
82+
*/
4183
public $submenu = array (
4284
'option=com_menus&view=menus',
4385
);
4486

4587
/**
4688
* Add a new menu item in the Menu Manager: Menu Items screen.
4789
*
48-
* @param string $menuItemType One of the allowed Menu Item Types (Single Article, Featured Contacts, etc.)
4990
* @param string $title Menu Title field
91+
* @param string $menuItemType One of the allowed Menu Item Types (Single Article, Featured Contacts, etc.)
5092
* @param string $menuLocation Menu Location field
5193
* @param array $otherFields associative array of other fields in the form label => value.
5294
*
5395
* Note that there a special field types for the request variable (e.g., article name or category name) which is required by some menu types.
5496
* This can be designated in the $otherFields with any of the following labels: 'request', 'category', 'article', 'contact', 'newsfeed', 'weblink'.
5597
* For example: array('article' => 'Australian Parks').
5698
*
57-
* @return MenuItmesManagerPage
99+
* @return MenuItemsManagerPage
58100
*/
59101
public function addMenuItem($title='Test Menu Item', $menuItemType='List All Categories', $menuLocation = 'Main Menu', array $otherFields = array())
60102
{
@@ -75,7 +117,14 @@ public function addMenuItem($title='Test Menu Item', $menuItemType='List All Cat
75117
return $this->test->getPageObject('MenuItemsManagerPage');
76118
}
77119

78-
120+
/**
121+
* Edit a menu item in the Menu Manager: Menu Items screen.
122+
*
123+
* @param string $title Menu Title field
124+
* @param array $fields associative array of fields in the form label => value.
125+
*
126+
* @return void
127+
*/
79128
public function editMenuItem($title, $fields)
80129
{
81130
$this->clickItem($title);

tests/system/webdriver/tests/menus/MenuItemsManager0001Test.php

Lines changed: 26 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
<?php
2-
2+
/**
3+
* @package Joomla.Test
4+
* @subpackage Webdriver
5+
*
6+
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
7+
* @license GNU General Public License version 2 or later; see LICENSE
8+
*/
39
require_once 'JoomlaWebdriverTestCase.php';
410

511
use SeleniumClient\By;
@@ -9,25 +15,39 @@
915
use SeleniumClient\DesiredCapabilities;
1016

1117
/**
12-
* This class tests the Manager: Add / Edit Screen
13-
* @author Mark
18+
* This class tests the Manager: Add / Edit Screen.
1419
*
20+
* @package Joomla.Test
21+
* @subpackage Webdriver
22+
* @since 3.0
1523
*/
1624
class MenuItemsManager0001Test extends JoomlaWebdriverTestCase
1725
{
1826
/**
27+
* The page class being tested.
1928
*
20-
* @var MenuItemsManagerPage
29+
* @var MenuItemsManagerPage
30+
* @since 3.0
2131
*/
2232
protected $menuItemsManagerPage = null; // Global configuration page
2333

34+
/**
35+
* Login to back end and navigate to menu item manager.
36+
*
37+
* @since 3.0
38+
*/
2439
public function setUp()
2540
{
2641
parent::setUp();
2742
$cpPage = $this->doAdminLogin();
2843
$this->menuItemsManagerPage = $cpPage->clickMenu('Main Menu', 'MenuItemsManagerPage');
2944
}
3045

46+
/**
47+
* Logout and close test.
48+
*
49+
* @since 3.0
50+
*/
3151
public function tearDown()
3252
{
3353
$this->doAdminLogout();
@@ -40,10 +60,9 @@ public function tearDown()
4060
public function constructor_OpenEditScreen_MenuEditOpened()
4161
{
4262
$this->menuItemsManagerPage->clickButton('toolbar-new');
43-
44-
/* @var $menuItemEditPage MenuItemEditPage */
4563
$menuItemEditPage = $this->getPageObject('MenuItemEditPage');
4664
$tabIds = $menuItemEditPage->getTabIds();
65+
// Keep the following line commented to make it easy to generate values for arrays as fields change.
4766
// $menuItemEditPage->printFieldArray($menuItemEditPage->getAllInputFields($tabIds));
4867
$menuItemEditPage->clickButton('toolbar-cancel');
4968
$this->menuItemsManagerPage = $this->getPageObject('MenuItemsManagerPage');
@@ -77,6 +96,7 @@ public function getMenuItemTypes_ShouldMatchExpected()
7796
$this->menuItemsManagerPage->clickButton('toolbar-new');
7897
$menuItemEditPage = $this->getPageObject('MenuItemEditPage');
7998
$actualMenuItemTypes = $menuItemEditPage->getMenuItemTypes();
99+
// Keep the following lines commented. They make it easy to re-generate the array of menu types as more are added.
80100
// foreach ($actualMenuItemTypes as $array)
81101
// {
82102
// echo "array('group' => '" . $array['group'] . "', 'type' => '" . $array['type'] . "' ),\n";

0 commit comments

Comments
 (0)