ILIAS  release_9 Revision v9.13-25-g2c18ec4c24f
HTTP\Services\CallbackDurationTest Class Reference
+ Inheritance diagram for HTTP\Services\CallbackDurationTest:
+ Collaboration diagram for HTTP\Services\CallbackDurationTest:

Public Member Functions

 testCallbackStretchingWithTooLongExecutionTime ()
 
 testCallbackStretching ()
 

Protected Member Functions

 getTestCallbackWithLength (int $duration_in_ms, bool $should_halt=false)
 

Detailed Description

Author
Thibeau Fuhrer thibe.nosp@m.au@s.nosp@m.r.sol.nosp@m.utio.nosp@m.ns

Definition at line 28 of file CallbackDurationTest.php.

Member Function Documentation

◆ getTestCallbackWithLength()

HTTP\Services\CallbackDurationTest::getTestCallbackWithLength ( int  $duration_in_ms,
bool  $should_halt = false 
)
protected

Definition at line 66 of file CallbackDurationTest.php.

References exit.

Referenced by HTTP\Services\CallbackDurationTest\testCallbackStretching(), and HTTP\Services\CallbackDurationTest\testCallbackStretchingWithTooLongExecutionTime().

66  : callable
67  {
68  return static function () use ($duration_in_ms, $should_halt) {
69  usleep(1_000 * $duration_in_ms);
70  if ($should_halt) {
71  exit;
72  }
73  };
74  }
exit
Definition: login.php:29
+ Here is the caller graph for this function:

◆ testCallbackStretching()

HTTP\Services\CallbackDurationTest::testCallbackStretching ( )

Definition at line 51 of file CallbackDurationTest.php.

References $duration, and HTTP\Services\CallbackDurationTest\getTestCallbackWithLength().

51  : void
52  {
53  $callback = $this->getTestCallbackWithLength(1);
54  $duration = new CallbackDuration(3);
55 
56  $start_time = microtime(true);
57  $duration->stretch($callback);
58  $end_time = microtime(true);
59 
60  $elapsed_time = ($end_time - $start_time); // in microseconds (us)
61  $expected_duration_in_us = (0.002);
62 
63  $this->assertGreaterThanOrEqual($expected_duration_in_us, ($end_time - $start_time));
64  }
$duration
getTestCallbackWithLength(int $duration_in_ms, bool $should_halt=false)
+ Here is the call graph for this function:

◆ testCallbackStretchingWithTooLongExecutionTime()

HTTP\Services\CallbackDurationTest::testCallbackStretchingWithTooLongExecutionTime ( )

Definition at line 41 of file CallbackDurationTest.php.

References $duration, and HTTP\Services\CallbackDurationTest\getTestCallbackWithLength().

41  : void
42  {
43  $callback = $this->getTestCallbackWithLength(2);
44  $duration = new CallbackDuration(1);
45 
46  $this->expectException(\RuntimeException::class);
47  $this->expectExceptionMessage("Execution of callback exceeded the given duration and could not be stretched.");
48  $duration->stretch($callback);
49  }
$duration
getTestCallbackWithLength(int $duration_in_ms, bool $should_halt=false)
+ Here is the call graph for this function:

The documentation for this class was generated from the following file: