19 declare(strict_types=1);
27 private function mock(
string $class)
29 return $this->getMockBuilder($class)->disableOriginalConstructor()->getMock();
32 private function mockMethod(
string $class,
string $method, array $args, $return, $times =
null)
34 $times ??= self::once();
35 $mock = $this->mock($class);
36 $mock->expects($times)->method($method)->with(...$args)->willReturn($return);
45 private function assertGetter($class_or_instance, array $methods_and_values): void
47 $instance = is_string($class_or_instance) ?
new $class_or_instance(...array_values($methods_and_values)) : $class_or_instance;
48 foreach ($methods_and_values as $method => $value) {
49 $this->assertSame($value, $instance->$method($value));
56 private function mockTree(
string $class, array $tree)
59 $mock = $this->mock($class);
60 foreach ($tree as $name => $value) {
61 $type = (string)
$r->getMethod($name)->getReturnType();
62 $type = $type ===
'self' ? $class : $type;
63 $type = preg_replace(
'/^\?/',
'', $type);
64 $mock->method($name)->willReturn(
65 class_exists($type) || interface_exists($type) ?
66 (is_array($value) ? $this->mockTree($type, $value) : $value) :
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null