dokuwiki-matrixnotifierwas-plugin – Blame information for rev 1

Subversion Repositories:
Rev:
Rev Author Line No. Line
1 office 1 <?php
2  
3 namespace MatrixPhp\Tests;
4  
5 use MatrixPhp\Exceptions\MatrixException;
6 use MatrixPhp\Exceptions\MatrixHttpLibException;
7 use MatrixPhp\Exceptions\ValidationException;
8 use GuzzleHttp\Client;
9 use GuzzleHttp\Psr7\Response;
10 use GuzzleHttp\Psr7\Request;
11  
12 class UserTest extends BaseTestCase {
13 const HOSTNAME = "http://localhost";
14 protected $userId = "@test:localhost";
15 protected $roomId = '!test:localhost';
16 /**
17 * @var MatrixClient
18 */
19 protected $client;
20 /**
21 * @var User
22 */
23 protected $user;
24 /**
25 * @var Room
26 */
27 protected $room;
28  
29 protected function setUp(): void
30 {
31 parent::setUp();
32 $this->client = new MatrixClient(self::HOSTNAME);
33 $this->user = new User($this->client->api(), $this->userId);
34 $this->room = $this->invokePrivateMethod($this->client, 'mkRoom', [$this->roomId]);
35 }
36  
37 public function testDisplayName() {
38 // No displayname
39 $displayname = 'test';
40 $this->assertEquals($this->user->userId(), $this->user->getDisplayName($this->room));
41 $container = [];
42 $handler = $this->getMockClientHandler([new Response(200, [], '{}')], $container);
43 $this->client->api()->setClient(new Client(['handler' => $handler]));
44 $this->assertEquals($this->user->userId(), $this->user->getDisplayName());
45 $this->assertEquals(1, count($container));
46  
47  
48 // $mapi->whoami();
49 // /** @var Request $req */
50 // $req = array_get($container, '0.request');
51 }
52  
53 public function testDisplayNameGlobal() {
54 $displayname = 'test';
55  
56 // Get global displayname
57 $container = [];
58 $str = sprintf('{"displayname": "%s"}', $displayname);
59 $handler = $this->getMockClientHandler([new Response(200, [], $str)], $container);
60 $this->client->api()->setClient(new Client(['handler' => $handler]));
61 $this->assertEquals($displayname, $this->user->getDisplayName());
62 $this->assertEquals(1, count($container));
63  
64 }
65 }