Skip to content

Commit d781843

Browse files
committed
more unit tests, and minor bug fix
1 parent db21e4d commit d781843

File tree

2 files changed

+32
-9
lines changed

2 files changed

+32
-9
lines changed

src/Splitice/BuyVM/BuyVMApi.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ function get($field){
8080
default:
8181
throw new ApiException('Unknown information field: '.$field);
8282
}
83-
$return = $this->execute_info(array($field));
83+
$return = $this->info(array($field));
8484

8585
if(isset($return[$return_field])){
8686
return $return[$return_field];

tests/ApiMethodsTest.php

Lines changed: 31 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,6 @@
11
<?php
22
use Splitice\BuyVM\BuyVMApi;
33

4-
/**
5-
* Created by PhpStorm.
6-
* User: splitice
7-
* Date: 6/4/14
8-
* Time: 2:24 PM
9-
*/
10-
114
class ApiMethodsTest extends PHPUnit_Framework_TestCase {
125
const API_CLIENT = '\\Splitice\\BuyVM\\IBuyVMApiClient';
136

@@ -38,10 +31,40 @@ function testBandwidth(){
3831
function testHardDrive(){
3932
//Assert
4033
$client = $this->getMock(self::API_CLIENT);
41-
$client->expects($this->once())->method('execute_info')->with($this->equalTo(array('hdd')))->will($this->returnValue(array('bw'=>'total,used,free,percentage')));
34+
$client->expects($this->once())->method('execute_info')->with($this->equalTo(array('hdd')))->will($this->returnValue(array('hdd'=>'total,used,free,percentage')));
4235

4336
//Do
4437
$api = new BuyVMApi($client);
4538
$api->get('hdd');
4639
}
40+
41+
function testMemory(){
42+
//Assert
43+
$client = $this->getMock(self::API_CLIENT);
44+
$client->expects($this->once())->method('execute_info')->with($this->equalTo(array('mem')))->will($this->returnValue(array('mem'=>'total,used,free,percentage')));
45+
46+
//Do
47+
$api = new BuyVMApi($client);
48+
$api->get('mem');
49+
}
50+
51+
function testIpAddresses(){
52+
//Assert
53+
$client = $this->getMock(self::API_CLIENT);
54+
$client->expects($this->once())->method('execute_info')->with($this->equalTo(array('ipaddr')))->will($this->returnValue(array('ipaddr'=>'1.2.3.4,2.3.4.5,4.5.6.7,7.8.9.10')));
55+
56+
//Do
57+
$api = new BuyVMApi($client);
58+
$api->get('ipaddr');
59+
}
60+
61+
function testStatus(){
62+
//Assert
63+
$client = $this->getMock(self::API_CLIENT);
64+
$client->expects($this->once())->method('execute_info')->with($this->equalTo(array('status')))->will($this->returnValue(array('statusmsg'=>'online')));
65+
66+
//Do
67+
$api = new BuyVMApi($client);
68+
$api->get('status');
69+
}
4770
}

0 commit comments

Comments
 (0)