ILIAS  trunk Revision v13.0_alpha-62-g3b72d83f2e5
ILIAS\WOPI\Handler\GetFileInfoResponseTest Class Reference
+ Inheritance diagram for ILIAS\WOPI\Handler\GetFileInfoResponseTest:
+ Collaboration diagram for ILIAS\WOPI\Handler\GetFileInfoResponseTest:

Public Member Functions

 testViewSessionDoesNotClaimRestrictionsItDoesNotMean ()
 RestrictedWebViewOnly restricts what the user may do with the file and its effect is up to the client; UserCanAttend is about viewing a broadcast. More...
 
 testEditSessionDoesNotClaimRestrictionsItDoesNotMean ()
 
 testViewSessionStaysReadOnly ()
 
 testEditSessionMayWrite ()
 
 testViewSessionOfAUserWhoMayWriteStaysReadOnlyButDoesNotBlameTheirRights ()
 The content tab of a file object is a viewer, also for someone who holds the permission to edit the file. More...
 
 testViewSessionOfAUserWhoMayNotWrite ()
 
 testTheHostDoesNotOfferAWayIntoEditMode ()
 ILIAS never handles the UI_Edit message, so it must not announce that it does. More...
 
 testNoCloseButtonOfTheClientIsAnnounced ()
 ILIAS closes the WOPI client itself, a close button of the client would do nothing. More...
 
 testIdsAndVersionAreStrings ()
 

Protected Member Functions

 setUp ()
 

Private Member Functions

 responseFor (bool $editable, ?bool $user_can_write=null)
 

Detailed Description

Member Function Documentation

◆ responseFor()

ILIAS\WOPI\Handler\GetFileInfoResponseTest::responseFor ( bool  $editable,
?bool  $user_can_write = null 
)
private

Definition at line 49 of file GetFileInfoResponseTest.php.

49 : array
50 {
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'));
55
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);
61
62 return (new GetFileInfoResponse($revision, 6, $editable, $user_can_write))->jsonSerialize();
63 }

Referenced by ILIAS\WOPI\Handler\GetFileInfoResponseTest\testEditSessionDoesNotClaimRestrictionsItDoesNotMean(), ILIAS\WOPI\Handler\GetFileInfoResponseTest\testEditSessionMayWrite(), ILIAS\WOPI\Handler\GetFileInfoResponseTest\testIdsAndVersionAreStrings(), ILIAS\WOPI\Handler\GetFileInfoResponseTest\testNoCloseButtonOfTheClientIsAnnounced(), ILIAS\WOPI\Handler\GetFileInfoResponseTest\testTheHostDoesNotOfferAWayIntoEditMode(), ILIAS\WOPI\Handler\GetFileInfoResponseTest\testViewSessionDoesNotClaimRestrictionsItDoesNotMean(), ILIAS\WOPI\Handler\GetFileInfoResponseTest\testViewSessionOfAUserWhoMayNotWrite(), ILIAS\WOPI\Handler\GetFileInfoResponseTest\testViewSessionOfAUserWhoMayWriteStaysReadOnlyButDoesNotBlameTheirRights(), and ILIAS\WOPI\Handler\GetFileInfoResponseTest\testViewSessionStaysReadOnly().

+ Here is the caller graph for this function:

◆ setUp()

ILIAS\WOPI\Handler\GetFileInfoResponseTest::setUp ( )
protected

Definition at line 32 of file GetFileInfoResponseTest.php.

32 : void
33 {
34 if (!defined('ILIAS_HTTP_PATH')) {
35 define('ILIAS_HTTP_PATH', 'https://ilias.example.org');
36 }
37
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']
44 );
45 $GLOBALS['DIC']['ilDB'] = static fn(): \ilDBInterface => $db;
46 }
47 }
Interface ilDBInterface.
$GLOBALS["DIC"]
Definition: wac.php:66

References ILIAS\$db, and $GLOBALS.

◆ testEditSessionDoesNotClaimRestrictionsItDoesNotMean()

ILIAS\WOPI\Handler\GetFileInfoResponseTest::testEditSessionDoesNotClaimRestrictionsItDoesNotMean ( )

Definition at line 78 of file GetFileInfoResponseTest.php.

78 : void
79 {
80 $response = $this->responseFor(true);
81
82 $this->assertArrayNotHasKey('RestrictedWebViewOnly', $response);
83 $this->assertArrayNotHasKey('UserCanAttend', $response);
84 }
responseFor(bool $editable, ?bool $user_can_write=null)
$response
Definition: xapitoken.php:92

References $response, and ILIAS\WOPI\Handler\GetFileInfoResponseTest\responseFor().

+ Here is the call graph for this function:

◆ testEditSessionMayWrite()

ILIAS\WOPI\Handler\GetFileInfoResponseTest::testEditSessionMayWrite ( )

Definition at line 95 of file GetFileInfoResponseTest.php.

95 : void
96 {
97 $response = $this->responseFor(true);
98
99 $this->assertFalse($response['ReadOnly']);
100 $this->assertTrue($response['UserCanWrite']);
101 $this->assertTrue($response['SupportsUpdate']);
102 }

References $response, and ILIAS\WOPI\Handler\GetFileInfoResponseTest\responseFor().

+ Here is the call graph for this function:

◆ testIdsAndVersionAreStrings()

ILIAS\WOPI\Handler\GetFileInfoResponseTest::testIdsAndVersionAreStrings ( )

Definition at line 150 of file GetFileInfoResponseTest.php.

150 : void
151 {
152 $response = $this->responseFor(true);
153
154 $this->assertSame('6', $response['OwnerId']);
155 $this->assertSame('6', $response['UserId']);
156 $this->assertIsString($response['Version']);
157 }

References $response, and ILIAS\WOPI\Handler\GetFileInfoResponseTest\responseFor().

+ Here is the call graph for this function:

◆ testNoCloseButtonOfTheClientIsAnnounced()

ILIAS\WOPI\Handler\GetFileInfoResponseTest::testNoCloseButtonOfTheClientIsAnnounced ( )

ILIAS closes the WOPI client itself, a close button of the client would do nothing.

Definition at line 140 of file GetFileInfoResponseTest.php.

140 : void
141 {
142 foreach ([false, true] as $editable) {
143 $response = $this->responseFor($editable);
144
145 $this->assertArrayNotHasKey('CloseUrl', $response);
146 $this->assertFalse($response['ClosePostMessage']);
147 }
148 }

References $response, and ILIAS\WOPI\Handler\GetFileInfoResponseTest\responseFor().

+ Here is the call graph for this function:

◆ testTheHostDoesNotOfferAWayIntoEditMode()

ILIAS\WOPI\Handler\GetFileInfoResponseTest::testTheHostDoesNotOfferAWayIntoEditMode ( )

ILIAS never handles the UI_Edit message, so it must not announce that it does.

Definition at line 131 of file GetFileInfoResponseTest.php.

131 : void
132 {
133 $this->assertFalse($this->responseFor(false, true)['EditModePostMessage']);
134 $this->assertFalse($this->responseFor(true)['EditModePostMessage']);
135 }

References ILIAS\WOPI\Handler\GetFileInfoResponseTest\responseFor().

+ Here is the call graph for this function:

◆ testViewSessionDoesNotClaimRestrictionsItDoesNotMean()

ILIAS\WOPI\Handler\GetFileInfoResponseTest::testViewSessionDoesNotClaimRestrictionsItDoesNotMean ( )

RestrictedWebViewOnly restricts what the user may do with the file and its effect is up to the client; UserCanAttend is about viewing a broadcast.

Neither describes the fact that this session opened a viewer, so neither is sent any more.

Definition at line 70 of file GetFileInfoResponseTest.php.

70 : void
71 {
72 $response = $this->responseFor(false);
73
74 $this->assertArrayNotHasKey('RestrictedWebViewOnly', $response);
75 $this->assertArrayNotHasKey('UserCanAttend', $response);
76 }

References $response, and ILIAS\WOPI\Handler\GetFileInfoResponseTest\responseFor().

+ Here is the call graph for this function:

◆ testViewSessionOfAUserWhoMayNotWrite()

ILIAS\WOPI\Handler\GetFileInfoResponseTest::testViewSessionOfAUserWhoMayNotWrite ( )

Definition at line 119 of file GetFileInfoResponseTest.php.

119 : void
120 {
121 $response = $this->responseFor(false, false);
122
123 $this->assertTrue($response['ReadOnly']);
124 $this->assertFalse($response['SupportsUpdate']);
125 $this->assertFalse($response['UserCanWrite']);
126 }

References $response, and ILIAS\WOPI\Handler\GetFileInfoResponseTest\responseFor().

+ Here is the call graph for this function:

◆ testViewSessionOfAUserWhoMayWriteStaysReadOnlyButDoesNotBlameTheirRights()

ILIAS\WOPI\Handler\GetFileInfoResponseTest::testViewSessionOfAUserWhoMayWriteStaysReadOnlyButDoesNotBlameTheirRights ( )

The content tab of a file object is a viewer, also for someone who holds the permission to edit the file.

The session stays read-only, but the client is told that the user is not the reason for it - otherwise it explains the viewer with missing access rights.

Definition at line 110 of file GetFileInfoResponseTest.php.

110 : void
111 {
112 $response = $this->responseFor(false, true);
113
114 $this->assertTrue($response['ReadOnly']);
115 $this->assertFalse($response['SupportsUpdate']);
116 $this->assertTrue($response['UserCanWrite']);
117 }

References $response, and ILIAS\WOPI\Handler\GetFileInfoResponseTest\responseFor().

+ Here is the call graph for this function:

◆ testViewSessionStaysReadOnly()

ILIAS\WOPI\Handler\GetFileInfoResponseTest::testViewSessionStaysReadOnly ( )

Definition at line 86 of file GetFileInfoResponseTest.php.

86 : void
87 {
88 $response = $this->responseFor(false);
89
90 $this->assertTrue($response['ReadOnly']);
91 $this->assertFalse($response['UserCanWrite']);
92 $this->assertFalse($response['SupportsUpdate']);
93 }

References $response, and ILIAS\WOPI\Handler\GetFileInfoResponseTest\responseFor().

+ Here is the call graph for this function:

The documentation for this class was generated from the following file: