Completed
Push — master ( 386146...a2d301 )
by John
07:40
created

DocumentRepositoryTest   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 52
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

Changes 3
Bugs 0 Features 0
Metric Value
wmc 5
c 3
b 0
f 0
lcom 0
cbo 3
dl 0
loc 52
rs 10

5 Methods

Rating   Name   Duplication   Size   Complexity  
A willFailWhenKeyIsEmpty() 0 5 1
A willFailWhenPathDoesNotExist() 0 5 1
A gettingDocumentThatDoestExistWillConstructIt() 0 6 1
A definitionIsObject() 0 6 1
A canUsePathPrefix() 0 6 1
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