Completed
Push — master ( 6bb449...6021e6 )
by David
22:53
created

testMatchAnonymousRequest()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 8
rs 9.4285
cc 1
eloc 4
nc 1
nop 0
1
<?php
2
3
/*
4
 * This file is part of the FOSHttpCacheBundle package.
5
 *
6
 * (c) FriendsOfSymfony <http://friendsofsymfony.github.com/>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace FOS\HttpCacheBundle\Tests\Unit\UserContext;
13
14
use FOS\HttpCacheBundle\UserContext\AnonymousRequestMatcher;
15
use PHPUnit_Framework_TestCase;
16
use Symfony\Component\HttpFoundation\Request;
17
18
class AnonymousRequestMatcherTest extends PHPUnit_Framework_TestCase
19
{
20
    public function testMatchAnonymousRequest()
21
    {
22
        $request = new Request();
23
24
        $requestMatcher = new AnonymousRequestMatcher(['Cookie', 'Authorization']);
25
26
        $this->assertTrue($requestMatcher->matches($request));
27
    }
28
29 View Code Duplication
    public function testNoMatchIfCookie()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
30
    {
31
        $request = new Request();
32
        $request->headers->set('Cookie', 'PHPSESSID7e476fc9f29f69d2ad6f11dbcd663b42=25f6d9c5a843e3c948cd26902385a527');
33
        $request->cookies->set('PHPSESSID7e476fc9f29f69d2ad6f11dbcd663b42', '25f6d9c5a843e3c948cd26902385a527');
34
35
        $requestMatcher = new AnonymousRequestMatcher(['Cookie', 'Authorization']);
36
37
        $this->assertFalse($requestMatcher->matches($request));
38
    }
39
40 View Code Duplication
    public function testNoMatchIfEmptyCookieHeader()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
41
    {
42
        $request = new Request();
43
        $request->headers->set('Cookie', '');
44
45
        $requestMatcher = new AnonymousRequestMatcher(['Cookie', 'Authorization']);
46
47
        $this->assertTrue($requestMatcher->matches($request));
48
    }
49
50 View Code Duplication
    public function testNoMatchIfAuthenticationHeader()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
51
    {
52
        $request = new Request();
53
        $request->headers->set('Authorization', 'foo: bar');
54
55
        $requestMatcher = new AnonymousRequestMatcher(['Cookie', 'Authorization']);
56
57
        $this->assertFalse($requestMatcher->matches($request));
58
    }
59
60 View Code Duplication
    public function testMatchEmptyCookieHeaderHeader()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
61
    {
62
        $request = new Request();
63
        $request->headers->set('Cookie', '');
64
65
        $requestMatcher = new AnonymousRequestMatcher(['Cookie', 'Authorization']);
66
67
        $this->assertTrue($requestMatcher->matches($request));
68
    }
69
}
70