Code Duplication    Length = 26-36 lines in 2 locations

tests/Unit/AccountTest.php 1 location

@@ 15-40 (lines=26) @@
12
use Vultr\Api\Account;
13
use Vultr\Tests\TestCase;
14
15
class AccountTest extends TestCase
16
{
17
    public function testGetUserInformation()
18
    {
19
        $mock    = $this->getRequest();
20
        $account = new Account($mock);
21
        $user    = $account->getUserInformation();
22
        $this->assertInstanceOf('Vultr\Entity\Account', $user);
23
        $this->assertEquals($user, new \Vultr\Entity\Account($this->getResponse(true)));
24
    }
25
26
    /**
27
     * Sample response.
28
     *
29
     * @return string
30
     **/
31
    protected function getResponse($decode = false)
32
    {
33
        $response = '{"balance": "-5519.11", "pending_charges": "57.03", "last_payment_date": "2014-07-18 15:31:01", "last_payment_amount": "-1.00" }';
34
        if ($decode) {
35
            return \json_decode($response);
36
        }
37
38
        return $response;
39
    }
40
}
41

tests/Unit/ApiKeyTest.php 1 location

@@ 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