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