InflectShellTest.php 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. <?php
  2. namespace Tools\Test\TestCase\Shell;
  3. use Cake\Console\ConsoleIo;
  4. use Tools\TestSuite\ConsoleOutput;
  5. use Tools\TestSuite\TestCase;
  6. /**
  7. */
  8. class InflectShellTest extends TestCase {
  9. /**
  10. * setUp method
  11. *
  12. * @return void
  13. */
  14. public function setUp() {
  15. parent::setUp();
  16. $this->out = new ConsoleOutput();
  17. $this->err = new ConsoleOutput();
  18. $io = new ConsoleIo($this->out, $this->err);
  19. $this->Shell = $this->getMock(
  20. 'Tools\Shell\InflectShell',
  21. ['in', '_stop'],
  22. [$io]
  23. );
  24. }
  25. /**
  26. * tearDown
  27. *
  28. * @return void
  29. */
  30. public function tearDown() {
  31. parent::tearDown();
  32. unset($this->Shell);
  33. }
  34. /**
  35. * test that the startup method supresses the shell header
  36. *
  37. * @return void
  38. */
  39. public function testMain() {
  40. $this->Shell->expects($this->any())->method('in')
  41. ->will($this->returnValue('FooBar'));
  42. $this->Shell->runCommand(['pluralize']);
  43. $output = $this->out->output();
  44. $expected = 'FooBars';
  45. $this->assertContains($expected, $output);
  46. $this->Shell->runCommand(['underscore']);
  47. $output = $this->out->output();
  48. $expected = 'foo_bar';
  49. $this->assertContains($expected, $output);
  50. $this->Shell->runCommand(['dasherize']);
  51. $output = $this->out->output();
  52. $expected = 'foo-bar';
  53. $this->assertContains($expected, $output);
  54. $this->Shell->runCommand(['slug']);
  55. $output = $this->out->output();
  56. $expected = 'foo-bar';
  57. $this->assertContains($expected, $output);
  58. $this->Shell->runCommand(['tableize']);
  59. $output = $this->out->output();
  60. $expected = 'foo_bar';
  61. $this->assertContains($expected, $output);
  62. }
  63. }