Skip to content
This repository was archived by the owner on Mar 17, 2020. It is now read-only.
Closed
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
17 changes: 0 additions & 17 deletions tests/_support/Page/Acceptance/Administrator/Login.php

This file was deleted.

11 changes: 11 additions & 0 deletions tests/_support/Page/Acceptance/Joomla3/Administrator/AdminPage.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?php
namespace Page\Acceptance\Joomla3\Administrator;

class AdminPage extends \AcceptanceTester
{
public static $systemMessageContainer = ['id' => 'system-message-container'];

public static $pageTitle = ['class' => 'page-title'];

public static $controlPanelText = "Control Panel";
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?php
namespace Page\Acceptance\Joomla3\Administrator;

use Page\Acceptance\Joomla3\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 $pageURL = "/administrator/index.php?option=com_content&view=articles";
}
17 changes: 17 additions & 0 deletions tests/_support/Page/Acceptance/Joomla3/Administrator/LoginPage.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?php
namespace Page\Acceptance\Joomla3\Administrator;

use Page\Acceptance\Joomla3\Administrator\AdminPage;

class LoginPage extends AdminPage
{
public static $usernameField = ['id' => 'mod-login-username'];

public static $passwordField = ['id' => 'mod-login-password'];

public static $pageTitle = ['class' => 'page-title'];

public static $loginButton = ['xpath' => "//button[contains(normalize-space(), 'Log in')]"];

public static $pageURL = "/administrator/index.php";
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
<?php

namespace Step\Acceptance\Joomla3\Administrator;

use Page\Acceptance\Joomla3\Administrator\ArticleManagerPage;

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

/**
* @When I fill mandatory fields for creating article
*/
public function iFillMandatoryFieldsForCreatingArticle(\Behat\Gherkin\Node\TableNode $fields)
{
$I = $this;
// iterate over all rows
foreach ($fields->getRows() as $index => $row) {
if ($index === 0) { // first row to define fields
$keys = $row;
continue;
}
else
{
if ($row[0] == "title")
{
$I->fillField(ArticleManagerPage::$articleTitleField, $row[1]);
}

if ($row[0] == "content")
{
$I->click(ArticleManagerPage::$toggleEditor);
$I->fillField(ArticleManagerPage::$articleContentField, $row[1]);
}
}
}
}

/**
* @When I save an article
*/
public function iSaveAnArticle()
{
$I = $this;
$I->clickToolbarButton('Save');
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
<?php

namespace Step\Acceptance\Joomla3\Administrator;

use Page\Acceptance\Joomla3\Administrator\AdminPage;

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

}

/**
* @Given Joomla CMS is installed
*/
public function joomlaCMSIsInstalled()
{
$I = $this;

}

/**
* @Then I see administrator dashboard
*/
public function iSeeAdministratorDashboard()
{
$I = $this;
$I->waitForText(AdminPage::$controlPanelText, 4, AdminPage::$pageTitle);
}

/**
* Method is to set Wait for page title
*
* @param string $title Page Title text
* @param integer $timeout Waiting time
*
* @return void
*/
private function waitForPageTitle($title, $timeout = 60)
{
$I = $this;
$I->waitForText($title, $timeout, AdminPage::$pageTitle);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?php

namespace Step\Acceptance\Joomla3\Administrator;

use Page\Acceptance\Joomla3\Administrator\LoginPage;

class LoginSteps extends \AcceptanceTester
{
/**
* @When Login into Joomla administrator with username :arg1 and password :arg1
*/
public function loginIntoJoomlaAdministratorWithUsernameAndPassword($arg1, $arg2)
{
$I = $this;
$I->amGoingTo('I open Joomla Administrator Login Page');
$I->amOnPage(LoginPage::$pageURL);
$I->waitForElement(LoginPage::$usernameField, 60);
$I->amGoingTo('Fill Username Text Field');
$I->fillField(LoginPage::$usernameField, $arg1);
$I->amGoingTo('Fill Password Text Field');
$I->fillField(LoginPage::$passwordField, $arg2);

$I->amGoingTo('I click LoginPage button');
$I->click(LoginPage::$loginButton);
$I->amGoingTo('I wait to see Administrator Control Panel');
$I->waitForText(LoginPage::$controlPanelText, 10, LoginPage::$pageTitle);
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?php
namespace Step\Acceptance\Administrator;
namespace Step\Acceptance\Joomla3\Administrator;

class User extends \AcceptanceTester
{
Expand Down
18 changes: 18 additions & 0 deletions tests/acceptance/content.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
Feature: content
In order to manage content article in the web
As an owner
I need to create content article

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

Scenario: Create an Article
Given There is a Add Content link
When I fill mandatory fields for creating article
| field | value |
| title | My_Article |
| content | This is my First Article |
Copy link
Contributor

Choose a reason for hiding this comment

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

very cool!

But I would only use tables when we want to repeat the same test with different values.

Fore example: create 10 articles:

  • article1 | content1
  • article2 | content2
  • article3 | content3

see:
screen shot 2016-06-10 at 11 18 19

And I save an article
Then I should see the "Article successfully saved." message
2 changes: 1 addition & 1 deletion tests/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"php": ">=5.3.10"
},
"require-dev": {
"codeception/codeception": "master@dev",
"codeception/codeception": "~2.2",
Copy link
Contributor

Choose a reason for hiding this comment

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

I have sent separate PR for the same.

Copy link
Contributor

Choose a reason for hiding this comment

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

@pritalpatel But Puneet commited his composer.lock ;)

"joomla-projects/joomla-browser": "v3.4.8.3",
"joomla-projects/selenium-server-standalone": "v2.52.0",
"codegyre/robo": "~0.6",
Expand Down
Loading