Skip to content

Commit

Permalink
Write all tests for getUser method ;)
Browse files Browse the repository at this point in the history
  • Loading branch information
ovr committed Jul 9, 2015
1 parent 42f49da commit 2fbfcfa
Showing 1 changed file with 29 additions and 12 deletions.
41 changes: 29 additions & 12 deletions tests/ClientTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,8 @@ protected function getDemoUserId()
return getenv('testUserId');
}

public function testRequestMethod()
protected function assertUser($user)
{
$client = $this->getClient();
$client->setAccessToken($this->getAccessToken());

$user = $client->request('users/' . $this->getDemoUserId());
$this->assertInternalType('object', $user);
$this->assertInternalType('string', $user->username);
$this->assertInternalType('string', $user->bio);
Expand All @@ -50,18 +46,39 @@ public function testRequestMethod()
$this->assertInternalType('object', $user->counts);
}

public function testRequestMethod()
{
$client = $this->getClient();
$client->setAccessToken($this->getAccessToken());

$user = $client->request('users/' . $this->getDemoUserId());
$this->assertUser($user);
}

public function testGetUser()
{
$client = $this->getClient();
$client->setAccessToken($this->getAccessToken());

$user = $client->getUser($this->getDemoUserId());
$this->assertInternalType('object', $user);
$this->assertInternalType('string', $user->username);
$this->assertInternalType('string', $user->bio);
$this->assertInternalType('string', $user->website);
$this->assertInternalType('string', $user->profile_picture);
$this->assertInternalType('string', $user->full_name);
$this->assertInternalType('object', $user->counts);
$this->assertUser($user);
}

public function testGetUserSelf()
{
$client = $this->getClient();
$client->setAccessToken($this->getAccessToken());

$user = $client->getUser('self');
$this->assertUser($user);
}

public function testGetUserWithoutParameters()
{
$client = $this->getClient();
$client->setAccessToken($this->getAccessToken());

$user = $client->getUser();
$this->assertUser($user);
}
}

0 comments on commit 2fbfcfa

Please sign in to comment.