From 77fe304bef31de2c6a458e226b57ce3577380544 Mon Sep 17 00:00:00 2001 From: javier gomez Date: Wed, 12 Aug 2015 17:54:05 +0200 Subject: [PATCH 1/2] Add Publish module on all Pages function --- src/JoomlaBrowser.php | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/src/JoomlaBrowser.php b/src/JoomlaBrowser.php index e1b0acc..4d139ca 100644 --- a/src/JoomlaBrowser.php +++ b/src/JoomlaBrowser.php @@ -571,4 +571,28 @@ private function searchResultLanguageName($languageName) return $xpath; } + + /** + * Publishes a module on all frontend pages + * + * @param string $module The name of the module + * @param string $position The template position where to publish the module. Right position by default + */ + public function publishModuleOnAllPages($module, $position = 'position-7') + { + $I = $this; + $I->amOnPage('administrator/index.php?option=com_modules'); + $I->searchForItem($module); + $I->checkAllResults(); + $I->click(['xpath' => "//div[@id='toolbar-publish']/button"]); + $I->waitForText('1 module successfully published.',30,['id' => 'system-message-container']); + $I->click(['link' => $module]); + $I->selectOptionInChosen('Position', $position); + $I->click(['link' => 'Menu Assignment']); + $I->waitForElement(['id' => 'jform_menus-lbl'], 30); + $I->click(['id' => 'jform_assignment_chzn']); + $I->click(['xpath' => "//li[@data-option-array-index='0']"]); + $I->click(['xpath' => "//div[@id='toolbar-apply']/button"]); + $I->waitForText('Module successfully saved',30,['id' => 'system-message-container']); + } } From 5b0fecdd61e4c2f70e202bd05365a51614d4cbc9 Mon Sep 17 00:00:00 2001 From: javier gomez Date: Thu, 13 Aug 2015 11:11:18 +0200 Subject: [PATCH 2/2] Module operations divided by responsibilities I have broken in 3 individual functions the Publish module function --- src/JoomlaBrowser.php | 35 +++++++++++++++++++++++++++++++---- 1 file changed, 31 insertions(+), 4 deletions(-) diff --git a/src/JoomlaBrowser.php b/src/JoomlaBrowser.php index 4d139ca..1dfaa93 100644 --- a/src/JoomlaBrowser.php +++ b/src/JoomlaBrowser.php @@ -575,10 +575,26 @@ private function searchResultLanguageName($languageName) /** * Publishes a module on all frontend pages * - * @param string $module The name of the module - * @param string $position The template position where to publish the module. Right position by default + * @param string $module The full name of the module + * @param string $position The template position of a module. Right position by default */ - public function publishModuleOnAllPages($module, $position = 'position-7') + public function setModulePosition($module, $position = 'position-7') + { + $I = $this; + $I->amOnPage('administrator/index.php?option=com_modules'); + $I->searchForItem($module); + $I->click(['link' => $module]); + $I->selectOptionInChosen('Position', $position); + $I->click(['xpath' => "//div[@id='toolbar-apply']/button"]); + $I->waitForText('Module successfully saved',30,['id' => 'system-message-container']); + } + + /** + * Publishes a module on all frontend pages + * + * @param string $module The full name of the module + */ + public function publishModule($module) { $I = $this; $I->amOnPage('administrator/index.php?option=com_modules'); @@ -586,8 +602,19 @@ public function publishModuleOnAllPages($module, $position = 'position-7') $I->checkAllResults(); $I->click(['xpath' => "//div[@id='toolbar-publish']/button"]); $I->waitForText('1 module successfully published.',30,['id' => 'system-message-container']); + } + + /** + * Changes the module Menu assignment to be shown on all the pages of the website + * + * @param string $module The full name of the module + */ + public function displayModuleOnAllPages($module) + { + $I = $this; + $I->amOnPage('administrator/index.php?option=com_modules'); + $I->searchForItem($module); $I->click(['link' => $module]); - $I->selectOptionInChosen('Position', $position); $I->click(['link' => 'Menu Assignment']); $I->waitForElement(['id' => 'jform_menus-lbl'], 30); $I->click(['id' => 'jform_assignment_chzn']);