88 ->getMockBuilder(\ilTermsOfServiceDocument::class)
89 ->disableOriginalConstructor()
90 ->setMethods([
'getId',
'fetchAllCriterionAssignments'])
94 ->expects($this->any())
95 ->method(
'fetchAllCriterionAssignments');
98 ->getMockBuilder(\ilHtmlPurifierInterface::class)
105 $this->getMockBuilder(ImmutableStringMap::class)->getMock(),
111 ->getMockBuilder(\ilObjUser::class)
112 ->disableOriginalConstructor()
113 ->setMethods([
'getId'])
117 ->expects($this->exactly(2))
122 ->getMockBuilder(Filesystem::class)
126 ->expects($this->exactly(2))
128 ->with(
'/agreements/' . $uploadResult->getName())
132 ->expects($this->exactly(2))
134 ->with(
'/agreements/' . $uploadResult->getName())
135 ->willReturn(
'phpunit');
138 ->expects($this->atLeast(1))
141 ->willReturnArgument(0);
144 ->expects($this->exactly(2))
146 ->with(
'/agreements/' . $uploadResult->getName());
149 ->getMockBuilder(FileUpload::class)
150 ->setMethods([
'moveFilesTo',
'uploadSizeLimit',
'register',
'hasBeenProcessed',
'hasUploads',
'process',
'getResults',
'moveOneFileTo'])
154 ->expects($this->any())
155 ->method(
'hasUploads')
159 ->expects($this->exactly(2))
160 ->method(
'hasBeenProcessed')
164 ->expects($this->exactly(2))
168 ->expects($this->exactly(2))
169 ->method(
'getResults')
175 ->expects($this->exactly(2))
176 ->method(
'moveOneFileTo')
187 $documentConnector = $this->getMockBuilder(\arConnector::class)->getMock();
188 $criterionConnector = $this->getMockBuilder(\arConnector::class)->getMock();
190 $expectedSortingValueExistingDocuments = 10;
193 ->expects($this->
once())
195 ->willReturnCallback(
function () use ($expectedSortingValueExistingDocuments) {
198 'title' =>
'another',
199 'sorting' => $expectedSortingValueExistingDocuments - 1,
204 ->expects($this->
once())
212 $form = $this->getMockBuilder(\ilTermsOfServiceDocumentFormGUI::class)
213 ->setConstructorArgs([
214 $document, $purifier,
$user, $fs, $fu,
215 'action',
'save',
'cancel',
218 ->setMethods([
'checkInput'])
222 ->expects($this->
once())
223 ->method(
'checkInput')
226 $_FILES[
'document'] = [];
228 'title' =>
'phpunit',
232 $form->setCheckInputCalled(
true);
234 $this->assertTrue(
$form->saveObject());
235 $this->assertFalse(
$form->hasTranslatedError());
236 $this->assertEmpty(
$form->getTranslatedError());
238 $expectedSortingValueExistingDocuments,
239 $document->getSorting(),
240 'Failed asserting that the sorting of the new document equals the maximum incremented by one when other documents exist' 243 $documentConnector = $this->getMockBuilder(\arConnector::class)->getMock();
246 ->expects($this->
once())
248 ->willReturnCallback(
function () {
254 $form = $this->getMockBuilder(\ilTermsOfServiceDocumentFormGUI::class)
255 ->setConstructorArgs([
256 $document, $purifier,
$user, $fs, $fu,
257 'action',
'save',
'cancel',
260 ->setMethods([
'checkInput'])
264 ->expects($this->
once())
265 ->method(
'checkInput')
268 $form->setCheckInputCalled(
true);
270 $this->assertTrue(
$form->saveObject());
271 $this->assertFalse(
$form->hasTranslatedError());
272 $this->assertEmpty(
$form->getTranslatedError());
275 $document->getSorting(),
276 'Failed asserting that the sorting of the new document equals 1 when no other document exists'
setGlobalVariable(string $name, $value)
static register(ActiveRecord $ar, arConnector $connector)
Class ilTermsOfServiceDocumentCriterionAssignment.
if(isset($_POST['submit'])) $form
Class ilTermsOfServiceDocument.
once($eventName, callable $callBack, $priority=100)
Subscribe to an event exactly once.