acquia / acquia-sdk-php

The Acquia SDK for PHP allows developers to build applications on top of Acquia services.
MIT License
25 stars 20 forks source link

Complete CloudApiClient #12

Closed webbj74 closed 10 years ago

webbj74 commented 10 years ago

The CloudApiClient class is missing methods for the following API functions

cpliakas commented 10 years ago

Added methods that consume GET resources for domains in commit f7ac13457388d2a9a0f73ab8b5edc3e77d143ed1. @webbj74, I need to figure out your awesome Mock response strategy to add tests!

cpliakas commented 10 years ago

Added method to purge Varnish cache at 4271ec57820bd8927e85e55a7d5d2c1d988dfd4f.

webbj74 commented 10 years ago

@cpliakas -- I've followed the original unit test examples you provided, the change to check responses doesn't actually use a mock, it's just using a standard Guzzle event subscriber.

First add a callback function for the create_request event, like:

public function domainsCallListener(Event $e) {
  $this->assertEquals('https://cloudapi.example.com/v1/sites/myhostingstage%3Amysitegroup/dev/domains.json', $e['request']->getUrl());
}

Since most of these URLs are similar in our tests, I use a const to alias the most common chunk:

$this->assertEquals(self::REQUEST_PATH . '/dev/domains.json', $e['request']->getUrl());

After instantiating the cloudapiclient, but before calling the domains method, add the domainsCallListener method as an event listener for client.create_request events:

$cloudapi->getEventDispatcher()->addListener('client.create_request', array($this, 'domainsCallListener'));

There's probably a more "phpunit" way to handle this using its built-in mocking capability, but this seemed like a quick and easy way to deal with it.

lahoosascoots commented 10 years ago

PRs in for add/delete domains and delete backups.

cpliakas commented 10 years ago

Remaining calls added at https://github.com/acquia/acquia-sdk-php/tree/18-refactor.

Testing system has been refactored to make it a little easier to write tests. Wrapper methods are also removed from the client for transparency, and the response objects are a little more DRY and provide methods to get the data returned so you know what is available.

cpliakas commented 10 years ago

Merged in branch. API is complete minus #13 and #24 which will be addressed in those issues.