Completed
Pull Request — master (#203)
by Alister
09:00
created

ModifiedSinceTest::testGetBadValue()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 10

Duplication

Lines 10
Ratio 100 %

Importance

Changes 0
Metric Value
dl 10
loc 10
rs 9.9332
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
namespace Debril\RssAtomBundle\Tests\Request;
4
5
use Debril\RssAtomBundle\Request\ModifiedSince;
6
use PHPUnit\Framework\TestCase;
7
use Psr\Log\NullLogger;
8
use Symfony\Component\HttpFoundation\Request;
9
use Symfony\Component\HttpFoundation\RequestStack;
10
11
class ModifiedSinceTest extends TestCase
12
{
13
14 View Code Duplication
    public function testGetValue()
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...
15
    {
16
        $stack = new RequestStack();
17
        $request = new Request();
18
        $date = new \DateTime('2018-06-01');
19
        $request->headers->set('If-Modified-Since', $date->format(\DATE_RSS));
20
        $stack->push($request);
21
22
        $modifiedSince = new ModifiedSince($stack, new NullLogger());
23
        $this->assertEquals($date, $modifiedSince->getValue());
24
    }
25
26 View Code Duplication
    public function testGetBadValue()
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...
27
    {
28
        $stack = new RequestStack();
29
        $request = new Request();
30
        $request->headers->set('If-Modified-Since', 'something that is not a date');
31
        $stack->push($request);
32
33
        $modifiedSince = new ModifiedSince($stack, new NullLogger());
34
        $this->assertInstanceOf('\DateTime', $modifiedSince->getValue());
35
    }
36
37 View Code Duplication
    public function testGetEmptyArrayValue()
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...
38
    {
39
        $stack = new RequestStack();
40
        $request = new Request();
41
        $request->headers->set('If-Modified-Since', array());
42
        $stack->push($request);
43
44
        $modifiedSince = new ModifiedSince($stack, new NullLogger());
45
        $this->assertInstanceOf('\DateTime', $modifiedSince->getValue());
46
    }
47
48
49 View Code Duplication
    public function testGetValueInArray()
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...
50
    {
51
        $stack = new RequestStack();
52
        $request = new Request();
53
        $date = new \DateTime('2018-06-01');
54
        $request->headers->set('If-Modified-Since', [$date->format(\DATE_RSS)]);
55
        $stack->push($request);
56
57
        $modifiedSince = new ModifiedSince($stack, new NullLogger());
58
        $this->assertEquals($date, $modifiedSince->getValue());
59
    }
60
61
}
62