codestyle + fix windows webdriver load

This commit is contained in:
Jelle Kok 2019-08-13 04:18:48 +02:00
parent 8712d4033a
commit 3b155af6e9
No known key found for this signature in database
GPG Key ID: EC8776F3C011B1D1
3 changed files with 36 additions and 33 deletions

View File

@ -12,6 +12,9 @@
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
use Joomla\Testing\Robo\Tasks\loadTasks;
use Robo\Tasks;
require_once 'vendor/autoload.php';
if (!defined('JPATH_BASE'))
@ -26,11 +29,11 @@ if (!defined('JPATH_BASE'))
*
* @since 1.0
*/
class RoboFile extends \Robo\Tasks
class RoboFile extends Tasks
{
// Load tasks from composer, see composer.json
use \Joomla\Testing\Robo\Tasks\loadTasks;
use \Joomla\Jorobo\Tasks\loadTasks;
use loadTasks;
use Joomla\Jorobo\Tasks\loadTasks;
/**
* File extension for executables
@ -77,22 +80,13 @@ class RoboFile extends \Robo\Tasks
/**
* Get the executable extension according to Operating System
*
* @return void
* @return string
*/
private function getExecutableExtension()
{
if ($this->isWindows())
{
// Check whether git.exe or git as command should be used,
// As on window both is possible
if (!$this->_exec('git.exe --version')->getMessage())
{
return '';
}
else
{
return '.exe';
}
return '.exe';
}
return '';
@ -102,10 +96,11 @@ class RoboFile extends \Robo\Tasks
* Executes all the Selenium System Tests in a suite on your machine
*
* @param array $opts Array of configuration options:
* - 'use-htaccess': renames and enable embedded Joomla .htaccess file
* - 'env': set a specific environment to get configuration from
* - 'use-htaccess': renames and enable embedded Joomla .htaccess file
* - 'env': set a specific environment to get configuration from
*
* @return mixed
* @throws \Codeception\Exception\ConfigurationException
*/
public function runTests($opts = ['use-htaccess' => false, 'env' => 'desktop'])
{
@ -166,6 +161,8 @@ class RoboFile extends \Robo\Tasks
* @param string $suite Optional name of the suite containing the tests, Acceptance by default.
*
* @return mixed
* @throws ReflectionException
* @throws \Codeception\Exception\ConfigurationException
*/
public function runTest($pathToTestFile = null, $suite = 'acceptance')
{
@ -205,8 +202,8 @@ class RoboFile extends \Robo\Tasks
}
$this->say('');
$testNumber = $this->ask('Type the number of the test in the list that you want to run...');
$test = $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;
@ -215,7 +212,7 @@ class RoboFile extends \Robo\Tasks
require 'tests/' . $suite . '/' . $test;
// Logic to fetch the class name from the file name
$fileName = explode("/", $test);
$fileName = explode("/", $test);
$className = explode(".", $fileName[1]);
// If the selected file is cest only than we will give the option to execute individual methods, we don't need this in cept file
@ -245,7 +242,7 @@ class RoboFile extends \Robo\Tasks
$this->say('');
$methodNumber = $this->ask('Please choose the method in the test that you would want to run...');
$method = $methods[$methodNumber];
$method = $methods[$methodNumber];
}
if (isset($method) && $method != 'All')
@ -441,20 +438,21 @@ class RoboFile extends \Robo\Tasks
* Runs Selenium Standalone Server.
*
* @return void
* @throws \Codeception\Exception\ConfigurationException
*/
public function runSelenium()
{
if ($this->isWindows())
{
// TODO: Move this logic to the selenium standalone server task in the parent joomla repo
$this->_exec('START java.exe -jar' . $this->getWebDriver() .
' vendor\joomla-projects\selenium-server-standalone\bin\selenium-server-standalone.jar ');
$this->_exec('START java.exe -jar ' . $this->getWebDriver() .
' .\\vendor\\joomla-projects\\selenium-server-standalone\\bin\\selenium-server-standalone.jar ');
sleep(3);
}
else
{
$this->taskSeleniumStandaloneServer()
->setWebdriver($this->getWebdriver())
->setWebdriver($this->getWebdriver())
->runSelenium()
->waitForSelenium()
->run()
@ -585,6 +583,7 @@ class RoboFile extends \Robo\Tasks
* @return string the webdriver string to use with selenium
*
* @since version
* @throws \Codeception\Exception\ConfigurationException
*/
public function getWebdriver()
{
@ -623,8 +622,8 @@ class RoboFile extends \Robo\Tasks
else
{
$this->yell(
print_r($codeceptMainConfig) .
'No driver for your browser. Check your browser in acceptance.suite.yml and the webDrivers in codeception.yml');
print_r($codeceptMainConfig) .
'No driver for your browser. Check your browser in acceptance.suite.yml and the webDrivers in codeception.yml');
// We can't do anything without a driver, exit
exit(1);
@ -695,9 +694,9 @@ class RoboFile extends \Robo\Tasks
*
* @param String $target The target joomla instance
*
* @return void
* @since __DEPLOY_VERSION__
*
* @return void
*/
public function map($target)
{

View File

@ -22,9 +22,10 @@ class category extends \AcceptanceTester
/**
* Function to create a Category in Joomla!
*
* @param String $categoryName Name of the Category which is to be created
* @param String $categoryName Name of the Category which is to be created
*
* @return void
* @throws \Exception
*/
public function createCategory($categoryName)
{
@ -47,9 +48,10 @@ class category extends \AcceptanceTester
/**
* Function to Trash a Category in Joomla!
*
* @param String $categoryName Name of the category which is to be trashed
* @param String $categoryName Name of the category which is to be trashed
*
* @return void
* @throws \Exception
*/
public function trashCategory($categoryName)
{
@ -66,9 +68,10 @@ class category extends \AcceptanceTester
/**
* Function to Delete a Category in Joomla!
*
* @param String $categoryName Name of the category which is to be deleted
* @param String $categoryName Name of the category which is to be deleted
*
* @return void
* @throws \Exception
*/
public function deleteCategory($categoryName)
{

View File

@ -16,10 +16,11 @@ class weblink extends \AcceptanceTester
/**
* Creates a weblink
*
* @param string $title The title for the weblink
* @param string $url The url for the weblink
* @param string $countClicks If not null, we set the "Count Clicks" weblink property to the given value.
* @param string $title The title for the weblink
* @param string $url The url for the weblink
* @param string $countClicks If not null, we set the "Count Clicks" weblink property to the given value.
*
* @throws \Exception
*/
public function createWeblink($title, $url, $countClicks = null)
{
@ -75,4 +76,4 @@ class weblink extends \AcceptanceTester
$I->waitForText('Web Links','30',['css' => 'h1']);
$I->waitForText('1 web link successfully deleted.', 30, ['id' => 'system-message-container']);
}
}
}