diff --git a/src/Connector/Client.php b/src/Connector/Client.php index 718ab5f9..4dd4b418 100644 --- a/src/Connector/Client.php +++ b/src/Connector/Client.php @@ -51,9 +51,12 @@ public static function factory(ConnectorInterface $connector) /** * @inheritdoc */ - public function request(string $verb, string $path) + public function request(string $verb, string $path, array $options = []) { - $options = $this->options; + // @TODO follow this up by removing $options from the parameters able + // to be passed into this function and instead solely relying on the + // addOption() method as this can then be tested. + $options = $this->options + $options; $options['query'] = $this->query; if (!empty($options['query']['filter']) && is_array($options['query']['filter'])) { diff --git a/src/Connector/ClientInterface.php b/src/Connector/ClientInterface.php index 6b94b1de..143d6c24 100644 --- a/src/Connector/ClientInterface.php +++ b/src/Connector/ClientInterface.php @@ -19,10 +19,11 @@ interface ClientInterface * * @param string $verb * @param string $path + * @param array $options * * @return mixed|StreamInterface */ - public function request(string $verb, string $path); + public function request(string $verb, string $path, array $options = []); /** * @param string $verb diff --git a/src/Endpoints/Applications.php b/src/Endpoints/Applications.php index 1802023b..b6e2d34d 100644 --- a/src/Endpoints/Applications.php +++ b/src/Endpoints/Applications.php @@ -52,12 +52,17 @@ public function get($applicationUuid) public function rename($applicationUuid, $name) { - $this->client->addOption('form_params', ['name' => $name]); + $options = [ + 'form_params' => [ + 'name' => $name, + ], + ]; return new OperationResponse( $this->client->request( 'put', - "/applications/${applicationUuid}" + "/applications/${applicationUuid}", + $options ) ); } @@ -90,16 +95,18 @@ public function getAllTags($applicationUuid) public function createTag($applicationUuid, $name, $color) { - $params = [ - 'name' => $name, - 'color' => $color, + $options = [ + 'form_params' => [ + 'name' => $name, + 'color' => $color, + ], ]; - $this->client->addOption('form_params', $params); return new OperationResponse( $this->client->request( 'post', - "/applications/${applicationUuid}/tags" + "/applications/${applicationUuid}/tags", + $options ) ); } diff --git a/src/Endpoints/Code.php b/src/Endpoints/Code.php index 853c86f5..aa57e4fc 100644 --- a/src/Endpoints/Code.php +++ b/src/Endpoints/Code.php @@ -39,12 +39,17 @@ public function getAll($applicationUuid) public function switch($environmentUuid, $branch) { - $this->client->addOption('form_params', ['branch' => $branch]); + $options = [ + 'form_params' => [ + 'branch' => $branch, + ], + ]; return new OperationResponse( $this->client->request( 'post', - "/environments/${environmentUuid}/code/actions/switch" + "/environments/${environmentUuid}/code/actions/switch", + $options ) ); } @@ -59,16 +64,18 @@ public function switch($environmentUuid, $branch) public function deploy($environmentFromUuid, $environmentToUuid, $commitMessage = null) { - $params = [ - 'source' => $environmentFromUuid, - 'message' => $commitMessage, + $options = [ + 'form_params' => [ + 'source' => $environmentFromUuid, + 'message' => $commitMessage, + ], ]; - $this->client->addOption('form_params', $params); return new OperationResponse( $this->client->request( 'post', - "/environments/${environmentToUuid}/code" + "/environments/${environmentToUuid}/code", + $options ) ); } diff --git a/src/Endpoints/Crons.php b/src/Endpoints/Crons.php index b7098374..421ca2fd 100644 --- a/src/Endpoints/Crons.php +++ b/src/Endpoints/Crons.php @@ -60,16 +60,17 @@ public function get($environmentUuid, $cronId) public function create($environmentUuid, $command, $frequency, $label, $serverId = null) { - $params = [ - 'command' => $command, - 'frequency' => $frequency, - 'label' => $label, - 'server_id' => $serverId + $options = [ + 'form_params' => [ + 'command' => $command, + 'frequency' => $frequency, + 'label' => $label, + 'server_id' => $serverId + ], ]; - $this->client->addOption('form_params', $params); return new OperationResponse( - $this->client->request('post', "/environments/${environmentUuid}/crons") + $this->client->request('post', "/environments/${environmentUuid}/crons", $options) ); } @@ -87,16 +88,17 @@ public function create($environmentUuid, $command, $frequency, $label, $serverId public function update($environmentUuid, $cronId, $command, $frequency, $label, $serverId = null) { - $params = [ - 'command' => $command, - 'frequency' => $frequency, - 'label' => $label, - 'server_id' => $serverId + $options = [ + 'form_params' => [ + 'command' => $command, + 'frequency' => $frequency, + 'label' => $label, + 'server_id' => $serverId + ], ]; - $this->client->addOption('form_params', $params); return new OperationResponse( - $this->client->request('post', "/environments/${environmentUuid}/crons/${cronId}") + $this->client->request('post', "/environments/${environmentUuid}/crons/${cronId}", $options) ); } diff --git a/src/Endpoints/Databases.php b/src/Endpoints/Databases.php index 34826439..d4f471d5 100644 --- a/src/Endpoints/Databases.php +++ b/src/Endpoints/Databases.php @@ -38,11 +38,14 @@ public function getAll($applicationUuid) */ public function create($applicationUuid, $name) { - - $this->client->addOption('form_params', ['name' => $name]); + $options = [ + 'form_params' => [ + 'name' => $name, + ], + ]; return new OperationResponse( - $this->client->request('post', "/applications/${applicationUuid}/databases") + $this->client->request('post', "/applications/${applicationUuid}/databases", $options) ); } @@ -90,14 +93,15 @@ public function truncate($applicationUuid, $name) */ public function copy($environmentFromUuid, $dbName, $environmentToUuid) { - $params = [ - 'name' => $dbName, - 'source' => $environmentFromUuid, + $options = [ + 'form_params' => [ + 'name' => $dbName, + 'source' => $environmentFromUuid, + ], ]; - $this->client->addOption('form_params', $params); return new OperationResponse( - $this->client->request('post', "/environments/${environmentToUuid}/databases") + $this->client->request('post', "/environments/${environmentToUuid}/databases", $options) ); } } diff --git a/src/Endpoints/Domains.php b/src/Endpoints/Domains.php index a05701ad..76d38ad4 100644 --- a/src/Endpoints/Domains.php +++ b/src/Endpoints/Domains.php @@ -58,10 +58,14 @@ public function get($environmentUuid, $domain) public function create($environmentUuid, $hostname) { - $this->client->addOption('form_params', ['hostname' => $hostname]); + $options = [ + 'form_params' => [ + 'hostname' => $hostname, + ], + ]; return new OperationResponse( - $this->client->request('post', "/environments/${environmentUuid}/domains") + $this->client->request('post', "/environments/${environmentUuid}/domains", $options) ); } @@ -89,12 +93,17 @@ public function delete($environmentUuid, $domain) public function purge($environmentUuid, array $domains) { - $this->client->addOption('form_params', ['domains' => $domains]); + $options = [ + 'form_params' => [ + 'domains' => $domains, + ], + ]; return new OperationResponse( $this->client->request( 'post', - "/environments/${environmentUuid}/domains/actions/clear-varnish" + "/environments/${environmentUuid}/domains/actions/clear-varnish", + $options ) ); } diff --git a/src/Endpoints/Environments.php b/src/Endpoints/Environments.php index 2e409ec2..b8789f0c 100644 --- a/src/Endpoints/Environments.php +++ b/src/Endpoints/Environments.php @@ -23,11 +23,14 @@ class Environments extends CloudApiBase implements CloudApiInterface */ public function copyFiles($environmentUuidFrom, $environmentUuidTo) { - - $this->client->addOption('form_params', ['source' => $environmentUuidFrom]); + $options = [ + 'form_params' => [ + 'source' => $environmentUuidFrom, + ], + ]; return new OperationResponse( - $this->client->request('post', "/environments/${environmentUuidTo}/files") + $this->client->request('post', "/environments/${environmentUuidTo}/files", $options) ); } @@ -73,12 +76,15 @@ public function getAll($applicationUuid) public function update($environmentUuid, array $config) { - $this->client->addOption('form_params', $config); + $options = [ + 'form_params' => $config, + ]; return new OperationResponse( $this->client->request( 'put', - "/environments/${environmentUuid}" + "/environments/${environmentUuid}", + $options ) ); } @@ -93,12 +99,17 @@ public function update($environmentUuid, array $config) public function rename($environmentUuid, $label) { - $this->client->addOption('form_params', ['label' => $label]); + $options = [ + 'form_params' => [ + 'label' => $label, + ], + ]; return new OperationResponse( $this->client->request( 'post', - "/environments/${environmentUuid}/actions/change-label" + "/environments/${environmentUuid}/actions/change-label", + $options ) ); } @@ -125,12 +136,17 @@ public function enableLiveDev($environmentUuid) public function disableLiveDev($environmentUuid) { - $this->client->addOption('form_params', ['discard' => 1]); + $options = [ + 'form_params' => [ + 'discard' => 1, + ], + ]; return new OperationResponse( $this->client->request( 'post', - "/environments/${environmentUuid}/livedev/actions/disable" + "/environments/${environmentUuid}/livedev/actions/disable", + $options ) ); } @@ -178,17 +194,19 @@ public function disableProductionMode($environmentUuid) */ public function create($applicationUuid, $label, $branch, array $databases) { - $params = [ - 'label' => $label, - 'branch' => $branch, - 'databases' => $databases, + $options = [ + 'form_params' => [ + 'label' => $label, + 'branch' => $branch, + 'databases' => $databases, + ], ]; - $this->client->addOption('form_params', $params); return new OperationResponse( $this->client->request( 'post', - "/applications/${applicationUuid}/environments" + "/applications/${applicationUuid}/environments", + $options ) ); } diff --git a/src/Endpoints/IdentityProviders.php b/src/Endpoints/IdentityProviders.php index a9a97e7f..130f7d8d 100644 --- a/src/Endpoints/IdentityProviders.php +++ b/src/Endpoints/IdentityProviders.php @@ -106,18 +106,20 @@ public function enable($idpUuid) public function update($idpUuid, $label, $entityId, $ssoUrl, $certificate) { - $params = [ - 'label' => $label, - 'entity_id' => $entityId, - 'sso_url' => $ssoUrl, - 'certificate' => $certificate, + $options = [ + 'form_params' => [ + 'label' => $label, + 'entity_id' => $entityId, + 'sso_url' => $ssoUrl, + 'certificate' => $certificate, + ], ]; - $this->client->addOption('form_params', $params); return new OperationResponse( $this->client->request( 'put', - "/identity-providers/${idpUuid}" + "/identity-providers/${idpUuid}", + $options ) ); } diff --git a/src/Endpoints/Ides.php b/src/Endpoints/Ides.php index 5269ddde..9914e6f1 100644 --- a/src/Endpoints/Ides.php +++ b/src/Endpoints/Ides.php @@ -56,10 +56,14 @@ public function get($ideUuid) public function create($applicationUuid, $name) { - $this->client->addOption('form_params', ['name' => $name]); + $options = [ + 'form_params' => [ + 'name' => $name, + ], + ]; return new OperationResponse( - $this->client->request('post', "/applications/${applicationUuid}/ides") + $this->client->request('post', "/applications/${applicationUuid}/ides", $options) ); } diff --git a/src/Endpoints/LogForwardingDestinations.php b/src/Endpoints/LogForwardingDestinations.php index f9553572..d86c428e 100644 --- a/src/Endpoints/LogForwardingDestinations.php +++ b/src/Endpoints/LogForwardingDestinations.php @@ -61,17 +61,18 @@ public function get($environmentUuid, $destinationId) public function create($environmentUuid, $label, $sources, $consumer, $credentials, $address) { - $params = [ - 'label' => $label, - 'sources' => $sources, - 'consumer' => $consumer, - 'credentials' => $credentials, - 'address' => $address + $options = [ + 'form_params' => [ + 'label' => $label, + 'sources' => $sources, + 'consumer' => $consumer, + 'credentials' => $credentials, + 'address' => $address + ], ]; - $this->client->addOption('form_params', $params); return new OperationResponse( - $this->client->request('post', "/environments/${environmentUuid}/log-forwarding-destinations") + $this->client->request('post', "/environments/${environmentUuid}/log-forwarding-destinations", $options) ); } @@ -138,19 +139,21 @@ public function enable($environmentUuid, $destId) public function update($environmentUuid, $destId, $label, $sources, $consumer, $creds, $address) { - $params = [ - 'label' => $label, - 'sources' => $sources, - 'consumer' => $consumer, - 'credentials' => $creds, - 'address' => $address + $options = [ + 'form_params' => [ + 'label' => $label, + 'sources' => $sources, + 'consumer' => $consumer, + 'credentials' => $creds, + 'address' => $address + ], ]; - $this->client->addOption('form_params', $params); return new OperationResponse( $this->client->request( 'put', - "/environments/${environmentUuid}/log-forwarding-destinations/${destId}" + "/environments/${environmentUuid}/log-forwarding-destinations/${destId}", + $options ) ); } diff --git a/src/Endpoints/Organizations.php b/src/Endpoints/Organizations.php index bb04c953..f05e9e93 100644 --- a/src/Endpoints/Organizations.php +++ b/src/Endpoints/Organizations.php @@ -148,11 +148,14 @@ public function getTeams($organizationUuid) */ public function inviteAdmin($organizationUuid, $email) { - - $this->client->addOption('form_params', ['email' => $email]); + $options = [ + 'form_params' => [ + 'email' => $email, + ], + ]; return new OperationResponse( - $this->client->request('post', "/organizations/${organizationUuid}/admin-invites") + $this->client->request('post', "/organizations/${organizationUuid}/admin-invites", $options) ); } } diff --git a/src/Endpoints/Roles.php b/src/Endpoints/Roles.php index c14f06c3..de7cd3b0 100644 --- a/src/Endpoints/Roles.php +++ b/src/Endpoints/Roles.php @@ -51,15 +51,16 @@ public function get($roleUuid) */ public function create($organizationUuid, $name, array $permissions, $description = null) { - $params = [ - 'name' => $name, - 'permissions' => $permissions, - 'description' => $description, + $options = [ + 'form_params' => [ + 'name' => $name, + 'permissions' => $permissions, + 'description' => $description, + ], ]; - $this->client->addOption('form_params', $params); return new OperationResponse( - $this->client->request('post', "/organizations/${organizationUuid}/roles") + $this->client->request('post', "/organizations/${organizationUuid}/roles", $options) ); } @@ -72,11 +73,14 @@ public function create($organizationUuid, $name, array $permissions, $descriptio */ public function update($roleUuid, array $permissions) { - - $this->client->addOption('form_params', ['permissions' => $permissions]); + $options = [ + 'form_params' => [ + 'permissions' => $permissions, + ], + ]; return new OperationResponse( - $this->client->request('put', "/roles/${roleUuid}") + $this->client->request('put', "/roles/${roleUuid}", $options) ); } diff --git a/src/Endpoints/Servers.php b/src/Endpoints/Servers.php index 1083a1d6..42a61f47 100644 --- a/src/Endpoints/Servers.php +++ b/src/Endpoints/Servers.php @@ -42,12 +42,11 @@ public function get($environmentUuid, $serverId) public function update($environmentUuid, $serverId, array $config) { - $this->client->addOption('form_params', $config); - return new OperationResponse( $this->client->request( 'put', - "/environments/${environmentUuid}/servers/${serverId}" + "/environments/${environmentUuid}/servers/${serverId}", + $config ) ); } diff --git a/src/Endpoints/SslCertificates.php b/src/Endpoints/SslCertificates.php index 9287eee7..1e585b39 100644 --- a/src/Endpoints/SslCertificates.php +++ b/src/Endpoints/SslCertificates.php @@ -62,18 +62,19 @@ public function get($environmentUuid, $certificateId) public function create($envUuid, $label, $cert, $key, $ca = null, $csr = null, $legacy = false) { - $params = [ - 'label' => $label, - 'certificate' => $cert, - 'private_key' => $key, - 'ca_certificates' => $ca, - 'csr_id' => $csr, - 'legacy' => $legacy + $options = [ + 'form_params' => [ + 'label' => $label, + 'certificate' => $cert, + 'private_key' => $key, + 'ca_certificates' => $ca, + 'csr_id' => $csr, + 'legacy' => $legacy + ], ]; - $this->client->addOption('form_params', $params); return new OperationResponse( - $this->client->request('post', "/environments/${envUuid}/ssl/certificates") + $this->client->request('post', "/environments/${envUuid}/ssl/certificates", $options) ); } diff --git a/src/Endpoints/Teams.php b/src/Endpoints/Teams.php index d8fe094a..62f80b7c 100644 --- a/src/Endpoints/Teams.php +++ b/src/Endpoints/Teams.php @@ -24,11 +24,14 @@ class Teams extends CloudApiBase implements CloudApiInterface */ public function create($organizationUuid, $name) { - - $this->client->addOption('form_params', ['name' => $name]); + $options = [ + 'form_params' => [ + 'name' => $name, + ], + ]; return new OperationResponse( - $this->client->request('post', "/organizations/${organizationUuid}/teams") + $this->client->request('post', "/organizations/${organizationUuid}/teams", $options) ); } @@ -53,11 +56,14 @@ public function getAll() */ public function rename($teamUuid, $name) { - - $this->client->addOption('form_params', ['name' => $name]); + $options = [ + 'form_params' => [ + 'name' => $name, + ], + ]; return new OperationResponse( - $this->client->request('put', "/teams/${teamUuid}") + $this->client->request('put', "/teams/${teamUuid}", $options) ); } @@ -84,11 +90,14 @@ public function delete($teamUuid) */ public function addApplication($teamUuid, $applicationUuid) { - - $this->client->addOption('form_params', ['uuid' => $applicationUuid]); + $options = [ + 'form_params' => [ + 'uuid' => $applicationUuid, + ], + ]; return new OperationResponse( - $this->client->request('post', "/teams/${teamUuid}/applications") + $this->client->request('post', "/teams/${teamUuid}/applications", $options) ); } @@ -102,14 +111,15 @@ public function addApplication($teamUuid, $applicationUuid) */ public function invite($teamUuid, $email, $roles) { - $params = [ - 'email' => $email, - 'roles' => $roles + $options = [ + 'form_params' => [ + 'email' => $email, + 'roles' => $roles + ], ]; - $this->client->addOption('form_params', $params); return new OperationResponse( - $this->client->request('post', "/teams/${teamUuid}/invites") + $this->client->request('post', "/teams/${teamUuid}/invites", $options) ); } diff --git a/src/Endpoints/Variables.php b/src/Endpoints/Variables.php index 35c93024..d8a23858 100644 --- a/src/Endpoints/Variables.php +++ b/src/Endpoints/Variables.php @@ -56,14 +56,15 @@ public function get($environmentUuid, $name) */ public function create($environmentUuid, $name, $value) { - $params = [ - 'name' => $name, - 'value' => $value, + $options = [ + 'form_params' => [ + 'name' => $name, + 'value' => $value, + ], ]; - $this->client->addOption('form_params', $params); return new OperationResponse( - $this->client->request('post', "/environments/${environmentUuid}/variables") + $this->client->request('post', "/environments/${environmentUuid}/variables", $options) ); } @@ -77,14 +78,15 @@ public function create($environmentUuid, $name, $value) */ public function update($environmentUuid, $name, $value) { - $params = [ - 'name' => $name, - 'value' => $value, + $options = [ + 'form_params' => [ + 'name' => $name, + 'value' => $value, + ], ]; - $this->client->addOption('form_params', $params); return new OperationResponse( - $this->client->request('put', "/environments/${environmentUuid}/variables/${name}") + $this->client->request('put', "/environments/${environmentUuid}/variables/${name}", $options) ); } diff --git a/tests/Endpoints/ApplicationsTest.php b/tests/Endpoints/ApplicationsTest.php index 07fe235e..a7487d12 100644 --- a/tests/Endpoints/ApplicationsTest.php +++ b/tests/Endpoints/ApplicationsTest.php @@ -74,14 +74,8 @@ public function testRenameApplication() $application = new Applications($client); $result = $application->rename('8ff6c046-ec64-4ce4-bea6-27845ec18600', "My application's new name"); - $params = [ - 'form_params' => [ - 'name' => "My application's new name" - ], - ]; - $this->assertEquals($params, $client->getOptions()); - $this->assertInstanceOf('\AcquiaCloudApi\Response\OperationResponse', $result); + $this->assertEquals('Application renamed.', $result->message); } @@ -115,15 +109,8 @@ public function testCreateTag() $application = new Applications($client); $result = $application->createTag('8ff6c046-ec64-4ce4-bea6-27845ec18600', "deloitte", "orange"); - $params = [ - 'form_params' => [ - 'name' => 'deloitte', - 'color' => 'orange' - ], - ]; - $this->assertEquals($params, $client->getOptions()); - $this->assertInstanceOf('\AcquiaCloudApi\Response\OperationResponse', $result); + $this->assertEquals('The tag has been added to the application.', $result->message); } diff --git a/tests/Endpoints/ClientTest.php b/tests/Endpoints/ClientTest.php index c3b5a9f2..062a2a4d 100644 --- a/tests/Endpoints/ClientTest.php +++ b/tests/Endpoints/ClientTest.php @@ -75,38 +75,4 @@ public function testOptions() $client->clearOptions(); $this->assertTrue(empty($client->getOptions())); } - - public function testOptionsAndPost() - { - $response = $this->getPsr7JsonResponseForFixture('Endpoints/Code/deployCode.json'); - $client = $this->getMockClient($response); - - $client->addOption('max', 5); - $client->addOption('curl.options', ['CURLOPT_RETURNTRANSFER' => true]); - $client->addOption('referer', true); - $client->addOption('connect_timeout', 100); - - $expectedOptions = [ - 'max' => 5, - 'curl.options' => [ - 'CURLOPT_RETURNTRANSFER' => true, - ], - 'connect_timeout' => 100, - 'referer' => true, - 'form_params' => [ - 'source' => '8ff6c046-ec64-4ce4-bea6-27845ec18600', - 'message' => 'Commit message' - ], - ]; - - /** @var \AcquiaCloudApi\CloudApi\ClientInterface $client */ - $code = new Code($client); - $result = $code->deploy( - '8ff6c046-ec64-4ce4-bea6-27845ec18600', - 'f9ef59eb-13ee-4050-8120-5524d8ce9821', - 'Commit message' - ); - - $this->assertEquals($expectedOptions, $client->getOptions()); - } } diff --git a/tests/Endpoints/CodeTest.php b/tests/Endpoints/CodeTest.php index b9b044cd..e113552c 100644 --- a/tests/Endpoints/CodeTest.php +++ b/tests/Endpoints/CodeTest.php @@ -43,13 +43,6 @@ public function testCodeSwitch() $code = new Code($client); $result = $code->switch('8ff6c046-ec64-4ce4-bea6-27845ec18600', 'my-feature-branch'); - $params = [ - 'form_params' => [ - 'branch' => 'my-feature-branch' - ], - ]; - $this->assertEquals($params, $client->getOptions()); - $this->assertInstanceOf('\AcquiaCloudApi\Response\OperationResponse', $result); $this->assertEquals('Switching code.', $result->message); } @@ -67,14 +60,6 @@ public function testCodeDeploy() 'Commit message' ); - $params = [ - 'form_params' => [ - 'source' => '8ff6c046-ec64-4ce4-bea6-27845ec18600', - 'message' => 'Commit message' - ], - ]; - $this->assertEquals($params, $client->getOptions()); - $this->assertInstanceOf('\AcquiaCloudApi\Response\OperationResponse', $result); $this->assertEquals('Deploying code.', $result->message); } diff --git a/tests/Endpoints/CronsTest.php b/tests/Endpoints/CronsTest.php index 0dc65d25..276effc8 100644 --- a/tests/Endpoints/CronsTest.php +++ b/tests/Endpoints/CronsTest.php @@ -76,16 +76,6 @@ public function testCreateCron() 'My New Cron' ); - $params = [ - 'form_params' => [ - 'command' => '/usr/local/bin/drush cc all', - 'frequency' => '*/30 * * * *', - 'label' => 'My New Cron', - 'server_id' => null - ], - ]; - $this->assertEquals($params, $client->getOptions()); - $this->assertInstanceOf('\AcquiaCloudApi\Response\OperationResponse', $result); $this->assertEquals('Creating a new cron.', $result->message); } @@ -105,16 +95,6 @@ public function testUpdateCron() 'My New Cron' ); - $params = [ - 'form_params' => [ - 'command' => '/usr/local/bin/drush cc all', - 'frequency' => '*/30 * * * *', - 'label' => 'My New Cron', - 'server_id' => null - ], - ]; - $this->assertEquals($params, $client->getOptions()); - $this->assertInstanceOf('\AcquiaCloudApi\Response\OperationResponse', $result); $this->assertEquals('Updating cron.', $result->message); } diff --git a/tests/Endpoints/DatabasesTest.php b/tests/Endpoints/DatabasesTest.php index 4ed9d6e6..5ddba6cd 100644 --- a/tests/Endpoints/DatabasesTest.php +++ b/tests/Endpoints/DatabasesTest.php @@ -47,14 +47,6 @@ public function testDatabaseCopy() '14-0c7e79ab-1c4a-424e-8446-76ae8be7e851' ); - $params = [ - 'form_params' => [ - 'name' => 'db_name', - 'source' => '24-a47ac10b-58cc-4372-a567-0e02b2c3d470' - ], - ]; - $this->assertEquals($params, $client->getOptions()); - $this->assertInstanceOf('\AcquiaCloudApi\Response\OperationResponse', $result); $this->assertEquals('The database is being copied', $result->message); } @@ -68,13 +60,6 @@ public function testDatabaseCreate() $databases = new Databases($client); $result = $databases->create('8ff6c046-ec64-4ce4-bea6-27845ec18600', 'db_name'); - $params = [ - 'form_params' => [ - 'name' => 'db_name' - ], - ]; - $this->assertEquals($params, $client->getOptions()); - $this->assertInstanceOf('\AcquiaCloudApi\Response\OperationResponse', $result); $this->assertEquals('The database is being created.', $result->message); } @@ -89,6 +74,7 @@ public function testDatabaseDelete() $result = $databases->delete('8ff6c046-ec64-4ce4-bea6-27845ec18600', 'db_name'); $this->assertInstanceOf('\AcquiaCloudApi\Response\OperationResponse', $result); + $this->assertEquals('The database is being deleted.', $result->message); } @@ -102,6 +88,7 @@ public function testDatabasesTruncate() $result = $databases->truncate('da1c0a8e-ff69-45db-88fc-acd6d2affbb7', 'drupal8'); $this->assertInstanceOf('\AcquiaCloudApi\Response\OperationResponse', $result); + $this->assertEquals('The database is being erased.', $result->message); } } diff --git a/tests/Endpoints/DomainsTest.php b/tests/Endpoints/DomainsTest.php index e28738fe..b51054a2 100644 --- a/tests/Endpoints/DomainsTest.php +++ b/tests/Endpoints/DomainsTest.php @@ -70,13 +70,6 @@ public function testDomainAdd() $domain = new Domains($client); $result = $domain->create('14-0c7e79ab-1c4a-424e-8446-76ae8be7e851', 'new-domain.com'); - $params = [ - 'form_params' => [ - 'hostname' => 'new-domain.com' - ], - ]; - $this->assertEquals($params, $client->getOptions()); - $this->assertInstanceOf('\AcquiaCloudApi\Response\OperationResponse', $result); $this->assertEquals("Adding domain example.com", $result->message); } diff --git a/tests/Endpoints/EnvironmentsTest.php b/tests/Endpoints/EnvironmentsTest.php index 0bc61ba0..920e3b78 100644 --- a/tests/Endpoints/EnvironmentsTest.php +++ b/tests/Endpoints/EnvironmentsTest.php @@ -74,15 +74,9 @@ public function testModifyEnvironment() $environment = new Environments($client); $result = $environment->update('24-a47ac10b-58cc-4372-a567-0e02b2c3d470', ['version' => '7.2']); - $params = [ - 'form_params' => [ - 'version' => '7.2' - ], - ]; - $this->assertEquals($params, $client->getOptions()); + $this->assertInstanceOf('\AcquiaCloudApi\Response\OperationResponse', $result); - $this->assertInstanceOf('\AcquiaCloudApi\Response\OperationResponse', $result); - $this->assertEquals('The environment configuration is being updated.', $result->message); + $this->assertEquals('The environment configuration is being updated.', $result->message); } public function testRenameEnvironment() @@ -95,14 +89,8 @@ public function testRenameEnvironment() $environment = new Environments($client); $result = $environment->rename('24-a47ac10b-58cc-4372-a567-0e02b2c3d470', 'Alpha'); - $params = [ - 'form_params' => [ - 'label' => 'Alpha' - ], - ]; - $this->assertEquals($params, $client->getOptions()); - $this->assertInstanceOf('\AcquiaCloudApi\Response\OperationResponse', $result); + $this->assertEquals('Changing environment label.', $result->message); } @@ -124,19 +112,8 @@ public function testCreateCDEnvironment() ] ); - $params = [ - 'form_params' => [ - 'label' => 'CD label', - 'branch' => 'my-feature-branch', - 'databases' => [ - 0 => 'database1', - 1 => 'database2' - ] - ], - ]; - $this->assertEquals($params, $client->getOptions()); - $this->assertInstanceOf('\AcquiaCloudApi\Response\OperationResponse', $result); + $this->assertEquals('Adding an environment.', $result->message); } @@ -151,6 +128,7 @@ public function testDeleteCDEnvironment() $result = $environment->delete('24-a47ac10b-58cc-4372-a567-0e02b2c3d470'); $this->assertInstanceOf('\AcquiaCloudApi\Response\OperationResponse', $result); + $this->assertEquals('The environment is being deleted.', $result->message); } } diff --git a/tests/Endpoints/FilesTest.php b/tests/Endpoints/FilesTest.php index 1990018f..fa213b59 100644 --- a/tests/Endpoints/FilesTest.php +++ b/tests/Endpoints/FilesTest.php @@ -19,14 +19,6 @@ public function testFilesCopy() '8ff6c046-ec64-4ce4-bea6-27845ec18600', '14-0c7e79ab-1c4a-424e-8446-76ae8be7e851' ); - - $params = [ - 'form_params' => [ - 'source' => '8ff6c046-ec64-4ce4-bea6-27845ec18600' - ], - ]; - $this->assertEquals($params, $client->getOptions()); - $this->assertInstanceOf('\AcquiaCloudApi\Response\OperationResponse', $result); $this->assertEquals('Copying files.', $result->message); } diff --git a/tests/Endpoints/IdentityProviderTest.php b/tests/Endpoints/IdentityProviderTest.php index e1a2706d..3a0857e5 100644 --- a/tests/Endpoints/IdentityProviderTest.php +++ b/tests/Endpoints/IdentityProviderTest.php @@ -67,6 +67,7 @@ public function testDeleteLogForwardingDestination() $result = $idp->delete('14-0c7e79ab-1c4a-424e-8446-76ae8be7e851'); $this->assertInstanceOf('\AcquiaCloudApi\Response\OperationResponse', $result); + $this->assertEquals('Identity provider has been deleted.', $result->message); } @@ -80,6 +81,7 @@ public function testEnableLogForwardingDestination() $result = $idp->enable('14-0c7e79ab-1c4a-424e-8446-76ae8be7e851'); $this->assertInstanceOf('\AcquiaCloudApi\Response\OperationResponse', $result); + $this->assertEquals('Identity Provider has been enabled.', $result->message); } @@ -93,6 +95,7 @@ public function testDisableLogForwardingDestination() $result = $idp->disable('14-0c7e79ab-1c4a-424e-8446-76ae8be7e851'); $this->assertInstanceOf('\AcquiaCloudApi\Response\OperationResponse', $result); + $this->assertEquals('Identity Provider has been disabled.', $result->message); } @@ -111,17 +114,8 @@ public function testUpdateLogForwardingDestination() "-----BEGIN CERTIFICATE-----...-----END CERTIFICATE-----" ); - $params = [ - 'form_params' => [ - 'label' => 'Test IDP', - 'entity_id' => 'entity-id', - 'sso_url' => 'https://idp.example.com', - 'certificate' => '-----BEGIN CERTIFICATE-----...-----END CERTIFICATE-----' - ], - ]; - $this->assertEquals($params, $client->getOptions()); - $this->assertInstanceOf('\AcquiaCloudApi\Response\OperationResponse', $result); + $this->assertEquals('Identity Provider has been updated.', $result->message); } } diff --git a/tests/Endpoints/IdesTest.php b/tests/Endpoints/IdesTest.php index 7d88f462..f00bd6bd 100644 --- a/tests/Endpoints/IdesTest.php +++ b/tests/Endpoints/IdesTest.php @@ -65,14 +65,8 @@ public function testCreateIde() 'My new IDE' ); - $params = [ - 'form_params' => [ - 'name' => 'My new IDE' - ], - ]; - $this->assertEquals($params, $client->getOptions()); - $this->assertInstanceOf('\AcquiaCloudApi\Response\OperationResponse', $result); + $this->assertEquals('The remote IDE is being created.', $result->message); } diff --git a/tests/Endpoints/InsightsTest.php b/tests/Endpoints/InsightsTest.php index eb87fe83..b7bf0680 100644 --- a/tests/Endpoints/InsightsTest.php +++ b/tests/Endpoints/InsightsTest.php @@ -163,6 +163,7 @@ public function testIgnoreAlert() ); $this->assertInstanceOf('\AcquiaCloudApi\Response\OperationResponse', $result); + $this->assertEquals('Alert ignored.', $result->message); } @@ -179,6 +180,7 @@ public function testRestoreAlert() ); $this->assertInstanceOf('\AcquiaCloudApi\Response\OperationResponse', $result); + $this->assertEquals('Alert restored.', $result->message); } @@ -192,6 +194,7 @@ public function testRevokeSite() $result = $insights->revoke('8ff6c046-ec64-4ce4-bea6-27845ec18600'); $this->assertInstanceOf('\AcquiaCloudApi\Response\OperationResponse', $result); + $this->assertEquals('Site revoked from submitting Insight score data.', $result->message); } @@ -205,6 +208,7 @@ public function testUnrevokeSite() $result = $insights->unrevoke('8ff6c046-ec64-4ce4-bea6-27845ec18600'); $this->assertInstanceOf('\AcquiaCloudApi\Response\OperationResponse', $result); + $this->assertEquals('Site un-revoked.', $result->message); } diff --git a/tests/Endpoints/LiveDevTest.php b/tests/Endpoints/LiveDevTest.php index 5725b0ab..3fd823a3 100644 --- a/tests/Endpoints/LiveDevTest.php +++ b/tests/Endpoints/LiveDevTest.php @@ -18,6 +18,7 @@ public function testLiveDevEnable() $result = $environment->enableLiveDev('14-0c7e79ab-1c4a-424e-8446-76ae8be7e851'); $this->assertInstanceOf('\AcquiaCloudApi\Response\OperationResponse', $result); + $this->assertEquals('Live Dev is being enabled.', $result->message); } @@ -30,14 +31,8 @@ public function testLiveDevDisable() $environment = new Environments($client); $result = $environment->disableLiveDev('14-0c7e79ab-1c4a-424e-8446-76ae8be7e851'); - $params = [ - 'form_params' => [ - 'discard' => 1 - ], - ]; - $this->assertEquals($params, $client->getOptions()); - $this->assertInstanceOf('\AcquiaCloudApi\Response\OperationResponse', $result); + $this->assertEquals('Live Dev is being disabled.', $result->message); } } diff --git a/tests/Endpoints/LogForwardingTest.php b/tests/Endpoints/LogForwardingTest.php index fb32a9c5..eadade0e 100644 --- a/tests/Endpoints/LogForwardingTest.php +++ b/tests/Endpoints/LogForwardingTest.php @@ -77,23 +77,8 @@ public function testCreateLogForwardingDestination() 'example.com:1234' ); - $params = [ - 'form_params' => [ - 'label' => 'Test destination', - 'sources' => [ - 0 => 'apache-access', - 1 => 'apache-error' - ], - 'consumer' => 'syslog', - 'credentials' => [ - "certificate" => "-----BEGIN CERTIFICATE-----...-----END CERTIFICATE-----" - ], - 'address' => 'example.com:1234' - ], - ]; - $this->assertEquals($params, $client->getOptions()); - $this->assertInstanceOf('\AcquiaCloudApi\Response\OperationResponse', $result); + $this->assertEquals('Log forwarding destination for the environment has been created.', $result->message); } @@ -121,6 +106,7 @@ public function testEnableLogForwardingDestination() $result = $logForwarding->enable('14-0c7e79ab-1c4a-424e-8446-76ae8be7e851', 2); $this->assertInstanceOf('\AcquiaCloudApi\Response\OperationResponse', $result); + $this->assertEquals('Log forwarding destination has been enabled.', $result->message); } @@ -134,6 +120,7 @@ public function testDisableLogForwardingDestination() $result = $logForwarding->disable('14-0c7e79ab-1c4a-424e-8446-76ae8be7e851', 2); $this->assertInstanceOf('\AcquiaCloudApi\Response\OperationResponse', $result); + $this->assertEquals('Log forwarding destination has been disabled.', $result->message); } @@ -154,23 +141,8 @@ public function testUpdateLogForwardingDestination() 'example.com:1234' ); - $params = [ - 'form_params' => [ - 'label' => 'Test destination', - 'sources' => [ - 0 => 'apache-access', - 1 => 'apache-error' - ], - 'consumer' => 'syslog', - 'credentials' => [ - "certificate" => "-----BEGIN CERTIFICATE-----...-----END CERTIFICATE-----" - ], - 'address' => 'example.com:1234' - ], - ]; - $this->assertEquals($params, $client->getOptions()); - $this->assertInstanceOf('\AcquiaCloudApi\Response\OperationResponse', $result); + $this->assertEquals('Log forwarding destination has been updated.', $result->message); } } diff --git a/tests/Endpoints/OrganizationsTest.php b/tests/Endpoints/OrganizationsTest.php index 279e815b..08ef5aed 100644 --- a/tests/Endpoints/OrganizationsTest.php +++ b/tests/Endpoints/OrganizationsTest.php @@ -87,14 +87,8 @@ public function testCreateOrganizationAdminInvite() $organization = new Organizations($client); $result = $organization->inviteAdmin('14-0c7e79ab-1c4a-424e-8446-76ae8be7e851', 'user@example.com'); - $params = [ - 'form_params' => [ - 'email' => 'user@example.com' - ], - ]; - $this->assertEquals($params, $client->getOptions()); - $this->assertInstanceOf('\AcquiaCloudApi\Response\OperationResponse', $result); + $this->assertEquals('Invited organization administrator.', $result->message); } diff --git a/tests/Endpoints/RolesTest.php b/tests/Endpoints/RolesTest.php index 561df5f1..a1c0ec5c 100644 --- a/tests/Endpoints/RolesTest.php +++ b/tests/Endpoints/RolesTest.php @@ -69,18 +69,6 @@ public function testCreateRole() 'My new role description' ); - $params = [ - 'form_params' => [ - 'name' => 'My new role', - 'permissions' => [ - 0 => 'access cloud api', - 1 => 'pull from prod' - ], - 'description' => 'My new role description' - ], - ]; - $this->assertEquals($params, $client->getOptions()); - $this->assertInstanceOf('\AcquiaCloudApi\Response\OperationResponse', $result); $this->assertEquals('Role created.', $result->message); } @@ -107,15 +95,6 @@ public function testUpdateRole() $role = new Roles($client); $result = $role->update('r47ac10b-58cc-4372-a567-0e02b2c3d470', ['pull from prod']); - $params = [ - 'form_params' => [ - 'permissions' => [ - 0 => 'pull from prod' - ], - ], - ]; - $this->assertEquals($params, $client->getOptions()); - $this->assertInstanceOf('\AcquiaCloudApi\Response\OperationResponse', $result); $this->assertEquals('Updating role.', $result->message); } diff --git a/tests/Endpoints/ServersTest.php b/tests/Endpoints/ServersTest.php index a1014161..ffcd129d 100644 --- a/tests/Endpoints/ServersTest.php +++ b/tests/Endpoints/ServersTest.php @@ -73,14 +73,8 @@ public function testUpdateServer() ['memcache' => 128] ); - $params = [ - 'form_params' => [ - 'memcache' => 128 - ], - ]; - $this->assertEquals($params, $client->getOptions()); - $this->assertInstanceOf('\AcquiaCloudApi\Response\OperationResponse', $result); + $this->assertEquals('The server configuration is being updated.', $result->message); } } diff --git a/tests/Endpoints/SslCertificatesTest.php b/tests/Endpoints/SslCertificatesTest.php index 2760c5ea..2f433411 100644 --- a/tests/Endpoints/SslCertificatesTest.php +++ b/tests/Endpoints/SslCertificatesTest.php @@ -77,19 +77,8 @@ public function testCreateSslCertificate() false ); - $params = [ - 'form_params' => [ - 'label' => 'My New Cert', - 'certificate' => '-----BEGIN CERTIFICATE-----abc123....-----END CERTIFICATE-----', - 'private_key' => '-----BEGIN RSA PRIVATE KEY-----secret....-----END RSA PRIVATE KEY-----', - 'ca_certificates' => '-----BEGIN CERTIFICATE-----123abc....-----END CERTIFICATE-----', - 'csr_id' => 123, - 'legacy' => false - ], - ]; - $this->assertEquals($params, $client->getOptions()); - $this->assertInstanceOf('\AcquiaCloudApi\Response\OperationResponse', $result); + $this->assertEquals('Installing the certificate.', $result->message); } @@ -103,6 +92,7 @@ public function testDeleteSslCertificate() $result = $certificate->delete('14-0c7e79ab-1c4a-424e-8446-76ae8be7e851', 14); $this->assertInstanceOf('\AcquiaCloudApi\Response\OperationResponse', $result); + $this->assertEquals('Deleting the certificate.', $result->message); } @@ -116,6 +106,7 @@ public function testActivateSslCertificate() $result = $certificate->enable('14-0c7e79ab-1c4a-424e-8446-76ae8be7e851', 2); $this->assertInstanceOf('\AcquiaCloudApi\Response\OperationResponse', $result); + $this->assertEquals('Activating the certificate.', $result->message); } @@ -129,6 +120,7 @@ public function testDeactivateSslCertificate() $result = $certificate->disable('14-0c7e79ab-1c4a-424e-8446-76ae8be7e851', 2); $this->assertInstanceOf('\AcquiaCloudApi\Response\OperationResponse', $result); + $this->assertEquals('Deactivating the certificate.', $result->message); } } diff --git a/tests/Endpoints/TeamsTest.php b/tests/Endpoints/TeamsTest.php index 0527a94f..d8625e8c 100644 --- a/tests/Endpoints/TeamsTest.php +++ b/tests/Endpoints/TeamsTest.php @@ -65,18 +65,8 @@ public function testCreateTeamInvite() ['access permissions', 'access servers'] ); - $params = [ - 'form_params' => [ - 'email' => 'hello@example.com', - 'roles' => [ - 0 => 'access permissions', - 1 => 'access servers' - ] - ], - ]; - $this->assertEquals($params, $client->getOptions()); - $this->assertInstanceOf('\AcquiaCloudApi\Response\OperationResponse', $result); + $this->assertEquals("Invited team member.", $result->message); } @@ -89,14 +79,8 @@ public function testCreateTeam() $organization = new Teams($client); $result = $organization->create('8ff6c046-ec64-4ce4-bea6-27845ec18600', 'Mega Team'); - $params = [ - 'form_params' => [ - 'name' => 'Mega Team' - ], - ]; - $this->assertEquals($params, $client->getOptions()); - $this->assertInstanceOf('\AcquiaCloudApi\Response\OperationResponse', $result); + $this->assertEquals("Team created.", $result->message); } @@ -109,14 +93,8 @@ public function testRenameTeam() $team = new Teams($client); $result = $team->rename('14-0c7e79ab-1c4a-424e-8446-76ae8be7e851', 'My Cool Application'); - $params = [ - 'form_params' => [ - 'name' => 'My Cool Application' - ], - ]; - $this->assertEquals($params, $client->getOptions()); - $this->assertInstanceOf('\AcquiaCloudApi\Response\OperationResponse', $result); + $this->assertEquals("Team renamed.", $result->message); } @@ -130,6 +108,7 @@ public function testDeleteTeam() $result = $team->delete('14-0c7e79ab-1c4a-424e-8446-76ae8be7e851'); $this->assertInstanceOf('\AcquiaCloudApi\Response\OperationResponse', $result); + $this->assertEquals("Removed team.", $result->message); } @@ -145,14 +124,8 @@ public function testAddApplicationToTeam() '14-0c7e79ab-1c4a-424e-8446-76ae8be7e851' ); - $params = [ - 'form_params' => [ - 'uuid' => '14-0c7e79ab-1c4a-424e-8446-76ae8be7e851' - ], - ]; - $this->assertEquals($params, $client->getOptions()); - $this->assertInstanceOf('\AcquiaCloudApi\Response\OperationResponse', $result); + $this->assertEquals('Added application to team.', $result->message); } diff --git a/tests/Endpoints/VariablesTest.php b/tests/Endpoints/VariablesTest.php index 89480ec7..d31ed431 100644 --- a/tests/Endpoints/VariablesTest.php +++ b/tests/Endpoints/VariablesTest.php @@ -59,14 +59,6 @@ public function testVariableAdd() $variable = new Variables($client); $result = $variable->create('123-c7056b9e-0fb7-44e9-a434-426a404211c1', 'test_variable', 'test_value'); - $params = [ - 'form_params' => [ - 'name' => 'test_variable', - 'value' => 'test_value' - ], - ]; - $this->assertEquals($params, $client->getOptions()); - $this->assertInstanceOf('\AcquiaCloudApi\Response\OperationResponse', $result); $this->assertEquals("The environment variable is being added.", $result->message); } @@ -83,15 +75,8 @@ public function testUpdateVariable() 'value' ); - $params = [ - 'form_params' => [ - 'name' => 'name', - 'value' => 'value' - ], - ]; - $this->assertEquals($params, $client->getOptions()); - $this->assertInstanceOf('\AcquiaCloudApi\Response\OperationResponse', $result); + $this->assertEquals('The environment variable is being updated.', $result->message); } diff --git a/tests/Endpoints/VarnishTest.php b/tests/Endpoints/VarnishTest.php index db65cc39..b5585110 100644 --- a/tests/Endpoints/VarnishTest.php +++ b/tests/Endpoints/VarnishTest.php @@ -20,17 +20,8 @@ public function testPurgeVarnish() ['example.com', 'www.example.com'] ); - $params = [ - 'form_params' => [ - 'domains' => [ - 0 => 'example.com', - 1 => 'www.example.com' - ] - ], - ]; - $this->assertEquals($params, $client->getOptions()); - $this->assertInstanceOf('\AcquiaCloudApi\Response\OperationResponse', $result); + $this->assertEquals('Varnish is being cleared for the selected domains.', $result->message); } }