Commit 8b8fe788 authored by Son Nguyen's avatar Son Nguyen Committed by Robert Lyon
Browse files

Upgrade behat 3.0. Bug 1463203

Fix behat step definitions, features

Change-Id: I2bf4e94804b9e86c4e54e5f9e66af233b3f86abf
parent 96379714
Loading
Loading
Loading
Loading
+11 −5
Original line number Diff line number Diff line
{
    "require": {
        "php": ">=5.3.1",
        "behat/behat": "2.5.4",
        "behat/mink": "1.6.0",
        "php": ">=5.3.3",
        "behat/behat": "3.0.10",
        "behat/mink": "1.6.1",

        "behat/mink-extension": "1.3.3",
        "behat/mink-extension": "2.0.1",

        "behat/mink-goutte-driver": "1.1.0",
        "behat/mink-selenium2-driver": "1.2.0",
        "fabpot/goutte": "1.0.7",
        "fabpot/goutte": "2.0.4",

        "phpunit/phpunit": "3.7.38"
    },

    "autoload": {
        "psr-0": {
          "MaharaExtension": "../htdocs/testing/frameworks/behat/extension/"
        }
    }
}
+2 −0
Original line number Diff line number Diff line
@@ -239,9 +239,11 @@ function saveitem(itemid) {
}

function changemenu() {
    isPageRendering = true;
    selectedmenu = $('menuselect').value;
    getitems();
    getadminfiles();
    isPageRendering = false;
}

var selectedmenu = 'loggedoutmenu';
+24 −59
Original line number Diff line number Diff line
@@ -56,65 +56,30 @@ if (empty($CFG->directorypermissions)) {
}
$CFG->filepermissions = $CFG->directorypermissions & 0666;

if (defined('BEHAT_SITE_RUNNING')) {
    // We already switched to behat test site previously.

}
else if (!empty($CFG->behat_wwwroot) ||empty($CFG->behat_dataroot) || !empty($CFG->behat_dbprefix)) {
    // The behat is configured on this server, we need to find out if this is the behat test
    // site based on the URL used for access.
    require_once($CFG->docroot . '/testing/frameworks/behat/lib.php');
    if (behat_is_test_site()) {
        // Checking the integrity of the provided $CFG->behat_* vars and the
        // selected wwwroot to prevent conflicts with production and phpunit environments.
        behat_check_config_vars();

        // Check that the directory does not contains other things.
        if (!file_exists("$CFG->behat_dataroot/behattestdir.txt")) {
            if ($dh = opendir($CFG->behat_dataroot)) {
                while (($file = readdir($dh)) !== false) {
                    if ($file === 'behat' || $file === '.' || $file === '..' || $file === '.DS_Store') {
                        continue;
                    }
                    behat_error(BEHAT_EXITCODE_CONFIG, '$CFG->behat_dataroot directory is not empty, ensure this is the directory where you want to install behat test dataroot');
                }
                closedir($dh);
                unset($dh);
                unset($file);
            }

            if (defined('BEHAT_UTIL')) {
                // Now we create dataroot directory structure for behat tests.
                testing_initdataroot($CFG->behat_dataroot, 'behat');
            } else {
                behat_error(BEHAT_EXITCODE_INSTALL);
// Check if the test mode is enabled
if (isset($CFG->behat_dataroot)) {
    require_once($CFG->docroot . '/testing/frameworks/behat/classes/util.php');
    if (BehatTestingUtil::is_test_site_enabled()) {
        define('BEHAT_TEST', 1);
    }
}

        if (!defined('BEHAT_UTIL') && !defined('BEHAT_TEST')) {
            // Somebody tries to access test site directly, tell them if not enabled.
            if (!file_exists($CFG->behat_dataroot . '/behat/test_environment_enabled.txt')) {
                behat_error(BEHAT_EXITCODE_CONFIG, 'Behat is configured but not enabled on this test site.');
// When running behat tests or behat util CLI commnands,
// switch the $CFG->X for $CFG->behat_X.
if (defined('BEHAT_UTIL') || defined('BEHAT_TEST')) {
    if (empty($CFG->behat_wwwroot) || empty($CFG->behat_dataroot) || empty($CFG->behat_dbprefix)) {
        log_('Behat tests cannot run unless $cfg->behat_wwwroot, $cfg->behat_dataroot, and $cfg->behat_dbprefix are defined in config.php');
        die(1);
    }
        }

        // Constant used to inform that the behat test site is being used,
        // this includes all the processes executed by the behat CLI command like
        // the site reset, the steps executed by the browser drivers when simulating
        // a user session and a real session when browsing manually to $CFG->behat_wwwroot
        // like the browser driver does automatically.
        // Different from BEHAT_TEST as only this last one can perform CLI
        // actions like reset the site or use data generators.
        define('BEHAT_SITE_RUNNING', true);

        // Clean extra config.php settings.
        //behat_clean_init_config();

    // Now we can begin switching $CFG->X for $CFG->behat_X.
    // Keep the origin settings for validating only
    $CFG->wwwroot_orig = isset($CFG->wwwroot) ? $CFG->wwwroot : null;
    $CFG->dataroot_orig = isset($CFG->dataroot) ? $CFG->dataroot : null;
    $CFG->dbprefix_orig = isset($CFG->dbprefix) ? $CFG->dbprefix : null;
    $CFG->wwwroot = $CFG->behat_wwwroot;
        $CFG->dbprefix = $CFG->behat_dbprefix;
    $CFG->dataroot = $CFG->behat_dataroot;
    }
    $CFG->dbprefix = $CFG->behat_dbprefix;
}

// Fix up paths in $CFG
+1 −0
Original line number Diff line number Diff line
@@ -174,6 +174,7 @@ function displayMessage(message, type, hideprevmsg) {
 * = true if the request is still in progress
 */
var isRequestStillProcessing = false;
var isPageRendering = false;

/* Display a nice little loading notification */
function processingStart(msg) {
+6 −0
Original line number Diff line number Diff line
@@ -470,6 +470,12 @@ EOF;
    }

    $smarty->assign('STRINGJS', $stringjs);

    // Disable CSS transforms, transitions, and animations when running behat tests
    if (defined('BEHAT_TEST')) {
        $stylesheets[] = get_config('wwwroot') . 'testing/frameworks/behat/no_transitions.css';
    }

    $stylesheets = append_version_number($stylesheets);
    $smarty->assign('STYLESHEETLIST', $stylesheets);
    if (!empty($theme_list)) {
Loading