GenerateStepObjectTest.php 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. <?php
  2. require_once __DIR__ . DIRECTORY_SEPARATOR . 'BaseCommandRunner.php';
  3. class GenerateStepObjectTest extends BaseCommandRunner
  4. {
  5. protected function setUp()
  6. {
  7. $this->makeCommand('\Codeception\Command\GenerateStepObject');
  8. $this->config = array(
  9. 'actor' => 'HobbitGuy',
  10. 'path' => 'tests/shire',
  11. );
  12. }
  13. public function testBasic()
  14. {
  15. $this->execute(array('suite' => 'shire', 'step' => 'Login', '--silent' => true));
  16. $generated = $this->log[0];
  17. $this->assertEquals(\Codeception\Configuration::supportDir().'Step/Shire/Login.php', $generated['filename']);
  18. $this->assertContains('class Login extends \HobbitGuy', $generated['content']);
  19. $this->assertContains('namespace Step\\Shire;', $generated['content']);
  20. $this->assertIsValidPhp($generated['content']);
  21. $this->assertIsValidPhp($this->content);
  22. }
  23. public function testNamespace()
  24. {
  25. $this->config['namespace'] = 'MiddleEarth';
  26. $this->execute(array('suite' => 'shire', 'step' => 'Login', '--silent' => true));
  27. $generated = $this->log[0];
  28. $this->assertEquals(\Codeception\Configuration::supportDir().'Step/Shire/Login.php', $generated['filename']);
  29. $this->assertContains('namespace MiddleEarth\Step\Shire;', $generated['content']);
  30. $this->assertContains('class Login extends \MiddleEarth\HobbitGuy', $generated['content']);
  31. $this->assertIsValidPhp($generated['content']);
  32. $this->assertIsValidPhp($this->content);
  33. }
  34. public function testCreateInSubpath()
  35. {
  36. $this->execute(array('suite' => 'shire', 'step' => 'User/Login', '--silent' => true));
  37. $generated = $this->log[0];
  38. $this->assertEquals(
  39. \Codeception\Configuration::supportDir().'Step/Shire/User/Login.php',
  40. $generated['filename']
  41. );
  42. $this->assertIsValidPhp($this->content);
  43. }
  44. }