19 declare(strict_types=1);
42 require_once __DIR__ .
'/../ContainerMock.php';
50 $this->assertInstanceOf(ProvideHistory::class,
new ProvideHistory(
'foo', $this->mock(HistoryRepository::class), $this->mock(ProvideDocument::class), $this->mock(Container::class)));
56 $legacy = $this->mock(Legacy\Content::class);
57 $legacy_factory = $this->mock(Legacy\Factory::class);
59 ->expects($this->once())
61 ->willReturn($legacy);
63 $table = $this->mockMethod(LegacyTable::class,
'getHTML', [],
'table html');
65 $container = $this->mockTree(Container::class, [
66 'ctrl' => $this->mock(ilCtrl::class),
67 'language' => $this->mock(ilLanguage::class),
69 'factory' => $this->mockMethod(UIFactory::class,
'legacy', [], $legacy_factory),
70 'mainTemplate' => $this->mock(ilGlobalTemplateInterface::class)
75 $this->assertSame($dummy_gui, $gui);
76 $this->assertSame(
'dummy command', $command);
77 $this->assertInstanceOf(HistoryTable::class, $t);
81 $instance =
new ProvideHistory(
'foo', $this->mock(HistoryRepository::class), $this->mock(ProvideDocument::class),
$container, $create_table_gui);
83 $this->assertSame($legacy, $instance->table($dummy_gui,
'dummy command',
'reset command',
'auto complete command'));
88 $user = $this->mock(ilObjUser::class);
89 $document = $this->mock(Document::class);
91 $repository = $this->mock(HistoryRepository::class);
92 $repository->expects(self::once())->method(
'acceptDocument')->with($user, $document);
94 $instance =
new ProvideHistory(
'foo', $repository, $this->mock(ProvideDocument::class), $this->mock(Container::class));
95 $instance->acceptDocument($user, $document);
100 $user = $this->mock(ilObjUser::class);
101 $document = $this->mock(Document::class);
103 $repository = $this->mockMethod(HistoryRepository::class,
'alreadyAccepted', [$user, $document],
true);
105 $instance =
new ProvideHistory(
'foo', $repository, $this->mock(ProvideDocument::class), $this->mock(Container::class));
106 $this->assertTrue($instance->alreadyAccepted($user, $document));
111 $user = $this->mock(ilObjUser::class);
113 $result = $this->mock(Result::class);
115 $repository = $this->mockMethod(HistoryRepository::class,
'acceptedVersion', [$user], $result);
117 $instance =
new ProvideHistory(
'foo', $repository, $this->mock(ProvideDocument::class), $this->mock(Container::class));
118 $this->assertSame($result, $instance->acceptedVersion($user));
123 $user = $this->mock(ilObjUser::class);
124 $result = $this->mock(Result::class);
125 $repository = $this->mockMethod(HistoryRepository::class,
'currentDocumentOfAcceptedVersion', [$user], $result);
126 $instance =
new ProvideHistory(
'foo', $repository, $this->mock(ProvideDocument::class), $this->mock(Container::class));
128 $this->assertSame($result, $instance->currentDocumentOfAcceptedVersion($user));
testCurrentDocumentOfAcceptedVersion()