@@ 39-54 (lines=16) @@ | ||
36 | $this->client->getEmitter()->attach($this->subscriber); |
|
37 | } |
|
38 | ||
39 | public function testGetUser() |
|
40 | { |
|
41 | $userData = json_decode(file_get_contents(__DIR__ . '/../dummy_response_data/getUser.json'), true); |
|
42 | // Set mocked response |
|
43 | $body = new Stream(fopen(__DIR__ . '/../dummy_response_data/getUser.json', 'r')); |
|
44 | $this->subscriber->addResponse(new Response(200, [], $body)); |
|
45 | ||
46 | $user = $this->client->getUser($userData['userId']); |
|
47 | $this->assertInstanceOf('Wonnova\SDK\Model\User', $user); |
|
48 | $this->assertEquals($userData['userId'], $user->getUserId()); |
|
49 | $this->assertEquals($userData['username'], $user->getUsername()); |
|
50 | $this->assertEquals($userData['provider'], $user->getProvider()); |
|
51 | $this->assertInstanceOf('DateTime', $user->getDateOfBirth()); |
|
52 | $this->assertEquals($userData['dateOfBirth']['date'], $user->getDateOfBirth()->format('Y-m-d H:i:s')); |
|
53 | $this->assertNull($user->getTimezone()); |
|
54 | } |
|
55 | ||
56 | public function testGetUsers() |
|
57 | { |
|
@@ 94-114 (lines=21) @@ | ||
91 | $this->assertEquals($expectedId, $newUser->getUserId()); |
|
92 | } |
|
93 | ||
94 | public function testUpdateUser() |
|
95 | { |
|
96 | $userData = json_decode(file_get_contents(__DIR__ . '/../dummy_response_data/getUser.json'), true); |
|
97 | // Set mocked response |
|
98 | $body = new Stream(fopen(__DIR__ . '/../dummy_response_data/getUser.json', 'r')); |
|
99 | $this->subscriber->addResponse(new Response(200, [], $body)); |
|
100 | ||
101 | $user = new User(); |
|
102 | $user->setUserId('123') |
|
103 | ->setEmail('[email protected]') |
|
104 | ->setFullName('EDITED'); |
|
105 | $this->client->updateUser($user); |
|
106 | ||
107 | // Test that the user has been populated with the response data |
|
108 | $this->assertEquals($userData['userId'], $user->getUserId()); |
|
109 | $this->assertEquals($userData['username'], $user->getUsername()); |
|
110 | $this->assertEquals($userData['provider'], $user->getProvider()); |
|
111 | $this->assertInstanceOf('DateTime', $user->getDateOfBirth()); |
|
112 | $this->assertEquals($userData['dateOfBirth']['date'], $user->getDateOfBirth()->format('Y-m-d H:i:s')); |
|
113 | $this->assertNull($user->getTimezone()); |
|
114 | } |
|
115 | ||
116 | /** |
|
117 | * @expectedException \Wonnova\SDK\Exception\InvalidArgumentException |