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

[imp] Added Weblink StepObject for creating weblinks

Updated the tests in AdministratorWeblinksCest and FrontendWeblinksCest for it

Removed MenuCest (as it does not do anything useful except creating menu links without testing them)
This commit is contained in:
Yves Hoppe 2015-09-28 20:25:05 +02:00
parent e31a75b409
commit d746257641
5 changed files with 63 additions and 116 deletions

View File

@ -16,32 +16,25 @@ class AdministratorWeblinksCest
public function __construct() public function __construct()
{ {
// This way works just fine, but not 100% sure if that is the recommended way: // This way works just fine, but not 100% sure if that is the recommended way:
$this->title = 'automated testing' . rand(1,100); $this->title = 'automated testing' . uniqid();
} }
public function administratorCreateWeblink(AcceptanceTester $I) /**
* Create a weblink in the backend
*
* @param \AcceptanceTester $I
* @param \Codeception\Scenario $scenario - DI $scenario is need for Weblink Step
*/
public function administratorCreateWeblink(AcceptanceTester $I, $scenario)
{ {
$I->am('Administrator'); $I->am('Administrator');
$I->wantToTest('Weblink creation in /administrator/'); $I->wantToTest('Weblink creation in /administrator/');
$I->doAdministratorLogin(); $I->doAdministratorLogin();
$I->amGoingTo('Navigate to Weblinks page in /administrator/'); // Get our Weblink Weblink StepObject
$I->amOnPage('administrator/index.php?option=com_weblinks'); $weblinkStep = new AcceptanceTester\WeblinkSteps($scenario);
$I->waitForText('Web Links','30',['css' => 'h1']); $weblinkStep->createWeblink($this->title);
$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->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->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']);
} }
/** /**

View File

@ -28,56 +28,19 @@ class FrontendWeblinksCest
* *
* @return void * @return void
*/ */
public function createWeblinkAndConfirmFrontend(AcceptanceTester $I) public function createWeblinkAndConfirmFrontend(AcceptanceTester $I, $scenario)
{ {
// We should think on making administratorCreateWeblink an step object or an actor
$I->am('Administrator'); $I->am('Administrator');
$I->wantToTest('Weblink creation in /administrator/'); $I->wantToTest('Weblink creation in /administrator/');
$I->doAdministratorLogin(); $I->doAdministratorLogin();
$I->amGoingTo('Navigate to Weblinks page in /administrator/'); // Create Weblink with Weblink StepObject
$I->amOnPage('administrator/index.php?option=com_weblinks'); $weblinkStep = new AcceptanceTester\WeblinkSteps($scenario);
$I->waitForText('Web Links','30',['css' => 'h1']); $weblinkStep->createWeblink($this->title);
$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->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->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']);
// Menu link // Menu link
$I->amGoingTo('Navigate to Menu Manager page in /administrator/'); $I->createMenuItem('automated testing' . rand(1, 100), 'Weblinks', 'List All Web Link Categories');
$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']);
// Go to the frontend // Go to the frontend
$I->wantToTest('If the menu entry exists in the frontend'); $I->wantToTest('If the menu entry exists in the frontend');

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 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();
$title = 'automated testing ' . uniqid();
$I->createMenuItem($title, 'Weblinks', 'List All Web Link Categories');
$I->expectTo('see a success message after saving the menu item');
$I->checkForPhpNoticesOrWarnings();
}
/**
* Create a menu to category Item
*
* @param \AcceptanceTester $I
*
* @return void
*/
public function createCategoryMenuItem(AcceptanceTester $I)
{
$I->am('Administrator');
$I->wantToTest('Frontend category menu creation in /administrator/');
$I->doAdministratorLogin();
$title = 'automated testing ' . uniqid();
$I->createMenuItem($title, 'Weblinks', 'List Web Links in a Category');
$I->expectTo('see a success message after saving the menu item');
$I->checkForPhpNoticesOrWarnings();
}
}

View File

@ -1,2 +1,4 @@
<?php <?php
// Here you can initialize variables that will be available to your tests // Here you can initialize variables that will be available to your tests
\Codeception\Util\Autoload::registerSuffix('Steps', __DIR__.DIRECTORY_SEPARATOR.'_steps');

View File

@ -0,0 +1,45 @@
<?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->am('Administrator');
$I->wantToTest('Weblink creation in /administrator/');
$I->doAdministratorLogin();
$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(['xpath' => "//button[@onclick=\"Joomla.submitbutton('weblink.add')\"]"]);
$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']);
}
}