Completed
Push — master ( b69735...6d6276 )
by John
05:05
created

SecuredApiTest   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 39
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 2
dl 0
loc 39
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A canGetUnsecuredContentWithoutAuth() 0 6 1
A cannotGetSecuredContentWithoutAuth() 0 6 1
A canGetSecuredContentWithAuth() 0 6 1
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\Functional;
10
11
use KleijnWeb\SwaggerBundle\Test\ApiResponseErrorException;
12
use KleijnWeb\SwaggerBundle\Test\ApiTestCase;
13
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
14
15
/**
16
 * @author John Kleijn <[email protected]>
17
 * @group  functional
18
 */
19
class SecuredApiTest extends WebTestCase
20
{
21
    use ApiTestCase;
22
23
    /**
24
     * @var string
25
     */
26
    protected $env = 'secure';
27
28
    /**
29
     * @test
30
     */
31
    public function canGetUnsecuredContentWithoutAuth()
32
    {
33
        $string = $this->get('/basic-auth/v1/unsecured');
34
35
        $this->assertSame($string, 'UNSECURED CONTENT');
36
    }
37
38
    /**
39
     * @test
40
     */
41
    public function cannotGetSecuredContentWithoutAuth()
42
    {
43
        $this->setExpectedException(ApiResponseErrorException::class, '', 401);
0 ignored issues
show
Deprecated Code introduced by
The method PHPUnit_Framework_TestCase::setExpectedException() has been deprecated with message: Method deprecated since Release 5.2.0; use expectException() instead

This method has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead.

Loading history...
44
45
        $this->get('/basic-auth/v1/secure');
46
    }
47
48
    /**
49
     * @test
50
     */
51
    public function canGetSecuredContentWithAuth()
52
    {
53
        $string = $this->get('/basic-auth/v1/secure', [], ['PHP_AUTH_USER' => 'user', 'PHP_AUTH_PW' => 'password']);
54
55
        $this->assertSame($string, 'SECURED CONTENT');
56
    }
57
}
58