Completed
Push — feature/EVO-8294-fileUpload ( 335fda...4260fa )
by Narcotic
08:45
created

testGetFileCollectionSchemaInformation()   B

Complexity

Conditions 1
Paths 1

Size

Total Lines 27
Code Lines 17

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 27
rs 8.8571
c 0
b 0
f 0
cc 1
eloc 17
nc 1
nop 0
1
<?php
2
/**
3
 * functional test for /file
4
 */
5
6
namespace Graviton\FileBundle\Tests\Controller;
7
8
use Graviton\TestBundle\Test\RestTestCase;
9
use Symfony\Component\HttpFoundation\File\UploadedFile;
10
use Symfony\Component\HttpFoundation\Response;
11
12
/**
13
 * Basic functional test for /file
14
 *
15
 * @author   List of contributors <https://github.com/libgraviton/graviton/graphs/contributors>
16
 * @license  http://opensource.org/licenses/gpl-license.php GNU Public License
17
 * @link     http://swisscom.ch
18
 */
19
class FileControllerTest extends RestTestCase
20
{
21
    /**
22
     * @const complete content type string expected on a resource
23
     */
24
    const CONTENT_TYPE = 'application/json; charset=UTF-8; profile=http://localhost/schema/file/item';
25
26
    /**
27
     * @const corresponding vendorized schema mime type
28
     */
29
    const COLLECTION_TYPE = 'application/json; charset=UTF-8; profile=http://localhost/schema/file/collection';
30
31
    /**
32
     * setup client and load fixtures
33
     *
34
     * @return void
35
     */
36
    public function setUp()
37
    {
38
        $this->loadFixtures(
39
            array(
40
                'GravitonDyn\FileBundle\DataFixtures\MongoDB\LoadFileData'
41
            ),
42
            null,
43
            'doctrine_mongodb'
44
        );
45
    }
46
47
    /**
48
     * check for empty collections when no fixtures are loaded
49
     *
50
     * @return void
51
     */
52 View Code Duplication
    public function testFindAllEmptyCollection()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
53
    {
54
        // reset fixtures since we already have some from setUp
55
        $this->loadFixtures(array(), null, 'doctrine_mongodb');
56
        $client = static::createRestClient();
57
        $client->request('GET', '/file/');
58
59
        $response = $client->getResponse();
60
        $results = $client->getResults();
61
62
        $this->assertResponseContentType(self::COLLECTION_TYPE, $response);
63
64
        $this->assertEquals(array(), $results);
65
    }
66
67
    /**
68
     * validate that we can post a new file
69
     *
70
     * @return void
71
     */
72
    public function testPostAndUpdateFile()
73
    {
74
        $fixtureData = file_get_contents(__DIR__.'/fixtures/test.txt');
75
        $fileHash = hash('sha256', $fixtureData);
76
        $fileHashCustom = 'some-custom-hash-for-testing';
77
78
        $client = static::createRestClient();
79
        $client->post(
80
            '/file/',
81
            $fixtureData,
82
            [],
83
            [],
84
            ['CONTENT_TYPE' => 'text/plain'],
85
            false
86
        );
87
        $this->assertEmpty($client->getResults());
88
        $response = $client->getResponse();
89
        $this->assertEquals(201, $response->getStatusCode());
90
91
        $fileLocation = $response->headers->get('Location');
92
93
        // update file contents to update mod date
94
        $client = static::createRestClient();
95
        $client->put(
96
            $fileLocation,
97
            $fixtureData,
98
            [],
99
            [],
100
            ['CONTENT_TYPE' => 'text/plain'],
101
            false
102
        );
103
        $this->assertEmpty($client->getResults(), $client->getResponse()->getContent());
104
        $response = $client->getResponse();
105
        $this->assertEquals(204, $response->getStatusCode());
106
107
        $client = static::createRestClient();
108
        $client->request('GET', $fileLocation);
109
        $data = $client->getResults();
110
111
        // check for valid format
112
        $this->assertNotFalse(\DateTime::createFromFormat(\DateTime::RFC3339, $data->metadata->createDate));
113
        $this->assertNotFalse(\DateTime::createFromFormat(\DateTime::RFC3339, $data->metadata->modificationDate));
114
        // Check valid hash encoding if no hash sent
115
        $this->assertEquals($fileHash, $data->metadata->hash);
116
117
        $data->links = [];
118
        $link = new \stdClass;
119
        $link->{'$ref'} = 'http://localhost/core/app/tablet';
120
        $data->links[] = $link;
121
122
        $filename = "test.txt";
123
        $data->metadata->filename = $filename;
124
        $data->metadata->hash = $fileHashCustom;
125
126
        $client = static::createRestClient();
127
        $client->put(sprintf('/file/%s', $data->id), $data);
128
129
        // re-fetch
130
        $client = static::createRestClient();
131
        $client->request('GET', sprintf('/file/%s', $data->id));
132
        $results = $client->getResults();
133
134
        $this->assertEquals($link->{'$ref'}, $results->links[0]->{'$ref'});
135
        $this->assertEquals($filename, $results->metadata->filename);
136
        $this->assertEquals($fileHashCustom, $data->metadata->hash);
137
138
        $client = static::createClient();
139
        $client->request('GET', sprintf('/file/%s', $data->id), [], [], ['HTTP_ACCEPT' => 'text/plain']);
140
141
        $results = $client->getResponse()->getContent();
142
143
        $this->assertEquals($fixtureData, $results);
144
145
        // change link and add second link
146
        $data->links[0]->{'$ref'} = 'http://localhost/core/app/admin';
147
        $link = new \stdClass;
148
        $link->{'$ref'} = 'http://localhost/core/app/web';
149
        $data->links[] = $link;
150
151
        // also add action command
152
        $command = new \stdClass();
153
        $command->command = 'print';
154
        $data->metadata->action = [$command];
155
156
        // also add additionalInformation
157
        $data->metadata->additionalInformation = 'someInfo';
158
159
        $client = static::createRestClient();
160
        $client->put(sprintf('/file/%s', $data->id), $data);
161
162
        // re-fetch
163
        $client = static::createRestClient();
164
        $client->request('GET', sprintf('/file/%s', $data->id));
165
        $results = $client->getResults();
166
167
        $this->assertEquals($data->links[0]->{'$ref'}, $results->links[0]->{'$ref'});
168
        $this->assertEquals($data->links[1]->{'$ref'}, $results->links[1]->{'$ref'});
169
170
        // check metadata
171
        $this->assertEquals(18, $data->metadata->size);
172
        $this->assertEquals('text/plain', $data->metadata->mime);
173
        $this->assertEquals('test.txt', $data->metadata->filename);
174
        $this->assertEquals('print', $data->metadata->action[0]->command);
175
        $this->assertEquals('someInfo', $data->metadata->additionalInformation);
176
        $this->assertNotNull($data->metadata->createDate);
177
        $this->assertNotNull($data->metadata->modificationDate);
178
179
        // remove a link
180
        unset($data->links[1]);
181
182
        $client = static::createRestClient();
183
        $client->put(sprintf('/file/%s', $data->id), $data);
184
        // re-fetch
185
        $client = static::createRestClient();
186
        $client->request('GET', sprintf('/file/%s', $data->id));
187
        $results = $client->getResults();
188
189
        $this->assertEquals($data->links[0]->{'$ref'}, $results->links[0]->{'$ref'});
190
        $this->assertCount(1, $results->links);
191
192
        // remove last link
193
        $data->links = [];
194
        $client = static::createRestClient();
195
        $client->put(sprintf('/file/%s', $data->id), $data);
196
197
        // re-fetch
198
        $client = static::createRestClient();
199
        $client->request('GET', sprintf('/file/%s', $data->id));
200
201
        $results = $client->getResults();
202
203
        $this->assertEmpty($results->links);
204
    }
205
206
    /**
207
     * validate that we can post a new file
208
     *
209
     * @return void
210
     */
211 View Code Duplication
    public function testPostNewFile()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
212
    {
213
        $client = static::createRestClient();
214
215
        $client->post(
216
            '/file',
217
            file_get_contents(__DIR__.'/fixtures/test.txt'),
218
            [],
219
            [],
220
            ['CONTENT_TYPE' => 'text/plain'],
221
            false
222
        );
223
224
        $response = $client->getResponse();
225
        $linkHeader = $response->headers->get('Link');
226
227
        $this->assertEquals(201, $response->getStatusCode());
228
        $this->assertRegExp('@/file/[a-z0-9]{32}>; rel="self"@', $linkHeader);
229
    }
230
231
    /**
232
     * validate that we can put a new file with a custom id
233
     *
234
     * @return void
235
     */
236 View Code Duplication
    public function testPutNewFile()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
237
    {
238
        $client = static::createRestClient();
239
240
        $client->put(
241
            '/file/testPutNewFile',
242
            file_get_contents(__DIR__ . '/fixtures/test.txt'),
243
            [],
244
            [],
245
            ['CONTENT_TYPE' => 'text/plain'],
246
            false
247
        );
248
249
        $response = $client->getResponse();
250
        $linkHeader = $response->headers->get('Link');
251
252
        $this->assertEquals(204, $response->getStatusCode());
253
        $this->assertContains('file/testPutNewFile>; rel="self"', $linkHeader);
254
    }
255
256
    /**
257
     * validate that we can delete a file
258
     *
259
     * @return void
260
     */
261
    public function testDeleteFile()
262
    {
263
        $fixtureData = file_get_contents(__DIR__.'/fixtures/test.txt');
264
        $client = static::createRestClient();
265
        $client->post(
266
            '/file/',
267
            $fixtureData,
268
            [],
269
            [],
270
            ['CONTENT_TYPE' => 'text/plain'],
271
            false
272
        );
273
        $response = $client->getResponse();
274
        $this->assertEquals(201, $response->getStatusCode());
275
276
        // re-fetch
277
        $client = static::createRestClient();
278
        $client->request('GET', $response->headers->get('Location'));
279
        $data = $client->getResults();
280
281
        $client = static::createRestClient();
282
        $client->request('DELETE', sprintf('/file/%s', $data->id));
283
284
        $client = static::createRestClient();
285
        $client->request('GET', sprintf('/file/%s', $data->id));
286
287
        $response = $client->getResponse();
288
        $this->assertEquals(404, $response->getStatusCode());
289
    }
290
291
    /**
292
     * validate that we can update the content from a file
293
     *
294
     * @return void
295
     */
296
    public function testUpdateFileContent()
297
    {
298
        $fixtureData = file_get_contents(__DIR__.'/fixtures/test.txt');
299
        $contentType = 'text/plain';
300
        $newData = "This is a new text!!!";
301
        $client = static::createRestClient();
302
        $client->post(
303
            '/file/',
304
            $fixtureData,
305
            [],
306
            [],
307
            ['CONTENT_TYPE' => $contentType],
308
            false
309
        );
310
        $response = $client->getResponse();
311
        $this->assertEquals(201, $response->getStatusCode());
312
313
        $linkHeader = $response->headers->get('Link');
314
        $this->assertRegExp('@/file/[a-z0-9]{32}>; rel="self"@', $linkHeader);
315
316
        // re-fetch
317
        $client = static::createRestClient();
318
        $client->request('GET', $response->headers->get('Location'));
319
        $retData = $client->getResults();
320
321
        $this->assertEquals(200, $client->getResponse()->getStatusCode());
322
        $this->assertEquals(strlen($fixtureData), $retData->metadata->size);
323
        $this->assertEquals($contentType, $retData->metadata->mime);
324
325
        $this->updateFileContent($retData->id, $newData, $contentType);
326
    }
327
328
    /**
329
     * post a file without any mime type.. check if that mime type is correctly determined.
330
     * fetch content back and compare the contents of the file
331
     *
332
     * @return void
333
     */
334
    public function testPostFileContentMimeDetectionAndContent()
335
    {
336
        $testData = file_get_contents(__DIR__.'/resources/testpicture.jpg');
337
        $contentType = 'image/jpeg';
338
        $client = static::createRestClient();
339
340
        $client->post(
341
            '/file/',
342
            $testData,
343
            [],
344
            [],
345
            [],
346
            false
347
        );
348
        $response = $client->getResponse();
349
        $this->assertEquals(201, $response->getStatusCode());
350
351
        $linkHeader = $response->headers->get('Link');
352
        $this->assertRegExp('@/file/[a-z0-9]{32}>; rel="self"@', $linkHeader);
353
354
        // re-fetch
355
        $client = static::createRestClient();
356
        $client->request('GET', $response->headers->get('Location'));
357
        $retData = $client->getResults();
358
359
        $this->assertEquals(200, $client->getResponse()->getStatusCode());
360
        $this->assertEquals($contentType, $retData->metadata->mime);
361
362
        /** we use the standard client as we don't want to have json forced */
363
        $client = static::createClient();
364
        $client->request(
365
            'GET',
366
            $response->headers->get('Location'),
367
            [],
368
            [],
369
            ['ACCEPT' => $contentType]
370
        );
371
372
        $response = $client->getInternalResponse();
373
374
        $this->assertTrue(($response->getContent() === $testData));
375
    }
376
377
    /**
378
     * test getting collection schema
379
     *
380
     * @return void
381
     */
382
    public function testGetFileCollectionSchemaInformation()
383
    {
384
        $client = static::createRestClient();
385
386
        $client->request('GET', '/schema/file/collection');
387
388
        $response = $client->getResponse();
389
        $results = $client->getResults();
390
391
        $this->assertResponseContentType('application/schema+json', $response);
392
        $this->assertEquals(200, $response->getStatusCode());
393
394
        $this->assertEquals('Array of file objects', $results->title);
395
        $this->assertEquals('array', $results->type);
396
        $this->assertIsFileSchema($results->items);
397
398
        $this->assertCorsHeaders('GET, POST, PUT, PATCH, DELETE, OPTIONS', $response);
399
        $this->assertContains(
400
            'Link',
401
            explode(',', $response->headers->get('Access-Control-Expose-Headers'))
402
        );
403
404
        $this->assertContains(
405
            '<http://localhost/schema/file/collection>; rel="self"',
406
            explode(',', $response->headers->get('Link'))
407
        );
408
    }
409
410
    /**
411
     * test behavior when data sent was multipart/form-data
412
     *
413
     * @return void
414
     */
415
    public function testPutNewFileViaForm()
416
    {
417
        copy(__DIR__ . '/fixtures/test.txt', sys_get_temp_dir() . '/test.txt');
418
        $file = sys_get_temp_dir() . '/test.txt';
419
        $uploadedFile = new UploadedFile($file, 'test.txt', 'text/plain', 15);
420
421
        $jsonData = '{
422
          "id": "myPersonalFile",
423
          "links": [
424
            {
425
              "$ref": "http://localhost/testcase/readonly/101",
426
              "type": "owner"
427
            },
428
            {
429
              "$ref": "http://localhost/testcase/readonly/102",
430
              "type": "module"
431
            }
432
          ],
433
          "metadata": {
434
            "action":[{"command":"print"},{"command":"archive"}],
435
            "additionalInformation": "someInfo",
436
            "additionalProperties": [
437
                {"name": "testName", "value": "testValue"},
438
                {"name": "testName2", "value": "testValue2"}
439
            ],
440
            "filename": "customFileName"
441
          }
442
        }';
443
444
        $client = static::createRestClient();
445
        $client->put(
446
            '/file/myPersonalFile',
447
            [],
448
            [
449
                'metadata' => $jsonData,
450
            ],
451
            [
452
                'upload' => $uploadedFile,
453
            ],
454
            [],
455
            false
456
        );
457
458
        $response = $client->getResponse();
459
460
        $this->assertEquals(Response::HTTP_NO_CONTENT, $response->getStatusCode());
461
        $this->assertNotContains('location', $response->headers->all());
462
463
        $response = $this->updateFileContent('myPersonalFile', "This is a new text!!!");
464
465
        $metaData = json_decode($jsonData, true);
466
        $returnData = json_decode($response->getContent(), true);
467
468
        $this->assertEquals($metaData['links'], $returnData['links']);
469
        $this->assertEquals($metaData['metadata']['action'], $returnData['metadata']['action']);
470
        $this->assertEquals(
471
            $metaData['metadata']['additionalInformation'],
472
            $returnData['metadata']['additionalInformation']
473
        );
474
        $this->assertEquals(
475
            $metaData['metadata']['additionalProperties'],
476
            $returnData['metadata']['additionalProperties']
477
        );
478
        $this->assertCount(2, $returnData['metadata']['additionalProperties']);
479
        $this->assertEquals($metaData['metadata']['filename'], $returnData['metadata']['filename']);
480
481
        // clean up
482
        $client = $this->createClient();
483
        $client->request(
484
            'DELETE',
485
            '/file/myPersonalFile'
486
        );
487
    }
488
489
    /**
490
     * check if a schema is of the file type
491
     *
492
     * @param \stdClass $schema schema from service to validate
493
     *
494
     * @return void
495
     */
496
    private function assertIsFileSchema(\stdClass $schema)
497
    {
498
        $this->assertEquals('File', $schema->title);
499
        $this->assertEquals('File storage service', $schema->description);
500
        $this->assertEquals('object', $schema->type);
501
502
        $this->assertEquals('string', $schema->properties->id->type);
503
        $this->assertEquals('ID', $schema->properties->id->title);
504
        $this->assertEquals('Unique identifier', $schema->properties->id->description);
505
        $this->assertObjectNotHasAttribute('readOnly', $schema->properties->id);
506
507
        // Metadata
508
        $this->assertEquals('object', $schema->properties->metadata->type);
509
        $this->assertEquals('Metadata', $schema->properties->metadata->title);
510
        $this->assertObjectNotHasAttribute('readOnly', $schema->properties->metadata);
511
512
        // Metadata size
513
        $this->assertEquals('integer', $schema->properties->metadata->properties->size->type);
514
        $this->assertEquals('File size', $schema->properties->metadata->properties->size->title);
515
        $this->assertEquals('Size of file.', $schema->properties->metadata->properties->size->description);
516
517
        // Metadata mime
518
        $this->assertContains('string', $schema->properties->metadata->properties->mime->type);
519
        $this->assertEquals('MIME Type', $schema->properties->metadata->properties->mime->title);
520
        $this->assertEquals('MIME-Type of file.', $schema->properties->metadata->properties->mime->description);
521
522
        // Metadata createDate
523
        $this->assertEquals(['string', 'null'], $schema->properties->metadata->properties->createDate->type);
524
        $this->assertEquals('date-time', $schema->properties->metadata->properties->createDate->format);
525
        $this->assertEquals('Creation date', $schema->properties->metadata->properties->createDate->title);
526
        $this->assertEquals(
527
            'Timestamp of file upload.',
528
            $schema->properties->metadata->properties->createDate->description
529
        );
530
531
        // Metadata modificationDate
532
        $this->assertEquals(['string', 'null'], $schema->properties->metadata->properties->modificationDate->type);
533
        $this->assertEquals('date-time', $schema->properties->metadata->properties->modificationDate->format);
534
        $this->assertEquals('Modification date', $schema->properties->metadata->properties->modificationDate->title);
535
        $this->assertEquals(
536
            'Timestamp of the last file change.',
537
            $schema->properties->metadata->properties->modificationDate->description
538
        );
539
540
        // Metadata filename
541
        $this->assertContains('string', $schema->properties->metadata->properties->filename->type);
542
        $this->assertEquals('File name', $schema->properties->metadata->properties->filename->title);
543
        $this->assertEquals(
544
            'Name of the file as it should get displayed to the user.',
545
            $schema->properties->metadata->properties->filename->description
546
        );
547
        $this->assertObjectNotHasAttribute('readOnly', $schema->properties->metadata->properties->filename);
548
549
        // metadata action.command array
550
        $this->assertContains(
551
            'string',
552
            $schema->properties->metadata->properties->action->items->properties->command->type
553
        );
554
        $this->assertEquals(
555
            'Action command array',
556
            $schema->properties->metadata->properties->action->items->properties->command->title
557
        );
558
        $this->assertObjectNotHasAttribute(
559
            'readOnly',
560
            $schema->properties->metadata->properties->action->items->properties->command
561
        );
562
563
        // metadata additionalInformation
564
        $this->assertContains(
565
            'string',
566
            $schema->properties->metadata->properties->additionalInformation->type
567
        );
568
        $this->assertEquals(
569
            'Additional Information',
570
            $schema->properties->metadata->properties->additionalInformation->title
571
        );
572
        $this->assertObjectNotHasAttribute(
573
            'readOnly',
574
            $schema->properties->metadata->properties->additionalInformation
575
        );
576
577
        // metadata additionalProperties
578
        $additionalPropertiesSchema = $schema->properties->metadata->properties->additionalProperties;
579
        $this->assertEquals('array', $additionalPropertiesSchema->type);
580
        $this->assertEquals('object', $additionalPropertiesSchema->items->type);
581
        $this->assertEquals('string', $additionalPropertiesSchema->items->properties->name->type);
582
        $this->assertEquals('property name', $additionalPropertiesSchema->items->properties->name->title);
583
        $this->assertEquals('string', $additionalPropertiesSchema->items->properties->value->type);
584
        $this->assertEquals('property value', $additionalPropertiesSchema->items->properties->value->title);
585
586
        // Links
587
        $this->assertEquals('array', $schema->properties->links->type);
588
        $this->assertEquals('many', $schema->properties->links->format);
589
        $this->assertEquals('links', $schema->properties->links->title);
590
        $this->assertEquals('@todo replace me', $schema->properties->links->description);
591
        $this->assertObjectNotHasAttribute('readOnly', $schema->properties->links);
592
593
594
        // Links items
595
        $this->assertEquals('object', $schema->properties->links->items->type);
596
        $this->assertEquals('Links', $schema->properties->links->items->title);
597
        $this->assertObjectNotHasAttribute('readOnly', $schema->properties->links->items);
598
599
600
        // Links item type
601
        $this->assertContains('string', $schema->properties->links->items->properties->type->type);
602
        $this->assertEquals('Type', $schema->properties->links->items->properties->type->title);
603
        $this->assertEquals('Type of the link.', $schema->properties->links->items->properties->type->description);
604
        $this->assertObjectNotHasAttribute('readOnly', $schema->properties->links->items->properties->type);
605
606
        // Links item $ref
607
        $this->assertEquals(['string', 'null'], $schema->properties->links->items->properties->{'$ref'}->type);
608
        $this->assertEquals('extref', $schema->properties->links->items->properties->{'$ref'}->format);
609
        $this->assertEquals('Link', $schema->properties->links->items->properties->{'$ref'}->title);
610
        $this->assertEquals(
611
            'Link to any document.',
612
            $schema->properties->links->items->properties->{'$ref'}->description
613
        );
614
        $this->assertEquals(
615
            ['*'],
616
            $schema->properties->links->items->properties->{'$ref'}->{'x-collection'}
617
        );
618
619
        $this->assertEquals(
620
            [
621
                'document.file.file.update',
622
                'document.file.file.create',
623
                'document.file.file.delete'
624
            ],
625
            $schema->{'x-events'}
626
        );
627
628
        $this->assertObjectNotHasAttribute('readOnly', $schema->properties->links->items->properties->{'$ref'});
629
    }
630
631
    /**
632
     * Verifies the update of a file content.
633
     *
634
     * @param string $fileId      identifier of the file to be updated
635
     * @param string $newContent  new content to be stored in the file
636
     * @param string $contentType Content-Type of the file
637
     *
638
     * @return null|Response
0 ignored issues
show
Documentation introduced by
Should the return type not be object|null?

This check compares the return type specified in the @return annotation of a function or method doc comment with the types returned by the function and raises an issue if they mismatch.

Loading history...
639
     */
640
    private function updateFileContent($fileId, $newContent, $contentType = 'text/plain')
641
    {
642
        $client = static::createRestClient();
643
        $client->put(
644
            sprintf('/file/%s', $fileId),
645
            $newContent,
646
            [],
647
            [],
648
            ['CONTENT_TYPE' => $contentType],
649
            false
650
        );
651
652
        $client = static::createRestClient();
653
        $client->request('GET', sprintf('/file/%s', $fileId));
654
655
        $retData = $client->getResults();
656
        $response = $client->getResponse();
657
        $this->assertEquals(200, $response->getStatusCode());
658
        $this->assertEquals($contentType, $retData->metadata->mime);
659
660
        return $response;
661
    }
662
}
663