InflectShellTest.php 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  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. class InflectShellTest extends TestCase {
  8. /**
  9. * @var \Tools\Shell\InflectShell
  10. */
  11. public $Shell;
  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->getMockBuilder(InflectShell::class)
  21. ->setMethods(['in', '_stop'])
  22. ->setConstructorArgs([$io])
  23. ->getMock();
  24. }
  25. /**
  26. * @return void
  27. */
  28. public function tearDown() {
  29. parent::tearDown();
  30. unset($this->Shell);
  31. }
  32. /**
  33. * test that the startup method supresses the shell header
  34. *
  35. * @return void
  36. */
  37. public function testMain() {
  38. $this->Shell->expects($this->any())->method('in')
  39. ->will($this->returnValue('FooBar'));
  40. $this->Shell->runCommand(['pluralize']);
  41. $output = $this->out->output();
  42. $expected = 'FooBars';
  43. $this->assertContains($expected, $output);
  44. $this->Shell->runCommand(['underscore']);
  45. $output = $this->out->output();
  46. $expected = 'foo_bar';
  47. $this->assertContains($expected, $output);
  48. $this->Shell->runCommand(['dasherize']);
  49. $output = $this->out->output();
  50. $expected = 'foo-bar';
  51. $this->assertContains($expected, $output);
  52. $this->Shell->runCommand(['slug']);
  53. $output = $this->out->output();
  54. $expected = 'foo-bar';
  55. $this->assertContains($expected, $output);
  56. $this->Shell->runCommand(['tableize']);
  57. $output = $this->out->output();
  58. $expected = 'foo_bar';
  59. $this->assertContains($expected, $output);
  60. }
  61. }