19declare(strict_types=1);
23use PHPUnit\Framework\TestCase;
32 protected function setUp(): void
34 if (!defined(
'ILIAS_HTTP_PATH')) {
35 define(
'ILIAS_HTTP_PATH',
'https://ilias.example.org');
38 $GLOBALS[
'DIC'] ??= new \ILIAS\DI\Container();
39 if (!isset(
$GLOBALS[
'DIC'][
'ilDB'])) {
40 $db = $this->createStub(\ilDBInterface::class);
41 $db->method(
'queryF')->willReturn($this->createStub(\ilDBStatement::class));
42 $db->method(
'fetchAssoc')->willReturn(
43 [
'firstname' =>
'Ada',
'lastname' =>
'Lovelace',
'title' =>
'',
'login' =>
'ada']
49 private function responseFor(
bool $editable, ?
bool $user_can_write =
null): array
51 $information = $this->createStub(Information::class);
52 $information->method(
'getSuffix')->willReturn(
'odt');
53 $information->method(
'getSize')->willReturn(1234);
54 $information->method(
'getCreationDate')->willReturn(
new \DateTimeImmutable(
'2026-01-01 12:00:00'));
56 $revision = $this->createStub(Revision::class);
57 $revision->method(
'getTitle')->willReturn(
'minutes.odt');
58 $revision->method(
'getVersionNumber')->willReturn(3);
59 $revision->method(
'getOwnerId')->willReturn(6);
60 $revision->method(
'getInformation')->willReturn($information);
62 return (
new GetFileInfoResponse($revision, 6, $editable, $user_can_write))->jsonSerialize();
74 $this->assertArrayNotHasKey(
'RestrictedWebViewOnly',
$response);
75 $this->assertArrayNotHasKey(
'UserCanAttend',
$response);
82 $this->assertArrayNotHasKey(
'RestrictedWebViewOnly',
$response);
83 $this->assertArrayNotHasKey(
'UserCanAttend',
$response);
91 $this->assertFalse(
$response[
'UserCanWrite']);
92 $this->assertFalse(
$response[
'SupportsUpdate']);
99 $this->assertFalse(
$response[
'ReadOnly']);
100 $this->assertTrue(
$response[
'UserCanWrite']);
101 $this->assertTrue(
$response[
'SupportsUpdate']);
114 $this->assertTrue(
$response[
'ReadOnly']);
115 $this->assertFalse(
$response[
'SupportsUpdate']);
116 $this->assertTrue(
$response[
'UserCanWrite']);
123 $this->assertTrue(
$response[
'ReadOnly']);
124 $this->assertFalse(
$response[
'SupportsUpdate']);
125 $this->assertFalse(
$response[
'UserCanWrite']);
133 $this->assertFalse($this->
responseFor(
false,
true)[
'EditModePostMessage']);
134 $this->assertFalse($this->
responseFor(
true)[
'EditModePostMessage']);
142 foreach ([
false,
true] as $editable) {
145 $this->assertArrayNotHasKey(
'CloseUrl',
$response);
146 $this->assertFalse(
$response[
'ClosePostMessage']);
154 $this->assertSame(
'6',
$response[
'OwnerId']);
155 $this->assertSame(
'6',
$response[
'UserId']);
156 $this->assertIsString(
$response[
'Version']);
responseFor(bool $editable, ?bool $user_can_write=null)
testEditSessionMayWrite()
testTheHostDoesNotOfferAWayIntoEditMode()
ILIAS never handles the UI_Edit message, so it must not announce that it does.
testViewSessionDoesNotClaimRestrictionsItDoesNotMean()
RestrictedWebViewOnly restricts what the user may do with the file and its effect is up to the client...
testEditSessionDoesNotClaimRestrictionsItDoesNotMean()
testViewSessionOfAUserWhoMayWriteStaysReadOnlyButDoesNotBlameTheirRights()
The content tab of a file object is a viewer, also for someone who holds the permission to edit the f...
testIdsAndVersionAreStrings()
testNoCloseButtonOfTheClientIsAnnounced()
ILIAS closes the WOPI client itself, a close button of the client would do nothing.
testViewSessionStaysReadOnly()
testViewSessionOfAUserWhoMayNotWrite()