ExtensionsCest.php 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. <?php
  2. class ExtensionsCest
  3. {
  4. // tests
  5. public function useAlternativeFormatter(CliGuy $I)
  6. {
  7. $I->wantTo('use alternative formatter delivered through extensions');
  8. $I->amInPath('tests/data/sandbox');
  9. $I->executeCommand('run tests/dummy/FileExistsCept.php -c codeception_extended.yml');
  10. $I->dontSeeInShellOutput("Check config");
  11. $I->seeInShellOutput('[+] FileExistsCept');
  12. $I->seeInShellOutput('Modules used: Filesystem, DumbHelper');
  13. }
  14. public function loadExtensionByOverride(CliGuy $I)
  15. {
  16. $I->amInPath('tests/data/sandbox');
  17. $I->executeCommand('run tests/dummy/FileExistsCept.php -o "extensions: enabled: [\Codeception\Extension\SimpleOutput]"');
  18. $I->dontSeeInShellOutput("Check config");
  19. $I->seeInShellOutput('[+] FileExistsCept');
  20. }
  21. public function reRunFailedTests(CliGuy $I)
  22. {
  23. $ds = DIRECTORY_SEPARATOR;
  24. $I->amInPath('tests/data/sandbox');
  25. $I->executeCommand('run unit FailingTest.php -c codeception_extended.yml --no-exit');
  26. $I->seeInShellOutput('FAILURES');
  27. $I->seeFileFound('failed', 'tests/_output');
  28. $I->seeFileContentsEqual(<<<EOF
  29. tests{$ds}unit{$ds}FailingTest.php:testMe
  30. EOF
  31. );
  32. $I->executeCommand('run -g failed -c codeception_extended.yml --no-exit');
  33. $I->seeInShellOutput('Tests: 1, Assertions: 1, Failures: 1');
  34. }
  35. public function checkIfExtensionsReceiveCorrectOptions(CliGuy $I)
  36. {
  37. $I->wantTo('check if extensions receive correct options');
  38. $I->amInPath('tests/data/sandbox');
  39. $I->executeCommand('run tests/dummy/AnotherCest.php:optimistic -c codeception_extended.yml');
  40. $I->seeInShellOutput('Low verbosity');
  41. $I->executeCommand('run tests/dummy/AnotherCest.php:optimistic -c codeception_extended.yml -v');
  42. $I->seeInShellOutput('Medium verbosity');
  43. $I->executeCommand('run tests/dummy/AnotherCest.php:optimistic -c codeception_extended.yml -vv');
  44. $I->seeInShellOutput('High verbosity');
  45. $I->executeCommand('run tests/dummy/AnotherCest.php:optimistic -c codeception_extended.yml -vvv');
  46. $I->seeInShellOutput('Extreme verbosity');
  47. }
  48. public function runPerSuiteExtensions(CliGuy $I)
  49. {
  50. $I->amInPath('tests/data/sandbox');
  51. $I->executeCommand('run extended,scenario', false);
  52. $I->seeInShellOutput('Suite setup for extended');
  53. $I->seeInShellOutput('Test setup for Hello');
  54. $I->seeInShellOutput('Test teardown for Hello');
  55. $I->seeInShellOutput('Suite teardown for extended');
  56. $I->dontSeeInShellOutput('Suite setup for scenario');
  57. $I->seeInShellOutput('Config1: value1');
  58. $I->seeInShellOutput('Config2: value2');
  59. }
  60. public function runPerSuiteExtensionsInEnvironment(CliGuy $I)
  61. {
  62. $I->amInPath('tests/data/sandbox');
  63. $I->executeCommand('run extended --env black', false);
  64. $I->seeInShellOutput('Suite setup for extended');
  65. $I->seeInShellOutput('Test setup for Hello');
  66. $I->seeInShellOutput('Config1: black_value');
  67. $I->seeInShellOutput('Config2: value2');
  68. }
  69. }