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::class);
58 $table = $this->mockMethod(LegacyTable::class,
'getHTML', [],
'table html');
60 $container = $this->mockTree(Container::class, [
61 'ctrl' => $this->mock(ilCtrl::class),
62 'language' => $this->mock(ilLanguage::class),
64 'factory' => $this->mockMethod(UIFactory::class,
'legacy', [
'table html'], $legacy),
65 'mainTemplate' => $this->mock(ilGlobalTemplateInterface::class)
70 $this->assertSame($dummy_gui, $gui);
71 $this->assertSame(
'dummy command', $command);
72 $this->assertInstanceOf(HistoryTable::class, $t);
76 $instance =
new ProvideHistory(
'foo', $this->mock(HistoryRepository::class), $this->mock(ProvideDocument::class),
$container, $create_table_gui);
78 $this->assertSame($legacy, $instance->table($dummy_gui,
'dummy command',
'reset command',
'auto complete command'));
83 $user = $this->mock(ilObjUser::class);
84 $document = $this->mock(Document::class);
86 $repository = $this->mock(HistoryRepository::class);
87 $repository->expects(self::once())->method(
'acceptDocument')->with($user, $document);
89 $instance =
new ProvideHistory(
'foo', $repository, $this->mock(ProvideDocument::class), $this->mock(Container::class));
90 $instance->acceptDocument($user, $document);
95 $user = $this->mock(ilObjUser::class);
96 $document = $this->mock(Document::class);
98 $repository = $this->mockMethod(HistoryRepository::class,
'alreadyAccepted', [$user, $document],
true);
100 $instance =
new ProvideHistory(
'foo', $repository, $this->mock(ProvideDocument::class), $this->mock(Container::class));
101 $this->assertTrue($instance->alreadyAccepted($user, $document));
106 $user = $this->mock(ilObjUser::class);
108 $result = $this->mock(Result::class);
110 $repository = $this->mockMethod(HistoryRepository::class,
'acceptedVersion', [$user], $result);
112 $instance =
new ProvideHistory(
'foo', $repository, $this->mock(ProvideDocument::class), $this->mock(Container::class));
113 $this->assertSame($result, $instance->acceptedVersion($user));
118 $user = $this->mock(ilObjUser::class);
119 $result = $this->mock(Result::class);
120 $repository = $this->mockMethod(HistoryRepository::class,
'currentDocumentOfAcceptedVersion', [$user], $result);
121 $instance =
new ProvideHistory(
'foo', $repository, $this->mock(ProvideDocument::class), $this->mock(Container::class));
123 $this->assertSame($result, $instance->currentDocumentOfAcceptedVersion($user));
testCurrentDocumentOfAcceptedVersion()