mirror of
https://github.com/joomla-extensions/weblinks.git
synced 2024-12-25 01:45:59 +00:00
[tests] Added integration tests and moved to codeception 2.1
This is a clean version of pull #94
This commit is contained in:
parent
88d25172ca
commit
a0d68ab93b
2
.gitignore
vendored
2
.gitignore
vendored
@ -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
|
||||
|
@ -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
|
||||
|
210
RoboFile.php
210
RoboFile.php
@ -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');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -8,10 +8,3 @@ settings:
|
||||
bootstrap: _bootstrap.php
|
||||
colors: true
|
||||
memory_limit: 1024M
|
||||
modules:
|
||||
config:
|
||||
Db:
|
||||
dsn: ''
|
||||
user: ''
|
||||
password: ''
|
||||
dump: tests/_data/dump.sql
|
||||
|
@ -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
2157
composer.lock
generated
Normal file
File diff suppressed because it is too large
Load Diff
203
tests/_data/scenarios/acceptance.txt
Normal file
203
tests/_data/scenarios/acceptance.txt
Normal 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 ""
|
||||
|
40
tests/_support/Step/Acceptance/weblink.php
Normal file
40
tests/_support/Step/Acceptance/weblink.php
Normal 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']);
|
||||
}
|
||||
}
|
0
tests/_support/_generated/.gitkeep
Normal file
0
tests/_support/_generated/.gitkeep
Normal 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
|
||||
|
@ -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']);
|
||||
}
|
||||
}
|
@ -1,57 +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 MenuCest
|
||||
*
|
||||
* @since 3.4.1
|
||||
*/
|
||||
class MenuCest
|
||||
{
|
||||
/**
|
||||
* Create a menu Item
|
||||
*
|
||||
* @param \AcceptanceTester $I
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function createMenuItem(AcceptanceTester $I)
|
||||
{
|
||||
$I->am('Administrator');
|
||||
$I->wantToTest('Frontend menu creation in /administrator/');
|
||||
|
||||
$I->doAdministratorLogin();
|
||||
$I->amGoingTo('Navigate to Menu Manager page in /administrator/');
|
||||
$I->amOnPage('administrator/index.php?option=com_menus&view=items&menutype=mainmenu');
|
||||
$I->waitForText('Menus: Items','30', ['css' => 'h1']);
|
||||
$I->expectTo('see menu menager items');
|
||||
$I->checkForPhpNoticesOrWarnings();
|
||||
$I->amGoingTo('try to save a category with a filled title');
|
||||
$I->click(['xpath' => "//button[@onclick=\"Joomla.submitbutton('item.add')\"]"]);
|
||||
$I->waitForText('Menus: New Item','30', ['css' => 'h1']);
|
||||
$I->fillField(['id' => 'jform_title'], 'automated testing' . rand(1, 100));
|
||||
$I->click(['xpath' => "//a[@href=\"#menuTypeModal\"]"]);
|
||||
$I->waitForElement('.iframe','30');
|
||||
$I->comment('I switch to Menu Type iframe');
|
||||
$I->switchToIFrame("Menu Item Type");
|
||||
$I->waitForElementVisible(['link' => "Weblinks"],'30');
|
||||
$I->click(['link' => "Weblinks"]);
|
||||
$I->wait(1);
|
||||
$I->waitForElementVisible(['xpath' => "//a[contains(@title, 'Show all the web link categories within a category')]"], 60);
|
||||
$I->click(['xpath' => "//a[contains(@title, 'Show all the web link categories within a category')]"]);
|
||||
$I->wait(1);
|
||||
$I->switchToIFrame();
|
||||
$I->waitForElement(['xpath' => "//input[@value='List All Web Link Categories']"],'30');
|
||||
$I->click(['xpath' => "//button[@onclick=\"Joomla.submitbutton('item.apply')\"]"]);
|
||||
$I->expectTo('see a success message after saving the category');
|
||||
$I->see('Menu item successfully saved', ['id' => 'system-message-container']);
|
||||
}
|
||||
}
|
@ -1,2 +1,4 @@
|
||||
<?php
|
||||
// Here you can initialize variables that will be available to your tests
|
||||
|
||||
\Codeception\Util\Autoload::registerSuffix('Steps', __DIR__.DIRECTORY_SEPARATOR.'_steps');
|
136
tests/acceptance/administrator/AdministratorCategoriesCest.php
Normal file
136
tests/acceptance/administrator/AdministratorCategoriesCest.php
Normal 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']);
|
||||
}
|
||||
}
|
@ -7,47 +7,43 @@
|
||||
* @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' . rand(1,100);
|
||||
$this->faker = Faker\Factory::create();
|
||||
$this->title = 'Weblink' . $this->faker->randomNumber();
|
||||
$this->url = $this->faker->url();
|
||||
}
|
||||
|
||||
public function administratorCreateWeblink(AcceptanceTester $I)
|
||||
public function administratorCreateWeblink(\Step\Acceptance\weblink $I)
|
||||
{
|
||||
$I->am('Administrator');
|
||||
$I->wantToTest('Weblink creation in /administrator/');
|
||||
|
||||
$I->doAdministratorLogin();
|
||||
|
||||
// Get the weblink StepObject
|
||||
$I->amGoingTo('Navigate to Weblinks page in /administrator/');
|
||||
$I->amOnPage('administrator/index.php?option=com_weblinks');
|
||||
$I->waitForText('Web Links','30',['css' => 'h1']);
|
||||
$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(['xpath'=> "//button[@onclick=\"Joomla.submitbutton('weblink.add')\"]"]);
|
||||
$I->waitForText('Web Link: New','30',['css' => 'h1']);
|
||||
$I->click('New');
|
||||
$I->waitForText('Web Link: New', '30', ['css' => 'h1']);
|
||||
$I->fillField(['id' => 'jform_title'], $this->title);
|
||||
$I->fillField(['id' => 'jform_url'],'http://example.com/automated_testing' . $this->title);
|
||||
$I->click(['xpath'=> "//button[@onclick=\"Joomla.submitbutton('weblink.save')\"]"]);
|
||||
$I->waitForText('Web Links','30',['css' => 'h1']);
|
||||
$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']);
|
||||
$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)
|
||||
{
|
||||
@ -75,9 +71,7 @@ class AdministratorWeblinksCest
|
||||
}
|
||||
|
||||
/**
|
||||
* @depends administratorCreateWeblink
|
||||
*
|
||||
* @param AcceptanceTester $I
|
||||
* @depends administratorTrashWeblink
|
||||
*/
|
||||
public function administratorDeleteWeblink(AcceptanceTester $I)
|
||||
{
|
53
tests/acceptance/frontend/FrontendWeblinksCest.php
Normal file
53
tests/acceptance/frontend/FrontendWeblinksCest.php
Normal 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']"]);
|
||||
}
|
||||
}
|
@ -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)');
|
Loading…
Reference in New Issue
Block a user