diff --git a/RoboFile.php b/RoboFile.php index efb03a43d7..79dc5da32a 100644 --- a/RoboFile.php +++ b/RoboFile.php @@ -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'; @@ -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 @@ -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() { @@ -57,6 +73,8 @@ public function __construct() /** * Get (optional) configuration from an external file * + * @since __DEPLOY_VERSION__ + * * @return \stdClass|null */ public function getConfiguration() @@ -85,6 +103,8 @@ public function getConfiguration() /** * Get the correct CMS root path * + * @since __DEPLOY_VERSION__ + * * @return string */ private function getTestingPath() @@ -107,6 +127,8 @@ private function getTestingPath() /** * Build the Joomla CMS * + * @since __DEPLOY_VERSION__ + * * @return bool */ public function build() @@ -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) { @@ -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()) { @@ -210,6 +240,8 @@ protected function copyJoomla($dst, $exclude = array()) /** * Downloads Composer * + * @since __DEPLOY_VERSION__ + * * @return void */ private function getComposer() @@ -224,7 +256,9 @@ private function getComposer() /** * Runs Selenium Standalone Server. * - * @return void + * @since __DEPLOY_VERSION__ + * + * @return void */ public function runSelenium() { @@ -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']) { @@ -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') @@ -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(); @@ -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 @@ -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'; @@ -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; } diff --git a/tests/codeception/_support/Page/Acceptance/Administrator/AdminPage.php b/tests/codeception/_support/Page/Acceptance/Administrator/AdminPage.php index 79e97c1ae0..fdfbdf44df 100644 --- a/tests/codeception/_support/Page/Acceptance/Administrator/AdminPage.php +++ b/tests/codeception/_support/Page/Acceptance/Administrator/AdminPage.php @@ -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; diff --git a/tests/codeception/_support/Step/Acceptance/Site/UsersFrontend.php b/tests/codeception/_support/Step/Acceptance/Site/UsersFrontend.php index 99e4d5d6ed..71078cf0f6 100644 --- a/tests/codeception/_support/Step/Acceptance/Site/UsersFrontend.php +++ b/tests/codeception/_support/Step/Acceptance/Site/UsersFrontend.php @@ -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'); } /** @@ -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; diff --git a/tests/codeception/acceptance/users_frontend.feature b/tests/codeception/acceptance/users_frontend.feature index d9f106f9b5..6a5ee9e01e 100644 --- a/tests/codeception/acceptance/users_frontend.feature +++ b/tests/codeception/acceptance/users_frontend.feature @@ -14,6 +14,7 @@ Feature: Users Frontend And I create a user with fields Name "User Two", Username "user2", Password "pass2" and Email "user2@example.com" 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 @@ -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"