public function testUserId() { $expected = '273c4392-4c5k-4c3b-a70e-72375216702f'; $this->assertNull($this->user->getUserId()); $this->assertSame($this->user, $this->user->setUserId($expected)); $this->assertEquals($expected, $this->user->getUserId()); }
public function testUpdateUser() { $userData = json_decode(file_get_contents(__DIR__ . '/../dummy_response_data/getUser.json'), true); // Set mocked response $body = new Stream(fopen(__DIR__ . '/../dummy_response_data/getUser.json', 'r')); $this->subscriber->addResponse(new Response(200, [], $body)); $user = new User(); $user->setUserId('123')->setEmail('*****@*****.**')->setFullName('EDITED'); $this->client->updateUser($user); // Test that the user has been populated with the response data $this->assertEquals($userData['userId'], $user->getUserId()); $this->assertEquals($userData['username'], $user->getUsername()); $this->assertEquals($userData['provider'], $user->getProvider()); $this->assertInstanceOf('DateTime', $user->getDateOfBirth()); $this->assertEquals($userData['dateOfBirth']['date'], $user->getDateOfBirth()->format('Y-m-d H:i:s')); $this->assertNull($user->getTimezone()); }
/** * Returns a partial model of certain user defined by its userId * By calling this method, only the properties username, fullName, avatar and score of the User will be popullated, * as well as the provided userId * * @param $userId * @return User */ public function getUserData($userId) { $response = $this->connect('GET', new Route(self::USER_ABOUT_ROUTE, ['userId' => $userId])); $contents = $response->getBody()->getContents(); $responseData = $this->serializer->deserialize($contents, 'array', 'json'); // Create the User model to be returned and populate it $user = new User(); $user->fromArray($responseData['userData']); $user->setUserId($userId); return $user; }