@@ 15-50 (lines=36) @@ | ||
12 | use Vultr\Api\Auth; |
|
13 | use Vultr\Tests\TestCase; |
|
14 | ||
15 | class ApiKeyTest extends TestCase |
|
16 | { |
|
17 | public function testGetKeyInformation() |
|
18 | { |
|
19 | $mock = $this->getRequest(); |
|
20 | $auth = new Auth($mock); |
|
21 | $info = $auth->getKeyInformation(); |
|
22 | $this->assertInstanceOf('Vultr\Entity\Auth', $info); |
|
23 | $this->assertEquals($info, new \Vultr\Entity\Auth($this->getResponse(true))); |
|
24 | $this->assertEquals($info->email, '[email protected]'); |
|
25 | } |
|
26 | ||
27 | /** |
|
28 | * Sample response. |
|
29 | * |
|
30 | * @return string |
|
31 | **/ |
|
32 | protected function getResponse($decode = false) |
|
33 | { |
|
34 | $response = '{ |
|
35 | "acls": [ |
|
36 | "subscriptions", |
|
37 | "billing", |
|
38 | "support", |
|
39 | "provisioning" |
|
40 | ], |
|
41 | "email": "[email protected]", |
|
42 | "name": "Example Account" |
|
43 | }'; |
|
44 | if ($decode) { |
|
45 | return \json_decode($response); |
|
46 | } |
|
47 | ||
48 | return $response; |
|
49 | } |
|
50 | } |
|
51 |
@@ 19-44 (lines=26) @@ | ||
16 | /** |
|
17 | * @coversDefault Account |
|
18 | */ |
|
19 | class AccountTest extends TestCase |
|
20 | { |
|
21 | /** |
|
22 | * @covers ::getUserInformation |
|
23 | * @covers ::__construct |
|
24 | */ |
|
25 | public function testGetUserInformation() |
|
26 | { |
|
27 | $mock = $this->getRequest(); |
|
28 | $account = new Account($mock); |
|
29 | $user = $account->getUserInformation(); |
|
30 | $this->assertInstanceOf('Vultr\Entity\Account', $user); |
|
31 | $this->assertEquals($user, new \Vultr\Entity\Account($this->getResponse(true))); |
|
32 | } |
|
33 | ||
34 | /** |
|
35 | * Sample response. |
|
36 | * |
|
37 | * @return string |
|
38 | **/ |
|
39 | protected function getResponse($decode = false) |
|
40 | { |
|
41 | $response = '{"balance": "-5519.11", "pending_charges": "57.03", "last_payment_date": "2014-07-18 15:31:01", "last_payment_amount": "-1.00" }'; |
|
42 | if ($decode) { |
|
43 | return \json_decode($response); |
|
44 | } |
|
45 | ||
46 | return $response; |
|
47 | } |