Skip to content
This repository was archived by the owner on Mar 17, 2020. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
<?php
/**
* @package Joomla.Test
* @subpackage AcceptanceTester.Page
*
* @copyright Copyright (C) 2005 - 2016 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/

namespace Page\Acceptance\Administrator;

/**
* Acceptance Page object class to define menu item manager page objects.
*
* @package Page\Acceptance\Administrator
*
* @since __DEPLOY_VERSION__
*/
class MenuItemManagerPage extends AdminPage
{
/**
* Link to the menu item listing url.
*
* @var string
* @since __DEPLOY_VERSION__
*/
public static $url = 'administrator/index.php?option=com_menus&view=items';

/**
* Locator for invalid category alert
*
* @var array
* @since __DEPLOY_VERSION__
*/
public static $invalidTitle = ['class' => 'alert-error'];

/**
* Locator for Menu Item unpublished icon
*
* @var array
* @since __DEPLOY_VERSION__
*/
public static $seeUnpublished = ['xpath' => "//table[@id='itemList']//*//span[@class='icon-unpublish']"];

/**
* Locator for menu Item language field
*
* @var array
* @since __DEPLOY_VERSION__
*/
public static $seeLanguage = ['xpath' => "//table[@id='itemList']//tr[1]//td[10]"];

public function selectMenuItemType($menuCategory, $menuItem)
{

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any reason for this many free lines? ;)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@yvesh I need to commit changes, will correct it in the next commit :)


// Open the category
$I->wait(1);
$I->waitForElement(['link' => $menuCategory], '60');
$I->click(['link' => $menuCategory]);

$I->comment("Choose the menu item type: $menuItem");
$I->wait(1);
$I->waitForElement(['xpath' => "//a[contains(text()[normalize-space()], '$menuItem')]"], '60');
$I->click(['xpath' => "//div[@id='collapseTypes']//a[contains(text()[normalize-space()], '$menuItem')]"]);
$I->comment('I switch back to the main window');
}

public function selectTypeAndMenu($type, $menu){

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CodeStyle my friend ;)

$I = $this;

$I->comment("Open the menu types iframe");
$I->click(['link' => "Select"]);
$I->waitForElement(['id' => 'menuTypeModal'], '60');
$I->wait(1);
$I->switchToIFrame("Menu Item Type");

$I->comment("Open the menu category: $type");


}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
class MenuManagerPage extends AdminPage
{
/**
* Link to the article category listing url.
* Link to the menu listing url.
*
* @var string
* @since __DEPLOY_VERSION__
Expand Down Expand Up @@ -59,6 +59,14 @@ class MenuManagerPage extends AdminPage
*/
public static $article = ['link' => 'Article'];

/**
* Locator for category unpublished icon
*
* @var array
* @since __DEPLOY_VERSION__
*/
public static $seeUnpublished = ['xpath' => "//table[@id='categoryList']//*//span[@class='icon-unpublish']"];

/**
* This method is to set page object to choose an article dynamically.
*
Expand Down
11 changes: 11 additions & 0 deletions tests/codeception/_support/Step/Acceptance/Administrator/Admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
use Page\Acceptance\Administrator\ArticleManagerPage;
use Page\Acceptance\Administrator\CategoryManagerPage;
use Page\Acceptance\Administrator\ExtensionManagerPage;
use Page\Acceptance\Administrator\MenuItemManagerPage;
use Page\Acceptance\Administrator\MenuManagerPage;
use Page\Acceptance\Administrator\UserAclPage;
use Page\Acceptance\Administrator\UserGroupPage;
Expand Down Expand Up @@ -91,6 +92,15 @@ class Admin extends \AcceptanceTester
*/
protected $menuManagerPage = null;

/**
* Menu Item Manager Page Object for this class
*
* @var null|MenuItemManagerPage
*
* @since __DEPLOY_VERSION__
*/
protected $menuItemManagerPage = null;

/**
* User constructor.
*
Expand All @@ -111,6 +121,7 @@ public function __construct(Scenario $scenario)
$this->userAclPage = new UserAclPage($scenario);
$this->menuManagerPage = new MenuManagerPage($scenario);
$this->extensionManagerPage = new ExtensionManagerPage($scenario);
$this->menuItemManagerPage = new MenuItemManagerPage($scenario);
}

/**
Expand Down
219 changes: 219 additions & 0 deletions tests/codeception/_support/Step/Acceptance/Administrator/MenuItem.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,219 @@
<?php
/**
* @package Joomla.Test
* @subpackage AcceptanceTester.Step
*
* @copyright Copyright (C) 2005 - 2016 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/

namespace Step\Acceptance\Administrator;

use Page\Acceptance\Administrator\AdminPage;
use Page\Acceptance\Administrator\MenuItemManagerPage;
use Page\Acceptance\Administrator\MenuManagerPage;
use Behat\Gherkin\Node\TableNode;
use Page\Acceptance\Site\FrontPage;

/**
* Acceptance Step object class contains suits for Menu Manager.
*
* @package Step\Acceptance\Administrator
*
* @since __DEPLOY_VERSION__
*/
class MenuItem extends Admin
{

/**
* @When I check available tabs in menu item
*/
public function iCheckAvailableTabsInMenuItem()
{
$I = $this;

$I->adminPage->clickToolbarButton('New');
$I->waitForText('Menus: New Item');
}

/**
* @Then I see the available tabs :arg1, :arg2, :arg3, :arg4, :arg5
*/
public function iSeeTheAvailableTabs($arg1, $arg2, $arg3, $arg4, $arg5)
{
$I = $this;

$I->adminPage->verifyAvailableTabs([$arg1, $arg2, $arg3, $arg4, $arg5]);
}

/**
* @When I fill mandatory fields for creating menu item
*/
public function iFillMandatoryFieldsForCreatingMenuItem(TableNode $title)
{
$I = $this;

$I->adminPage->clickToolbarButton('New');

$totalRows = count($title->getRows());
$lastIndex = ($totalRows - 1);

// Iterate over all rows
foreach ($title->getRows() as $index => $row)
{
if ($index !== 0)
{
$I->fillField(MenuItemManagerPage::$title, $row[0]);

if ($index == $lastIndex)
{
$I->adminPage->clickToolbarButton('Save');
}
else
{
$I->adminPage->clickToolbarButton('Save & New');
}
}
}
}

/**
* @When I should see :arg1
*/
public function iShouldSee($menuItem)
{
$I = $this;

$I->menuItemManagerPage->seeItemIsCreated($menuItem);
}

/**
* @When I should see error :arg1
*/
public function iShouldSeeError($error)
{
$I = $this;

$I->see($error, MenuItemManagerPage::$invalidTitle);
}

/**
* @Given There is an menu item link
*/
public function thereIsAnMenuItemLink()
{
$I = $this;

$I->amOnPage(MenuItemManagerPage::$url);
$I->adminPage->clickToolbarButton('New');
}

/**
* @Given I have a menu item with title :arg1 which needs to be unpublished
*/
public function iHaveAMenuItemWithTitleWhichNeedsToBeUnpublished($title)
{
$this->menuItemManagerPage->haveItemUsingSearch($title);
}

/**
* @When I unpublish the menu item
*/
public function iUnpublishTheMenuItem()
{
$I = $this;

$I->adminPage->clickToolbarButton('unpublish');
}

/**
* @Then I should see the menu item is now unpublished
*/
public function iShouldSeeTheMenuItemIsNowUnpublished()
{
$I = $this;

$I->seeNumberOfElements(MenuItemManagerPage::$seeUnpublished, 1);
}

/**
* @Given I have a menu item with title :arg1 which needs to be trash
*/
public function iHaveAMenuItemWithTitleWhichNeedsToBeTrash($title)
{
$this->menuItemManagerPage->haveItemUsingSearch($title); }

/**
* @When I trash the menu item
*/
public function iTrashTheMenuItem($title)
{
$this->menuItemManagerPage->haveItemUsingSearch($title);
}

/**
* @When I create new menu item without field title
*/
public function iCreateNewMenuItemWithoutFieldTitle()
{
$I = $this;

$I->amOnPage(MenuItemManagerPage::$url);
$I->adminPage->clickToolbarButton('New');

$I->waitForText('Menus: New Item');
$I->adminPage->clickToolbarButton('Save');
}

/**
* @When I choose menu item type :arg1 and Menu :arg2
*/
public function iChooseMenuItemTypeAndMenu($type, $menu)
{
$I = $this;

$I->menuItemManagerPage->selectTypeAndMenu($type, $menu);
}

/**
* @When I set the menu as :arg1
*/
public function iSetTheMenuAs($name)
{
$I = $this;

$I->adminPage->selectOptionInChosenById('jform_menutype', $name);
}

/**
* @When I go to joomla home page
*/
public function iGoToJoomlaHomePage()
{
$I = $this;

$I->amOnPage(FrontPage::$url);
}

/**
* @Then I should see the menu item language as :arg1
*/
public function iShouldSeeTheMenuItemLanguageAs($title)
{
$I = $this;

$I->amOnPage(MenuItemManagerPage::$url);
$I->see($title, MenuItemManagerPage::$seeLanguage);
}

/**
* @When I search and select menu Item with title :arg1
*/
public function iSearchAndSelectMenuItemWithTitle($title)
{
$I = $this;

$I->menuItemManagerPage->haveItemUsingSearch($title);
$I->adminPage->clickToolbarButton('edit');
}
}
Loading