ConsoleInputTest.php 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  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. use function Cake\Core\env;
  21. /**
  22. * ConsoleInput test.
  23. */
  24. class ConsoleInputTest extends TestCase
  25. {
  26. /**
  27. * @var \Cake\Console\ConsoleInput
  28. */
  29. protected $in;
  30. /**
  31. * setUp method
  32. */
  33. public function setUp(): void
  34. {
  35. parent::setUp();
  36. $this->in = new ConsoleInput();
  37. }
  38. /**
  39. * Test dataAvailable method
  40. */
  41. public function testDataAvailable(): void
  42. {
  43. $this->skipIf(
  44. (bool)env('GITHUB_ACTIONS'),
  45. 'Skip test for ConsoleInput::dataAvailable() on Github VM as stream_select() incorrectly return 1 even though no data is available on STDIN.'
  46. );
  47. try {
  48. $this->assertFalse($this->in->dataAvailable());
  49. } catch (ConsoleException) {
  50. $this->markTestSkipped(
  51. 'stream_select raised an exception. ' .
  52. 'This can happen when FD_SETSIZE is too small.'
  53. );
  54. }
  55. }
  56. }