BaseOAuthProviderTest::urlProvider()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
dl 0
loc 8
rs 9.4286
c 1
b 0
f 1
cc 1
eloc 5
nc 1
nop 0
1
<?php
2
3
namespace Sleepness\UberOAuthRestBundle\Tests\Provider;
4
5
class BaseOAuthProviderTest extends \PHPUnit_Framework_TestCase
6
{
7
    /**
8
     *  @dataProvider urlProvider
9
     */
10
    public function testNormilizeUrl($url, $params, $expected)
11
    {
12
        $stub = $this->getMockBuilder('Sleepness\UberOAuthRestBundle\Provider\BaseOAuthProvider')
13
            ->disableOriginalConstructor()
14
            ->getMockForAbstractClass();
15
16
        $stub
17
            ->expects($this->any())
18
            ->method('normalizeUrl')
19
        ;
20
21
        $this->assertEquals($expected, $this->invokeMethod($stub, 'normalizeUrl', [$url, $params]));
22
    }
23
24
    public function urlProvider()
25
    {
26
        return [
27
            ['http://vk.com', [], 'http://vk.com'],
28
            ['http://vk.com', ['a' => 'aa'], 'http://vk.com?a=aa'],
29
            ['http://vk.com?b=bb', ['a' => 'aa'], 'http://vk.com?b=bb&a=aa'],
30
        ];
31
    }
32
33
    public function invokeMethod(&$object, $methodName, array $parameters = [])
34
    {
35
        $reflection = new \ReflectionClass(get_class($object));
36
        $method = $reflection->getMethod($methodName);
37
        $method->setAccessible(true);
38
39
        return $method->invokeArgs($object, $parameters);
40
    }
41
}
42