RunEnvironmentCest.php 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. <?php
  2. class RunEnvironmentCest
  3. {
  4. public function testDevEnvironment(CliGuy $I)
  5. {
  6. $I->wantTo('execute test in --dev environment');
  7. $I->amInPath('tests/data/sandbox');
  8. $I->executeCommand('run dummy --env=dev');
  9. $I->seeInShellOutput("OK (");
  10. }
  11. public function testProdEnvironment(CliGuy $I)
  12. {
  13. $I->wantTo('execute test in non existent --prod environment');
  14. $I->amInPath('tests/data/sandbox');
  15. $I->executeCommand('run dummy --env=prod');
  16. $I->dontSeeInShellOutput("OK (");
  17. $I->seeInShellOutput("No tests executed");
  18. }
  19. public function testEnvironmentParams(CliGuy $I)
  20. {
  21. $I->wantTo('execute check that env params applied');
  22. $I->amInPath('tests/data/sandbox');
  23. $I->executeCommand('run powers PowerIsRisingCept.php --env=dev -vv --steps');
  24. $I->seeInShellOutput('I got the power');
  25. $I->seeInShellOutput("PASSED");
  26. $I->seeInShellOutput("OK (");
  27. }
  28. public function testWithoutEnvironmentParams(CliGuy $I)
  29. {
  30. $I->wantTo('execute check that env params applied');
  31. $I->amInPath('tests/data/sandbox');
  32. $I->executeCommand('run powers PowerIsRisingCept.php -vv --no-exit');
  33. $I->seeInShellOutput("I have no power");
  34. $I->seeInShellOutput("FAIL");
  35. }
  36. public function runTestForSpecificEnvironment(CliGuy $I)
  37. {
  38. $I->amInPath('tests/data/sandbox');
  39. $I->executeCommand('run powers MageGuildCest.php --env whisky');
  40. $I->seeInShellOutput('MageGuildCest: Red label');
  41. $I->seeInShellOutput('MageGuildCest: Black label');
  42. $I->seeInShellOutput('MageGuildCest: Power of the universe');
  43. $I->seeInShellOutput('OK (3 tests, 3 assertions)');
  44. }
  45. public function runTestForNotIncludedEnvironment(CliGuy $I)
  46. {
  47. $I->amInPath('tests/data/sandbox');
  48. $I->executeCommand('run powers MageGuildCest.php --env dev');
  49. $I->seeInShellOutput('MageGuildCest: Power of the universe');
  50. $I->seeInShellOutput('OK (1 test, 1 assertion)');
  51. }
  52. public function testEnvFileLoading(CliGuy $I)
  53. {
  54. $I->wantTo('test that env configuration files are loaded correctly');
  55. $I->amInPath('tests/data/sandbox');
  56. $I->executeCommand('run messages MessageCest.php:allMessages -vv --env env2');
  57. $I->seeInShellOutput('message1: MESSAGE1 FROM ENV2-DIST.');
  58. $I->seeInShellOutput('message2: MESSAGE2 FROM ENV2.');
  59. $I->seeInShellOutput('message3: MESSAGE3 FROM SUITE.');
  60. $I->seeInShellOutput('message4: DEFAULT MESSAGE4.');
  61. }
  62. public function testEnvMerging(CliGuy $I)
  63. {
  64. $I->wantTo('test that given environments are merged properly');
  65. $I->amInPath('tests/data/sandbox');
  66. $I->executeCommand('run messages MessageCest.php:allMessages -vv --env env1,env2');
  67. $I->seeInShellOutput('message1: MESSAGE1 FROM ENV2-DIST.');
  68. $I->seeInShellOutput('message4: MESSAGE4 FROM SUITE-ENV1.');
  69. $I->executeCommand('run messages MessageCest.php:allMessages -vv --env env2,env1');
  70. $I->seeInShellOutput('message1: MESSAGE1 FROM SUITE-ENV1.');
  71. $I->seeInShellOutput('message4: MESSAGE4 FROM SUITE-ENV1.');
  72. }
  73. public function runTestForMultipleEnvironments(CliGuy $I)
  74. {
  75. $I->wantTo('check that multiple required environments are taken into account');
  76. $I->amInPath('tests/data/sandbox');
  77. $I->executeCommand('run messages MessageCest.php:multipleEnvRequired -vv --env env1');
  78. $I->dontSeeInShellOutput('Multiple env given');
  79. $I->executeCommand('run messages MessageCest.php:multipleEnvRequired -vv --env env2');
  80. $I->dontSeeInShellOutput('Multiple env given');
  81. $I->executeCommand('run messages MessageCest.php:multipleEnvRequired -vv --env env1,env2');
  82. $I->seeInShellOutput('Multiple env given');
  83. $I->executeCommand('run messages MessageCest.php:multipleEnvRequired -vv --env env2,env1');
  84. $I->seeInShellOutput('Multiple env given');
  85. }
  86. public function generateEnvConfig(CliGuy $I)
  87. {
  88. $I->amInPath('tests/data/sandbox');
  89. $I->executeCommand('g:env firefox');
  90. $I->seeInShellOutput('firefox config was created');
  91. $I->seeFileFound('tests/_envs/firefox.yml');
  92. }
  93. public function runEnvironmentForCept(CliGuy $I)
  94. {
  95. $I->amInPath('tests/data/sandbox');
  96. $I->executeCommand('run messages --env email');
  97. $I->seeInShellOutput('Test emails');
  98. $I->dontSeeInShellOutput('Multiple env given');
  99. $I->executeCommand('run messages --env env1');
  100. $I->dontSeeInShellOutput('Test emails');
  101. }
  102. public function showExceptionForUnconfiguredEnvironment(CliGuy $I)
  103. {
  104. $I->amInPath('tests/data/sandbox');
  105. $I->executeCommand('run skipped NoEnvironmentCept --no-exit');
  106. $I->seeInShellOutput("Environment nothing was not configured but used");
  107. $I->seeInShellOutput('WARNING');
  108. }
  109. public function environmentsFromSubfolders(CliGuy $I)
  110. {
  111. $I->amInPath('tests/data/sandbox');
  112. $I->executeCommand('run messages MessageCest.php:allMessages -vv --env env3');
  113. $I->seeInShellOutput('MESSAGE2 FROM ENV3');
  114. }
  115. }