GenerateGroupTest.php 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. <?php
  2. require_once __DIR__ . DIRECTORY_SEPARATOR . 'BaseCommandRunner.php';
  3. class GenerateGroupTest extends BaseCommandRunner
  4. {
  5. protected function setUp()
  6. {
  7. $this->makeCommand('\Codeception\Command\GenerateGroup');
  8. $this->config = array(
  9. 'class_name' => 'HobbitGuy',
  10. 'path' => 'tests/shire',
  11. 'paths' => array('support' => 'tests/_support','tests' => 'tests'),
  12. 'settings' => array('bootstrap' => '_bootstrap.php')
  13. );
  14. }
  15. public function testBasic()
  16. {
  17. $this->execute(array('group' => 'Core'));
  18. $generated = $this->log[0];
  19. $this->assertEquals(\Codeception\Configuration::supportDir().'Group/Core.php', $generated['filename']);
  20. $this->assertContains('namespace Group;', $generated['content']);
  21. $this->assertContains('class Core', $generated['content']);
  22. $this->assertContains('public function _before', $generated['content']);
  23. $this->assertContains('public function _after', $generated['content']);
  24. $this->assertContains('static $group = \'core\'', $generated['content']);
  25. $this->assertIsValidPhp($generated['content']);
  26. }
  27. public function testNamespace()
  28. {
  29. $this->config['namespace'] = 'Shire';
  30. $this->execute(array('group' => 'Core'));
  31. $generated = $this->log[0];
  32. $this->assertEquals(\Codeception\Configuration::supportDir().'Group/Core.php', $generated['filename']);
  33. $this->assertContains('namespace Shire\Group;', $generated['content']);
  34. $this->assertIsValidPhp($generated['content']);
  35. }
  36. }