ILIAS  trunk Revision v11.0_alpha-1749-g1a06bdef097
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
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 29 of file CallbackDurationTest.php.

Member Function Documentation

◆ getTestCallbackWithLength()

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

Definition at line 67 of file CallbackDurationTest.php.

References exit.

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

67  : callable
68  {
69  return static function () use ($duration_in_ms, $should_halt): void {
70  usleep(1_000 * $duration_in_ms);
71  if ($should_halt) {
72  exit;
73  }
74  };
75  }
exit
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
+ Here is the caller graph for this function:

◆ testCallbackStretching()

HTTP\Services\CallbackDurationTest::testCallbackStretching ( )

Definition at line 52 of file CallbackDurationTest.php.

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

52  : void
53  {
54  $callback = $this->getTestCallbackWithLength(1);
55  $duration = new CallbackDuration(3);
56 
57  $start_time = microtime(true);
58  $duration->stretch($callback);
59  $end_time = microtime(true);
60 
61  $elapsed_time = ($end_time - $start_time); // in microseconds (us)
62  $expected_duration_in_us = (0.002);
63 
64  $this->assertGreaterThanOrEqual($expected_duration_in_us, ($end_time - $start_time));
65  }
$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 42 of file CallbackDurationTest.php.

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

42  : void
43  {
44  $callback = $this->getTestCallbackWithLength(2);
45  $duration = new CallbackDuration(1);
46 
47  $this->expectException(\RuntimeException::class);
48  $this->expectExceptionMessage("Execution of callback exceeded the given duration and could not be stretched.");
49  $duration->stretch($callback);
50  }
$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: