ConfigurationTest.php 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. <?php
  2. class ConfigurationTest extends \PHPUnit\Framework\TestCase
  3. {
  4. public function setUp()
  5. {
  6. $this->config = \Codeception\Configuration::config();
  7. }
  8. protected function tearDown()
  9. {
  10. \Codeception\Module\UniversalFramework::$includeInheritedActions = true;
  11. \Codeception\Module\UniversalFramework::$onlyActions = [];
  12. \Codeception\Module\UniversalFramework::$excludeActions = [];
  13. }
  14. /**
  15. * @group core
  16. */
  17. public function testSuites()
  18. {
  19. $suites = \Codeception\Configuration::suites();
  20. $this->assertContains('unit', $suites);
  21. $this->assertContains('cli', $suites);
  22. }
  23. /**
  24. * @group core
  25. */
  26. public function testFunctionForStrippingClassNames()
  27. {
  28. $matches = array();
  29. $this->assertEquals(1, preg_match('~\\\\?(\\w*?Helper)$~', '\\Codeception\\Module\\UserHelper', $matches));
  30. $this->assertEquals('UserHelper', $matches[1]);
  31. $this->assertEquals(1, preg_match('~\\\\?(\\w*?Helper)$~', 'UserHelper', $matches));
  32. $this->assertEquals('UserHelper', $matches[1]);
  33. }
  34. /**
  35. * @group core
  36. */
  37. public function testModules()
  38. {
  39. $settings = array('modules' => array('enabled' => array('EmulateModuleHelper')));
  40. $modules = \Codeception\Configuration::modules($settings);
  41. $this->assertContains('EmulateModuleHelper', $modules);
  42. $settings = array('modules' => array(
  43. 'enabled' => array('EmulateModuleHelper'),
  44. 'disabled' => array('EmulateModuleHelper'),
  45. ));
  46. $modules = \Codeception\Configuration::modules($settings);
  47. $this->assertNotContains('EmulateModuleHelper', $modules);
  48. }
  49. /**
  50. * @group core
  51. */
  52. public function testDefaultCustomCommandConfig()
  53. {
  54. $defaultConfig = \Codeception\Configuration::$defaultConfig;
  55. $this->assertArrayHasKey('extensions', $defaultConfig);
  56. $commandsConfig = $defaultConfig['extensions'];
  57. $this->assertArrayHasKey('commands', $commandsConfig);
  58. $this->assertArrayHasKey('extends', $defaultConfig);
  59. $this->assertNull($defaultConfig['extends']);
  60. }
  61. }