Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Impoved image test #140

Merged
merged 2 commits into from
Aug 7, 2016
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Improved the get image by id to test for the size_gigabytes attribute
  • Loading branch information
yassirh committed Aug 7, 2016
commit cd1f3cad6868b03fd2dd34838e52a595fb98e1ca
47 changes: 25 additions & 22 deletions spec/DigitalOceanV2/Api/ImageSpec.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,17 @@

class ImageSpec extends \PhpSpec\ObjectBehavior
{
function let(AdapterInterface $adapter)
public function let(AdapterInterface $adapter)
{
$this->beConstructedWith($adapter);
}

function it_is_initializable()
public function it_is_initializable()
{
$this->shouldHaveType('DigitalOceanV2\Api\Image');
}

function it_returns_an_empty_array($adapter)
public function it_returns_an_empty_array($adapter)
{
$adapter->get('https://api.digitalocean.com/v2/images?per_page=200')->willReturn('{"images": []}');

Expand All @@ -26,7 +26,7 @@ function it_returns_an_empty_array($adapter)
$images->shouldHaveCount(0);
}

function it_returns_an_array_of_image_entity($adapter)
public function it_returns_an_array_of_image_entity($adapter)
{
$total = 3;
$adapter
Expand All @@ -44,7 +44,7 @@ function it_returns_an_array_of_image_entity($adapter)
$meta->total->shouldBe($total);
}

function it_returns_an_array_of_distribution_image_entity($adapter)
public function it_returns_an_array_of_distribution_image_entity($adapter)
{
$total = 3;
$adapter
Expand All @@ -62,7 +62,7 @@ function it_returns_an_array_of_distribution_image_entity($adapter)
$meta->total->shouldBe($total);
}

function it_returns_an_array_of_application_image_entity($adapter)
public function it_returns_an_array_of_application_image_entity($adapter)
{
$total = 3;
$adapter
Expand All @@ -80,7 +80,7 @@ function it_returns_an_array_of_application_image_entity($adapter)
$meta->total->shouldBe($total);
}

function it_returns_an_array_of_private_application_image_entity($adapter)
public function it_returns_an_array_of_private_application_image_entity($adapter)
{
$total = 3;
$adapter
Expand All @@ -98,7 +98,7 @@ function it_returns_an_array_of_private_application_image_entity($adapter)
$meta->total->shouldBe($total);
}

function it_returns_an_array_of_private_image_entity($adapter)
public function it_returns_an_array_of_private_image_entity($adapter)
{
$total = 3;
$adapter
Expand All @@ -116,7 +116,7 @@ function it_returns_an_array_of_private_image_entity($adapter)
$meta->total->shouldBe($total);
}

function it_returns_an_image_entity_get_by_its_id($adapter)
public function it_returns_an_image_entity_get_by_its_id($adapter)
{
$adapter
->get('https://api.digitalocean.com/v2/images/123')
Expand All @@ -132,16 +132,19 @@ function it_returns_an_image_entity_get_by_its_id($adapter)
"nyc1"
],
"created_at": "2014-06-27T21:10:28Z",
"min_disk_size": 20
}
"min_disk_size": 20,
"size_gigabytes": 2.34
}
}
');

$this->getById(123)->shouldReturnAnInstanceOf('DigitalOceanV2\Entity\Image');
$image = $this->getById(123);
$image->shouldReturnAnInstanceOf('DigitalOceanV2\Entity\Image');
$image->sizeGigabytes->shouldBe(2.34);
$this->getMeta()->shouldBeNull();
}

function it_returns_an_image_entity_get_by_its_slug($adapter)
public function it_returns_an_image_entity_get_by_its_slug($adapter)
{
$adapter
->get('https://api.digitalocean.com/v2/images/foo-bar')
Expand All @@ -165,7 +168,7 @@ function it_returns_an_image_entity_get_by_its_slug($adapter)
$this->getBySlug('foo-bar')->shouldReturnAnInstanceOf('DigitalOceanV2\Entity\Image');
}

function it_returns_the_updated_image($adapter)
public function it_returns_the_updated_image($adapter)
{
$adapter
->put('https://api.digitalocean.com/v2/images/123', ['name' => 'bar-baz'])
Expand All @@ -189,7 +192,7 @@ function it_returns_the_updated_image($adapter)
$this->update(123, 'bar-baz')->shouldReturnAnInstanceOf('DigitalOceanV2\Entity\Image');
}

function it_throws_an_http_exception_when_trying_to_update_an_inexisting_image($adapter)
public function it_throws_an_http_exception_when_trying_to_update_an_inexisting_image($adapter)
{
$adapter
->put('https://api.digitalocean.com/v2/images/0', ['name' => 'baz-baz'])
Expand All @@ -198,7 +201,7 @@ function it_throws_an_http_exception_when_trying_to_update_an_inexisting_image($
$this->shouldThrow(new HttpException('Request not processed.'))->during('update', [0, 'baz-baz']);
}

function it_deletes_the_image_and_returns_nothing($adapter)
public function it_deletes_the_image_and_returns_nothing($adapter)
{
$adapter
->delete('https://api.digitalocean.com/v2/images/678')
Expand All @@ -207,7 +210,7 @@ function it_deletes_the_image_and_returns_nothing($adapter)
$this->delete(678);
}

function it_throws_an_http_exception_when_trying_to_delete_an_inexisting_image($adapter)
public function it_throws_an_http_exception_when_trying_to_delete_an_inexisting_image($adapter)
{
$adapter
->delete('https://api.digitalocean.com/v2/images/0')
Expand All @@ -216,7 +219,7 @@ function it_throws_an_http_exception_when_trying_to_delete_an_inexisting_image($
$this->shouldThrow(new HttpException('Request not processed.'))->during('delete', [0]);
}

function it_transfer_the_image_to_an_other_region_and_returns_its_image($adapter)
public function it_transfer_the_image_to_an_other_region_and_returns_its_image($adapter)
{
$adapter
->post('https://api.digitalocean.com/v2/images/123/actions', ['type' => 'transfer', 'region' => 'nyc2'])
Expand Down Expand Up @@ -247,7 +250,7 @@ function it_transfer_the_image_to_an_other_region_and_returns_its_image($adapter
$image->region->shouldReturnAnInstanceOf('DigitalOceanV2\Entity\Region');
}

function it_throws_an_http_exception_if_trying_to_transfer_to_unknown_region_slug($adapter)
public function it_throws_an_http_exception_if_trying_to_transfer_to_unknown_region_slug($adapter)
{
$adapter
->post('https://api.digitalocean.com/v2/images/0/actions', ['type' => 'transfer', 'region' => 'foo'])
Expand All @@ -256,7 +259,7 @@ function it_throws_an_http_exception_if_trying_to_transfer_to_unknown_region_slu
$this->shouldThrow(new HttpException('Request not processed.'))->during('transfer', [0, 'foo']);
}

function it_can_convert_the_image_to_a_snapshot($adapter)
public function it_can_convert_the_image_to_a_snapshot($adapter)
{
$adapter
->post('https://api.digitalocean.com/v2/images/123/actions', ['type' => 'convert'])
Expand All @@ -281,7 +284,7 @@ function it_can_convert_the_image_to_a_snapshot($adapter)
$image->region->shouldReturn(null);
}

function it_returns_the_requested_action_entity_of_the_given_image($adapter)
public function it_returns_the_requested_action_entity_of_the_given_image($adapter)
{
$adapter
->get('https://api.digitalocean.com/v2/images/123/actions/456')
Expand Down Expand Up @@ -312,7 +315,7 @@ function it_returns_the_requested_action_entity_of_the_given_image($adapter)
$action->region->shouldReturnAnInstanceOf('DigitalOceanV2\Entity\Region');
}

function it_throws_an_http_exception_when_retrieving_non_existing_image_action($adapter)
public function it_throws_an_http_exception_when_retrieving_non_existing_image_action($adapter)
{
$adapter
->get('https://api.digitalocean.com/v2/images/0/actions/0')
Expand Down