Completed
Push — master ( f0fa18...b24fdb )
by John
20:29
created

ParameterRefBuilderTest::construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 6
rs 9.4285
cc 1
eloc 3
nc 1
nop 2
1
<?php declare(strict_types = 1);
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
use KleijnWeb\SwaggerBundle\Document\ParameterRefBuilder;
13
use Symfony\Component\HttpFoundation\Request;
14
15
/**
16
 * @author John Kleijn <[email protected]>
17
 */
18
class ParameterRefBuilderTest extends \PHPUnit_Framework_TestCase
19
{
20
    /**
21
     * @test
22
     */
23
    public function willDefaultToRequestUri()
24
    {
25
        $builder    = new ParameterRefBuilder('/');
26
        $repository = new DocumentRepository('src/Tests/Functional/PetStore/app');
27
        $document   = $repository->get('swagger/petstore.yml');
28
        $request    = Request::create(
29
            '/pet/100',
30
            'POST'
31
        );
32
        $request->attributes->set('_definition', 'swagger/petstore.yml');
33
        $request->attributes->set('_swagger_path', '/pet/{petId}');
34
        $request->attributes->set('_swagger_document', $document);
35
        $request->attributes->set('_swagger_operation', $document->getOperationObject('/pet/{petId}', 'POST'));
36
37
        $actual = $builder->buildSpecificationLink($request, 'name');
38
39
        $this->assertStringStartsWith('http://petstore.swagger.io/swagger/petstore.yml', $actual);
40
    }
41
}
42