Completed
Push — master ( 82a3a6...721814 )
by Дмитрий
05:02 queued 02:25
created

AbstractProviderTestCase::makeIdentityClientResponse()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 18
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 18
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 11
nc 1
nop 2
1
<?php
2
/**
3
 * SocialConnect project
4
 * @author: Patsura Dmitry https://github.com/ovr <[email protected]>
5
 */
6
7
namespace Test\Providers;
8
9
use ReflectionClass;
10
use SocialConnect\Auth\Provider\Exception\InvalidAccessToken;
11
use SocialConnect\Auth\Consumer;
12
use SocialConnect\OAuth2\AccessToken;
13
use SocialConnect\Common\Http\Client\ClientInterface;
14
use Test\TestCase;
15
16
class AbstractProviderTestCase extends TestCase
17
{
18
    /**
19
     * @param mixed $responseData
20
     * @param int $responseCode
21
     * @return \PHPUnit_Framework_MockObject_MockObject
22
     */
23
    protected function makeIdentityClientResponse($responseData, $responseCode = 200)
24
    {
25
        $mockedHttpClient = $this->getMockBuilder(\SocialConnect\Common\Http\Client\Curl::class)
26
            ->disableProxyingToOriginalMethods()
27
            ->getMock();
28
29
        $response = new \SocialConnect\Common\Http\Response(
30
            $responseCode,
31
            $responseData,
32
            []
33
        );
34
35
        $mockedHttpClient->expects($this->once())
36
            ->method('request')
37
            ->willReturn($response);
38
39
        return $mockedHttpClient;
40
    }
41
42
    /**
43
     * @param object $object
44
     * @param string $name
45
     * @param array $params
46
     * @return mixed
47
     */
48
    protected static function callProtectedMethod($object, $name, array $params = [])
49
    {
50
        $class = new ReflectionClass($object);
51
52
        $method = $class->getMethod($name);
53
        $method->setAccessible(true);
54
55
        return $method->invokeArgs($object, $params);
56
    }
57
}
58