ConsoleInputTest.php 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. <?php
  2. declare(strict_types=1);
  3. /**
  4. * CakePHP : Rapid Development Framework (https://cakephp.org)
  5. * Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org)
  6. *
  7. * Licensed under The MIT License
  8. * For full copyright and license information, please see the LICENSE.txt
  9. * Redistributions of files must retain the above copyright notice.
  10. *
  11. * @copyright Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org)
  12. * @link https://cakephp.org CakePHP Project
  13. * @since 3.7.3
  14. * @license https://opensource.org/licenses/mit-license.php MIT License
  15. */
  16. namespace Cake\Test\TestCase\Console;
  17. use Cake\Console\ConsoleInput;
  18. use Cake\Console\Exception\ConsoleException;
  19. use Cake\TestSuite\TestCase;
  20. /**
  21. * ConsoleInput test.
  22. */
  23. class ConsoleInputTest extends TestCase
  24. {
  25. /**
  26. * setUp method
  27. *
  28. * @return void
  29. */
  30. public function setUp(): void
  31. {
  32. parent::setUp();
  33. $this->in = new ConsoleInput();
  34. }
  35. /**
  36. * Test dataAvailable method
  37. *
  38. * @return void
  39. */
  40. public function testDataAvailable()
  41. {
  42. $this->skipIf(
  43. DS === '\\',
  44. 'Skip ConsoleInput tests on Windows as they fail on AppVeyor.'
  45. );
  46. $this->skipIf(
  47. (bool)env('GITHUB_ACTIONS'),
  48. 'Skip test for ConsoleInput::dataAvailable() on Github VM as stream_select() incorrectly return 1 even though no data is available on STDIN.'
  49. );
  50. try {
  51. $this->assertFalse($this->in->dataAvailable());
  52. } catch (ConsoleException $e) {
  53. $this->markTestSkipped(
  54. 'stream_select raised an exception. ' .
  55. 'This can happen when FD_SETSIZE is too small.'
  56. );
  57. }
  58. }
  59. }