GenerateSuiteTest.php 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. <?php
  2. require_once __DIR__ . DIRECTORY_SEPARATOR . 'BaseCommandRunner.php';
  3. class GenerateSuiteTest extends BaseCommandRunner
  4. {
  5. public $config = ['actor_suffix' => 'Guy'];
  6. protected function setUp()
  7. {
  8. $this->makeCommand('\Codeception\Command\GenerateSuite');
  9. }
  10. public function testBasic()
  11. {
  12. $this->execute(array('suite' => 'shire', 'actor' => 'Hobbit'), false);
  13. $configFile = $this->log[1];
  14. $this->assertEquals(\Codeception\Configuration::projectDir().'tests/shire.suite.yml', $configFile['filename']);
  15. $conf = \Symfony\Component\Yaml\Yaml::parse($configFile['content']);
  16. $this->assertEquals('Hobbit', $conf['actor']);
  17. $this->assertContains('\Helper\Shire', $conf['modules']['enabled']);
  18. $this->assertContains('Suite shire generated', $this->output);
  19. $actor = $this->log[2];
  20. $this->assertEquals(\Codeception\Configuration::supportDir().'Hobbit.php', $actor['filename']);
  21. $this->assertContains('class Hobbit extends \Codeception\Actor', $actor['content']);
  22. $helper = $this->log[0];
  23. $this->assertEquals(\Codeception\Configuration::supportDir().'Helper/Shire.php', $helper['filename']);
  24. $this->assertContains('namespace Helper;', $helper['content']);
  25. $this->assertContains('class Shire extends \Codeception\Module', $helper['content']);
  26. }
  27. public function testGuyWithSuffix()
  28. {
  29. $this->execute(array('suite' => 'shire', 'actor' => 'HobbitTester'), false);
  30. $configFile = $this->log[1];
  31. $conf = \Symfony\Component\Yaml\Yaml::parse($configFile['content']);
  32. $this->assertEquals('HobbitTester', $conf['actor']);
  33. $this->assertContains('\Helper\Shire', $conf['modules']['enabled']);
  34. $helper = $this->log[0];
  35. $this->assertEquals(\Codeception\Configuration::supportDir().'Helper/Shire.php', $helper['filename']);
  36. $this->assertContains('class Shire extends \Codeception\Module', $helper['content']);
  37. }
  38. }