Completed
Push — master ( 6ebd1c...df9bae )
by John
10:14
created

canRenderResourcesFromPetStore()   B

Complexity

Conditions 2
Paths 2

Size

Total Lines 24
Code Lines 18

Duplication

Lines 0
Ratio 0 %

Importance

Changes 4
Bugs 2 Features 0
Metric Value
c 4
b 2
f 0
dl 0
loc 24
rs 8.9713
cc 2
eloc 18
nc 2
nop 0
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\Dev\Generator;
10
11
use KleijnWeb\SwaggerBundle\Tests\Dev\Document\SwaggerDocumentTest;
12
use KleijnWeb\SwaggerBundle\Dev\Generator\ResourceGenerator;
13
use KleijnWeb\SwaggerBundle\Tests\Functional\PetStore\PetStoreBundle;
14
15
/**
16
 * @author John Kleijn <[email protected]>
17
 */
18
class ResourceGeneratorTest extends \PHPUnit_Framework_TestCase
19
{
20
    /**
21
     * @test
22
     */
23
    public function canRenderResourcesFromPetStore()
24
    {
25
        $bundle = new PetStoreBundle();
26
        $document = SwaggerDocumentTest::getPetStoreDocument();
27
        $generator = new ResourceGenerator();
28
        $generator->setSkeletonDirs('src/Dev/Resources/skeleton');
0 ignored issues
show
Documentation introduced by
'src/Dev/Resources/skeleton' is of type string, but the function expects a array.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
29
        $generator->generate($bundle, $document, 'Foo\Bar');
30
        $files = [
31
            'User.php',
32
            'Category.php',
33
            'Pet.php',
34
            'Order.php',
35
        ];
36
37
        foreach ($files as $file) {
38
            $filePathName = $bundle->getPath() . '/Foo/Bar/' . $file;
39
            $this->assertTrue(
40
                file_exists($filePathName),
41
                sprintf('%s has not been generated', $filePathName)
42
            );
43
            $content = file_get_contents($filePathName);
44
            $this->assertContains("namespace {$bundle->getNamespace()}\\Foo\\Bar;", $content);
45
        }
46
    }
47
}
48