2015-05-30 15:57:47 +00:00
< ? 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 AdministratorWeblinksCest
{
2015-05-30 22:10:41 +00:00
public function __construct ()
{
2015-09-30 17:29:14 +00:00
$this -> faker = Faker\Factory :: create ();
$this -> title = 'Weblink' . $this -> faker -> randomNumber ();
$this -> url = $this -> faker -> url ();
2015-05-30 22:10:41 +00:00
}
2015-09-30 17:29:14 +00:00
public function administratorCreateWeblink ( \Step\Acceptance\weblink $I )
2015-05-30 15:57:47 +00:00
{
2015-05-30 16:29:24 +00:00
$I -> am ( 'Administrator' );
2015-05-30 16:30:25 +00:00
$I -> wantToTest ( 'Weblink creation in /administrator/' );
2015-05-30 16:29:24 +00:00
$I -> doAdministratorLogin ();
2015-09-30 17:29:14 +00:00
// Get the weblink StepObject
2015-05-30 16:30:25 +00:00
$I -> amGoingTo ( 'Navigate to Weblinks page in /administrator/' );
$I -> amOnPage ( 'administrator/index.php?option=com_weblinks' );
2015-09-30 17:29:14 +00:00
$I -> waitForText ( 'Web Links' , '30' , [ 'css' => 'h1' ]);
2015-05-30 16:30:25 +00:00
$I -> expectTo ( 'see weblinks page' );
2015-05-30 16:29:24 +00:00
$I -> checkForPhpNoticesOrWarnings ();
2015-05-30 16:30:25 +00:00
$I -> amGoingTo ( 'try to save a weblink with a filled title and URL' );
2015-09-30 17:29:14 +00:00
$I -> click ( 'New' );
$I -> waitForText ( 'Web Link: New' , '30' , [ 'css' => 'h1' ]);
2015-05-30 22:10:41 +00:00
$I -> fillField ([ 'id' => 'jform_title' ], $this -> title );
2015-09-30 17:29:14 +00:00
$I -> fillField ([ 'id' => 'jform_url' ], $this -> url );
$I -> click ([ 'xpath' => " //button[@onclick= \" Joomla.submitbutton('weblink.save') \" ] " ]);
$I -> waitForText ( 'Web Links' , '30' , [ 'css' => 'h1' ]);
2015-05-30 22:10:41 +00:00
$I -> expectTo ( 'see a success message and the weblink added after saving the weblink' );
2015-09-30 17:29:14 +00:00
$I -> see ( 'Web link successfully saved' , [ 'id' => 'system-message-container' ]);
$I -> see ( $this -> title , [ 'id' => 'weblinkList' ]);
2015-05-30 22:10:41 +00:00
}
2015-05-30 22:19:28 +00:00
/**
2015-05-30 22:21:18 +00:00
* @ depends administratorCreateWeblink
2015-05-30 22:19:28 +00:00
*/
2015-07-29 16:23:47 +00:00
public function administratorTrashWeblink ( AcceptanceTester $I )
2015-05-30 22:10:41 +00:00
{
$I -> am ( 'Administrator' );
2015-06-09 11:50:04 +00:00
$I -> wantToTest ( 'Weblink removal in /administrator/' );
2015-05-30 22:10:41 +00:00
$I -> doAdministratorLogin ();
$I -> amGoingTo ( 'Navigate to Weblinks page in /administrator/' );
$I -> amOnPage ( 'administrator/index.php?option=com_weblinks' );
2015-07-29 16:23:47 +00:00
$I -> waitForText ( 'Web Links' , '30' ,[ 'css' => 'h1' ]);
2015-05-30 22:10:41 +00:00
$I -> expectTo ( 'see weblinks page' );
$I -> amGoingTo ( 'Search the just saved weblink' );
2015-07-29 16:23:47 +00:00
$I -> searchForItem ( $this -> title );
$I -> waitForText ( 'Web Links' , '30' ,[ 'css' => 'h1' ]);
2015-05-30 22:10:41 +00:00
$I -> amGoingTo ( 'Delete the just saved weblink' );
2015-07-29 16:23:47 +00:00
$I -> checkAllResults ();
2015-09-06 17:19:36 +00:00
$I -> click ([ 'xpath' => " //button[@onclick= \" if (document.adminForm.boxchecked.value==0) { alert('Please first make a selection from the list.');}else { Joomla.submitbutton('weblinks.trash')} \" ] " ]);
2015-07-29 16:23:47 +00:00
$I -> waitForText ( 'Web Links' , '30' ,[ 'css' => 'h1' ]);
2015-05-30 22:10:41 +00:00
$I -> expectTo ( 'see a success message and the weblink removed from the list' );
$I -> see ( 'Web link successfully trashed' ,[ 'id' => 'system-message-container' ]);
$I -> cantSee ( $this -> title ,[ 'id' => 'weblinkList' ]);
2015-05-30 15:57:47 +00:00
}
2015-05-30 16:45:18 +00:00
2015-07-29 16:23:47 +00:00
/**
2015-09-30 17:29:14 +00:00
* @ depends administratorTrashWeblink
2015-07-29 16:23:47 +00:00
*/
public function administratorDeleteWeblink ( AcceptanceTester $I )
{
$I -> am ( 'Administrator' );
$I -> wantToTest ( 'Weblink removal 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 -> selectOptionInChosen ( '- Select Status -' , 'Trashed' );
$I -> amGoingTo ( 'Search the just saved weblink' );
$I -> searchForItem ( $this -> title );
$I -> waitForText ( 'Web Links' , '30' ,[ 'css' => 'h1' ]);
$I -> amGoingTo ( 'Delete the just saved weblink' );
$I -> checkAllResults ();
$I -> click ([ 'xpath' => '//div[@id="toolbar-delete"]/button' ]);
$I -> waitForText ( 'Web Links' , '30' ,[ 'css' => 'h1' ]);
$I -> expectTo ( 'see a success message and the weblink removed from the list' );
$I -> see ( '1 web link successfully deleted.' ,[ 'id' => 'system-message-container' ]);
$I -> cantSee ( $this -> title ,[ 'id' => 'weblinkList' ]);
}
2015-05-30 16:45:18 +00:00
public function administratorCreateWeblinkWithoutTitleFails ( AcceptanceTester $I )
{
$I -> am ( 'Administrator' );
2015-06-09 11:50:04 +00:00
$I -> wantToTest ( 'Weblink creation without title fails in /administrator/' );
2015-05-30 16:45:18 +00:00
$I -> doAdministratorLogin ();
$I -> amGoingTo ( 'Navigate to Weblinks page in /administrator/' );
$I -> amOnPage ( 'administrator/index.php?option=com_weblinks' );
2015-07-29 16:23:47 +00:00
$I -> waitForText ( 'Web Links' , '30' ,[ 'css' => 'h1' ]);
2015-05-30 16:45:18 +00:00
$I -> expectTo ( 'see weblinks page' );
$I -> checkForPhpNoticesOrWarnings ();
$I -> amGoingTo ( 'try to save a weblink with empty title and it should fail' );
$I -> click ([ 'xpath' => " //button[@onclick= \" Joomla.submitbutton('weblink.add') \" ] " ]);
2015-07-29 16:23:47 +00:00
$I -> waitForText ( 'Web Link: New' , '30' ,[ 'css' => 'h1' ]);
2015-05-30 16:45:18 +00:00
$I -> click ([ 'xpath' => " //button[@onclick= \" Joomla.submitbutton('weblink.apply') \" ] " ]);
$I -> expectTo ( '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' ]);
}
2015-05-30 15:57:47 +00:00
}