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