ConsoleIntegrationTestCaseTest.php 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. <?php
  2. namespace Cake\Test\TestCase\TestSuite;
  3. use Cake\Console\Shell;
  4. use Cake\Core\Configure;
  5. use Cake\TestSuite\ConsoleIntegrationTestCase;
  6. class ConsoleIntegrationTestCaseTest extends ConsoleIntegrationTestCase
  7. {
  8. /**
  9. * setUp
  10. *
  11. * @return void
  12. */
  13. public function setUp()
  14. {
  15. parent::setUp();
  16. Configure::write('App.namespace', 'TestApp');
  17. }
  18. /**
  19. * tests exec
  20. *
  21. * @return void
  22. */
  23. public function testExec()
  24. {
  25. $this->exec('');
  26. $this->assertOutputContains('Welcome to CakePHP');
  27. $this->assertExitCode(Shell::CODE_ERROR);
  28. }
  29. /**
  30. * tests a valid core command
  31. *
  32. * @return void
  33. */
  34. public function testExecCoreCommand()
  35. {
  36. $this->exec('routes');
  37. $this->assertOutputContains('Welcome to CakePHP');
  38. $this->assertExitCode(Shell::CODE_SUCCESS);
  39. }
  40. /**
  41. * tests exec with input
  42. *
  43. * @return void
  44. */
  45. public function testExecWithInput()
  46. {
  47. $this->exec('integration bridge', ['javascript']);
  48. $this->assertErrorContains('No!');
  49. $this->assertExitCode(Shell::CODE_ERROR);
  50. }
  51. /**
  52. * tests exec with multiple inputs
  53. *
  54. * @return void
  55. */
  56. public function testExecWithMultipleInput()
  57. {
  58. $this->exec('integration bridge', ['cake', 'blue']);
  59. $this->assertOutputContains('You may pass');
  60. $this->assertExitCode(Shell::CODE_SUCCESS);
  61. }
  62. /**
  63. * tests _commandStringToArgs
  64. *
  65. * @return void
  66. */
  67. public function testCommandStringToArgs()
  68. {
  69. $result = $this->_commandStringToArgs('command --something=nothing --with-spaces="quote me on that"');
  70. $expected = [
  71. 'command',
  72. '--something=nothing',
  73. '--with-spaces=quote me on that'
  74. ];
  75. $this->assertSame($expected, $result);
  76. }
  77. }