Skip to content
This repository was archived by the owner on Mar 17, 2020. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
91 changes: 65 additions & 26 deletions RoboFile.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,12 @@
* Download robo.phar from http://robo.li/robo.phar and type in the root of the repo: $ php robo.phar
* Or do: $ composer update, and afterwards you will be able to execute robo like $ php libraries/vendor/bin/robo
*
* @see http://robo.li/
* @package Joomla.Site
* @subpackage RoboFile
*
* @copyright Copyright (C) 2005 - 2016 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
* @see http://robo.li/
*/
require_once __DIR__ . '/tests/codeception/vendor/autoload.php';

Expand All @@ -14,6 +19,13 @@
define('JPATH_BASE', __DIR__);
}

/**
* Modern php task runner for Joomla! Browser Automated Tests execution
*
* @package RoboFile
*
* @since __DEPLOY_VERSION__
*/
class RoboFile extends \Robo\Tasks
{
// Load tasks from composer, see composer.json
Expand All @@ -30,19 +42,23 @@ class RoboFile extends \Robo\Tasks
/**
* Local configuration parameters
*
* @var array
* @var array
* @since __DEPLOY_VERSION__
*/
private $configuration = array();

/**
* Path to the local CMS test folder
*
* @var string
* @var string
* @since __DEPLOY_VERSION__
*/
protected $cmsPath = null;

/**
* Constructor
* RoboFile constructor.
*
* @since __DEPLOY_VERSION__
*/
public function __construct()
{
Expand All @@ -57,6 +73,8 @@ public function __construct()
/**
* Get (optional) configuration from an external file
*
* @since __DEPLOY_VERSION__
*
* @return \stdClass|null
*/
public function getConfiguration()
Expand Down Expand Up @@ -85,6 +103,8 @@ public function getConfiguration()
/**
* Get the correct CMS root path
*
* @since __DEPLOY_VERSION__
*
* @return string
*/
private function getTestingPath()
Expand All @@ -107,6 +127,8 @@ private function getTestingPath()
/**
* Build the Joomla CMS
*
* @since __DEPLOY_VERSION__
*
* @return bool
*/
public function build()
Expand All @@ -118,6 +140,10 @@ public function build()
* Creates a testing Joomla site for running the tests (use it before run:test)
*
* @param bool $use_htaccess (1/0) Rename and enable embedded Joomla .htaccess file
*
* @since __DEPLOY_VERSION__
*
* @return void
*/
public function createTestingSite($use_htaccess = false)
{
Expand Down Expand Up @@ -162,10 +188,14 @@ public function createTestingSite($use_htaccess = false)
/**
* Copy the joomla installation excluding folders
*
* @param string $dst Target folder
* @param array $exclude Exclude list of folders
* @param string $dst Target folder
* @param array $exclude Exclude list of folders
*
* @throws Exception
*
* @since __DEPLOY_VERSION__
*
* @return void
*/
protected function copyJoomla($dst, $exclude = array())
{
Expand Down Expand Up @@ -210,6 +240,8 @@ protected function copyJoomla($dst, $exclude = array())
/**
* Downloads Composer
*
* @since __DEPLOY_VERSION__
*
* @return void
*/
private function getComposer()
Expand All @@ -224,7 +256,9 @@ private function getComposer()
/**
* Runs Selenium Standalone Server.
*
* @return void
* @since __DEPLOY_VERSION__
*
* @return void
*/
public function runSelenium()
{
Expand Down Expand Up @@ -252,10 +286,13 @@ public function runSelenium()
/**
* 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
* @return mixed
* @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
*
* @since __DEPLOY_VERSION__
*
* @return mixed
*/
public function runTests($opts = ['use-htaccess' => false, 'env' => 'desktop'])
{
Expand Down Expand Up @@ -357,6 +394,8 @@ public function runTests($opts = ['use-htaccess' => false, 'env' => 'desktop'])
* @param string $pathToTestFile Optional name of the test to be run
* @param string $suite Optional name of the suite containing the tests, Acceptance by default.
*
* @since __DEPLOY_VERSION__
*
* @return mixed
*/
public function runTest($pathToTestFile = null, $suite = 'acceptance')
Expand Down Expand Up @@ -387,7 +426,6 @@ public function runTest($pathToTestFile = null, $suite = 'acceptance')
if (strripos($iterator->getSubPathName(), 'cept.php')
|| strripos($iterator->getSubPathName(), 'cest.php')
|| strripos($iterator->getSubPathName(), '.feature'))

{
$this->say('[' . $i . '] ' . $iterator->getSubPathName());
$tests[$i] = $iterator->getSubPathName();
Expand All @@ -398,15 +436,15 @@ public function runTest($pathToTestFile = null, $suite = 'acceptance')
}

$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 = $this->testsPath . $suite . '/' . $test;

//loading the class to display the methods in the class
// Loading the class to display the methods in the class

//logic to fetch the class name from the file name
// Logic to fetch the class name from the file name
$fileName = explode("/", $test);

// If the selected file is cest only then we will give the option to execute individual methods, we don't need this in cept or feature files
Expand All @@ -416,7 +454,7 @@ public function runTest($pathToTestFile = null, $suite = 'acceptance')
{
require $this->testsPath . $suite . '/' . $test;

$className = explode(".", $fileName[1]);
$className = explode(".", $fileName[1]);
$class_methods = get_class_methods($className[0]);
$this->say('[' . $i . '] ' . 'All');
$methods[$i] = 'All';
Expand All @@ -425,22 +463,23 @@ public function runTest($pathToTestFile = null, $suite = 'acceptance')
foreach ($class_methods as $method_name)
{
$reflect = new ReflectionMethod($className[0], $method_name);
if(!$reflect->isConstructor())

if (!$reflect->isConstructor() && $reflect->isPublic())
{
if ($reflect->isPublic())
{
$this->say('[' . $i . '] ' . $method_name);
$methods[$i] = $method_name;
$i++;
}
$this->say('[' . $i . '] ' . $method_name);

$methods[$i] = $method_name;

$i++;
}
}

$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')
if (isset($method) && $method != 'All')
{
$pathToTestFile = $pathToTestFile . ':' . $method;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -298,12 +298,13 @@ public function doAdministratorLogout()
* Function to Verify the Tabs on a Joomla! screen
*
* @param array $expectedTabs Expected Tabs on the Page
* @param array $tabsLocator Locator for the Tabs in Edit View
*
* @since __DEPLOY_VERSION__
*
* @return void
*/
public function verifyAvailableTabs($expectedTabs)
public function verifyAvailableTabs($expectedTabs, $tabsLocator = NULL)
{
$I = $this;

Expand Down
18 changes: 14 additions & 4 deletions tests/codeception/_support/Step/Acceptance/Site/UsersFrontend.php
Original file line number Diff line number Diff line change
Expand Up @@ -191,15 +191,25 @@ public function iShouldSeeMessage($message)
/**
* Method to declare user is created
*
* @Then user is created
* @param string $username The username to look for.
*
* @Then user :username is created
*
* @since __DEPLOY_VERSION__
*
* @return void
*/
public function userIsCreated()
public function userIsCreated($username)
{
$I = $this;

$I->amOnPage(UserManagerPage::$url);

// Looking for username
$I->adminPage->search($username);
$I->see($username, UserManagerPage::$seeName);

$I->comment('User is created');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We still need the check here, don't we? :)

}

/**
Expand Down Expand Up @@ -490,13 +500,13 @@ public function iShouldSeeTheName($name)
*
* @param string $name The name of the user
*
* @Given Needs to user :arg1 logged in at least once
* @Given User :arg1 did login at least once
*
* @since __DEPLOY_VERSION__
*
* @return void
*/
public function needsToUserLoggedInAtLeastOnce($name)
public function UserLogInAtLeastOnce($name)
{
// Do nothing as user will be already logged in previous tests.
$I = $this;
Expand Down
4 changes: 3 additions & 1 deletion tests/codeception/acceptance/users_frontend.feature
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ Feature: Users Frontend
And I create a user with fields Name "User Two", Username "user2", Password "pass2" and Email "[email protected]"
And I press the "Register" button
Then I should see "Could not instantiate mail function." message
And user "User Two" is created

Scenario: check the created user in the backend
Given I am on the User Manager page
Expand Down Expand Up @@ -45,6 +46,7 @@ Feature: Users Frontend
Then I should see the name "User Three"

Scenario: Test last login date
Given Needs to user "User Two" logged in at least once
Given I am on the User Manager page
And User "User Three" did login at least once
When I login as a super admin from backend
Then I should see last login date for "User Three"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't it be "User Two"?