GenerateCeptTest.php 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. <?php
  2. require_once __DIR__ . DIRECTORY_SEPARATOR . 'BaseCommandRunner.php';
  3. class GenerateCeptTest extends BaseCommandRunner
  4. {
  5. protected function setUp()
  6. {
  7. $this->makeCommand('\Codeception\Command\GenerateCept');
  8. $this->config = array(
  9. 'actor' => 'HobbitGuy',
  10. 'path' => 'tests/shire',
  11. );
  12. }
  13. public function testGenerateBasic()
  14. {
  15. $this->execute(array('suite' => 'shire', 'test' => 'HomeCanInclude12Dwarfs'));
  16. $this->assertEquals($this->filename, 'tests/shire/HomeCanInclude12DwarfsCept.php');
  17. $this->assertContains('$I = new HobbitGuy($scenario);', $this->content);
  18. $this->assertContains('Test was created in tests/shire/HomeCanInclude12DwarfsCept.php', $this->output);
  19. $this->assertIsValidPhp($this->content);
  20. }
  21. public function testGenerateWithSuffix()
  22. {
  23. $this->execute(array('suite' => 'shire', 'test' => 'HomeCanInclude12DwarfsCept'));
  24. $this->assertEquals($this->filename, 'tests/shire/HomeCanInclude12DwarfsCept.php');
  25. $this->assertIsValidPhp($this->content);
  26. }
  27. /**
  28. * @group command
  29. */
  30. public function testGenerateWithFullName()
  31. {
  32. $this->execute(array('suite' => 'shire', 'test' => 'HomeCanInclude12DwarfsCept.php'));
  33. $this->assertEquals($this->filename, 'tests/shire/HomeCanInclude12DwarfsCept.php');
  34. $this->assertIsValidPhp($this->content);
  35. }
  36. /**
  37. * @group command
  38. */
  39. public function testGenerateWithGuyNamespaced()
  40. {
  41. $this->config['namespace'] = 'MiddleEarth';
  42. $this->execute(array('suite' => 'shire', 'test' => 'HomeCanInclude12Dwarfs'));
  43. $this->assertEquals($this->filename, 'tests/shire/HomeCanInclude12DwarfsCept.php');
  44. $this->assertContains('use MiddleEarth\HobbitGuy;', $this->content);
  45. $this->assertContains('$I = new HobbitGuy($scenario);', $this->content);
  46. $this->assertIsValidPhp($this->content);
  47. }
  48. }