InflectShellTest.php 1.6 KB

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