BaseOAuthProviderTest   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 37
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 3
lcom 0
cbo 0
dl 0
loc 37
rs 10
c 1
b 0
f 1

3 Methods

Rating   Name   Duplication   Size   Complexity  
A testNormilizeUrl() 0 13 1
A urlProvider() 0 8 1
A invokeMethod() 0 8 1
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