Skip to content

Commit 1bbb7b9

Browse files
authored
Merge pull request #142 from yvesh/createcategory
Added method to create a new category (com_categories)
2 parents 7b1e25f + a75f773 commit 1bbb7b9

File tree

2 files changed

+59
-1
lines changed

2 files changed

+59
-1
lines changed

src/JoomlaBrowser.php

Lines changed: 43 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ class JoomlaBrowser extends WebDriver
4646
/**
4747
* The locator
4848
*
49-
* @var Codeception\Module\Locators\Locators
49+
* @var Locators
5050
* @since 3.7.4.2
5151
*/
5252
protected $locator;
@@ -1103,4 +1103,46 @@ public function disableStatistics()
11031103
$this->waitForElement(['link' => 'Never'], TIMEOUT);
11041104
$this->click(['link' => 'Never']);
11051105
}
1106+
1107+
/**
1108+
* Create a new category
1109+
*
1110+
* @param string $title Title of the new category
1111+
* @param string $extension Optional extension to use
1112+
*
1113+
* @return void
1114+
*
1115+
* @since 3.7.5
1116+
*/
1117+
public function createCategory($title, $extension = '')
1118+
{
1119+
$this->debug('Category creation in /administrator/');
1120+
$this->doAdministratorLogin();
1121+
1122+
if (!empty($extension))
1123+
{
1124+
$extension = '&extension=' . $extension;
1125+
}
1126+
1127+
$this->amOnPage('administrator/index.php?option=com_categories' . $extension);
1128+
1129+
$this->waitForElement(['class' => 'page-title']);
1130+
$this->checkForPhpNoticesOrWarnings();
1131+
1132+
$this->debug('Click new category button');
1133+
$this->click($this->locator->adminToolbarButtonNew);
1134+
1135+
$this->waitForElement(['class' => 'page-title']);
1136+
1137+
$this->checkForPhpNoticesOrWarnings();
1138+
$this->fillField(['id' => 'jform_title'], $title);
1139+
1140+
$this->debug('Click new category apply button');
1141+
$this->click($this->locator->adminToolbarButtonApply);
1142+
1143+
$this->debug('see a success message after saving the category');
1144+
1145+
$this->see('Category saved', ['id' => 'system-message-container']);
1146+
$this->checkForPhpNoticesOrWarnings();
1147+
}
11061148
}

src/Locators/Locators.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,4 +105,20 @@ class Locators
105105
* @since 3.7.4.2
106106
*/
107107
public $frontEndLoginUrl = '/index.php?option=com_users&view=login';
108+
109+
/**
110+
* New Button in the Admin toolbar
111+
*
112+
* @var array
113+
* @since 3.7.5
114+
*/
115+
public $adminToolbarButtonNew = ['class' => 'button-new'];
116+
117+
/**
118+
* Apply Button in the Admin toolbar
119+
*
120+
* @var array
121+
* @since 3.7.5
122+
*/
123+
public $adminToolbarButtonApply = ['class' => 'button-apply'];
108124
}

0 commit comments

Comments
 (0)