Skip to content

Commit ccb4168

Browse files
committed
Added test for Tag Manager. Thanks Puneet Kala.
1 parent 98a690a commit ccb4168

File tree

6 files changed

+278
-1
lines changed

6 files changed

+278
-1
lines changed

tests/CHANGELOG

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ $ -> Language fix or change
2828

2929
2-May-2013 Mark Dexter
3030
# Fix up doc blocks as example for Webdriver page classes and tests.
31+
# Added test for Tag Manager. Thanks Puneet Kala.
3132

3233
30-Apr-2013 Mark Dexter
3334
# Fix system tests for clearfix class in front end
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
<?php
2+
3+
use SeleniumClient\By;
4+
use SeleniumClient\SelectElement;
5+
use SeleniumClient\WebDriver;
6+
use SeleniumClient\WebDriverWait;
7+
use SeleniumClient\DesiredCapabilities;
8+
use SeleniumClient\WebElement;
9+
10+
/**
11+
* @package Joomla.Test
12+
* @subpackage Webdriver
13+
*
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
24+
*/
25+
class TagEditPage extends AdminEditPage
26+
{
27+
/**
28+
* XPath string used to uniquely identify this page
29+
*
30+
* @var string
31+
* @since 3.0
32+
*/
33+
protected $waitForXpath = "//form[@id='item-form']";
34+
35+
/**
36+
* URL used to uniquely identify this page
37+
*
38+
* @var string
39+
* @since 3.0
40+
*/
41+
protected $url = 'administrator/index.php?option=com_tags&view=tag&layout=edit';
42+
43+
/**
44+
* Array of tabs present on this page
45+
*
46+
* @var array
47+
* @since 3.0
48+
*/
49+
public $tabs = array('general', 'publishing', 'metadata');
50+
51+
/**
52+
* Array of tab labels for this page
53+
*
54+
* @var array
55+
* @since 3.0
56+
*/
57+
public $tabLabels = array('Tag Details', 'Publishing Options', 'Metadata Options');
58+
59+
/**
60+
* Array of all the field Details of the Edit page, along with the ID and tab value they are present on
61+
*
62+
* @var array
63+
* @since 3.0
64+
*/
65+
public $inputFields = array (
66+
array('label' => 'Title', 'id' => 'jform_title', 'type' => 'input', 'tab' => 'general'),
67+
array('label' => 'Status', 'id' => 'jform_published', 'type' => 'select', 'tab' => 'general'),
68+
array('label' => 'Access', 'id' => 'jform_access', 'type' => 'select', 'tab' => 'general'),
69+
array('label' => 'Language', 'id' => 'jform_language', 'type' => 'select', 'tab' => 'general'),
70+
array('label' => 'Float', 'id' => 'jform_images_float_fulltext', 'type' => 'select', 'tab' => 'general'),
71+
array('label' => 'Alt', 'id' => 'jform_images_image_fulltext_alt', 'type' => 'input', 'tab' => 'general'),
72+
array('label' => 'Caption', 'id' => 'jform_images_image_fulltext_caption', 'type' => 'input', 'tab' => 'general'),
73+
);
74+
75+
}
76+
Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
<?php
2+
3+
use SeleniumClient\By;
4+
use SeleniumClient\SelectElement;
5+
use SeleniumClient\WebDriver;
6+
use SeleniumClient\WebDriverWait;
7+
use SeleniumClient\DesiredCapabilities;
8+
use SeleniumClient\WebElement;
9+
10+
/**
11+
* @package Joomla.Test
12+
* @subpackage Webdriver
13+
*
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 component tags menu.
20+
*
21+
* @package Joomla.Test
22+
* @subpackage Webdriver
23+
* @since 3.0
24+
*/
25+
class TagManagerPage extends AdminManagerPage
26+
{
27+
/**
28+
* XPath string used to uniquely identify this page
29+
*
30+
* @var string
31+
* @since 3.0
32+
*/
33+
protected $waitForXpath = "//ul/li/a[@href='index.php?option=com_tags']";
34+
35+
/**
36+
* URL used to uniquely identify this page
37+
*
38+
* @var string
39+
* @since 3.0
40+
*/
41+
protected $url = 'administrator/index.php?option=com_tags';
42+
43+
/**
44+
* Array of filter id values for this page
45+
*
46+
* @var array
47+
* @since 3.0
48+
*/
49+
public $filters = array(
50+
'Select Status' => 'filter_published',
51+
'Select Access' => 'filter_access',
52+
'Select Language' => 'filter_language',
53+
);
54+
55+
/**
56+
* Array of toolbar id values for this page
57+
*
58+
* @var array
59+
* @since 3.0
60+
*/
61+
public $toolbar = array (
62+
'New' => 'toolbar-new',
63+
'Edit' => 'toolbar-edit',
64+
'Publish' => 'toolbar-publish',
65+
'Unpublish' => 'toolbar-unpublish',
66+
'Archive' => 'toolbar-archive',
67+
'Check In' => 'toolbar-check-in',
68+
'Trash' => 'toolbar-trash',
69+
'Empty Trash' => 'toolbar-delete',
70+
'Batch' => 'toolbar-batch',
71+
'Options' => 'toolbar-options',
72+
'Help' => 'toolbar-help',
73+
);
74+
75+
/**
76+
* Add a new Tag item in the Tag Manager: Component screen.
77+
*
78+
* @param string $title Test Tag Name
79+
*
80+
*
81+
* @return TagManagerPage
82+
*/
83+
public function addTag($name='Test Tag')
84+
{
85+
$new_name = $name . rand(1,100);
86+
$login = "testing";
87+
//echo $new_name;
88+
$this->clickButton('toolbar-new');
89+
$tagEditPage = $this->test->getPageObject('TagEditPage');
90+
$tagEditPage->setFieldValues(array('Title' => $new_name));
91+
$tagEditPage->clickButton('toolbar-save');
92+
$this->test->getPageObject('TagManagerPage');
93+
}
94+
95+
/**
96+
* Edit a Tag item in the Tag Manager: Tag Items screen.
97+
*
98+
* @param string $name Tag Title field
99+
* @param array $fields associative array of fields in the form label => value.
100+
*
101+
* @return void
102+
*/
103+
public function editTag($name, $fields)
104+
{
105+
$this->clickItem($name);
106+
$tagEditPage = $this->test->getPageObject('TagEditPage');
107+
$tagEditPage->setFieldValues($fields);
108+
$tagEditPage->clickButton('toolbar-save');
109+
$this->test->getPageObject('TagManagerPage');
110+
$this->searchFor();
111+
}
112+
113+
114+
}

tests/system/webdriver/Pages/System/AdminPage.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,7 @@ abstract class AdminPage
140140
'Security Center' => 'http://developer.joomla.org/security.html',
141141
'Developer Resources' => 'http://developer.joomla.org/',
142142
'Joomla Shop' => 'http://shop.joomla.org/',
143+
'Tags' => 'administrator/index.php?option=com_tags',
143144
);
144145

145146

@@ -327,4 +328,4 @@ public function saveAndClose($returnPage = 'GenericAdminPage')
327328
return $this->test->getPageObject($returnPage);
328329
}
329330

330-
}
331+
}
Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
<?php
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+
*/
9+
require_once 'JoomlaWebdriverTestCase.php';
10+
11+
use SeleniumClient\By;
12+
use SeleniumClient\SelectElement;
13+
use SeleniumClient\WebDriver;
14+
use SeleniumClient\WebDriverWait;
15+
use SeleniumClient\DesiredCapabilities;
16+
17+
/**
18+
* This class tests the Tags: Add / Edit Screen.
19+
*
20+
* @package Joomla.Test
21+
* @subpackage Webdriver
22+
* @since 3.0
23+
*/
24+
class TagManager0001Test extends JoomlaWebdriverTestCase
25+
{
26+
/**
27+
* The page class being tested.
28+
*
29+
* @var TagManagerPage
30+
* @since 3.0
31+
*/
32+
protected $tagManagerPage = null;
33+
34+
/**
35+
* Login to back end and navigate to menu Tags.
36+
*
37+
* @since 3.0
38+
*/
39+
public function setUp()
40+
{
41+
parent::setUp();
42+
$cpPage = $this->doAdminLogin();
43+
$this->tagManagerPage = $cpPage->clickMenu('Tags', 'TagManagerPage');
44+
}
45+
46+
/**
47+
* Logout and close test.
48+
*
49+
* @since 3.0
50+
*/
51+
public function tearDown()
52+
{
53+
$this->doAdminLogout();
54+
parent::tearDown();
55+
}
56+
57+
/**
58+
* @test
59+
*/
60+
public function constructor_OpenEditScreen_TagEditOpened()
61+
{
62+
$this->tagManagerPage->clickButton('new');
63+
$tagEditPage = $this->getPageObject('TagEditPage');
64+
$tagEditPage->clickButton('cancel');
65+
$this->tagManagerPage = $this->getPageObject('TagManagerPage');
66+
}
67+
68+
/**
69+
* @test
70+
*/
71+
public function addTag_WithGivenFields_TagAdded()
72+
{
73+
$salt = rand();
74+
$tagName = 'Tag' . $salt;
75+
$this->assertFalse($this->tagManagerPage->getRowNumber($tagName), 'Test Tag should not be present');
76+
$this->tagManagerPage->addTag($tagName);
77+
$message = $this->tagManagerPage->getAlertMessage();
78+
$this->assertTrue(strpos($message, 'Tag successfully saved') >= 0, 'Tag save should return success');
79+
$this->assertEquals(1, $this->tagManagerPage->getRowNumber($tagName), 'Test Tag should be in row 2');
80+
$this->tagManagerPage->deleteItem($tagName);
81+
$this->assertFalse($this->tagManagerPage->getRowNumber($tagName), 'Test Tag should not be present');
82+
}
83+
84+
}

tests/system/webdriver/tests/phpunit.xml.dist

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
<directory>extensions</directory>
88
<directory>menus</directory>
99
<directory>users</directory>
10+
<directory>components</directory>
1011
</testsuite>
1112
</testsuites>
1213
<logging>

0 commit comments

Comments
 (0)