ExtUvLoopTest.php 3.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. <?php
  2. namespace React\Tests\EventLoop;
  3. use React\EventLoop\ExtUvLoop;
  4. class ExtUvLoopTest extends AbstractLoopTest
  5. {
  6. public function createLoop()
  7. {
  8. if (!function_exists('uv_loop_new')) {
  9. $this->markTestSkipped('uv tests skipped because ext-uv is not installed.');
  10. }
  11. return new ExtUvLoop();
  12. }
  13. /** @dataProvider intervalProvider */
  14. public function testTimerInterval($interval, $expectedExceptionMessage)
  15. {
  16. $this->expectException('InvalidArgumentException');
  17. $this->expectExceptionMessage($expectedExceptionMessage);
  18. $this->loop
  19. ->addTimer(
  20. $interval,
  21. function () {
  22. return 0;
  23. }
  24. );
  25. }
  26. public function intervalProvider()
  27. {
  28. $oversizeInterval = PHP_INT_MAX / 1000;
  29. $maxValue = (int) (PHP_INT_MAX / 1000);
  30. $oneMaxValue = $maxValue + 1;
  31. $tenMaxValue = $maxValue + 10;
  32. $tenMillionsMaxValue = $maxValue + 10000000;
  33. $intMax = PHP_INT_MAX;
  34. $oneIntMax = PHP_INT_MAX + 1;
  35. $tenIntMax = PHP_INT_MAX + 10;
  36. $oneHundredIntMax = PHP_INT_MAX + 100;
  37. $oneThousandIntMax = PHP_INT_MAX + 1000;
  38. $tenMillionsIntMax = PHP_INT_MAX + 10000000;
  39. $tenThousandsTimesIntMax = PHP_INT_MAX * 1000;
  40. return array(
  41. array(
  42. $oversizeInterval,
  43. "Interval overflow, value must be lower than '{$maxValue}', but '{$oversizeInterval}' passed."
  44. ),
  45. array(
  46. $oneMaxValue,
  47. "Interval overflow, value must be lower than '{$maxValue}', but '{$oneMaxValue}' passed.",
  48. ),
  49. array(
  50. $tenMaxValue,
  51. "Interval overflow, value must be lower than '{$maxValue}', but '{$tenMaxValue}' passed.",
  52. ),
  53. array(
  54. $tenMillionsMaxValue,
  55. "Interval overflow, value must be lower than '{$maxValue}', but '{$tenMillionsMaxValue}' passed.",
  56. ),
  57. array(
  58. $intMax,
  59. "Interval overflow, value must be lower than '{$maxValue}', but '{$intMax}' passed.",
  60. ),
  61. array(
  62. $oneIntMax,
  63. "Interval overflow, value must be lower than '{$maxValue}', but '{$oneIntMax}' passed.",
  64. ),
  65. array(
  66. $tenIntMax,
  67. "Interval overflow, value must be lower than '{$maxValue}', but '{$tenIntMax}' passed.",
  68. ),
  69. array(
  70. $oneHundredIntMax,
  71. "Interval overflow, value must be lower than '{$maxValue}', but '{$oneHundredIntMax}' passed.",
  72. ),
  73. array(
  74. $oneThousandIntMax,
  75. "Interval overflow, value must be lower than '{$maxValue}', but '{$oneThousandIntMax}' passed.",
  76. ),
  77. array(
  78. $tenMillionsIntMax,
  79. "Interval overflow, value must be lower than '{$maxValue}', but '{$tenMillionsIntMax}' passed.",
  80. ),
  81. array(
  82. $tenThousandsTimesIntMax,
  83. "Interval overflow, value must be lower than '{$maxValue}', but '{$tenThousandsTimesIntMax}' passed.",
  84. ),
  85. );
  86. }
  87. }