ILIAS  release_9 Revision v9.13-25-g2c18ec4c24f
SlotConstructorTest.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
22 
35 
36 require_once __DIR__ . '/ContainerMock.php';
37 
38 class SlotConstructorTest extends TestCase
39 {
40  use ContainerMock;
41 
42  public function testConstruct(): void
43  {
44  $this->assertInstanceOf(SlotConstructor::class, new SlotConstructor('foo', $this->mock(Container::class), $this->mock(UserAction::class)));
45  }
46 
47  public function testId(): void
48  {
49  $this->assertSame('foo', (new SlotConstructor('foo', $this->mock(Container::class), $this->mock(UserAction::class)))->id());
50  }
51 
52  public function testHistory(): void
53  {
54  $document = $this->mockTree(ProvideDocument::class, ['repository' => $this->mock(DatabaseDocumentRepository::class)]);
55  $instance = new SlotConstructor('foo', $this->mock(Container::class), $this->mock(UserAction::class));
56  $this->assertInstanceOf(ProvideHistory::class, $instance->history($document));
57  }
58 
59  public function testDocument(): void
60  {
61  $instance = new SlotConstructor('foo', $this->mock(Container::class), $this->mock(UserAction::class));
62  $this->assertInstanceOf(ProvideDocument::class, $instance->document($this->mock(DocumentRepository::class), new SelectionMap(), []));
63  }
64 
65  public function testDocumentRepository(): void
66  {
67  $instance = new SlotConstructor('foo', $this->mock(Container::class), $this->mock(UserAction::class));
68  $this->assertInstanceOf(DatabaseDocumentRepository::class, $instance->documentRepository());
69  }
70 
71  public function testReadOnlyDocuments(): void
72  {
73  $instance = new SlotConstructor('foo', $this->mock(Container::class), $this->mock(UserAction::class));
74  $this->assertInstanceOf(ReadOnlyDocumentRepository::class, $instance->readOnlyDocuments($this->mock(DocumentRepository::class)));
75  }
76 
77  public function testWithdrawalFinished(): void
78  {
79  $called = false;
80 
81  $container = $this->mockTree(Container::class, [
82  'http' => ['request' => $this->mockTree(ServerRequestInterface::class, ['getQueryParams' => ['withdrawal_finished' => 'foo']])]
83  ]);
84 
85  $instance = new SlotConstructor('foo', $container, $this->mock(UserAction::class));
86 
87  $proc = $instance->withdrawalFinished(function () use (&$called): void {
88  $called = true;
89  });
90 
91  $this->assertFalse($called);
92  $proc();
93  $this->assertTrue($called);
94  }
95 
97  {
98  $called = false;
99 
100  $container = $this->mockTree(Container::class, [
101  'http' => ['request' => $this->mockTree(ServerRequestInterface::class, ['getQueryParams' => []])]
102  ]);
103 
104  $instance = new SlotConstructor('foo', $container, $this->mock(UserAction::class));
105 
106  $proc = $instance->withdrawalFinished(function () use (&$called): void {
107  $called = true;
108  });
109 
110  $this->assertFalse($called);
111  $proc();
112  $this->assertFalse($called);
113  }
114 }
$container
Definition: wac.php:14