Skip to content
This repository was archived by the owner on Mar 17, 2020. It is now read-only.
Merged
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
9 changes: 9 additions & 0 deletions RoboFile.php
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,15 @@ public function runTests($opts = ['use-htaccess' => false, 'env' => 'desktop'])
->run()
->stopOnFail();

$this->taskCodecept($pathToCodeception)
->arg('--steps')
->arg('--debug')
->arg('--fail-fast')
->arg('--env ' . $opts['env'])
->arg('tests/acceptance/content.feature')
->run()
->stopOnFail();

$this->taskCodecept($pathToCodeception)
->arg('--steps')
->arg('--debug')
Expand Down
20 changes: 13 additions & 7 deletions tests/_support/AcceptanceHelper.php
Original file line number Diff line number Diff line change
@@ -1,22 +1,28 @@
<?php
namespace Codeception\Module;

use Codeception\Configuration;

// here you can define custom actions
// all public methods declared in helper class will be available in $I
class AcceptanceHelper extends \Codeception\Module
{
protected static $acceptanceSuiteConfiguration = [];

/**
* Function to getConfiguration from the YML and return in the test
* Function to get Configuration from the acceptance.suite.yml to be used by a test
*
* @param null $element
* @return array
*
* @return mixed
* @throws InvalidArgumentException
*/
public function getConfiguration($element = null)
public function getSuiteConfiguration()
{
if (is_null($element)) {
throw new InvalidArgumentException('empty value or non existing element was requested from configuration');
if (empty(self::$acceptanceSuiteConfiguration))
{
self::$acceptanceSuiteConfiguration = Configuration::suiteSettings('acceptance', Configuration::config());
}
return $this->config[$element];

return self::$acceptanceSuiteConfiguration;
}
}
8 changes: 3 additions & 5 deletions tests/_support/AcceptanceTester.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
<?php

use Page\Acceptance\Administrator\LoginPage;

use Page\Acceptance\Administrator\AdminPage;

/**
Expand Down Expand Up @@ -105,10 +103,10 @@ public function clickToolbarButton($button)
$I = $this;
$input = strtolower($button);

// @todo Needs to find way to work with different window size.
$screenSize = explode("x", $this->getConfiguration('window_size'));
$suiteConfiguration = $I->getSuiteConfiguration();
$screenWidth = explode("x", $suiteConfiguration['modules']['config']['JoomlaBrowser']['window_size']);

if ($screenSize[0] <= 480)
if ($screenWidth[0] <= 480)
{
$I->click('Toolbar');
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?php
namespace Page\Acceptance\Administrator;

use Page\Acceptance\Administrator\AdminPage;

class ArticleManagerPage extends AdminPage
{
public static $articleTitleField = ['id' => 'jform_title'];

public static $articleContentField = ['id' => 'jform_articletext'];

public static $toggleEditor = "Toggle editor";

public static $filterSearch = ['id' => 'filter_search'];

public static $iconSearch = ['class' => 'icon-search'];

public static $pageURL = "/administrator/index.php?option=com_content&view=articles";

}
172 changes: 172 additions & 0 deletions tests/_support/Step/Acceptance/Administrator/Content.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,172 @@
<?php
namespace Step\Acceptance\Administrator;

use Page\Acceptance\Administrator\AdminPage;
use Page\Acceptance\Administrator\ArticleManagerPage;

class Content extends \AcceptanceTester
{
/**
* @Given There is a add content link
*/
public function thereIsAAddContentLink()
{
$I = $this;
$I->amOnPage(ArticleManagerPage::$pageURL);
$I->clickToolbarButton('New');
}

/**
* @When I create new content with field title as :title and content as a :content
*/
public function iCreateNewContent($title, $content)
{
$I = $this;
$I->fillField(ArticleManagerPage::$articleTitleField, $title);
$I->click(ArticleManagerPage::$toggleEditor);
$I->fillField(ArticleManagerPage::$articleContentField, $content);
}

/**
* @When I save an article
*/
public function iSaveAnArticle()
{
$I = $this;
$I->clickToolbarButton('Save');
}

/**
* @Then I should see the :arg1 message
*/
public function iShouldSeeTheMessage($message)
{
$I = $this;
$I->waitForPageTitle('Articles');
$I->see($message, AdminPage::$systemMessageContainer);
}

/**
* @Given I search and select content article with title :arg1
*/
public function iSearchAndSelectContentArticleWithTitle($title)
{
$I = $this;
$I->amOnPage(ArticleManagerPage::$pageURL);
$I->fillField(ArticleManagerPage::$filterSearch, $title);
$I->click(ArticleManagerPage::$iconSearch);
$I->checkAllResults();
}

/**
* @When I featured the article
*/
public function iFeatureTheContentWithTitle()
{
$I = $this;
$I->clickToolbarButton('featured');
}

/**
* @Then I save and see the :arg1 message
*/
public function iSaveAndSeeTheMessage($message)
{
$I = $this;
$I->waitForPageTitle('Articles');
$I->see($message, AdminPage::$systemMessageContainer);
}

/**
* @Given I select the content article with title :arg1
*/
public function iSelectTheContentArticleWithTitle($title)
{
$I = $this;
$I->amOnPage(ArticleManagerPage::$pageURL);
$I->fillField(ArticleManagerPage::$filterSearch, $title);
$I->click(ArticleManagerPage::$iconSearch);
$I->checkAllResults();
$I->clickToolbarButton('edit');
}

/**
* @Given I set access level as a :arg1
*/
public function iSetAccessLevelAsA($accessLevel)
{
$I = $this;
$I->selectOptionInChosenById('jform_access', $accessLevel);
}

/**
* @When I save the article
*/
public function iSaveTheArticle()
{
$I = $this;
$I->clickToolbarButton('Save & Close');
}

/**
* @Given I have article with name :arg1
*/
public function iHaveArticleWithName($title)
{
$I = $this;
$I->amOnPage(ArticleManagerPage::$pageURL);
$I->fillField(ArticleManagerPage::$filterSearch, $title);
$I->click(ArticleManagerPage::$iconSearch);
$I->checkAllResults();
}

/**
* @When I unpublish the article
*/
public function iUnpublish()
{
$I = $this;
$I->clickToolbarButton('unpublish');
}
/**
* @Then I see article unpublish message :arg1
*/
public function iSeeArticleUnpublishMessage($message)
{
$I = $this;
$I->waitForPageTitle('Articles');
$I->see($message, AdminPage::$systemMessageContainer);
}


/**
* @Given I have :arg1 content article which needs to be Trash
*/
public function iHaveContentArticleWhichNeedsToBeTrash($title)
{
$I = $this;
$I->amOnPage(ArticleManagerPage::$pageURL);
$I->fillField(ArticleManagerPage::$filterSearch, $title);
$I->click(ArticleManagerPage::$iconSearch);
$I->checkAllResults();
}

/**
* @When I Trash the article
*/
public function iTrashTheArticleWithName()
{
$I = $this;
$I->clickToolbarButton('trash');
}

/**
* @Then I see article trash message :arg1
*/
public function iSeeArticleTrashMessage($message)
{
$I = $this;
$I->waitForPageTitle('Articles');
$I->see($message, AdminPage::$systemMessageContainer);
}
}
3 changes: 2 additions & 1 deletion tests/acceptance.suite.dist.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class_name: AcceptanceTester
modules:
enabled:
- JoomlaBrowser
- AcceptanceHelper
- AcceptanceHelper
- Asserts
config:
JoomlaBrowser:
Expand Down Expand Up @@ -38,3 +38,4 @@ gherkin:
- AcceptanceTester
- Step\Acceptance\Administrator\User
- Page\Acceptance\Administrator\Login
- Step\Acceptance\Administrator\Content
37 changes: 37 additions & 0 deletions tests/acceptance/content.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
Feature: content
In order to manage content article in the web
As an owner
I need to create modify trash publish and Unpublish content article

Background:
Given Joomla CMS is installed
When Login into Joomla administrator with username "admin" and password "admin"
Then I see administrator dashboard

Scenario: Create an Article
Given There is a add content link
When I create new content with field title as "My_Article" and content as a "This is my first article"
And I save an article
Then I should see the "Article successfully saved." message

Scenario: Feature an Article
Given I search and select content article with title "My_Article"
When I featured the article
Then I save and see the "1 article featured." message

Scenario: Modify an article
Given I select the content article with title "My_Article"
And I set access level as a "Registered"
When I save the article
Then I should see the "Article successfully saved" message

Scenario: Unpublish an article
Given I have article with name "My_Article"
When I unpublish the article
Then I see article unpublish message "1 article unpublished."

Scenario: Trash an article
Given I have "My_Article" content article which needs to be Trash
When I Trash the article
Then I see article trash message "1 article trashed."