SimpleWithDataProviderYieldGeneratorCest.php 626 B

12345678910111213141516171819202122232425262728293031
  1. <?php
  2. class SimpleWithDataProviderYieldGeneratorCest
  3. {
  4. /**
  5. * @dataProvider getTestData
  6. *
  7. * @example ["fizz", "buzz"]
  8. * @example [null, "test"]
  9. */
  10. public function helloWorld(\CodeGuy $I, \Codeception\Example $example) {
  11. $I->execute(function($example) {
  12. if (!is_array($example)) {
  13. return false;
  14. }
  15. return count($example);
  16. })->seeResultEquals(2);
  17. }
  18. /**
  19. * @return Generator
  20. */
  21. protected function getTestData()
  22. {
  23. yield ['foo', 'bar'];
  24. yield [1, 2];
  25. yield [true, false];
  26. }
  27. }