@@ -143,13 +143,13 @@ public function testWopiPutFile(): void {
143
143
}
144
144
145
145
/**
146
- * Tests new File creation on successful requests.
146
+ * Tests new file creation on successful requests.
147
147
*
148
148
* @covers ::wopiPutFile
149
149
*/
150
150
public function testWopiPutFileNewFile (): void {
151
151
// Change configuration to 300 seconds and attempt a save immediately after.
152
- // File was created just before, so no new File .
152
+ // File was created just before, so no new file .
153
153
$ wopi_settings = \Drupal::configFactory ()->getEditable ('collabora_online.settings ' );
154
154
$ wopi_settings ->set ('cool.new_file_interval ' , 300 )->save ();
155
155
$ this ->doTestWopiPutFile ();
@@ -158,12 +158,12 @@ public function testWopiPutFileNewFile(): void {
158
158
\Drupal::time ()->setTime ('+100 seconds ' );
159
159
$ this ->doTestWopiPutFile ();
160
160
161
- // Wait more than 300 seconds to trigger the File creation.
162
- \Drupal::time ()->setTime ('+301 seconds ' );
163
- $ this ->doTestWopiPutFile (new_file: TRUE );
161
+ // Wait more than 300 seconds to trigger the file creation.
162
+ \Drupal::time ()->setTime ('+305 seconds ' );
163
+ $ this ->doTestWopiPutfile (new_file: TRUE );
164
164
165
165
// Multiple sequential calls under the configured time does not prevent the
166
- // creation of the File .
166
+ // creation of the file .
167
167
\Drupal::time ()->setTime ('+295 seconds ' );
168
168
$ this ->doTestWopiPutFile ();
169
169
\Drupal::time ()->setTime ('+295 seconds ' );
@@ -173,12 +173,12 @@ public function testWopiPutFileNewFile(): void {
173
173
\Drupal::time ()->setTime ('+295 seconds ' );
174
174
$ this ->doTestWopiPutFile (new_file: TRUE );
175
175
176
- // Configured interval of 0 won't create any File .
176
+ // Configured interval of 0 won't create any file .
177
177
$ wopi_settings ->set ('cool.new_file_interval ' , 0 )->save ();
178
178
\Drupal::time ()->setTime ('+5 seconds ' );
179
179
$ this ->doTestWopiPutFile ();
180
180
181
- // Empty value on the configuration won't create any File .
181
+ // Empty value on the configuration won't create any file .
182
182
$ wopi_settings ->set ('cool.new_file_interval ' , '' )->save ();
183
183
\Drupal::time ()->setTime ('+5 seconds ' );
184
184
$ this ->doTestWopiPutFile ();
@@ -193,7 +193,7 @@ public function testWopiPutFileNewFile(): void {
193
193
* Request headers.
194
194
* @param string $reason_message
195
195
* Reason message expected to appear in the log and in the revision log.
196
- * @param string $new_file
196
+ * @param bool $new_file
197
197
* New file is expected.
198
198
*/
199
199
protected function doTestWopiPutFile (
@@ -203,6 +203,8 @@ protected function doTestWopiPutFile(
203
203
): void {
204
204
$ new_file_content = "File content " . str_repeat ('m ' , rand (0 , 999 )) . '. ' ;
205
205
$ old_file = $ this ->loadCurrentMediaFile ();
206
+ $ old_file_id = $ old_file ->id ();
207
+ $ old_file_uri = $ old_file ->getFileUri ();
206
208
$ this ->logger ->reset ();
207
209
$ request = $ this ->createRequest (
208
210
'/contents ' ,
@@ -230,18 +232,22 @@ protected function doTestWopiPutFile(
230
232
$ this ->assertSame (strlen ($ new_file_content ), $ file ->getSize ());
231
233
232
234
if (!$ new_file ) {
233
- // The URI remains the same, and no File entity has been created.
234
- $ this ->assertSame ($ old_file -> id () , $ file ->id ());
235
- $ this ->assertSame ($ file -> getFileUri () , $ file ->getFileUri ());
235
+ // The URI remains the same, and no file entity has been created.
236
+ $ this ->assertSame ($ old_file_id , $ file ->id ());
237
+ $ this ->assertSame ($ old_file_uri , $ file ->getFileUri ());
236
238
237
239
$ this ->assertLogMessage (
238
240
RfcLogLevel::INFO ,
239
- 'File entity @file_id source @file_uri was replaced with Collabora.<br>
240
- Save reason: @reason<br> ' ,
241
+ 'The file contents for media @media_id were overwritten with Collabora.<br>
242
+ Save reason: @reason<br>
243
+ File: @file_id / @file_uri<br>
244
+ User ID: @user_id ' ,
241
245
[
246
+ '@media_id ' => $ media ->id (),
247
+ '@reason ' => $ reason_message ,
242
248
'@file_id ' => $ file ->id (),
243
249
'@file_uri ' => $ file ->getFileUri (),
244
- '@reason ' => $ reason_message ,
250
+ '@user_id ' => $ this -> user -> id () ,
245
251
],
246
252
);
247
253
@@ -250,7 +256,7 @@ protected function doTestWopiPutFile(
250
256
251
257
$ i = $ this ->getCounterValue ();
252
258
// Assert that a new file was created.
253
- $ this ->assertGreaterThan ((int ) $ old_file -> id () , (int ) $ file ->id ());
259
+ $ this ->assertGreaterThan ((int ) $ old_file_id , (int ) $ file ->id ());
254
260
// The file uri is fully predictable in the context of this test.
255
261
// Each new file version gets a new number suffix.
256
262
// There is no repeated suffix like "test_0_0_0_0.txt".
@@ -268,14 +274,16 @@ protected function doTestWopiPutFile(
268
274
'Media entity @media_id was updated with Collabora.<br>
269
275
Save reason: @reason<br>
270
276
Old file: @old_file_id / @old_file_uri<br>
271
- New file: @new_file_id / @new_file_uri ' ,
277
+ New file: @new_file_id / @new_file_uri<br>
278
+ User ID: @user_id ' ,
272
279
[
273
280
'@media_id ' => $ this ->media ->id (),
274
281
'@reason ' => $ reason_message ,
275
282
'@old_file_id ' => $ old_file ->id (),
276
283
'@old_file_uri ' => $ old_file ->getFileUri (),
277
284
'@new_file_id ' => $ file ->id (),
278
285
'@new_file_uri ' => $ file ->getFileUri (),
286
+ '@user_id ' => $ this ->user ->id (),
279
287
],
280
288
);
281
289
}
0 commit comments