32
1
mirror of https://github.com/joomla-extensions/weblinks.git synced 2024-11-16 17:45:08 +00:00

Merge pull request #1 from javigomez/94fixesb

[tests] update tests to Codeception 2.1
This commit is contained in:
Yves Hoppe 2015-09-30 18:56:38 +02:00
commit 1d5dc56c47
17 changed files with 2712 additions and 391 deletions

2
.gitignore vendored
View File

@ -40,7 +40,6 @@ phing-latest.phar
/Gemfile.lock
# composer
composer.lock
composer.phar
vendor/*
@ -50,6 +49,7 @@ robo.phar
# Test related files
tests/acceptance.suite.yml
tests/*/*Tester.php
tests/_support/_generated/*TesterActions.php
tests/joomla-cms3*
tests/_output*
selenium-server-standalone.jar

View File

@ -27,7 +27,7 @@ before_script:
- sudo apt-get install fluxbox -y --force-yes
- fluxbox &
- sleep 3 # give fluxbox some time to start
- composer update
- composer install
script:
- mv tests/acceptance.suite.dist.yml tests/acceptance.suite.yml

View File

@ -42,76 +42,37 @@ class RoboFile extends \Robo\Tasks
{
$this->setExecExtension();
// Get Joomla Clean Testing sites
if (is_dir('tests/joomla-cms3'))
{
$this->taskDeleteDir('tests/joomla-cms3')->run();
}
$this->createTestingSite();
$this->_exec('git' . $this->extension . ' clone -b staging --single-branch --depth 1 https://github.com/joomla/joomla-cms.git tests/joomla-cms3');
$this->say('Joomla CMS site created at tests/joomla-cms3');
$this->getComposer();
if (!$seleniumPath)
{
if (!file_exists('selenium-server-standalone.jar'))
{
$this->say('Downloading Selenium Server, this may take a while.');
$this->taskComposerInstall()->run();
if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN')
{
$this->_exec('curl.exe -sS http://selenium-release.storage.googleapis.com/2.45/selenium-server-standalone-2.45.0.jar > selenium-server-standalone.jar');
}
else
{
$this->taskExec('wget')
->arg('http://selenium-release.storage.googleapis.com/2.45/selenium-server-standalone-2.45.0.jar')
->arg('-O selenium-server-standalone.jar')
->printed(false)
->run();
}
}
$this->runSelenium();
$seleniumPath = 'selenium-server-standalone.jar';
}
if (strtoupper(substr(PHP_OS, 0, 3)) !== 'WIN')
{
$seleniumPath = "java -jar $seleniumPath >> selenium.log 2>&1 &";
}
else
{
$seleniumPath = "START java.exe -jar .\\" . $seleniumPath;
}
// Make sure we have Composer
if (!file_exists('./composer.phar'))
{
$this->_exec('curl' . $this->extension . ' -sS https://getcomposer.org/installer | php');
}
$this->taskComposerUpdate()->run();
// Running Selenium server
$this->_exec($seleniumPath);
if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN')
{
sleep(10);
}
else
{
$this->taskWaitForSeleniumStandaloneServer()
->run()
->stopOnFail();
}
// Loading Symfony Command and running with passed argument
$this->_exec('php' . $this->extension . ' vendor/bin/codecept build');
$this->taskCodecept()
->suite($suite)
->arg('--steps')
->arg('--debug')
->arg('--fail-fast')
->arg('tests/acceptance/install/')
->run()
->stopOnFail();
$this->taskCodecept()
->arg('--steps')
->arg('--debug')
->arg('--fail-fast')
->arg('tests/acceptance/administrator/')
->run()
->stopOnFail();
$this->taskCodecept()
->arg('--steps')
->arg('--debug')
->arg('--fail-fast')
->arg('tests/acceptance/frontend/')
->run()
->stopOnFail();
@ -139,63 +100,50 @@ class RoboFile extends \Robo\Tasks
*
* @return mixed
*/
public function runTest($seleniumPath = null, $pathToTestFile = null, $suite = 'acceptance')
public function runTest($pathToTestFile = null, $suite = 'acceptance')
{
if (!$seleniumPath)
{
if (!file_exists('selenium-server-standalone.jar'))
{
$this->say('Downloading Selenium Server, this may take a while.');
$this->taskExec('wget')
->arg('http://selenium-release.storage.googleapis.com/2.46/selenium-server-standalone-2.46.0.jar')
->arg('-O selenium-server-standalone.jar')
->printed(false)
->run();
}
$seleniumPath = 'selenium-server-standalone.jar';
}
// Make sure we have Composer
if (!file_exists('./composer.phar'))
{
$this->_exec('curl -sS https://getcomposer.org/installer | php');
}
$this->taskComposerUpdate()->run();
// Running Selenium server
$this->_exec("java -jar $seleniumPath > selenium-errors.log 2>selenium.log &");
$this->taskWaitForSeleniumStandaloneServer()
->run()
->stopOnFail();
$this->runSelenium();
// Make sure to Run the Build Command to Generate AcceptanceTester
$this->_exec("php vendor/bin/codecept build");
if (!$pathToTestFile)
{
$tests = array();
$this->say('Available tests in the system:');
$filesInSuite = scandir(getcwd() . '/tests/' . $suite);
$iterator = new RecursiveIteratorIterator(
new RecursiveDirectoryIterator(
'tests/' . $suite,
RecursiveDirectoryIterator::SKIP_DOTS
),
RecursiveIteratorIterator::SELF_FIRST
);
$tests = array();
$iterator->rewind();
$i = 1;
foreach ($filesInSuite as $file)
while ($iterator->valid())
{
// Make sure the file is a Test file
if (strripos($file, 'cept.php') || strripos($file, 'cest.php'))
if (strripos($iterator->getSubPathName(), 'cept.php')
|| strripos($iterator->getSubPathName(), 'cest.php'))
{
$tests[$i] = $file;
$this->say('[' . $i . '] ' . $file);
$this->say('[' . $i . '] ' . $iterator->getSubPathName());
$tests[$i] = $iterator->getSubPathName();
$i++;
}
$iterator->next();
}
$this->say('');
$testNumber = $this->ask('Type the number of the test in the list that you want to run...');
$pathToTestFile = "tests/$suite/" . $tests[$testNumber];
$testNumber = $this->ask('Type the number of the test in the list that you want to run...');
$test = $tests[$testNumber];
}
$pathToTestFile = 'tests/' . $suite . '/' . $test;
$this->taskCodecept()
->test($pathToTestFile)
->arg('--steps')
@ -205,28 +153,6 @@ class RoboFile extends \Robo\Tasks
// Kill selenium server
// $this->_exec('curl http://localhost:4444/selenium-server/driver/?cmd=shutDownSeleniumServer');
$this->say('Printing Selenium Log files');
$this->say('------ selenium-errors.log (start) ---------');
$seleniumErrors = file_get_contents('selenium-errors.log');
if ($seleniumErrors)
{
$this->say(file_get_contents('selenium-errors.log'));
}
else
{
$this->say('no errors were found');
}
$this->say('------ selenium-errors.log (end) -----------');
/*
// Uncomment if you need to debug issues in selenium
$this->say('');
$this->say('------ selenium.log (start) -----------');
$this->say(file_get_contents('selenium.log'));
$this->say('------ selenium.log (end) -----------');
*/
}
/**
@ -243,4 +169,46 @@ class RoboFile extends \Robo\Tasks
$this->_exec('git' . $this->extension . ' clone -b staging --single-branch --depth 1 https://github.com/joomla/joomla-cms.git tests/joomla-cms3');
$this->say('Joomla CMS site created at tests/joomla-cms3');
}
/**
* Runs Selenium Standalone Server.
*
* @return void
*/
public function runSelenium()
{
if (strtoupper(substr(PHP_OS, 0, 3)) !== 'WIN')
{
$this->_exec("vendor/bin/selenium-server-standalone >> selenium.log 2>&1 &");
}
else
{
$this->_exec("START java.exe -jar .\\vendor\\joomla-projects\\selenium-server-standalone\\bin\\selenium-server-standalone.jar");
}
if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN')
{
sleep(10);
}
else
{
$this->taskWaitForSeleniumStandaloneServer()
->run()
->stopOnFail();
}
}
/**
* Downloads Composer
*
* @return void
*/
private function getComposer()
{
// Make sure we have Composer
if (!file_exists('./composer.phar'))
{
$this->_exec('curl --retry 3 --retry-delay 5 -sS https://getcomposer.org/installer | php');
}
}
}

View File

@ -8,10 +8,3 @@ settings:
bootstrap: _bootstrap.php
colors: true
memory_limit: 1024M
modules:
config:
Db:
dsn: ''
user: ''
password: ''
dump: tests/_data/dump.sql

View File

@ -6,9 +6,11 @@
"php": ">=5.3.10"
},
"require-dev": {
"codeception/codeception": "2.0.13",
"codeception/codeception": "~2.1",
"joomla-projects/joomla-browser": "dev-develop",
"codegyre/robo": "~0.5",
"joomla-projects/robo": "dev-master"
"joomla-projects/robo": "dev-master",
"joomla-projects/selenium-server-standalone": "v2.47.1",
"fzaninotto/faker": "^1.5"
}
}

2157
composer.lock generated Normal file

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,203 @@
I WANT TO TEST CATEGORY CREATION IN /ADMINISTRATOR/
I am "Administrator"
I do administrator login ""
I am going to "Navigate to Categories page in /administrator/"
I am on page "administrator/index.php?option=com_categories&extension=com_weblinks"
I wait for text "Weblinks: Categories"," '30"," ['css' => 'h1']"
I expect to "see categories page"
I check for php notices or warnings ""
I am going to "try to save a category with a filled title"
I click(['xpath' => "//button[@onclick=\"joomla.submitbutton "category.add')\"]"]"
I wait for text "Category Manager: Add A New Weblinks Category"," '30"," ['css' => 'h1']"
I fill field(['id' => 'jform_title'], 'automated testing' . rand "1"," 100)"
I click(['xpath' => "//button[@onclick=\"joomla.submitbutton "category.apply')\"]"]"
I expect to "see a success message after saving the category"
I see "Category successfully saved"," ['id' => 'system-message-container']"
I WANT TO TEST CATEGORY CREATION IN /ADMINISTRATOR/ WITHOUT TITLE
I am "Administrator"
I do administrator login ""
I am going to "Navigate to Categories page in /administrator/"
I am on page "administrator/index.php?option=com_categories&extension=com_weblinks"
I wait for text "Weblinks: Categories"," '30"," ['css' => 'h1']"
I expect to "see categories page"
I am going to "try to save a category with empty title and it should fail"
I click(['xpath' => "//button[@onclick=\"joomla.submitbutton "category.add')\"]"]"
I wait for text "Category Manager: Add A New Weblinks Category"," '30"," ['css' => 'h1']"
I click(['xpath' => "//button[@onclick=\"joomla.submitbutton "category.apply')\"]"]"
I expect to "see an error when trying to save a category without title"
I see "Invalid field: Title"," ['id' => 'system-message-container']"
I WANT TO TEST CATEGORY PUBLISHING IN /ADMINISTRATOR/
I am "Administrator"
I do administrator login ""
I am going to "Navigate to Categories page in /administrator/"
I am on page "administrator/index.php?option=com_categories&extension=com_weblinks"
I wait for text "Weblinks: Categories"," '30"," ['css' => 'h1']"
I expect to "see categories page"
I check for php notices or warnings ""
I am going to "try to save a category with a filled title"
I click(['xpath' => "//button[@onclick=\"joomla.submitbutton "category.add')\"]"]"
I wait for text "Category Manager: Add A New Weblinks Category"," '30"," ['css' => 'h1']"
I fill field(['id' => 'jform_title'], 'automated testing pub' . rand "1"," 100)"
I click(['xpath' => "//button[@onclick=\"joomla.submitbutton "category.save')\"]"]"
I expect to "see a success message after saving the category"
I see "Category successfully saved"," ['id' => 'system-message-container']"
I am going to "Search for automated testing"
I fill field "['xpath' => "//input[@id=\"filter_search\"]"]"," "automated testing pub" . "\n""
I wait for text "Weblinks: Categories"," '30"," ['css' => 'h1']"
I am going to "Select the first weblink"
I click "['xpath' => "//input[@id=\"cb0\"]"]"
I am going to "try to publish a weblink category"
I click(['xpath' => "//button[@onclick=\"if (document.admin form.boxchecked.value==0){alert('please first make a selection from the list.');}else{ joomla.submitbutton "categories.publish')}\"]"]"
I wait for text "Weblinks: Categories"," '30"," ['css' => 'h1']"
I expect to "see a success message after publishing the category"
I see "1 category successfully published."," ['id' => 'system-message-container']"
I WANT TO TEST CATEGORY UNPUBLISHING IN /ADMINISTRATOR/
I am "Administrator"
I do administrator login ""
I am going to "Navigate to Categories page in /administrator/"
I am on page "administrator/index.php?option=com_categories&extension=com_weblinks"
I wait for text "Weblinks: Categories"," '30"," ['css' => 'h1']"
I expect to "see categories page"
I check for php notices or warnings ""
I am going to "try to save a category with a filled title"
I click(['xpath' => "//button[@onclick=\"joomla.submitbutton "category.add')\"]"]"
I wait for text "Category Manager: Add A New Weblinks Category"," '30"," ['css' => 'h1']"
I fill field(['id' => 'jform_title'], 'automated testing unpub' . rand "1"," 100)"
I click(['xpath' => "//button[@onclick=\"joomla.submitbutton "category.save')\"]"]"
I expect to "see a success message after saving the category"
I see "Category successfully saved"," ['id' => 'system-message-container']"
I am going to "Search for automated testing"
I fill field "['xpath' => "//input[@id=\"filter_search\"]"]"," "automated testing unpub" . "\n""
I wait for text "Weblinks: Categories"," '30"," ['css' => 'h1']"
I am going to "Select the first weblink"
I click "['xpath' => "//input[@id=\"cb0\"]"]"
I am going to "Try to publish a weblink category"
I click(['xpath' => "//button[@onclick=\"if (document.admin form.boxchecked.value==0){alert('please first make a selection from the list.');}else{ joomla.submitbutton "categories.publish')}\"]"]"
I wait for text "Weblinks: Categories"," '30"," ['css' => 'h1']"
I expect to "See a success message after publishing the category"
I see "1 category successfully published."," ['id' => 'system-message-container']"
I wait for text "Weblinks: Categories"," '30"," ['css' => 'h1']"
I am going to "Select the first weblink"
I click "['xpath' => "//input[@id=\"cb0\"]"]"
I am going to "Try to unpublish a weblink category"
I click(['xpath' => "//button[@onclick=\"if (document.admin form.boxchecked.value==0){alert('please first make a selection from the list.');}else{ joomla.submitbutton "categories.unpublish')}\"]"]"
I wait for text "Weblinks: Categories"," '30"," ['css' => 'h1']"
I expect to "See a success message after unpublishing the category"
I see "1 category successfully unpublished"," ['id' => 'system-message-container']"
I WANT TO TEST WEBLINK CREATION IN /ADMINISTRATOR/
I am "Administrator"
I do administrator login ""
I am going to "Navigate to Weblinks page in /administrator/"
I am on page "administrator/index.php?option=com_weblinks"
I wait for text "Web Links"," '30"," ['css' => 'h1']"
I expect to "see weblinks page"
I check for php notices or warnings ""
I am going to "try to save a weblink with a filled title and URL"
I click "New"
I wait for text "Web Link: New"," '30"," ['css' => 'h1']"
I fill field "['id' => 'jform_title']"," $this->title"
I fill field "['id' => 'jform_url']"," $this->url"
I click(['xpath' => "//button[@onclick=\"joomla.submitbutton "weblink.save')\"]"]"
I wait for text "Web Links"," '30"," ['css' => 'h1']"
I expect to "see a success message and the weblink added after saving the weblink"
I see "Web link successfully saved"," ['id' => 'system-message-container']"
I see "$this->title"," ['id' => 'weblinkList']"
I WANT TO TEST WEBLINK REMOVAL IN /ADMINISTRATOR/
I am "Administrator"
I do administrator login ""
I am going to "Navigate to Weblinks page in /administrator/"
I am on page "administrator/index.php?option=com_weblinks"
I wait for text "Web Links","30","['css' => 'h1']"
I expect to "see weblinks page"
I am going to "Search the just saved weblink"
I search for item "$this->title"
I wait for text "Web Links","30","['css' => 'h1']"
I am going to "Delete the just saved weblink"
I check all results ""
I click(['xpath'=> "//button[@onclick=\"if (document.admin form.boxchecked.value==0){alert('please first make a selection from the list.');}else{ joomla.submitbutton "weblinks.trash')}\"]"]"
I wait for text "Web Links","30","['css' => 'h1']"
I expect to "see a success message and the weblink removed from the list"
I see "Web link successfully trashed","['id' => 'system-message-container']"
I cant see "$this->title","['id' => 'weblinkList']"
I WANT TO TEST WEBLINK REMOVAL IN /ADMINISTRATOR/
I am "Administrator"
I do administrator login ""
I am going to "Navigate to Weblinks page in /administrator/"
I am on page "administrator/index.php?option=com_weblinks"
I wait for text "Web Links","30","['css' => 'h1']"
I expect to "see weblinks page"
I select option in chosen "- Select Status -"," 'Trashed"
I am going to "Search the just saved weblink"
I search for item "$this->title"
I wait for text "Web Links","30","['css' => 'h1']"
I am going to "Delete the just saved weblink"
I check all results ""
I click "['xpath'=> '//div[@id="toolbar-delete"]/button']"
I wait for text "Web Links","30","['css' => 'h1']"
I expect to "see a success message and the weblink removed from the list"
I see "1 web link successfully deleted.","['id' => 'system-message-container']"
I cant see "$this->title","['id' => 'weblinkList']"
I WANT TO TEST WEBLINK CREATION WITHOUT TITLE FAILS IN /ADMINISTRATOR/
I am "Administrator"
I do administrator login ""
I am going to "Navigate to Weblinks page in /administrator/"
I am on page "administrator/index.php?option=com_weblinks"
I wait for text "Web Links","30","['css' => 'h1']"
I expect to "see weblinks page"
I check for php notices or warnings ""
I am going to "try to save a weblink with empty title and it should fail"
I click(['xpath'=> "//button[@onclick=\"joomla.submitbutton "weblink.add')\"]"]"
I wait for text "Web Link: New","30","['css' => 'h1']"
I click(['xpath'=> "//button[@onclick=\"joomla.submitbutton "weblink.apply')\"]"]"
I expect to "see an error when trying to save a weblink without title and without URL"
I see "Invalid field: Title","['id' => 'system-message-container']"
I see "Invalid field: URL","['id' => 'system-message-container']"
I WANT TO TEST LISTING A CATEGORY OF WEBLINKS IN FRONTEND
I am "Administrator"
I do administrator login ""
I create weblink "$this->title"," $this->url"
I create menu item "$this->menuItem"," 'Weblinks"," 'List All Web Link Categories"," 'Main Menu"
I comment "I want to check if the menu entry exists in the frontend"
I am on page "index.php?option=com_weblinks"
I expect to "see weblink categories"
I wait for text "Uncategorised","30"," ['css' => 'h3']"
I check for php notices or warnings ""
I comment "I open the uncategorised Weblink Category"
I click "['link' => 'Uncategorised']"
I wait for text "Uncategorised","30"," ['css' => 'h2']"
I expect to "see the weblink we created"
I see element "['link' => $this->title]"
I see element "['xpath' => "//a[@href='$this->url']"]"
I WANT TO INSTALL JOOMLA
I am "Administrator"
I install joomla ""
I do administrator login ""
I set error reporting to development ""
I WANT TO INSTALL WEBLINKS
I do administrator login ""
I comment('get weblinks repository folder from acceptance.suite.yml "see _support/AcceptanceHelper.php)"
I get configuration "repo_folder"
I install extension from folder "$path . 'src/com_weblinks/"
I do administrator logout ""

View File

@ -0,0 +1,40 @@
<?php
namespace Step\Acceptance;
/**
* Class Weblink
*
* Step Object to interact with a weblink
*
* @todo: this class should grow until being able to execute generic operations over a Weblink: change status, add to category...
*
* @package Step\Acceptance
* @see http://codeception.com/docs/06-ReusingTestCode#StepObjects
*/
class Weblink extends \AcceptanceTester
{
/**
* Creates a weblink
*
* @param string $title The title for the weblink
* @param string $url The url for the
*
*/
public function createWeblink($title, $url)
{
$I = $this;
$I->comment('I navigate to Weblinks page in /administrator/');
$I->amOnPage('administrator/index.php?option=com_weblinks');
$I->waitForText('Web Links', '30', ['css' => 'h1']);
$I->comment('I see weblinks page');
$I->comment('I try to save a weblink with a filled title and URL');
$I->click('New');
$I->waitForText('Web Link: New', '30', ['css' => 'h1']);
$I->fillField(['id' => 'jform_title'], $title);
$I->fillField(['id' => 'jform_url'], $url);
$I->click(['xpath' => "//button[@onclick=\"Joomla.submitbutton('weblink.save')\"]"]);
$I->waitForText('Web link successfully saved', '30', ['id' => 'system-message-container']);
}
}

View File

View File

@ -28,7 +28,7 @@ modules:
database host: 'localhost' # place where the Application is Hosted #server Address
database user: 'root' # MySQL Server user ID, usually root
database password: '' # MySQL Server password, usually empty or root
database name: 'testweblinks' # DB Name, at the Server
database name: 'test_weblinks' # DB Name, at the Server
database type: 'mysqli' # type in lowercase one of the options: MySQL\MySQLi\PDO
database prefix: 'jos_' # DB Prefix for tables
install sample data: 'no' # Do you want to Download the Sample Data Along with Joomla Installation, then keep it Yes

View File

@ -1,138 +0,0 @@
<?php
/**
* @package Joomla.Administrator
* @subpackage com_weblinks
*
* @copyright Copyright (C) 2005 - 2015 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
use \AcceptanceTester;
class AdministratorCategoriesCest
{
public function administratorCreateCategory(AcceptanceTester $I)
{
$I->am('Administrator');
$I->wantToTest('Category creation in /administrator/');
$I->doAdministratorLogin();
$I->amGoingTo('Navigate to Categories page in /administrator/');
$I->amOnPage('administrator/index.php?option=com_categories&extension=com_weblinks');
$I->waitForText('Weblinks: Categories','30',['css' => 'h1']);
$I->expectTo('see categories page');
$I->checkForPhpNoticesOrWarnings();
$I->amGoingTo('try to save a category with a filled title');
$I->click(['xpath'=> "//button[@onclick=\"Joomla.submitbutton('category.add')\"]"]);
$I->waitForText('Category Manager: Add A New Weblinks Category','30',['css' => 'h1']);
$I->fillField(['id' => 'jform_title'],'automated testing' . rand(1,100));
$I->click(['xpath'=> "//button[@onclick=\"Joomla.submitbutton('category.apply')\"]"]);
$I->expectTo('see a success message after saving the category');
$I->see('Category successfully saved',['id' => 'system-message-container']);
}
public function administratorCreateCategoryWithoutTitleFails(AcceptanceTester $I)
{
$I->am('Administrator');
$I->wantToTest('Category creation in /administrator/ without title');
$I->doAdministratorLogin();
$I->amGoingTo('Navigate to Categories page in /administrator/');
$I->amOnPage('administrator/index.php?option=com_categories&extension=com_weblinks');
$I->waitForText('Weblinks: Categories','30',['css' => 'h1']);
$I->expectTo('see categories page');
$I->amGoingTo('try to save a category with empty title and it should fail');
$I->click(['xpath'=> "//button[@onclick=\"Joomla.submitbutton('category.add')\"]"]);
$I->waitForText('Category Manager: Add A New Weblinks Category','30',['css' => 'h1']);
$I->click(['xpath'=> "//button[@onclick=\"Joomla.submitbutton('category.apply')\"]"]);
$I->expectTo('see an error when trying to save a category without title');
$I->see('Invalid field: Title',['id' => 'system-message-container']);
}
public function administratorPublishWeblink(AcceptanceTester $I)
{
$I->am('Administrator');
$I->wantToTest('Category publishing in /administrator/');
$I->doAdministratorLogin();
$I->amGoingTo('Navigate to Categories page in /administrator/');
$I->amOnPage('administrator/index.php?option=com_categories&extension=com_weblinks');
$I->waitForText('Weblinks: Categories','30',['css' => 'h1']);
$I->expectTo('see categories page');
$I->checkForPhpNoticesOrWarnings();
$I->amGoingTo('try to save a category with a filled title');
$I->click(['xpath'=> "//button[@onclick=\"Joomla.submitbutton('category.add')\"]"]);
$I->waitForText('Category Manager: Add A New Weblinks Category','30',['css' => 'h1']);
$I->fillField(['id' => 'jform_title'],'automated testing pub' . rand(1,100));
$I->click(['xpath'=> "//button[@onclick=\"Joomla.submitbutton('category.save')\"]"]);
$I->expectTo('see a success message after saving the category');
$I->see('Category successfully saved',['id' => 'system-message-container']);
$I->amGoingTo('Search for automated testing');
$I->fillField(['xpath'=> "//input[@id=\"filter_search\"]"], "automated testing pub" . "\n");
$I->waitForText('Weblinks: Categories','30',['css' => 'h1']);
$I->amGoingTo('Select the first weblink');
$I->click(['xpath'=> "//input[@id=\"cb0\"]"]);
$I->amGoingTo('try to publish a weblink category');
$I->click(['xpath'=> "//button[@onclick=\"if (document.adminForm.boxchecked.value==0){alert('Please first make a selection from the list.');}else{ Joomla.submitbutton('categories.publish')}\"]"]);
$I->waitForText('Weblinks: Categories','30',['css' => 'h1']);
$I->expectTo('see a success message after publishing the category');
$I->see('1 category successfully published.',['id' => 'system-message-container']);
}
public function administratorUnpublishWeblink(AcceptanceTester $I)
{
$I->am('Administrator');
$I->wantToTest('Category unpublishing in /administrator/');
$I->doAdministratorLogin();
$I->amGoingTo('Navigate to Categories page in /administrator/');
$I->amOnPage('administrator/index.php?option=com_categories&extension=com_weblinks');
$I->waitForText('Weblinks: Categories','30',['css' => 'h1']);
$I->expectTo('see categories page');
$I->checkForPhpNoticesOrWarnings();
$I->amGoingTo('try to save a category with a filled title');
$I->click(['xpath'=> "//button[@onclick=\"Joomla.submitbutton('category.add')\"]"]);
$I->waitForText('Category Manager: Add A New Weblinks Category','30',['css' => 'h1']);
$I->fillField(['id' => 'jform_title'],'automated testing unpub' . rand(1,100));
$I->click(['xpath'=> "//button[@onclick=\"Joomla.submitbutton('category.save')\"]"]);
$I->expectTo('see a success message after saving the category');
$I->see('Category successfully saved',['id' => 'system-message-container']);
$I->amGoingTo('Search for automated testing');
$I->fillField(['xpath'=> "//input[@id=\"filter_search\"]"], "automated testing unpub" . "\n");
$I->waitForText('Weblinks: Categories','30',['css' => 'h1']);
$I->amGoingTo('Select the first weblink');
$I->click(['xpath'=> "//input[@id=\"cb0\"]"]);
$I->amGoingTo('Try to publish a weblink category');
$I->click(['xpath'=> "//button[@onclick=\"if (document.adminForm.boxchecked.value==0){alert('Please first make a selection from the list.');}else{ Joomla.submitbutton('categories.publish')}\"]"]);
$I->waitForText('Weblinks: Categories','30',['css' => 'h1']);
$I->expectTo('See a success message after publishing the category');
$I->see('1 category successfully published.',['id' => 'system-message-container']);
// Unpublish it again
$I->waitForText('Weblinks: Categories','30',['css' => 'h1']);
$I->amGoingTo('Select the first weblink');
$I->click(['xpath'=> "//input[@id=\"cb0\"]"]);
$I->amGoingTo('Try to unpublish a weblink category');
$I->click(['xpath'=> "//button[@onclick=\"if (document.adminForm.boxchecked.value==0){alert('Please first make a selection from the list.');}else{ Joomla.submitbutton('categories.unpublish')}\"]"]);
$I->waitForText('Weblinks: Categories','30',['css' => 'h1']);
$I->expectTo('See a success message after unpublishing the category');
$I->see('1 category successfully unpublished',['id' => 'system-message-container']);
}
}

View File

@ -1,56 +0,0 @@
<?php
/**
* @package Joomla.Administrator
* @subpackage com_weblinks
*
* @copyright Copyright (C) 2005 - 2015 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
use \AcceptanceTester;
class FrontendWeblinksCest
{
private $title;
public function __construct()
{
// This way works just fine, but not 100% sure if that is the recommended way:
$this->title = 'automated testing ' . uniqid();
}
/**
* Create a weblink in the backend and confirm it exists and is visible in the Frontend
*
* @param AcceptanceTester $I
* @param \Codeception\Scenario $scenario DI - is needed for Weblink Step
*/
public function createWeblinkAndConfirmFrontend(AcceptanceTester $I, $scenario)
{
$I->am('Administrator');
$I->wantToTest('Weblink creation in /administrator/');
$I->doAdministratorLogin();
// Get weblink StepObject
$weblinkStep = new AcceptanceTester\WeblinkSteps($scenario);
$weblinkStep->createWeblink($this->title);
// Menu link
$I->createMenuItem('automated testing' . rand(1, 100), 'Weblinks', 'List All Web Link Categories');
// Go to the frontend
$I->wantToTest('If the menu entry exists in the frontend');
$I->amOnPage('index.php?option=com_weblinks');
$I->waitForText('Uncategorised','30', ['css' => 'h3']);
$I->expectTo('see weblink categories');
$I->checkForPhpNoticesOrWarnings();
$I->amGoingTo('try to open the uncategorised Item');
$I->click(['xpath' => "//a[contains(text(), 'Uncategorised')]"]);
// It's a h2 now..
$I->waitForText('Uncategorised','30', ['css' => 'h2']);
$I->expectTo('see the weblink we created');
$I->see($this->title, ['class' => 'list-title']);
}
}

View File

@ -1,40 +0,0 @@
<?php
/**
* @package Joomla.Administrator
* @subpackage com_weblinks
*
* @copyright Copyright (C) 2005 - 2015 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
namespace AcceptanceTester;
class WeblinkSteps extends \AcceptanceTester
{
/**
* Creates a weblink
*
* @param string $title The title for the weblink
*/
public function createWeblink($title)
{
$I = $this;
$I->amGoingTo('Navigate to Weblinks page in /administrator/');
$I->amOnPage('administrator/index.php?option=com_weblinks');
$I->waitForText('Web Links', '30', ['css' => 'h1']);
$I->expectTo('see weblinks page');
$I->checkForPhpNoticesOrWarnings();
$I->amGoingTo('try to save a weblink with a filled title and URL');
$I->click('New');
$I->waitForText('Web Link: New', '30', ['css' => 'h1']);
$I->fillField(['id' => 'jform_title'], $title);
$I->fillField(['id' => 'jform_url'], 'http://example.com/automated_testing' . $title);
$I->click(['xpath' => "//button[@onclick=\"Joomla.submitbutton('weblink.save')\"]"]);
$I->waitForText('Web Links', '30', ['css' => 'h1']);
$I->expectTo('see a success message and the weblink added after saving the weblink');
$I->see('Web link successfully saved', ['id' => 'system-message-container']);
$I->see($title, ['id' => 'weblinkList']);
}
}

View File

@ -0,0 +1,136 @@
<?php
/**
* @package Joomla.Administrator
* @subpackage com_weblinks
*
* @copyright Copyright (C) 2005 - 2015 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
class AdministratorCategoriesCest
{
public function administratorCreateCategory(AcceptanceTester $I)
{
$I->am('Administrator');
$I->wantToTest('Category creation in /administrator/');
$I->doAdministratorLogin();
$I->amGoingTo('Navigate to Categories page in /administrator/');
$I->amOnPage('administrator/index.php?option=com_categories&extension=com_weblinks');
$I->waitForText('Weblinks: Categories', '30', ['css' => 'h1']);
$I->expectTo('see categories page');
$I->checkForPhpNoticesOrWarnings();
$I->amGoingTo('try to save a category with a filled title');
$I->click(['xpath' => "//button[@onclick=\"Joomla.submitbutton('category.add')\"]"]);
$I->waitForText('Category Manager: Add A New Weblinks Category', '30', ['css' => 'h1']);
$I->fillField(['id' => 'jform_title'], 'automated testing' . rand(1, 100));
$I->click(['xpath' => "//button[@onclick=\"Joomla.submitbutton('category.apply')\"]"]);
$I->expectTo('see a success message after saving the category');
$I->see('Category successfully saved', ['id' => 'system-message-container']);
}
public function administratorCreateCategoryWithoutTitleFails(AcceptanceTester $I)
{
$I->am('Administrator');
$I->wantToTest('Category creation in /administrator/ without title');
$I->doAdministratorLogin();
$I->amGoingTo('Navigate to Categories page in /administrator/');
$I->amOnPage('administrator/index.php?option=com_categories&extension=com_weblinks');
$I->waitForText('Weblinks: Categories', '30', ['css' => 'h1']);
$I->expectTo('see categories page');
$I->amGoingTo('try to save a category with empty title and it should fail');
$I->click(['xpath' => "//button[@onclick=\"Joomla.submitbutton('category.add')\"]"]);
$I->waitForText('Category Manager: Add A New Weblinks Category', '30', ['css' => 'h1']);
$I->click(['xpath' => "//button[@onclick=\"Joomla.submitbutton('category.apply')\"]"]);
$I->expectTo('see an error when trying to save a category without title');
$I->see('Invalid field: Title', ['id' => 'system-message-container']);
}
public function administratorPublishCategory(AcceptanceTester $I)
{
$I->am('Administrator');
$I->wantToTest('Category publishing in /administrator/');
$I->doAdministratorLogin();
$I->amGoingTo('Navigate to Categories page in /administrator/');
$I->amOnPage('administrator/index.php?option=com_categories&extension=com_weblinks');
$I->waitForText('Weblinks: Categories', '30', ['css' => 'h1']);
$I->expectTo('see categories page');
$I->checkForPhpNoticesOrWarnings();
$I->amGoingTo('try to save a category with a filled title');
$I->click(['xpath' => "//button[@onclick=\"Joomla.submitbutton('category.add')\"]"]);
$I->waitForText('Category Manager: Add A New Weblinks Category', '30', ['css' => 'h1']);
$I->fillField(['id' => 'jform_title'], 'automated testing pub' . rand(1, 100));
$I->click(['xpath' => "//button[@onclick=\"Joomla.submitbutton('category.save')\"]"]);
$I->expectTo('see a success message after saving the category');
$I->see('Category successfully saved', ['id' => 'system-message-container']);
$I->amGoingTo('Search for automated testing');
$I->fillField(['xpath' => "//input[@id=\"filter_search\"]"], "automated testing pub" . "\n");
$I->waitForText('Weblinks: Categories', '30', ['css' => 'h1']);
$I->amGoingTo('Select the first weblink');
$I->click(['xpath' => "//input[@id=\"cb0\"]"]);
$I->amGoingTo('try to publish a weblink category');
$I->click(['xpath' => "//button[@onclick=\"if (document.adminForm.boxchecked.value==0){alert('Please first make a selection from the list.');}else{ Joomla.submitbutton('categories.publish')}\"]"]);
$I->waitForText('Weblinks: Categories', '30', ['css' => 'h1']);
$I->expectTo('see a success message after publishing the category');
$I->see('1 category successfully published.', ['id' => 'system-message-container']);
}
public function administratorUnpublishCategory(AcceptanceTester $I)
{
$I->am('Administrator');
$I->wantToTest('Category unpublishing in /administrator/');
$I->doAdministratorLogin();
$I->amGoingTo('Navigate to Categories page in /administrator/');
$I->amOnPage('administrator/index.php?option=com_categories&extension=com_weblinks');
$I->waitForText('Weblinks: Categories', '30', ['css' => 'h1']);
$I->expectTo('see categories page');
$I->checkForPhpNoticesOrWarnings();
$I->amGoingTo('try to save a category with a filled title');
$I->click(['xpath' => "//button[@onclick=\"Joomla.submitbutton('category.add')\"]"]);
$I->waitForText('Category Manager: Add A New Weblinks Category', '30', ['css' => 'h1']);
$I->fillField(['id' => 'jform_title'], 'automated testing unpub' . rand(1, 100));
$I->click(['xpath' => "//button[@onclick=\"Joomla.submitbutton('category.save')\"]"]);
$I->expectTo('see a success message after saving the category');
$I->see('Category successfully saved', ['id' => 'system-message-container']);
$I->amGoingTo('Search for automated testing');
$I->fillField(['xpath' => "//input[@id=\"filter_search\"]"], "automated testing unpub" . "\n");
$I->waitForText('Weblinks: Categories', '30', ['css' => 'h1']);
$I->amGoingTo('Select the first weblink');
$I->click(['xpath' => "//input[@id=\"cb0\"]"]);
$I->amGoingTo('Try to publish a weblink category');
$I->click(['xpath' => "//button[@onclick=\"if (document.adminForm.boxchecked.value==0){alert('Please first make a selection from the list.');}else{ Joomla.submitbutton('categories.publish')}\"]"]);
$I->waitForText('Weblinks: Categories', '30', ['css' => 'h1']);
$I->expectTo('See a success message after publishing the category');
$I->see('1 category successfully published.', ['id' => 'system-message-container']);
// Unpublish it again
$I->waitForText('Weblinks: Categories', '30', ['css' => 'h1']);
$I->amGoingTo('Select the first weblink');
$I->click(['xpath' => "//input[@id=\"cb0\"]"]);
$I->amGoingTo('Try to unpublish a weblink category');
$I->click(['xpath' => "//button[@onclick=\"if (document.adminForm.boxchecked.value==0){alert('Please first make a selection from the list.');}else{ Joomla.submitbutton('categories.unpublish')}\"]"]);
$I->waitForText('Weblinks: Categories', '30', ['css' => 'h1']);
$I->expectTo('See a success message after unpublishing the category');
$I->see('1 category successfully unpublished', ['id' => 'system-message-container']);
}
}

View File

@ -7,25 +7,16 @@
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
use \AcceptanceTester;
class AdministratorWeblinksCest
{
private $title;
public function __construct()
{
// This way works just fine, but not 100% sure if that is the recommended way:
$this->title = 'automated testing' . uniqid();
$this->faker = Faker\Factory::create();
$this->title = 'Weblink' . $this->faker->randomNumber();
$this->url = $this->faker->url();
}
/**
* Create a weblink in the backend
*
* @param AcceptanceTester $I
* @param \Codeception\Scenario $scenario DI - is needed for Weblink Step
*/
public function administratorCreateWeblink(AcceptanceTester $I, $scenario)
public function administratorCreateWeblink(\Step\Acceptance\Weblink $I)
{
$I->am('Administrator');
$I->wantToTest('Weblink creation in /administrator/');
@ -33,14 +24,26 @@ class AdministratorWeblinksCest
$I->doAdministratorLogin();
// Get the weblink StepObject
$I = new AcceptanceTester\WeblinkSteps($scenario);
$I->createWeblink($this->title);
$I->amGoingTo('Navigate to Weblinks page in /administrator/');
$I->amOnPage('administrator/index.php?option=com_weblinks');
$I->waitForText('Web Links', '30', ['css' => 'h1']);
$I->expectTo('see weblinks page');
$I->checkForPhpNoticesOrWarnings();
$I->amGoingTo('try to save a weblink with a filled title and URL');
$I->click('New');
$I->waitForText('Web Link: New', '30', ['css' => 'h1']);
$I->fillField(['id' => 'jform_title'], $this->title);
$I->fillField(['id' => 'jform_url'], $this->url);
$I->click(['xpath' => "//button[@onclick=\"Joomla.submitbutton('weblink.save')\"]"]);
$I->waitForText('Web Links', '30', ['css' => 'h1']);
$I->expectTo('see a success message and the weblink added after saving the weblink');
$I->see('Web link successfully saved', ['id' => 'system-message-container']);
$I->see($this->title, ['id' => 'weblinkList']);
}
/**
* @depends administratorCreateWeblink
*
* @param AcceptanceTester $I
*/
public function administratorTrashWeblink(AcceptanceTester $I)
{
@ -68,9 +71,7 @@ class AdministratorWeblinksCest
}
/**
* @depends administratorCreateWeblink
*
* @param AcceptanceTester $I
* @depends administratorTrashWeblink
*/
public function administratorDeleteWeblink(AcceptanceTester $I)
{

View File

@ -0,0 +1,53 @@
<?php
/**
* @package Joomla.Administrator
* @subpackage com_weblinks
*
* @copyright Copyright (C) 2005 - 2015 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
class FrontendWeblinksCest
{
private $title;
public function __construct()
{
$this->faker = Faker\Factory::create();
$this->title = 'Weblink' . $this->faker->randomNumber();
$this->url = $this->faker->url();
$this->menuItem = 'Menu Item' . $this->faker->randomNumber();
}
/**
* Create a weblink in the backend and confirm it exists and is visible in the Frontend
*
* @param \Step\Acceptance\Weblink $I
*/
public function createWeblinkAndConfirmFrontend(\Step\Acceptance\Weblink $I)
{
$I->am('Administrator');
$I->wantToTest('Listing a category of Weblinks in frontend');
$I->doAdministratorLogin();
$I->createWeblink($this->title, $this->url);
// Menu link
$I->createMenuItem($this->menuItem, 'Weblinks', 'List All Web Link Categories', 'Main Menu');
// Go to the frontend
$I->comment('I want to check if the menu entry exists in the frontend');
$I->amOnPage('index.php?option=com_weblinks');
$I->expectTo('see weblink categories');
$I->waitForText('Uncategorised','30', ['css' => 'h3']);
$I->checkForPhpNoticesOrWarnings();
$I->comment('I open the uncategorised Weblink Category');
$I->click(['link' => 'Uncategorised']);
$I->waitForText('Uncategorised','30', ['css' => 'h2']);
$I->expectTo('see the weblink we created');
$I->seeElement(['link' => $this->title]);
$I->seeElement(['xpath' => "//a[@href='$this->url']"]);
}
}

View File

@ -1,4 +1,5 @@
<?php
/**
* @package Joomla.Administrator
* @subpackage com_weblinks
@ -7,11 +8,10 @@
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
use \AcceptanceTester;
class InstallWeblinksCest
{
public function installJoomla(AcceptanceTester $I)
public function installJoomla(\AcceptanceTester $I)
{
$I->am('Administrator');
$I->installJoomla();
@ -19,8 +19,10 @@ class InstallWeblinksCest
$I->setErrorReportingToDevelopment();
}
// tests
public function installWeblinks(AcceptanceTester $I)
/**
* @depends installJoomla
*/
public function installWeblinks(\AcceptanceTester $I)
{
$I->doAdministratorLogin();
$I->comment('get Weblinks repository folder from acceptance.suite.yml (see _support/AcceptanceHelper.php)');