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. * @var \Tools\Shell\InflectShell
  12. */
  13. public $Shell;
  14. /**
  15. * @return void
  16. */
  17. public function setUp() {
  18. parent::setUp();
  19. $this->out = new ConsoleOutput();
  20. $this->err = new ConsoleOutput();
  21. $io = new ConsoleIo($this->out, $this->err);
  22. $this->Shell = $this->getMockBuilder(InflectShell::class)
  23. ->setMethods(['in', '_stop'])
  24. ->setConstructorArgs([$io])
  25. ->getMock();
  26. }
  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. }