UrlDTOArrayTest   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 110
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 37
dl 0
loc 110
rs 10
c 0
b 0
f 0
wmc 6

6 Methods

Rating   Name   Duplication   Size   Complexity  
A testGetUrlsAddedViaAdd() 0 11 1
A testCurrent() 0 10 1
A testCount() 0 8 1
A urlsDataProvider() 0 14 1
A testGetUrlsAddedViaConstructor() 0 9 1
A testGetUrlsAddedViaSet() 0 11 1
1
<?php
2
/**
3
 * File: UrlDTOArrayTest.php
4
 *
5
 * @author      Maciej Sławik <[email protected]>
6
 * Github:      https://github.com/maciejslawik
7
 */
8
9
namespace MSlwk\Otomoto\Middleware\Test\Unit\Webpage\Data;
10
11
use MSlwk\Otomoto\Middleware\Webpage\Data\UrlDTO;
12
use MSlwk\Otomoto\Middleware\Webpage\Data\UrlDTOArray;
13
use PHPUnit\Framework\TestCase;
14
15
/**
16
 * Class UrlDTOArrayTest
17
 * @package MSlwk\Otomoto\Middleware\Test\Unit\Webpage\Data
18
 */
19
class UrlDTOArrayTest extends TestCase
20
{
21
    /**
22
     * @return array
23
     */
24
    public function urlsDataProvider()
25
    {
26
        return [
27
            [
28
                'http://url1.com',
29
                'http://url4.com'
30
            ],
31
            [
32
                'http://url11.com',
33
                'http://url153.com'
34
            ],
35
            [
36
                'http://url11.com',
37
                'http://url421.com'
38
            ],
39
        ];
40
    }
41
42
    /**
43
     * @test
44
     * @dataProvider urlsDataProvider
45
     * @param $firstUrl
46
     * @param $secondUrl
47
     */
48
    public function testGetUrlsAddedViaConstructor($firstUrl, $secondUrl)
49
    {
50
        $firstUrlDTO = new UrlDTO($firstUrl);
51
        $secondUrlDTO = new UrlDTO($secondUrl);
52
53
        $urlDTOArray = new UrlDTOArray($firstUrlDTO, $secondUrlDTO);
54
55
        $this->assertEquals($firstUrl, $urlDTOArray->get(0)->getUrl());
56
        $this->assertEquals($secondUrl, $urlDTOArray->get(1)->getUrl());
57
    }
58
59
    /**
60
     * @test
61
     * @dataProvider urlsDataProvider
62
     * @param $firstUrl
63
     * @param $secondUrl
64
     */
65
    public function testGetUrlsAddedViaAdd($firstUrl, $secondUrl)
66
    {
67
        $firstUrlDTO = new UrlDTO($firstUrl);
68
        $secondUrlDTO = new UrlDTO($secondUrl);
69
70
        $urlDTOArray = new UrlDTOArray();
71
        $urlDTOArray->add($firstUrlDTO);
72
        $urlDTOArray->add($secondUrlDTO);
73
74
        $this->assertEquals($firstUrl, $urlDTOArray->get(0)->getUrl());
75
        $this->assertEquals($secondUrl, $urlDTOArray->get(1)->getUrl());
76
    }
77
78
    /**
79
     * @test
80
     * @dataProvider urlsDataProvider
81
     * @param $firstUrl
82
     * @param $secondUrl
83
     */
84
    public function testGetUrlsAddedViaSet($firstUrl, $secondUrl)
85
    {
86
        $firstUrlDTO = new UrlDTO($firstUrl);
87
        $secondUrlDTO = new UrlDTO($secondUrl);
88
89
        $urlDTOArray = new UrlDTOArray();
90
        $urlDTOArray->set(4, $firstUrlDTO);
91
        $urlDTOArray->set(1, $secondUrlDTO);
92
93
        $this->assertEquals($firstUrl, $urlDTOArray->get(4)->getUrl());
94
        $this->assertEquals($secondUrl, $urlDTOArray->get(1)->getUrl());
95
    }
96
97
    /**
98
     * @test
99
     * @dataProvider urlsDataProvider
100
     * @param $firstUrl
101
     * @param $secondUrl
102
     */
103
    public function testCurrent($firstUrl, $secondUrl)
104
    {
105
        $firstUrlDTO = new UrlDTO($firstUrl);
106
        $secondUrlDTO = new UrlDTO($secondUrl);
107
108
        $urlDTOArray = new UrlDTOArray($firstUrlDTO, $secondUrlDTO);
109
110
        $this->assertEquals($firstUrl, $urlDTOArray->current()->getUrl());
111
        $urlDTOArray->next();
112
        $this->assertEquals($secondUrl, $urlDTOArray->current()->getUrl());
113
    }
114
115
    /**
116
     * @test
117
     * @dataProvider urlsDataProvider
118
     * @param $firstUrl
119
     * @param $secondUrl
120
     */
121
    public function testCount($firstUrl, $secondUrl)
122
    {
123
        $firstUrlDTO = new UrlDTO($firstUrl);
124
        $secondUrlDTO = new UrlDTO($secondUrl);
125
126
        $urlDTOArray = new UrlDTOArray($firstUrlDTO, $secondUrlDTO);
127
128
        $this->assertEquals(2, $urlDTOArray->count());
129
    }
130
}
131