ILIAS  trunk Revision v11.0_alpha-1769-g99a433fe2dc
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
LazyProvideTest.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
22 
26 
27 require_once __DIR__ . '/ContainerMock.php';
28 
29 class LazyProvideTest extends TestCase
30 {
31  use ContainerMock;
32 
33  public function testConstruct(): void
34  {
35  $this->assertInstanceOf(LazyProvide::class, new LazyProvide($this->fail(...)));
36  }
37 
41  public function testMethods(string $method, $return = []): void
42  {
43  $called = false;
44  $provide = $this->mockTree(Provide::class, [$method => $return]);
45 
46  $create = function () use (&$called, $provide) {
47  $called = true;
48  return $provide;
49  };
50 
51  $instance = new LazyProvide($create);
52  $this->assertFalse($called);
53  $this->assertSame($provide->$method(), $instance->$method());
54  $this->assertTrue($called);
55  }
56 
57  public static function methods(): array
58  {
59  return [
60  ['withdrawal'],
61  ['publicPage'],
62  ['document'],
63  ['history'],
64  ['allowEditing'],
65  ['publicApi'],
66  ['id', ''],
67  ];
68  }
69 }
testMethods(string $method, $return=[])
methods