IncludedCest.php 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  1. <?php
  2. class IncludedCest
  3. {
  4. public function _before()
  5. {
  6. \Codeception\Util\FileSystem::doEmptyDir('tests/data/included/_log');
  7. file_put_contents('tests/data/included/_log/.gitkeep', '');
  8. }
  9. /**
  10. * @param CliGuy $I
  11. */
  12. protected function moveToIncluded(\CliGuy $I)
  13. {
  14. $I->amInPath('tests/data/included');
  15. }
  16. /**
  17. * @before moveToIncluded
  18. * @param CliGuy $I
  19. */
  20. public function runSuitesFromIncludedConfigs(\CliGuy $I)
  21. {
  22. $I->executeCommand('run');
  23. $I->seeInShellOutput('[Jazz]');
  24. $I->seeInShellOutput('Jazz.functional Tests');
  25. $I->seeInShellOutput('[Jazz\Pianist]');
  26. $I->seeInShellOutput('Jazz\Pianist.functional Tests');
  27. $I->seeInShellOutput('[Shire]');
  28. $I->seeInShellOutput('Shire.functional Tests');
  29. }
  30. /**
  31. * @before moveToIncluded
  32. * @param CliGuy $I
  33. */
  34. public function runTestsFromIncludedConfigs(\CliGuy $I)
  35. {
  36. $ds = DIRECTORY_SEPARATOR;
  37. $I->executeCommand("run jazz{$ds}tests{$ds}functional{$ds}DemoCept.php", false);
  38. // Suite is not run
  39. $I->dontSeeInShellOutput('[Jazz]');
  40. // DemoCept tests are run
  41. $I->seeInShellOutput('Jazz.functional Tests');
  42. $I->seeInShellOutput('DemoCept');
  43. // Other include tests are not run
  44. $I->dontSeeInShellOutput('[Shire]');
  45. $I->dontSeeInShellOutput('Shire.functional Tests');
  46. $I->dontSeeInShellOutput('[Jazz\Pianist]');
  47. $I->dontSeeInShellOutput('Jazz\Pianist.functional Tests');
  48. }
  49. /**
  50. * @before moveToIncluded
  51. * @param CliGuy $I
  52. */
  53. public function runTestsFromIncludedConfigsNested(\CliGuy $I)
  54. {
  55. $I->executeCommand('run jazz/pianist/tests/functional/PianistCept.php', false);
  56. // Suite is not run
  57. $I->dontSeeInShellOutput('[Jazz\Pianist]');
  58. // DemoCept tests are run
  59. $I->seeInShellOutput('Jazz\Pianist.functional Tests');
  60. $I->seeInShellOutput('PianistCept');
  61. // Other include tests are not run
  62. $I->dontSeeInShellOutput('[Shire]');
  63. $I->dontSeeInShellOutput('Shire.functional Tests');
  64. $I->dontSeeInShellOutput('[Jazz]');
  65. $I->dontSeeInShellOutput('Jazz.functional Tests');
  66. }
  67. /**
  68. * @before moveToIncluded
  69. * @param CliGuy $I
  70. */
  71. public function runTestsFromIncludedConfigsSingleTest(\CliGuy $I)
  72. {
  73. $ds = DIRECTORY_SEPARATOR;
  74. $I->executeCommand("run jazz{$ds}tests{$ds}unit{$ds}SimpleTest.php:testSimple", false);
  75. // Suite is not run
  76. $I->dontSeeInShellOutput('[Jazz]');
  77. // SimpleTest:testSimple is run
  78. $I->seeInShellOutput('Jazz.unit Tests');
  79. $I->dontSeeInShellOutput('Jazz.functional Tests');
  80. $I->seeInShellOutput('SimpleTest');
  81. // SimpleTest:testSimpler is not run
  82. $I->dontSeeInShellOutput('SimplerTest');
  83. // Other include tests are not run
  84. $I->dontSeeInShellOutput('[Shire]');
  85. $I->dontSeeInShellOutput('Shire.functional Tests');
  86. $I->dontSeeInShellOutput('[Jazz\Pianist]');
  87. $I->dontSeeInShellOutput('Jazz\Pianist.functional Tests');
  88. }
  89. /**
  90. * @before moveToIncluded
  91. * @param CliGuy $I
  92. */
  93. public function runIncludedWithXmlOutput(\CliGuy $I)
  94. {
  95. $I->executeCommand('run --xml');
  96. $I->amInPath('_log');
  97. $I->seeFileFound('report.xml');
  98. $I->seeInThisFile('<testsuite name="Jazz.functional" tests="1" assertions="1"');
  99. $I->seeInThisFile('<testsuite name="Jazz\Pianist.functional" tests="1" assertions="1"');
  100. $I->seeInThisFile('<testsuite name="Shire.functional" tests="1" assertions="1"');
  101. $I->seeInThisFile('<testcase name="Hobbit"');
  102. $I->seeInThisFile('<testcase name="Demo"');
  103. $I->seeInThisFile('<testcase name="Pianist"');
  104. }
  105. /**
  106. * @before moveToIncluded
  107. * @param CliGuy $I
  108. */
  109. public function runIncludedWithHtmlOutput(\CliGuy $I)
  110. {
  111. $I->executeCommand('run --html');
  112. $I->amInPath('_log');
  113. $I->seeFileFound('report.html');
  114. $I->seeInThisFile('Codeception Results');
  115. $I->seeInThisFile('Jazz.functional Tests');
  116. $I->seeInThisFile('Check that jazz musicians can add numbers');
  117. $I->seeInThisFile('Jazz\Pianist.functional Tests');
  118. $I->seeInThisFile('Check that jazz pianists can add numbers');
  119. $I->seeInThisFile('Shire.functional Tests');
  120. }
  121. /**
  122. * @before moveToIncluded
  123. * @group coverage
  124. * @param CliGuy $I
  125. */
  126. public function runIncludedWithCoverage(\CliGuy $I)
  127. {
  128. $I->executeCommand('run --coverage-xml');
  129. $I->amInPath('_log');
  130. $I->seeFileFound('coverage.xml');
  131. $I->seeInThisFile('BillEvans" namespace="Jazz\Pianist">');
  132. $I->seeInThisFile('Musician" namespace="Jazz">');
  133. $I->seeInThisFile('Hobbit" namespace="Shire">');
  134. }
  135. /**
  136. * @before moveToIncluded
  137. * @param CliGuy $I
  138. */
  139. public function buildIncluded(\CliGuy $I)
  140. {
  141. $I->executeCommand('build');
  142. $I->seeInShellOutput('generated successfully');
  143. $I->seeInShellOutput('Jazz\\TestGuy');
  144. $I->seeInShellOutput('Jazz\\Pianist\\TestGuy');
  145. $I->seeInShellOutput('Shire\\TestGuy');
  146. }
  147. }