mantis-matrix-integration – Blame information for rev 1
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
1 | office | 1 | <?php |
2 | |||
3 | namespace MatrixPhp\Tests; |
||
4 | |||
5 | use GuzzleHttp\Client; |
||
6 | use GuzzleHttp\Handler\MockHandler; |
||
7 | use GuzzleHttp\HandlerStack; |
||
8 | use GuzzleHttp\Psr7\Response; |
||
9 | use GuzzleHttp\Psr7\Request; |
||
10 | use GuzzleHttp\Middleware; |
||
11 | |||
12 | abstract class BaseTestCase extends \PHPUnit\Framework\TestCase { |
||
13 | const MATRIX_V2_API_PATH = "/_matrix/client/r0"; |
||
14 | protected $userId = "@alice:matrix.org"; |
||
15 | |||
16 | /** |
||
17 | * Call protected/private method of a class. |
||
18 | * |
||
19 | * @param object &$object Instantiated object that we will run method on. |
||
20 | * @param string $methodName Method name to call |
||
21 | * @param array $parameters Array of parameters to pass into method. |
||
22 | * |
||
23 | * @return mixed Method return. |
||
24 | * @throws \ReflectionException |
||
25 | */ |
||
26 | protected function invokePrivateMethod(&$object, $methodName, array $parameters = []) { |
||
27 | $reflection = new \ReflectionClass(get_class($object)); |
||
28 | $method = $reflection->getMethod($methodName); |
||
29 | $method->setAccessible(true); |
||
30 | |||
31 | return $method->invokeArgs($object, $parameters); |
||
32 | } |
||
33 | |||
34 | protected function getMockClientHandler(array $responses, array &$container): HandlerStack { |
||
35 | $mock = new MockHandler($responses); |
||
36 | $history = Middleware::history($container); |
||
37 | $handler = HandlerStack::create($mock); |
||
38 | $handler->push($history); |
||
39 | |||
40 | return $handler; |
||
41 | } |
||
42 | } |