19 declare(strict_types=1);
44 require_once __DIR__ .
'/ContainerMock.php';
52 $config = $this->getMockBuilder(Config::class)->disableOriginalConstructor()->getMock();
53 $container = $this->getMockBuilder(Container::class)->disableOriginalConstructor()->getMock();
54 $ui = $this->getMockBuilder(UI::class)->disableOriginalConstructor()->getMock();
61 $config = $this->getMockBuilder(Config::class)->disableOriginalConstructor()->getMock();
62 $container = $this->getMockBuilder(Container::class)->disableOriginalConstructor()->getMock();
63 $ui = $this->mockMethod(UI::class,
'txt', [
'sure_delete_documents_p'],
'translated');
65 $documents = [$this->
doc(9,
'First title'), $this->
doc(49,
'Second title')];
67 $confirmation = $this->mockMethod(
75 [9 =>
'First title', 49 =>
'Second title']
81 $this->assertSame(
'rendered', $instance->deleteDocumentsConfirmation(
'link',
'submitCommand',
'cancelCommand', $documents));
86 $container = $this->getMockBuilder(Container::class)->disableOriginalConstructor()->getMock();
87 $ui = $this->getMockBuilder(UI::class)->disableOriginalConstructor()->getMock();
90 $this->getMockBuilder(Document::class)->disableOriginalConstructor()->getMock(),
91 $this->getMockBuilder(Document::class)->disableOriginalConstructor()->getMock(),
92 $this->getMockBuilder(Document::class)->disableOriginalConstructor()->getMock(),
95 $repository = $this->getMockBuilder(DocumentRepository::class)->getMock();
97 $consecutive = $documents;
98 $repository->expects(self::exactly(count($documents)))->method(
'deleteDocument')->with(
99 $this->callback(
function ($value) use (&$consecutive) {
100 $this->assertSame(array_shift($consecutive), $value);
105 $config = $this->mockMethod(Config::class,
'legalDocuments', [], $this->mockMethod(
109 $this->mockMethod(ProvideDocument::class,
'repository', [], $repository)
113 $instance->deleteDocuments($documents);
118 $container = $this->getMockBuilder(Container::class)->disableOriginalConstructor()->getMock();
119 $ui = $this->getMockBuilder(UI::class)->disableOriginalConstructor()->getMock();
121 $criterion = $this->mockMethod(Criterion::class,
'id', [], 98);
122 $document = $this->mockMethod(Document::class,
'criteria', [], [
123 $this->mockMethod(Criterion::class,
'id', [], 8),
127 $repository = $this->mockMethod(DocumentRepository::class,
'find', [459],
new Ok($document));
128 $config = $this->mockMethod(Config::class,
'legalDocuments', [], $this->mockMethod(
132 $this->mockMethod(ProvideDocument::class,
'repository', [], $repository)
135 $query_params = [
'legal_document_id' => [
'459'],
'criterion_id' =>
'98'];
137 $query = $this->mock(ArrayBasedRequestWrapper::class);
140 ->expects($this->exactly(2))
142 ->willReturnCallback(
function ($parameter1) {
143 return match ([$parameter1]) {
144 [
'legal_document_id'] => [459],
149 $httpWrapper = $this->mockMethod(WrapperFactory::class,
'query', [], $query, $this->exactly(2));
151 $http = $this->mockMethod(HTTPServices::class,
'request', [], $this->mockMethod(
152 ServerRequestInterface::class,
157 ), self::exactly(1));
158 $http->method(
'wrapper')->willReturn($httpWrapper);
160 $refinery = $this->mockMethod(Refinery::class,
'kindlyTo', [], $this->mockMethod(KindlyToGroup::class,
'int', [], $this->mockMethod(
161 Transformation::class,
165 ), $this->exactly(3)), $this->exactly(4));
172 $instance->withDocumentAndCriterion(
function (
$d,
$c) use ($document, $criterion, &$called) {
173 $this->assertSame($document,
$d);
174 $this->assertSame($criterion,
$c);
177 $this->assertTrue($called);
182 $document = $this->getMockBuilder(Document::class)->disableOriginalConstructor()->getMock();
183 $document->expects(self::once())->method(
'id')->willReturn($id);
184 $document->expects(self::once())->method(
'content')->willReturn(
185 $this->mockMethod(DocumentContent::class,
'title', [], $title)
doc(int $id, string $title)
Transformations in this group transform data to primitive types to establish a baseline for more comp...
testDeleteDocumentsConfirmation()
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
A result encapsulates a value or an error and simplifies the handling of those.
testWithDocumentAndCriterion()
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins