|
1 | 1 | <?php
|
2 | 2 |
|
3 |
| -namespace JsonSchema\Tests\Uri\Retrievers |
4 |
| -{ |
5 |
| - use JsonSchema\Uri\Retrievers\FileGetContents; |
6 |
| - use PHPUnit\Framework\TestCase; |
| 3 | +namespace JsonSchema\Tests\Uri\Retrievers; |
| 4 | + |
| 5 | +use JsonSchema\Uri\Retrievers\FileGetContents; |
| 6 | +use PHPUnit\Framework\TestCase; |
7 | 7 |
|
| 8 | +/** |
| 9 | + * @group FileGetContents |
| 10 | + */ |
| 11 | +class FileGetContentsTest extends TestCase |
| 12 | +{ |
8 | 13 | /**
|
9 |
| - * @group FileGetContents |
| 14 | + * @expectedException \JsonSchema\Exception\ResourceNotFoundException |
10 | 15 | */
|
11 |
| - class FileGetContentsTest extends TestCase |
| 16 | + public function testFetchMissingFile() |
| 17 | + { |
| 18 | + $res = new FileGetContents(); |
| 19 | + $res->retrieve(__DIR__ . '/Fixture/missing.json'); |
| 20 | + } |
| 21 | + |
| 22 | + public function testFetchFile() |
| 23 | + { |
| 24 | + $res = new FileGetContents(); |
| 25 | + $result = $res->retrieve(__DIR__ . '/../Fixture/child.json'); |
| 26 | + $this->assertNotEmpty($result); |
| 27 | + } |
| 28 | + |
| 29 | + public function testContentType() |
| 30 | + { |
| 31 | + $res = new FileGetContents(); |
| 32 | + |
| 33 | + $reflector = new \ReflectionObject($res); |
| 34 | + $fetchContentType = $reflector->getMethod('fetchContentType'); |
| 35 | + $fetchContentType->setAccessible(true); |
| 36 | + |
| 37 | + $this->assertTrue($fetchContentType->invoke($res, array('Content-Type: application/json'))); |
| 38 | + $this->assertFalse($fetchContentType->invoke($res, array('X-Some-Header: whateverValue'))); |
| 39 | + } |
| 40 | + |
| 41 | + public function testCanHandleHttp301PermanentRedirect() |
12 | 42 | {
|
13 |
| - /** |
14 |
| - * @expectedException \JsonSchema\Exception\ResourceNotFoundException |
15 |
| - */ |
16 |
| - public function testFetchMissingFile() |
17 |
| - { |
18 |
| - $res = new FileGetContents(); |
19 |
| - $res->retrieve(__DIR__ . '/Fixture/missing.json'); |
20 |
| - } |
21 |
| - |
22 |
| - public function testFetchFile() |
23 |
| - { |
24 |
| - $res = new FileGetContents(); |
25 |
| - $result = $res->retrieve(__DIR__ . '/../Fixture/child.json'); |
26 |
| - $this->assertNotEmpty($result); |
27 |
| - } |
28 |
| - |
29 |
| - public function testContentType() |
30 |
| - { |
31 |
| - $res = new FileGetContents(); |
32 |
| - |
33 |
| - $reflector = new \ReflectionObject($res); |
34 |
| - $fetchContentType = $reflector->getMethod('fetchContentType'); |
35 |
| - $fetchContentType->setAccessible(true); |
36 |
| - |
37 |
| - $this->assertTrue($fetchContentType->invoke($res, array('Content-Type: application/json'))); |
38 |
| - $this->assertFalse($fetchContentType->invoke($res, array('X-Some-Header: whateverValue'))); |
39 |
| - } |
40 |
| - |
41 |
| - public function testCanHandleHttp301PermanentRedirect() |
42 |
| - { |
43 |
| - $res = new FileGetContents(); |
44 |
| - |
45 |
| - $res->retrieve('http://asyncapi.com/definitions/2.0.0/asyncapi.json'); |
46 |
| - |
47 |
| - $this->assertSame('application/schema+json', $res->getContentType()); |
48 |
| - } |
| 43 | + $res = new FileGetContents(); |
| 44 | + |
| 45 | + $res->retrieve('http://asyncapi.com/definitions/2.0.0/asyncapi.json'); |
| 46 | + |
| 47 | + $this->assertSame('application/schema+json', $res->getContentType()); |
49 | 48 | }
|
50 | 49 | }
|
0 commit comments