MDL-64557 tool_behat: fix broken test
[moodle.git] / admin / tool / behat / tests / manager_util_test.php
1 <?php
2 // @codingStandardsIgnoreFile
3 // @codeCoverageIgnoreStart
5 // This file is part of Moodle - http://moodle.org/
6 //
7 // Moodle is free software: you can redistribute it and/or modify
8 // it under the terms of the GNU General Public License as published by
9 // the Free Software Foundation, either version 3 of the License, or
10 // (at your option) any later version.
11 //
12 // Moodle is distributed in the hope that it will be useful,
13 // but WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 // GNU General Public License for more details.
16 //
17 // You should have received a copy of the GNU General Public License
18 // along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
20 /**
21  * Unit tests for behat manager.
22  *
23  * @package   tool_behat
24  * @copyright  2016 Rajesh Taneja
25  * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
26  */
28 defined('MOODLE_INTERNAL') || die();
30 global $CFG;
31 require_once($CFG->dirroot . '/' . $CFG->admin .'/tool/behat/locallib.php');
32 require_once($CFG->libdir . '/behat/classes/util.php');
33 require_once($CFG->libdir . '/behat/classes/behat_config_manager.php');
35 /**
36  * Behat manager tests.
37  *
38  * @package    tool_behat
39  * @copyright  2016 Rajesh Taneja
40  * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
41  */
42 class tool_behat_manager_util_testcase extends advanced_testcase {
44     /** @var array Fixtures features which are available. */
45     private $featurepaths = array(
46         'default' => array(
47             'test_1.feature',
48             'test_2.feature',
49         ),
50         'withfeatures' => array(
51             'theme_test_1.feature',
52             'theme_test_2.feature',
53             'theme_test_3.feature',
54             'theme_test_4.feature',
55             'theme_test_5.feature',
56         ),
57         'nofeatures' => array()
58     );
60     /** @var array Fixture contexts which are available */
61     private $contextspath = array(
62         'default' => array(
63             'behat_test_context_1',
64             'behat_test_context_2',
65             'behat_theme_defaulttheme_test_context_1'
66         ),
67         'withfeatures' => array(
68             'behat_test_context_2',
69             'behat_theme_withfeatures_test_context_2',
70             'behat_theme_withfeatures_behat_test_context_1'
71         ),
72         'nofeatures' => array(
73             'behat_test_context_1',
74             'behat_theme_nofeatures_test_context_1',
75             'behat_theme_nofeatures_behat_test_context_2'
76         ),
77     );
79     /** @var array List of core features. */
80     private $corefeatures = array('test_1_core_fixtures_tests_behat_tool' => __DIR__.'/fixtures/core/test_1.feature',
81                                  'test_2_core_fixtures_tests_behat_tool' => __DIR__.'/fixtures/core/test_2.feature');
83     /** @var array List of core contexts. */
84     private $corecontexts = array('behat_test_context_1' => __DIR__.'/fixtures/core/behat_test_context_1.php',
85                                   'behat_test_context_2' => __DIR__.'/fixtures/core/behat_test_context_2.php');
87     /**
88      * Setup test.
89      */
90     public function setup() {
91         global $CFG;
93         $this->resetAfterTest();
94         $CFG->behat_wwwroot = 'http://example.com/behat';
95     }
97     /**
98      * Utility function to build mock object.
99      *
100      * @param  behat_config_util $behatconfigutil
101      * @param bool $notheme
102      * @return mixed
103      */
104     private function get_behat_config_util($behatconfigutil, $notheme = false) {
105         // Create a map of arguments to return values.
106         $map = array(
107             array('withfeatures', __DIR__.'/fixtures/theme/withfeatures'),
108             array('nofeatures', __DIR__.'/fixtures/theme/nofeatures'),
109             array('defaulttheme', __DIR__.'/fixtures/theme/defaulttheme'),
110         );
112         // List of themes is const for test.
113         if ($notheme) {
114             $themelist = array('defaulttheme');
115         } else {
116             $themelist = array('withfeatures', 'nofeatures', 'defaulttheme');
117         }
119         $behatconfigutil->expects($this->any())
120             ->method('get_list_of_themes')
121             ->will($this->returnValue($themelist));
123         // Theme directory for testing.
124         $behatconfigutil->expects($this->any())
125             ->method('get_theme_test_directory')
126             ->will($this->returnValueMap($map));
128         $behatconfigutil->expects($this->any())
129             ->method('get_default_theme')
130             ->will($this->returnValue('defaulttheme'));
132         return $behatconfigutil;
133     }
135     /**
136      * Behat config for single run.
137      */
138     public function test_get_config_file_contents_with_single_run() {
140         $mockbuilder = $this->getMockBuilder('behat_config_util');
141         $mockbuilder->setMethods(array('get_theme_test_directory', 'get_list_of_themes', 'get_default_theme'));
143         $behatconfigutil = $mockbuilder->getMock();
145         $behatconfigutil = $this->get_behat_config_util($behatconfigutil);
146         $config = $behatconfigutil->get_config_file_contents($this->corefeatures, $this->corecontexts);
148         // Two suites should be present.
149         $suites = $config['default']['suites'];
150         $this->assertCount(3, $suites);
152         // Check features.
153         foreach ($this->featurepaths as $themename => $paths) {
154             $this->assertCount(count($paths), $suites[$themename]['paths']);
156             foreach ($paths as $key => $feature) {
157                 $this->assertContains($feature, $suites[$themename]['paths'][$key]);
158             }
159         }
161         // Check contexts.
162         foreach ($this->contextspath as $themename => $paths) {
163             $this->assertCount(count($paths), $suites[$themename]['contexts']);
165             foreach ($paths as $key => $context) {
166                 $this->assertTrue(in_array($context, $suites[$themename]['contexts']));
167             }
168         }
170         // There are 7 step definitions.
171         $this->assertCount(7, $config['default']['extensions']['Moodle\BehatExtension']['steps_definitions']);
172     }
174     /**
175      * Behat config for single run with no theme installed.
176      */
177     public function test_get_config_file_contents_with_single_run_no_theme() {
179         $mockbuilder = $this->getMockBuilder('behat_config_util');
180         $mockbuilder->setMethods(array('get_theme_test_directory', 'get_list_of_themes', 'get_default_theme'));
182         $behatconfigutil = $mockbuilder->getMock();
184         $behatconfigutil = $this->get_behat_config_util($behatconfigutil, true);
185         $config = $behatconfigutil->get_config_file_contents($this->corefeatures, $this->corecontexts);
187         // Two suites should be present.
188         $suites = $config['default']['suites'];
189         $this->assertCount(1, $suites);
191         $featurepaths = array(
192             'default' => array(
193                 'test_1.feature',
194                 'test_2.feature',
195             )
196         );
198         $contextspath = array(
199             'default' => array(
200                 'behat_test_context_1',
201                 'behat_test_context_2',
202                 'behat_theme_defaulttheme_test_context_1',
203             )
204         );
206         // Check features.
207         foreach ($featurepaths as $themename => $paths) {
208             $this->assertCount(count($paths), $suites[$themename]['paths']);
210             foreach ($paths as $key => $feature) {
211                 $this->assertContains($feature, $suites[$themename]['paths'][$key]);
212             }
213         }
215         // Check contexts.
216         foreach ($contextspath as $themename => $paths) {
217             $this->assertCount(count($paths), $suites[$themename]['contexts']);
219             foreach ($paths as $key => $context) {
220                 $this->assertTrue(in_array($context, $suites[$themename]['contexts']));
221             }
222         }
224         // There are 3 step definitions.
225         $this->assertCount(3, $config['default']['extensions']['Moodle\BehatExtension']['steps_definitions']);
226     }
228     /**
229      * Behat config for parallel run.
230      */
231     public function test_get_config_file_contents_with_parallel_run() {
233         $mockbuilder = $this->getMockBuilder('behat_config_util');
234         $mockbuilder->setMethods(array('get_theme_test_directory', 'get_list_of_themes', 'get_default_theme'));
236         $behatconfigutil = $mockbuilder->getMock();
238         $behatconfigutil = $this->get_behat_config_util($behatconfigutil);
240         // Test first run out of 3.
241         $config = $behatconfigutil->get_config_file_contents($this->corefeatures, $this->corecontexts, '', 3, 1);
242         // Three suites should be present.
243         $suites = $config['default']['suites'];
244         $this->assertCount(3, $suites);
245         // There is first feature file in first run.
246         $featurepaths = array(
247             'default' => array('test_1.feature'),
248             'withfeatures' => array('theme_test_1.feature', 'theme_test_2.feature'),
249             'nofeatures' => array()
250         );
251         // Check features.
252         foreach ($featurepaths as $themename => $paths) {
253             $this->assertCount(count($paths), $suites[$themename]['paths']);
255             foreach ($paths as $key => $feature) {
256                 $this->assertContains($feature, $suites[$themename]['paths'][$key]);
257             }
258         }
260         // Check contexts.
261         foreach ($this->contextspath as $themename => $paths) {
262             $this->assertCount(count($paths), $suites[$themename]['contexts']);
264             foreach ($paths as $key => $context) {
265                 $this->assertTrue(in_array($context, $suites[$themename]['contexts']));
266             }
267         }
268         // There are 7 step definitions.
269         $this->assertCount(7, $config['default']['extensions']['Moodle\BehatExtension']['steps_definitions']);
271         // Test second run out of 3.
272         $config = $behatconfigutil->get_config_file_contents('', '', '', 3, 2);
273         // Three suites should be present.
274         $suites = $config['default']['suites'];
275         $this->assertCount(3, $suites);
276         // There is second feature file in first run.
277         $featurepaths = array(
278             'default' => array('test_2.feature'),
279             'withfeatures' => array('theme_test_3.feature', 'theme_test_4.feature'),
280             'nofeatures' => array()
281         );
282         // Check features.
283         foreach ($featurepaths as $themename => $paths) {
284             $this->assertCount(count($paths), $suites[$themename]['paths']);
286             foreach ($paths as $key => $feature) {
287                 $this->assertContains($feature, $suites[$themename]['paths'][$key]);
288             }
289         }
290         // Check contexts.
291         foreach ($this->contextspath as $themename => $paths) {
292             $this->assertCount(count($paths), $suites[$themename]['contexts']);
294             foreach ($paths as $key => $context) {
295                 $this->assertTrue(in_array($context, $suites[$themename]['contexts']));
296             }
297         }
298         // There are 7 step definitions.
299         $this->assertCount(7, $config['default']['extensions']['Moodle\BehatExtension']['steps_definitions']);
301         // Test third run out of 3.
302         $config = $behatconfigutil->get_config_file_contents('', '', '', 3, 3);
303         $suites = $config['default']['suites'];
304         $this->assertCount(3, $suites);
305         // There is second feature file in first run.
306         $featurepaths = array(
307             'default' => array(),
308             'withfeatures' => array('theme_test_5.feature'),
309             'nofeatures' => array()
310         );
311         // Check features.
312         foreach ($featurepaths as $themename => $paths) {
313             $this->assertCount(count($paths), $suites[$themename]['paths']);
315             foreach ($paths as $key => $feature) {
316                 $this->assertContains($feature, $suites[$themename]['paths'][$key]);
317             }
318         }
319         // Check contexts.
320         foreach ($this->contextspath as $themename => $paths) {
321             $this->assertCount(count($paths), $suites[$themename]['contexts']);
323             foreach ($paths as $key => $context) {
324                 $this->assertTrue(in_array($context, $suites[$themename]['contexts']));
325             }
326         }
327         // There are 7 step definitions.
328         $this->assertCount(7, $config['default']['extensions']['Moodle\BehatExtension']['steps_definitions']);
329     }
331     /**
332      * Behat config for parallel run.
333      */
334     public function test_get_config_file_contents_with_parallel_run_optimize_tags() {
336         $mockbuilder = $this->getMockBuilder('behat_config_util');
337         $mockbuilder->setMethods(array('get_theme_test_directory', 'get_list_of_themes', 'get_default_theme'));
339         $behatconfigutil = $mockbuilder->getMock();
341         $behatconfigutil = $this->get_behat_config_util($behatconfigutil);
343         // Test first run out of 3.
344         $config = $behatconfigutil->get_config_file_contents($this->corefeatures, $this->corecontexts, '@commontag', 3, 1);
346         // Three suites should be present.
347         $suites = $config['default']['suites'];
348         $this->assertCount(3, $suites);
349         // There is first feature file in first run.
350         $featurepaths = array(
351             'default' => array('test_1.feature'),
352             'withfeatures' => array('theme_test_1.feature', 'theme_test_3.feature'),
353             'nofeatures' => array()
354         );
355         // Check features.
356         foreach ($featurepaths as $themename => $paths) {
357             $this->assertCount(count($paths), $suites[$themename]['paths']);
359             foreach ($paths as $key => $feature) {
360                 $this->assertContains($feature, $suites[$themename]['paths'][$key]);
361             }
362         }
363         // Check contexts.
364         foreach ($this->contextspath as $themename => $paths) {
365             $this->assertCount(count($paths), $suites[$themename]['contexts']);
367             foreach ($paths as $key => $context) {
368                 $this->assertTrue(in_array($context, $suites[$themename]['contexts']));
369             }
370         }
371         // There are 7step definitions.
372         $this->assertCount(7, $config['default']['extensions']['Moodle\BehatExtension']['steps_definitions']);
374         // Test second run out of 3.
375         $config = $behatconfigutil->get_config_file_contents('', '', '@commontag', 3, 2);
377         // Three suites should be present.
378         $suites = $config['default']['suites'];
379         $this->assertCount(3, $suites);
380         // There is second feature file in first run.
381         $featurepaths = array(
382             'default' => array('test_2.feature'),
383             'withfeatures' => array('theme_test_2.feature', 'theme_test_4.feature'),
384             'nofeatures' => array()
385         );
386         // Check features.
387         foreach ($featurepaths as $themename => $paths) {
388             $this->assertCount(count($paths), $suites[$themename]['paths']);
390             foreach ($paths as $key => $feature) {
391                 $this->assertContains($feature, $suites[$themename]['paths'][$key]);
392             }
393         }
394         // Check contexts.
395         foreach ($this->contextspath as $themename => $paths) {
396             $this->assertCount(count($paths), $suites[$themename]['contexts']);
398             foreach ($paths as $key => $context) {
399                 $this->assertTrue(in_array($context, $suites[$themename]['contexts']));
400             }
401         }
402         // There are 7 step definitions.
403         $this->assertCount(7, $config['default']['extensions']['Moodle\BehatExtension']['steps_definitions']);
405         // Test third run out of 3.
406         $config = $behatconfigutil->get_config_file_contents('', '', '', 3, 3);
407         $suites = $config['default']['suites'];
408         $this->assertCount(3, $suites);
409         // There is second feature file in first run.
410         $featurepaths = array(
411             'default' => array(),
412             'withfeatures' => array('theme_test_5.feature'),
413             'nofeatures' => array()
414         );
415         // Check features.
416         foreach ($featurepaths as $themename => $paths) {
417             $this->assertCount(count($paths), $suites[$themename]['paths']);
419             foreach ($paths as $key => $feature) {
420                 $this->assertContains($feature, $suites[$themename]['paths'][$key]);
421             }
422         }
423         // Check contexts.
424         foreach ($this->contextspath as $themename => $paths) {
425             $this->assertCount(count($paths), $suites[$themename]['contexts']);
427             foreach ($paths as $key => $context) {
428                 $this->assertTrue(in_array($context, $suites[$themename]['contexts']));
429             }
430         }
431         // There are 7 step definitions.
432         $this->assertCount(7, $config['default']['extensions']['Moodle\BehatExtension']['steps_definitions']);
433     }
435     /**
436      * Test if clean features key and path is returned.
437      * @dataProvider clean_features_path_list
438      */
439     public function test_get_clean_feature_key_and_path($featurepath, $key, $cleanfeaturepath) {
440         global $CFG;
442         // This is a hack so directory name is correctly detected in tests.
443         //FIXME: MDL-55722 work out why this is necessary..
444         $oldroot = $CFG->dirroot;
445         $CFG->dirroot = 'C:';
447         $behatconfigutil = new behat_config_util();
449         // Fix expected directory path for OS.
450         $cleanfeaturepath = testing_cli_fix_directory_separator($cleanfeaturepath);
452         list($retkey, $retcleanfeaturepath) = $behatconfigutil->get_clean_feature_key_and_path($featurepath);
454         $this->assertEquals($key, $retkey);
455         $this->assertEquals($cleanfeaturepath, $retcleanfeaturepath);
456         //FIXME: MDL-55722 work out why this is necessary..
457         $CFG->dirroot = $oldroot;
458     }
460     public function clean_features_path_list() {
461         return array(
462             ['/home/test/this/that/test/behat/mod_assign.feature', 'mod_assign_behat_test_that_this_test', '/home/test/this/that/test/behat/mod_assign.feature'],
463             ['/home/this/that/test/behat/mod_assign.feature', 'mod_assign_behat_test_that_this_home', '/home/this/that/test/behat/mod_assign.feature'],
464             ['/home/that/test/behat/mod_assign.feature', 'mod_assign_behat_test_that_home', '/home/that/test/behat/mod_assign.feature'],
465             ['/home/test/behat/mod_assign.feature', 'mod_assign_behat_test_home', '/home/test/behat/mod_assign.feature'],
466             ['mod_assign.feature', 'mod_assign', 'mod_assign.feature'],
467             ['C:\test\this\that\test\behat\mod_assign.feature', 'mod_assign_behat_test_that_this_test', 'C:\test\this\that\test\behat\mod_assign.feature'],
468             ['C:\this\that\test\behat\mod_assign.feature', 'mod_assign_behat_test_that_this', 'C:\this\that\test\behat\mod_assign.feature'],
469             ['C:\that\test\behat\mod_assign.feature', 'mod_assign_behat_test_that', 'C:\that\test\behat\mod_assign.feature'],
470             ['C:\test\behat\mod_assign.feature', 'mod_assign_behat_test', 'C:\test\behat\mod_assign.feature'],
471             ['C:\mod_assign.feature', 'mod_assign', 'C:\mod_assign.feature'],
472         );
473     }
475     /**
476      * Behat config for blacklisted tags.
477      */
478     public function test_get_config_file_contents_with_blacklisted_tags() {
480         $mockbuilder = $this->getMockBuilder('behat_config_util');
481         $mockbuilder->setMethods(array('get_theme_test_directory', 'get_list_of_themes', 'get_blacklisted_tests_for_theme',
482             'get_default_theme'));
484         $behatconfigutil = $mockbuilder->getMock();
486         $behatconfigutil = $this->get_behat_config_util($behatconfigutil);
488         // Blacklisted tags.
489         $map = array(
490             array('withfeatures', 'tags', array('@test1')),
491             array('nofeatures', 'tags', array('@test2')),
492             array('defaulttheme', 'tags', array()),
493             array('withfeatures', 'features', array()),
494             array('nofeatures', 'features', array()),
495             array('defaulttheme', 'features', array()),
496             array('withfeatures', 'contexts', array()),
497             array('nofeatures', 'contexts', array()),
498             array('defaulttheme', 'contexts', array())
499         );
501         $behatconfigutil->expects($this->any())
502             ->method('get_blacklisted_tests_for_theme')
503             ->will($this->returnValueMap($map));
505         $behatconfigutil->set_theme_suite_to_include_core_features(true);
506         $config = $behatconfigutil->get_config_file_contents($this->corefeatures, $this->corecontexts);
508         // Three suites should be present.
509         $suites = $config['default']['suites'];
510         $this->assertCount(3, $suites);
512         $featurepaths = array(
513             'default' => array('test_1.feature', 'test_2.feature'),
514             'withfeatures' => array('test_2.feature', 'theme_test_1.feature', 'theme_test_2.feature', 'theme_test_3.feature',
515                 'theme_test_4.feature', 'theme_test_5.feature'),
516             'nofeatures' => array('test_1.feature')
517         );
519         // Check features.
520         foreach ($featurepaths as $themename => $paths) {
521             $this->assertCount(count($paths), $suites[$themename]['paths']);
523             foreach ($paths as $key => $feature) {
524                 $this->assertContains($feature, $suites[$themename]['paths'][$key]);
525             }
526         }
527         // Check contexts.
528         foreach ($this->contextspath as $themename => $paths) {
529             $this->assertCount(count($paths), $suites[$themename]['contexts']);
531             foreach ($paths as $key => $context) {
532                 $this->assertTrue(in_array($context, $suites[$themename]['contexts']));
533             }
534         }
535         // There are 7 step definitions.
536         $this->assertCount(7, $config['default']['extensions']['Moodle\BehatExtension']['steps_definitions']);
537     }
539     /**
540      * Behat config for blacklisted features.
541      */
542     public function test_get_config_file_contents_with_blacklisted_features_contexts() {
544         $mockbuilder = $this->getMockBuilder('behat_config_util');
545         $mockbuilder->setMethods(array('get_theme_test_directory', 'get_list_of_themes', 'get_blacklisted_tests_for_theme',
546             'get_default_theme'));
548         $behatconfigutil = $mockbuilder->getMock();
550         $behatconfigutil = $this->get_behat_config_util($behatconfigutil);
552         // Blacklisted features and contexts.
553         $map = array(
554             array('withfeatures', 'tags', array()),
555             array('nofeatures', 'tags', array()),
556             array('defaulttheme', 'tags', array()),
557             array('withfeatures', 'features', array('admin/tool/behat/tests/fixtures/core/test_1.feature')),
558             array('nofeatures', 'features', array('admin/tool/behat/tests/fixtures/core/test_2.feature')),
559             array('defaulttheme', 'features', array()),
560             array('withfeatures', 'contexts', array('admin/tool/behat/tests/fixtures/core/behat_test_context_2.php')),
561             array('nofeatures', 'contexts', array('admin/tool/behat/tests/fixtures/core/behat_test_context_1.php')),
562             array('defaulttheme', 'contexts', array()),
563         );
565         $behatconfigutil->expects($this->any())
566             ->method('get_blacklisted_tests_for_theme')
567             ->will($this->returnValueMap($map));
569         $behatconfigutil->set_theme_suite_to_include_core_features(true);
570         $config = $behatconfigutil->get_config_file_contents($this->corefeatures, $this->corecontexts);
572         // Three suites should be present.
573         $suites = $config['default']['suites'];
574         $this->assertCount(3, $suites);
576         $featurepaths = array(
577             'default' => array('test_1.feature', 'test_2.feature'),
578             'withfeatures' => array('test_2.feature', 'theme_test_1.feature', 'theme_test_2.feature', 'theme_test_3.feature',
579                 'theme_test_4.feature', 'theme_test_5.feature'),
580             'nofeatures' => array('test_1.feature')
581         );
582         $contextspath = array(
583             'default' => array(
584                 'behat_test_context_1',
585                 'behat_test_context_2',
586                 'behat_theme_defaulttheme_test_context_1',
587             ),
588             'withfeatures' => array(
589                 'behat_theme_withfeatures_test_context_2',
590                 'behat_theme_withfeatures_behat_test_context_1'
591             ),
592             'nofeatures' => array(
593                 'behat_theme_nofeatures_test_context_1',
594                 'behat_theme_nofeatures_behat_test_context_2'
595             ),
596         );
598         // Check features.
599         foreach ($featurepaths as $themename => $paths) {
600             $this->assertCount(count($paths), $suites[$themename]['paths']);
602             foreach ($paths as $key => $feature) {
603                 $this->assertContains($feature, $suites[$themename]['paths'][$key]);
604             }
605         }
606         // Check contexts.
607         foreach ($contextspath as $themename => $paths) {
608             $this->assertCount(count($paths), $suites[$themename]['contexts']);
610             foreach ($paths as $key => $context) {
611                 $this->assertTrue(in_array($context, $suites[$themename]['contexts']));
612             }
613         }
614         // There are 7 step definitions.
615         $this->assertCount(7, $config['default']['extensions']['Moodle\BehatExtension']['steps_definitions']);
616     }
618     /**
619      * Behat config for blacklisted tags.
620      */
621     public function test_core_features_to_include_in_specified_theme() {
623         $mockbuilder = $this->getMockBuilder('behat_config_util');
624         $mockbuilder->setMethods(array('get_theme_test_directory', 'get_list_of_themes', 'get_default_theme'));
626         $behatconfigutil = $mockbuilder->getMock();
628         $behatconfigutil = $this->get_behat_config_util($behatconfigutil);
630         // Check features when, no theme is specified.
631         $behatconfigutil->set_theme_suite_to_include_core_features('');
632         $config = $behatconfigutil->get_config_file_contents($this->corefeatures, $this->corecontexts);
633         $suites = $config['default']['suites'];
634         foreach ($this->featurepaths as $themename => $paths) {
635             $this->assertCount(count($paths), $suites[$themename]['paths']);
637             foreach ($paths as $key => $feature) {
638                 $this->assertContains($feature, $suites[$themename]['paths'][$key]);
639             }
640         }
642         // Check features when all themes are specified.
643         $featurepaths = $this->featurepaths;
644         $featurepaths['withfeatures'] = array_merge ($featurepaths['default'], $featurepaths['withfeatures']);
645         $featurepaths['nofeatures'] = array_merge ($featurepaths['default'], $featurepaths['nofeatures']);
647         $behatconfigutil->set_theme_suite_to_include_core_features('ALL');
648         $config = $behatconfigutil->get_config_file_contents($this->corefeatures, $this->corecontexts);
649         $suites = $config['default']['suites'];
650         foreach ($featurepaths as $themename => $paths) {
651             $this->assertCount(count($paths), $suites[$themename]['paths']);
653             foreach ($paths as $key => $feature) {
654                 $this->assertContains($feature, $suites[$themename]['paths'][$key]);
655             }
656         }
658         // Check features when all themes are specified.
659         $featurepaths = $this->featurepaths;
660         $featurepaths['withfeatures'] = array_merge ($featurepaths['default'], $featurepaths['withfeatures']);
661         $featurepaths['nofeatures'] = array_merge ($featurepaths['default'], $featurepaths['nofeatures']);
663         $behatconfigutil->set_theme_suite_to_include_core_features('withfeatures, nofeatures');
664         $config = $behatconfigutil->get_config_file_contents($this->corefeatures, $this->corecontexts);
665         $suites = $config['default']['suites'];
666         foreach ($featurepaths as $themename => $paths) {
667             $this->assertCount(count($paths), $suites[$themename]['paths']);
669             foreach ($paths as $key => $feature) {
670                 $this->assertContains($feature, $suites[$themename]['paths'][$key]);
671             }
672         }
674         // Check features when specified themes are passed..
675         $featurepaths = $this->featurepaths;
676         $featurepaths['nofeatures'] = array_merge ($featurepaths['default'], $featurepaths['nofeatures']);
678         $behatconfigutil->set_theme_suite_to_include_core_features('nofeatures');
679         $config = $behatconfigutil->get_config_file_contents($this->corefeatures, $this->corecontexts);
680         $suites = $config['default']['suites'];
681         foreach ($featurepaths as $themename => $paths) {
682             $this->assertCount(count($paths), $suites[$themename]['paths']);
684             foreach ($paths as $key => $feature) {
685                 $this->assertContains($feature, $suites[$themename]['paths'][$key]);
686             }
687         }
688     }
690 // @codeCoverageIgnoreEnd