mirror of
https://github.com/moodle/moodle.git
synced 2025-08-07 09:56:38 +02:00
Merge branch 'wip-mdl-55746' of https://github.com/rajeshtaneja/moodle
This commit is contained in:
commit
846baba950
2 changed files with 172 additions and 8 deletions
|
@ -75,9 +75,11 @@ class tool_behat_manager_util_testcase extends advanced_testcase {
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
private $corefatures = array('test_1' => __DIR__.'/fixtures/core/test_1.feature',
|
/** @var array List of core features. */
|
||||||
'test_2' => __DIR__.'/fixtures/core/test_2.feature');
|
private $corefatures = array('test_1_core_fixtures_tests_behat_tool' => __DIR__.'/fixtures/core/test_1.feature',
|
||||||
|
'test_2_core_fixtures_tests_behat_tool' => __DIR__.'/fixtures/core/test_2.feature');
|
||||||
|
|
||||||
|
/** @var array List of core contexts. */
|
||||||
private $corecontexts = array('behat_test_context_1' => __DIR__.'/fixtures/core/behat_test_context_1.php',
|
private $corecontexts = array('behat_test_context_1' => __DIR__.'/fixtures/core/behat_test_context_1.php',
|
||||||
'behat_test_context_2' => __DIR__.'/fixtures/core/behat_test_context_2.php');
|
'behat_test_context_2' => __DIR__.'/fixtures/core/behat_test_context_2.php');
|
||||||
|
|
||||||
|
@ -461,5 +463,139 @@ class tool_behat_manager_util_testcase extends advanced_testcase {
|
||||||
['C:\mod_assign.feature', 'mod_assign', 'C:\mod_assign.feature'],
|
['C:\mod_assign.feature', 'mod_assign', 'C:\mod_assign.feature'],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Behat config for blacklisted tags.
|
||||||
|
*/
|
||||||
|
public function test_get_config_file_contents_with_blacklisted_tags() {
|
||||||
|
|
||||||
|
$mockbuilder = $this->getMockBuilder('behat_config_util');
|
||||||
|
$mockbuilder->setMethods(array('get_theme_test_directory', 'get_list_of_themes', 'get_blacklisted_tests_for_theme'));
|
||||||
|
|
||||||
|
$behatconfigutil = $mockbuilder->getMock();
|
||||||
|
|
||||||
|
$behatconfigutil = $this->get_behat_config_util($behatconfigutil);
|
||||||
|
|
||||||
|
// Blacklisted tags.
|
||||||
|
$map = array(
|
||||||
|
array('withfeatures', 'tags', array('@test1')),
|
||||||
|
array('nofeatures', 'tags', array('@test2')),
|
||||||
|
array('withfeatures', 'features', array()),
|
||||||
|
array('nofeatures', 'features', array()),
|
||||||
|
array('withfeatures', 'contexts', array()),
|
||||||
|
array('nofeatures', 'contexts', array())
|
||||||
|
);
|
||||||
|
|
||||||
|
$behatconfigutil->expects($this->any())
|
||||||
|
->method('get_blacklisted_tests_for_theme')
|
||||||
|
->will($this->returnValueMap($map));
|
||||||
|
|
||||||
|
$behatconfigutil->set_theme_suite_to_include_core_features(true);
|
||||||
|
$config = $behatconfigutil->get_config_file_contents($this->corefatures, $this->corecontexts);
|
||||||
|
|
||||||
|
// Three suites should be present.
|
||||||
|
$suites = $config['default']['suites'];
|
||||||
|
$this->assertCount(3, $suites);
|
||||||
|
|
||||||
|
$featurepaths = array(
|
||||||
|
'default' => array('test_1.feature', 'test_2.feature'),
|
||||||
|
'withfeatures' => array('test_2.feature', 'theme_test_1.feature', 'theme_test_2.feature', 'theme_test_3.feature',
|
||||||
|
'theme_test_4.feature', 'theme_test_5.feature'),
|
||||||
|
'nofeatures' => array('test_1.feature')
|
||||||
|
);
|
||||||
|
|
||||||
|
// Check features.
|
||||||
|
foreach ($featurepaths as $themename => $paths) {
|
||||||
|
$this->assertCount(count($paths), $suites[$themename]['paths']);
|
||||||
|
|
||||||
|
foreach ($paths as $key => $feature) {
|
||||||
|
$this->assertContains($feature, $suites[$themename]['paths'][$key]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Check contexts.
|
||||||
|
foreach ($this->contextspath as $themename => $paths) {
|
||||||
|
$this->assertCount(count($paths), $suites[$themename]['contexts']);
|
||||||
|
|
||||||
|
foreach ($paths as $key => $context) {
|
||||||
|
$this->assertTrue(in_array($context, $suites[$themename]['contexts']));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// There are 6 step definitions.
|
||||||
|
$this->assertCount(6, $config['default']['extensions']['Moodle\BehatExtension']['steps_definitions']);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Behat config for blacklisted features.
|
||||||
|
*/
|
||||||
|
public function test_get_config_file_contents_with_blacklisted_features_contexts() {
|
||||||
|
|
||||||
|
$mockbuilder = $this->getMockBuilder('behat_config_util');
|
||||||
|
$mockbuilder->setMethods(array('get_theme_test_directory', 'get_list_of_themes', 'get_blacklisted_tests_for_theme'));
|
||||||
|
|
||||||
|
$behatconfigutil = $mockbuilder->getMock();
|
||||||
|
|
||||||
|
$behatconfigutil = $this->get_behat_config_util($behatconfigutil);
|
||||||
|
|
||||||
|
// Blacklisted features and contexts.
|
||||||
|
$map = array(
|
||||||
|
array('withfeatures', 'tags', array()),
|
||||||
|
array('nofeatures', 'tags', array()),
|
||||||
|
array('withfeatures', 'features', array('admin/tool/behat/tests/fixtures/core/test_1.feature')),
|
||||||
|
array('nofeatures', 'features', array('admin/tool/behat/tests/fixtures/core/test_2.feature')),
|
||||||
|
array('withfeatures', 'contexts', array('admin/tool/behat/tests/fixtures/core/behat_test_context_2.php')),
|
||||||
|
array('nofeatures', 'contexts', array('admin/tool/behat/tests/fixtures/core/behat_test_context_1.php'))
|
||||||
|
);
|
||||||
|
|
||||||
|
$behatconfigutil->expects($this->any())
|
||||||
|
->method('get_blacklisted_tests_for_theme')
|
||||||
|
->will($this->returnValueMap($map));
|
||||||
|
|
||||||
|
$behatconfigutil->set_theme_suite_to_include_core_features(true);
|
||||||
|
$config = $behatconfigutil->get_config_file_contents($this->corefatures, $this->corecontexts);
|
||||||
|
|
||||||
|
// Three suites should be present.
|
||||||
|
$suites = $config['default']['suites'];
|
||||||
|
$this->assertCount(3, $suites);
|
||||||
|
|
||||||
|
$featurepaths = array(
|
||||||
|
'default' => array('test_1.feature', 'test_2.feature'),
|
||||||
|
'withfeatures' => array('test_2.feature', 'theme_test_1.feature', 'theme_test_2.feature', 'theme_test_3.feature',
|
||||||
|
'theme_test_4.feature', 'theme_test_5.feature'),
|
||||||
|
'nofeatures' => array('test_1.feature')
|
||||||
|
);
|
||||||
|
$contextspath = array(
|
||||||
|
'default' => array(
|
||||||
|
'behat_test_context_1',
|
||||||
|
'behat_test_context_2'
|
||||||
|
),
|
||||||
|
'withfeatures' => array(
|
||||||
|
'behat_theme_withfeatures_test_context_2',
|
||||||
|
'behat_theme_withfeatures_behat_test_context_1'
|
||||||
|
),
|
||||||
|
'nofeatures' => array(
|
||||||
|
'behat_theme_nofeatures_test_context_1',
|
||||||
|
'behat_theme_nofeatures_behat_test_context_2'
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
|
// Check features.
|
||||||
|
foreach ($featurepaths as $themename => $paths) {
|
||||||
|
$this->assertCount(count($paths), $suites[$themename]['paths']);
|
||||||
|
|
||||||
|
foreach ($paths as $key => $feature) {
|
||||||
|
$this->assertContains($feature, $suites[$themename]['paths'][$key]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Check contexts.
|
||||||
|
foreach ($contextspath as $themename => $paths) {
|
||||||
|
$this->assertCount(count($paths), $suites[$themename]['contexts']);
|
||||||
|
|
||||||
|
foreach ($paths as $key => $context) {
|
||||||
|
$this->assertTrue(in_array($context, $suites[$themename]['contexts']));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// There are 6 step definitions.
|
||||||
|
$this->assertCount(6, $config['default']['extensions']['Moodle\BehatExtension']['steps_definitions']);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// @codeCoverageIgnoreEnd
|
// @codeCoverageIgnoreEnd
|
||||||
|
|
|
@ -208,17 +208,24 @@ class behat_config_util {
|
||||||
$features = array_merge($features, $additionalfeatures);
|
$features = array_merge($features, $additionalfeatures);
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->features = $features;
|
// Sanitize feature key.
|
||||||
|
$cleanfeatures = array();
|
||||||
|
foreach ($features as $featurepath) {
|
||||||
|
list($key, $path) = $this->get_clean_feature_key_and_path($featurepath);
|
||||||
|
$cleanfeatures[$key] = $path;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Sort feature list.
|
||||||
|
ksort($cleanfeatures);
|
||||||
|
|
||||||
|
$this->features = $cleanfeatures;
|
||||||
|
|
||||||
// If tags are passed then filter features which has sepecified tags.
|
// If tags are passed then filter features which has sepecified tags.
|
||||||
if (!empty($tags)) {
|
if (!empty($tags)) {
|
||||||
$features = $this->filtered_features_with_tags($features, $tags);
|
$cleanfeatures = $this->filtered_features_with_tags($cleanfeatures, $tags);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Return sorted list.
|
return $cleanfeatures;
|
||||||
ksort($features);
|
|
||||||
|
|
||||||
return $features;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1220,6 +1227,7 @@ class behat_config_util {
|
||||||
// Get list of features defined by theme.
|
// Get list of features defined by theme.
|
||||||
$themefeatures = $this->get_tests_for_theme($theme, 'features');
|
$themefeatures = $this->get_tests_for_theme($theme, 'features');
|
||||||
$themeblacklistfeatures = $this->get_blacklisted_tests_for_theme($theme, 'features');
|
$themeblacklistfeatures = $this->get_blacklisted_tests_for_theme($theme, 'features');
|
||||||
|
$themeblacklisttags = $this->get_blacklisted_tests_for_theme($theme, 'tags');
|
||||||
|
|
||||||
// Clean feature key and path.
|
// Clean feature key and path.
|
||||||
$features = array();
|
$features = array();
|
||||||
|
@ -1234,6 +1242,26 @@ class behat_config_util {
|
||||||
$blacklistfeatures[$blacklistfeaturekey] = $blacklistfeaturepath;
|
$blacklistfeatures[$blacklistfeaturekey] = $blacklistfeaturepath;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// If blacklist tags then add those features to list.
|
||||||
|
if (!empty($themeblacklisttags)) {
|
||||||
|
// Remove @ if given, so we are sure we have only tag names.
|
||||||
|
$themeblacklisttags = array_map(function($v) {
|
||||||
|
return ltrim($v, '@');
|
||||||
|
}, $themeblacklisttags);
|
||||||
|
|
||||||
|
$themeblacklisttags = '@' . implode(',@', $themeblacklisttags);
|
||||||
|
$blacklistedfeatureswithtag = $this->filtered_features_with_tags($this->get_components_features(),
|
||||||
|
$themeblacklisttags);
|
||||||
|
|
||||||
|
// Add features with blacklisted tags.
|
||||||
|
if (!empty($blacklistedfeatureswithtag)) {
|
||||||
|
foreach ($blacklistedfeatureswithtag as $themeblacklistfeature) {
|
||||||
|
list($key, $path) = $this->get_clean_feature_key_and_path($themeblacklistfeature);
|
||||||
|
$blacklistfeatures[$key] = $path;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
ksort($features);
|
ksort($features);
|
||||||
|
|
||||||
$retval = array(
|
$retval = array(
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue