|
1
|
|
|
<?php |
|
2
|
|
|
/* |
|
3
|
|
|
* This file is part of the KleijnWeb\SwaggerBundle package. |
|
4
|
|
|
* |
|
5
|
|
|
* For the full copyright and license information, please view the LICENSE |
|
6
|
|
|
* file that was distributed with this source code. |
|
7
|
|
|
*/ |
|
8
|
|
|
|
|
9
|
|
|
namespace KleijnWeb\SwaggerBundle\Tests\Document; |
|
10
|
|
|
|
|
11
|
|
|
use KleijnWeb\SwaggerBundle\Document\DocumentRepository; |
|
12
|
|
|
|
|
13
|
|
|
/** |
|
14
|
|
|
* @author John Kleijn <[email protected]> |
|
15
|
|
|
*/ |
|
16
|
|
|
class DocumentRepositoryTest extends \PHPUnit_Framework_TestCase |
|
17
|
|
|
{ |
|
18
|
|
|
/** |
|
19
|
|
|
* @test |
|
20
|
|
|
* @expectedException \InvalidArgumentException |
|
21
|
|
|
*/ |
|
22
|
|
|
public function willFailWhenKeyIsEmpty() |
|
23
|
|
|
{ |
|
24
|
|
|
$repository = new DocumentRepository(); |
|
25
|
|
|
$repository->get(''); |
|
26
|
|
|
} |
|
27
|
|
|
|
|
28
|
|
|
/** |
|
29
|
|
|
* @test |
|
30
|
|
|
* @expectedException \KleijnWeb\SwaggerBundle\Document\Exception\ResourceNotReadableException |
|
31
|
|
|
*/ |
|
32
|
|
|
public function willFailWhenPathDoesNotExist() |
|
33
|
|
|
{ |
|
34
|
|
|
$repository = new DocumentRepository(); |
|
35
|
|
|
$repository->get('/this/is/total/bogus'); |
|
36
|
|
|
} |
|
37
|
|
|
|
|
38
|
|
|
/** |
|
39
|
|
|
* @test |
|
40
|
|
|
*/ |
|
41
|
|
|
public function gettingDocumentThatDoestExistWillConstructIt() |
|
42
|
|
|
{ |
|
43
|
|
|
$repository = new DocumentRepository(); |
|
44
|
|
|
$document = $repository->get('src/Tests/Functional/PetStore/app/swagger/petstore.yml'); |
|
45
|
|
|
$this->assertInstanceOf('KleijnWeb\SwaggerBundle\Document\SwaggerDocument', $document); |
|
46
|
|
|
} |
|
47
|
|
|
|
|
48
|
|
|
/** |
|
49
|
|
|
* @test |
|
50
|
|
|
*/ |
|
51
|
|
|
public function definitionIsObject() |
|
52
|
|
|
{ |
|
53
|
|
|
$repository = new DocumentRepository(); |
|
54
|
|
|
$document = $repository->get('src/Tests/Functional/PetStore/app/swagger/petstore.yml'); |
|
55
|
|
|
$this->assertInternalType('object', $document->getDefinition()); |
|
56
|
|
|
} |
|
57
|
|
|
|
|
58
|
|
|
/** |
|
59
|
|
|
* @test |
|
60
|
|
|
*/ |
|
61
|
|
|
public function canUsePathPrefix() |
|
62
|
|
|
{ |
|
63
|
|
|
$repository = new DocumentRepository('src/Tests/Functional/PetStore'); |
|
64
|
|
|
$document = $repository->get('app/swagger/petstore.yml'); |
|
65
|
|
|
$this->assertInstanceOf('KleijnWeb\SwaggerBundle\Document\SwaggerDocument', $document); |
|
66
|
|
|
} |
|
67
|
|
|
} |
|
68
|
|
|
|