* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
-$string['allavailablesteps'] = 'All the available steps';
+$string['allavailablesteps'] = 'All the available steps definitions';
$string['giveninfo'] = 'Given. Processes to set up the environment';
$string['installinfo'] = 'for installation and tests execution info';
$string['moreinfoin'] = 'More info in';
-$string['newstepsinfo'] = 'for info about adding new steps definitions';
-$string['newtestsinfo'] = 'for info about writting new tests';
-$string['noaction'] = 'No action selected';
-$string['nostepsdefinitions'] = 'There aren\'t steps definitions matching this filter';
+$string['newstepsinfo'] = 'for info about how to add new steps definitions';
+$string['newtestsinfo'] = 'for info about how to write new tests';
+$string['nostepsdefinitions'] = 'There aren\'t steps definitions matching this filters';
$string['pluginname'] = 'Acceptance testing';
$string['phpunitenvproblem'] = 'PHPUnit environment problem';
$string['stepsdefinitionscomponent'] = 'Area';
$string['theninfo'] = 'Then. Checkings to ensure the outcomes are the expected ones';
$string['viewsteps'] = 'Filter';
$string['wheninfo'] = 'When. Actions that provokes an event';
-$string['wrongphpversion'] = 'PHP 5.4.0 or higher is required to run acceptance tests';
+$string['wrongphpversion'] = 'PHP 5.4 or higher is required to run acceptance tests. See config-dist.php for alternatives.';
$string['wrongbehatsetup'] = 'Something is wrong with the setup, ensure you ran the composer installer and vendor/bin/behat file has execution permissions';
$currentcwd = getcwd();
chdir($CFG->dirroot);
- exec(self::get_behat_command() . ' --config="' . self::get_steps_list_config_filepath() . '" ' . $filteroption, $steps, $code);
+ exec(self::get_behat_command() . ' --config="'.self::get_steps_list_config_filepath(). '" '.$filteroption, $steps, $code);
chdir($currentcwd);
if ($steps) {
$prefix = '';
$configfilepath = $CFG->dirroot . '/behat.yml';
- // Alternative for steps definitions filtering
+ // Alternative for steps definitions filtering.
} else {
$configfilepath = self::get_steps_list_config_filepath();
$prefix = $CFG->dirroot .'/';
unset($config);
}
- // Add the param if it doesn't exists.
+ // Add the param if it doesn't exists or merge branches.
if (empty($config[$key])) {
$config[$key] = $value;
-
- // Merge branches if the key exists in both branches.
} else {
$config[$key] = self::merge_config($config[$key], $localconfig[$key]);
}
}
// Moodle setting.
- if (!tool_behat::are_behat_dependencies_installed()) {
+ if (!self::are_behat_dependencies_installed()) {
$msg = get_string('wrongbehatsetup', 'tool_behat');
// With HTML.
- $docslink = tool_behat::$docsurl . '#Installation';
+ $docslink = self::$docsurl . '#Installation';
if (!CLI_SCRIPT) {
$docslink = html_writer::tag('a', $docslink, array('href' => $docslink, 'target' => '_blank'));
}
class testable_tool_behat extends tool_behat {
/**
+ * Allow access to protected method
* @see parent::merge_config()
* @param mixed $config
* @param mixed $localconfig
}
/**
+ * Allow access to protected method
* @see parent::get_config_file_contents()
* @param string $prefix
* @param array $features
*/
class tool_behat_testcase extends advanced_testcase {
+ /**
+ * test_switch_environment
+ */
+ public function test_switch_environment() {
- public function test_switch_environment() {
-
- // Only run the tests if behat dependencies are installed.
- // We don't need to pre-check PHPUnit initialisation because we are running on it.
- if (version_compare(PHP_VERSION, '5.4.0', '>=') && tool_behat::are_behat_dependencies_installed()) {
+ // Only run the tests if behat dependencies are installed.
+ // We don't need to pre-check PHPUnit initialisation because we are running on it.
+ if (version_compare(PHP_VERSION, '5.4.0', '>=') && tool_behat::are_behat_dependencies_installed()) {
tool_behat::switchenvironment('enable');
$this->assertTrue(tool_behat::is_test_mode_enabled());
$this->assertFalse(tool_behat::is_test_environment_running());
// Ensure all continues disabled.
$this->assertFalse(tool_behat::is_test_mode_enabled());
$this->assertFalse(tool_behat::is_test_environment_running());
- }
- }
-
- public function test_merge_configs() {
-
- // Simple default config.
- $array1 = array(
- 'the' => 'same',
- 'simple' => 'value',
- 'array' => array(
- 'one' => 'arrayvalue1',
- 'two' => 'arrayvalue2'
- )
- );
-
- // Simple override.
- $array2 = array(
- 'simple' => 'OVERRIDDEN1',
- 'array' => array(
- 'one' => 'OVERRIDDEN2'
- ),
- 'newprofile' => array(
- 'anotherlevel' => array(
- 'andanotherone' => array(
- 'list1',
- 'list2'
- )
- )
- )
- );
-
- $array = testable_tool_behat::merge_config($array1, $array2);
-
- // Overriddes are applied.
- $this->assertEquals('OVERRIDDEN1', $array['simple']);
- $this->assertEquals('OVERRIDDEN2', $array['array']['one']);
-
- // Other values are respected.
- $this->assertNotEmpty($array['array']['two']);
-
- // Completely new nodes are added.
- $this->assertNotEmpty($array['newprofile']);
- $this->assertNotEmpty($array['newprofile']['anotherlevel']['andanotherone']);
- $this->assertEquals('list1', $array['newprofile']['anotherlevel']['andanotherone'][0]);
- $this->assertEquals('list2', $array['newprofile']['anotherlevel']['andanotherone'][1]);
-
- // Complex override changing vectors to scalars and scalars to vectors.
- $array2 = array(
- 'simple' => array(
- 'simple' => 'should',
- 'be' => 'overridden',
- 'by' => 'this-array'
- ),
- 'array' => 'one'
- );
-
- $array = testable_tool_behat::merge_config($array1, $array2);
-
- // Overrides applied.
- $this->assertNotEmpty($array['simple']);
- $this->assertNotEmpty($array['array']);
- $this->assertTrue(is_array($array['simple']));
- $this->assertFalse(is_array($array['array']));
-
- // Other values are maintained.
- $this->assertEquals('same', $array['the']);
- }
-
- public function test_config_file_contents() {
- global $CFG;
-
- unset($CFG->behat_config);
-
- // List.
- $features = array(
- 'feature1',
- 'feature2',
- 'feature3'
- );
-
- // Associative array.
- $stepsdefinitions = array(
- 'micarro' => '/me/lo/robaron',
- 'anoche' => '/cuando/yo/dormia'
- );
-
- $contents = testable_tool_behat::get_config_file_contents('/i/am/a/prefix/', $features, $stepsdefinitions);
-
- $this->assertContains('features: /i/am/a/prefix/lib/behat/features', $contents);
- $this->assertContains('micarro: /me/lo/robaron', $contents);
- $this->assertContains('base_url: \'' . $CFG->behat_wwwroot . '\'', $contents);
- $this->assertContains('class: behat_init_context', $contents);
- $this->assertContains('- feature1', $contents);
- $this->assertContains('- feature3', $contents);
-
- }
+ }
+ }
+
+ /**
+ * test_merge_configs
+ */
+ public function test_merge_configs() {
+
+ // Simple default config.
+ $array1 = array(
+ 'the' => 'same',
+ 'simple' => 'value',
+ 'array' => array(
+ 'one' => 'arrayvalue1',
+ 'two' => 'arrayvalue2'
+ )
+ );
+
+ // Simple override.
+ $array2 = array(
+ 'simple' => 'OVERRIDDEN1',
+ 'array' => array(
+ 'one' => 'OVERRIDDEN2'
+ ),
+ 'newprofile' => array(
+ 'anotherlevel' => array(
+ 'andanotherone' => array(
+ 'list1',
+ 'list2'
+ )
+ )
+ )
+ );
+
+ $array = testable_tool_behat::merge_config($array1, $array2);
+
+ // Overriddes are applied.
+ $this->assertEquals('OVERRIDDEN1', $array['simple']);
+ $this->assertEquals('OVERRIDDEN2', $array['array']['one']);
+
+ // Other values are respected.
+ $this->assertNotEmpty($array['array']['two']);
+
+ // Completely new nodes are added.
+ $this->assertNotEmpty($array['newprofile']);
+ $this->assertNotEmpty($array['newprofile']['anotherlevel']['andanotherone']);
+ $this->assertEquals('list1', $array['newprofile']['anotherlevel']['andanotherone'][0]);
+ $this->assertEquals('list2', $array['newprofile']['anotherlevel']['andanotherone'][1]);
+
+ // Complex override changing vectors to scalars and scalars to vectors.
+ $array2 = array(
+ 'simple' => array(
+ 'simple' => 'should',
+ 'be' => 'overridden',
+ 'by' => 'this-array'
+ ),
+ 'array' => 'one'
+ );
+
+ $array = testable_tool_behat::merge_config($array1, $array2);
+
+ // Overrides applied.
+ $this->assertNotEmpty($array['simple']);
+ $this->assertNotEmpty($array['array']);
+ $this->assertTrue(is_array($array['simple']));
+ $this->assertFalse(is_array($array['array']));
+
+ // Other values are maintained.
+ $this->assertEquals('same', $array['the']);
+ }
+
+ /**
+ * test_config_file_contents
+ */
+ public function test_config_file_contents() {
+ global $CFG;
+
+ unset($CFG->behat_config);
+
+ // List.
+ $features = array(
+ 'feature1',
+ 'feature2',
+ 'feature3'
+ );
+
+ // Associative array.
+ $stepsdefinitions = array(
+ 'micarro' => '/me/lo/robaron',
+ 'anoche' => '/cuando/yo/dormia'
+ );
+
+ $contents = testable_tool_behat::get_config_file_contents('/i/am/a/prefix/', $features, $stepsdefinitions);
+
+ $this->assertContains('features: /i/am/a/prefix/lib/behat/features', $contents);
+ $this->assertContains('micarro: /me/lo/robaron', $contents);
+ $this->assertContains('base_url: \'' . $CFG->behat_wwwroot . '\'', $contents);
+ $this->assertContains('class: behat_init_context', $contents);
+ $this->assertContains('- feature1', $contents);
+ $this->assertContains('- feature3', $contents);
+ }
+
}
),
'tool' => array(
- 'assignmentupgrade', 'capability', 'customlang', 'dbtransfer', 'generator',
- 'health', 'innodb', 'langimport', 'multilangupgrade', 'phpunit', 'profiling',
- 'qeupgradehelper', 'replace', 'spamcleaner', 'timezoneimport', 'unittest',
- 'uploaduser', 'unsuproles', 'xmldb'
+ 'assignmentupgrade', 'behat', 'capability', 'customlang', 'dbtransfer',
+ 'generator', 'health', 'innodb', 'langimport', 'multilangupgrade', 'phpunit',
+ 'profiling', 'qeupgradehelper', 'replace', 'spamcleaner', 'timezoneimport',
+ 'unittest', 'uploaduser', 'unsuproles', 'xmldb'
),
'webservice' => array(