forked from zendframework/zendframework
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
ezimuel
committed
Apr 27, 2011
1 parent
936ee54
commit 4ca5c2c
Showing
5 changed files
with
416 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,150 @@ | ||
<?php | ||
/** | ||
* Zend Framework | ||
* | ||
* LICENSE | ||
* | ||
* This source file is subject to the new BSD license that is bundled | ||
* with this package in the file LICENSE.txt. | ||
* It is also available through the world-wide-web at this URL: | ||
* http://framework.zend.com/license/new-bsd | ||
* If you did not receive a copy of the license and are unable to | ||
* obtain it through the world-wide-web, please send an email | ||
* to [email protected] so we can send you a copy immediately. | ||
* | ||
* @category Zend | ||
* @package Zend_Service_GoGrid | ||
* @subpackage UnitTests | ||
* @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com) | ||
* @license http://framework.zend.com/license/new-bsd New BSD License | ||
*/ | ||
|
||
/** | ||
* @namespace | ||
*/ | ||
namespace ZendTest\Service\GoGrid; | ||
use Zend\Service\GoGrid\Job; | ||
|
||
/** | ||
* Test helper | ||
*/ | ||
|
||
/** | ||
* @see Zend_Service_Amazon | ||
*/ | ||
|
||
/** | ||
* @see Zend_Service_Amazon_ResultSet | ||
*/ | ||
|
||
/** | ||
* @see Zend_Service_Amazon_ResultSet | ||
*/ | ||
|
||
/** | ||
* @see Zend_Http_Client_Adapter_Socket | ||
*/ | ||
|
||
/** | ||
* @see Zend\Http\Client\Adapter\Test | ||
*/ | ||
|
||
|
||
/** | ||
* @category Zend | ||
* @package Zend\Service\GoGrid | ||
* @subpackage UnitTests | ||
* @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com) | ||
* @license http://framework.zend.com/license/new-bsd New BSD License | ||
* @group Zend_Service | ||
* @group Zend_Service_GoGrid | ||
*/ | ||
class JobOfflineTest extends \PHPUnit_Framework_TestCase | ||
{ | ||
/** | ||
* Reference to GoGrid Job | ||
* | ||
* @var Zend\Service\GoGrid\Job | ||
*/ | ||
protected $_job; | ||
|
||
/** | ||
* HTTP client adapter for testing | ||
* | ||
* @var Zend\Http\Client\Adapter\Test | ||
*/ | ||
protected $_httpClientAdapterTest; | ||
|
||
/** | ||
* Sets up this test case | ||
* | ||
* @return void | ||
*/ | ||
public function setUp() | ||
{ | ||
$this->_job = new Job(TESTS_ZEND_SERVICE_GOGRID_OFFLINE_KEY,TESTS_ZEND_SERVICE_GOGRID_OFFLINE_SECRET); | ||
|
||
} | ||
|
||
/** | ||
* Ensures that __construct() throws an exception when given an empty key attribute | ||
* | ||
* @return void | ||
*/ | ||
public function testConstructExceptionMissingKeyAttribute() | ||
{ | ||
$this->setExpectedException( | ||
'Zend\Service\GoGrid\Exception\InvalidArgumentException', | ||
'The key cannot be empty' | ||
); | ||
$job= new Job(null,TESTS_ZEND_SERVICE_GOGRID_OFFLINE_SECRET); | ||
} | ||
/** | ||
* Ensures that __construct() throws an exception when given an empty secret attribute | ||
* | ||
* @return void | ||
*/ | ||
public function testConstructExceptionMissingSecretAttribute() | ||
{ | ||
$this->setExpectedException( | ||
'Zend\Service\GoGrid\Exception\InvalidArgumentException', | ||
'The secret cannot be empty' | ||
); | ||
$job= new Job(TESTS_ZEND_SERVICE_GOGRID_OFFLINE_KEY,null); | ||
} | ||
/** | ||
* testJobList | ||
* | ||
* @return void | ||
*/ | ||
public function testJobList() | ||
{ | ||
$file= file_get_contents(__DIR__."/_files/job_list.json"); | ||
$joblist= new Zend\Service\GoGrid\ObjectList($file); | ||
|
||
$this->assertEquals(count($joblist),2); | ||
$this->assertEquals($joblist['status'],'success'); | ||
|
||
$job= $joblist[0]; | ||
$this->assertEquals($job->getAttribute('id'), '60531'); | ||
$this->assertEquals($job->getAttribute('owner'),'[email protected]'); | ||
$command= $job->getAttribute('command'); | ||
$this->assertEquals($command['name'],'CreateVirtualServer'); | ||
$history= $job->getAttribute('history'); | ||
$this->assertEquals($history[0]['id'],'10242'); | ||
$this->assertEquals(count($history),4); | ||
} | ||
|
||
/** | ||
* testApiVersion | ||
* | ||
* @return void | ||
*/ | ||
public function testApiVersion() | ||
{ | ||
$this->assertEquals($this->_job->getApiVersion(),Job::VERSION_API); | ||
$this->_job->setApiVersion('1.0'); | ||
$this->assertEquals($this->_job->getApiVersion(),'1.0'); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
{ | ||
"list": [ | ||
{ | ||
"attempts": 1, | ||
"command": { | ||
"description": "Create Virtual Server", | ||
"id": 6, | ||
"name": "CreateVirtualServer", | ||
"object": "option" | ||
}, | ||
"createdon": 1231007644632, | ||
"currentstate": { | ||
"description": "Change request has succeeded.", | ||
"id": 3, | ||
"name": "Succeeded", | ||
"object": "option" | ||
}, | ||
"datacenter": { | ||
"description": "US East 1 Datacenter", | ||
"id": 2, | ||
"name": "US-East-1", | ||
"object": "option" | ||
}, | ||
"detail": { | ||
"description": "tests", | ||
"image": "w2k3_64_iis_asp_mssql2k5xp", | ||
"ip": "208.113.76.34", | ||
"name": "test 2", | ||
"type": "virtual_server" | ||
}, | ||
"history": [ | ||
{ | ||
"id": 10242, | ||
"state": { | ||
"description": "Change request is created but not queued yet", | ||
"id": 7, | ||
"name": "Created", | ||
"object": "option" | ||
} | ||
}, | ||
{ | ||
"id": 10243, | ||
"state": { | ||
"description": "Change request is new to the system.", | ||
"id": 1, | ||
"name": "Queued", | ||
"object": "option" | ||
} | ||
}, | ||
{ | ||
"id": 10244, | ||
"state": { | ||
"description": "Change request is is transient state...Processing.", | ||
"id": 2, | ||
"name": "Processing", | ||
"object": "option" | ||
} | ||
}, | ||
{ | ||
"id": 10251, | ||
"state": { | ||
"description": "Change request has succeeded.", | ||
"id": 3, | ||
"name": "Succeeded", | ||
"object": "option" | ||
}, | ||
"updatedon": 1231008346317 | ||
} | ||
], | ||
"id": 60531, | ||
"lastupdatedon": 1231008346317, | ||
"object": "job", | ||
"objecttype": { | ||
"description": null, | ||
"id": 1, | ||
"name": "VirtualServer", | ||
"object": "option" | ||
}, | ||
"owner": "[email protected]" | ||
} | ||
], | ||
"method": "/grid/job/get", | ||
"status": "success", | ||
"summary": { | ||
"numpages": 1, | ||
"returned": 1, | ||
"start": 0, | ||
"total": 1 | ||
} | ||
} |
Oops, something went wrong.