Completed
Push — master ( b3079f...65c6d8 )
by
unknown
02:54
created

Repository/RouteDocumentRepositoryTest.php (1 issue)

duplicate/similar methods.

Duplication Informational

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
2
3
namespace OpenOrchestra\FunctionalTests\ModelBundle\Repository;
4
5
use OpenOrchestra\BaseBundle\Tests\AbstractTest\AbstractKernelTestCase;
6
use OpenOrchestra\ModelBundle\Repository\RouteDocumentRepository;
7
8
/**
9
 * Test RouteDocumentRepositoryTest
10
 *
11
 * @group integrationTest
12
 */
13
class RouteDocumentRepositoryTest extends AbstractKernelTestCase
14
{
15
    /**
16
     * @var RouteDocumentRepository
17
     */
18
    protected $repository;
19
20
    /**
21
     * Set up the test
22
     */
23
    public function setUp()
24
    {
25
        parent::setUp();
26
27
        static::bootKernel();
28
        $this->repository = static::$kernel->getContainer()->get('open_orchestra_model.repository.route_document');
29
    }
30
31
    /**
32
     * Test simple route
33
     *
34
     * @param string $pathInfo
35
     * @param string $name
36
     *
37
     * @dataProvider provideSimplePathInfo
38
     */
39
    public function testFindByPathInfoWithSingleAnswer($pathInfo, $name)
40
    {
41
        $routes = $this->repository->findByPathInfo($pathInfo);
42
43
        $this->assertCount(1, $routes);
44
        $this->assertSame($name, $routes[0]->getName());
45
    }
46
47
    /**
48
     * @return array
49
     */
50 View Code Duplication
    public function provideSimplePathInfo()
0 ignored issues
show
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
        return array(
53
            array('foo', 'foo'),
54
            array('baz/bar', 'baz/bar'),
55
            array('foo/test', 'foo/{bar}'),
56
            array('foo/test/baz', 'foo/{bar}/baz'),
57
        );
58
    }
59
60
    /**
61
     * @param string $pathInfo
62
     * @param string $name0
63
     * @param string $name1
64
     *
65
     * @dataProvider provideMultiplePath
66
     */
67
    public function testFindByPathInfoWithMultipleAnswer($pathInfo, $name0, $name1)
68
    {
69
        $routes = $this->repository->findByPathInfo($pathInfo);
70
71
        $this->assertCount(2, $routes);
72
        $this->assertSame($name0, $routes[0]->getName());
73
        $this->assertSame($name1, $routes[1]->getName());
74
    }
75
76
    /**
77
     * @return array
78
     */
79
    public function provideMultiplePath()
80
    {
81
        return array(
82
            array('foo/bar', 'foo/bar', 'foo/{bar}'),
83
        );
84
    }
85
86
    /**
87
     * @param string $pathInfo
88
     * @param int    $count
89
     * @param string $name0
90
     * @param string $name1
91
     * @param string $name2
92
     * @param string $name3
93
     *
94
     * @dataProvider provideLongUrlPattern
95
     */
96
    public function testFindByPathInfoWithLongUrl($pathInfo, $count, $name0, $name1, $name2, $name3)
97
    {
98
        $routes = $this->repository->findByPathInfo($pathInfo);
99
100
        $this->assertCount($count, $routes);
101
        $this->assertSame($name0, $routes[0]->getName());
102
        $this->assertSame($name1, $routes[1]->getName());
103
        $this->assertSame($name2, $routes[2]->getName());
104
        $this->assertSame($name3, $routes[3]->getName());
105
106
    }
107
108
    /**
109
     * @return array
110
     */
111
    public function provideLongUrlPattern()
112
    {
113
        return array(
114
            array(
115
                'zero/one/two/three/four/five/six/{seven}/eight/nine/ten/eleven',
116
                4,
117
                'zero/one/two/three/four/five/six/{seven}/eight/nine/ten/eleven',
118
                'zero/one/two/three/four/five/six/{seven}/eight/nine/ten/eleven/twelve',
119
                'zero/one/two/three/four/five/six/{seven}/eight/nine/ten/{eleven}/twelve',
120
                'zero/one/two/three/four/five/six/{seven}/eight/nine/ten/eleven/{twelve}',
121
            ),
122
            array(
123
                'zero/one/two/three/four/five/six/{seven}/eight/nine/ten/eleven/twelve',
124
                4,
125
                'zero/one/two/three/four/five/six/{seven}/eight/nine/ten/eleven',
126
                'zero/one/two/three/four/five/six/{seven}/eight/nine/ten/eleven/twelve',
127
                'zero/one/two/three/four/five/six/{seven}/eight/nine/ten/{eleven}/twelve',
128
                'zero/one/two/three/four/five/six/{seven}/eight/nine/ten/eleven/{twelve}',
129
            ),
130
            array(
131
                'zero/one/two/three/four/five/six/{seven}/eight/nine/ten/eleven/other',
132
                4,
133
                'zero/one/two/three/four/five/six/{seven}/eight/nine/ten/eleven',
134
                'zero/one/two/three/four/five/six/{seven}/eight/nine/ten/eleven/twelve',
135
                'zero/one/two/three/four/five/six/{seven}/eight/nine/ten/{eleven}/twelve',
136
                'zero/one/two/three/four/five/six/{seven}/eight/nine/ten/eleven/{twelve}',
137
            ),
138
            array(
139
                'zero/one/two/three/four/five/six/{seven}/eight/nine/ten/other/twelve',
140
                4,
141
                'zero/one/two/three/four/five/six/{seven}/eight/nine/ten/eleven',
142
                'zero/one/two/three/four/five/six/{seven}/eight/nine/ten/eleven/twelve',
143
                'zero/one/two/three/four/five/six/{seven}/eight/nine/ten/{eleven}/twelve',
144
                'zero/one/two/three/four/five/six/{seven}/eight/nine/ten/eleven/{twelve}',
145
            ),
146
        );
147
    }
148
149
    /**
150
     * @param string $siteId
151
     * @param int    $count
152
     *
153
     * @dataProvider provideSiteIdCount
154
     */
155
    public function testFindBySiteId($siteId, $count)
156
    {
157
        $this->assertCount($count, $this->repository->findBySiteId($siteId));
158
    }
159
160
    /**
161
     * @return array
162
     */
163
    public function provideSiteIdCount()
164
    {
165
        return array(
166
            array('2', 36),
167
            array('fake2', 0),
168
        );
169
    }
170
}
171