diff --git a/src/Connector/Client.php b/src/Connector/Client.php index 4dd4b418..718ab5f9 100644 --- a/src/Connector/Client.php +++ b/src/Connector/Client.php @@ -51,12 +51,9 @@ public static function factory(ConnectorInterface $connector) /** * @inheritdoc */ - public function request(string $verb, string $path, array $options = []) + public function request(string $verb, string $path) { - // @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 = $this->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 143d6c24..6b94b1de 100644 --- a/src/Connector/ClientInterface.php +++ b/src/Connector/ClientInterface.php @@ -19,11 +19,10 @@ interface ClientInterface * * @param string $verb * @param string $path - * @param array $options * * @return mixed|StreamInterface */ - public function request(string $verb, string $path, array $options = []); + public function request(string $verb, string $path); /** * @param string $verb diff --git a/src/Endpoints/Applications.php b/src/Endpoints/Applications.php index b6e2d34d..1802023b 100644 --- a/src/Endpoints/Applications.php +++ b/src/Endpoints/Applications.php @@ -52,17 +52,12 @@ public function get($applicationUuid) public function rename($applicationUuid, $name) { - $options = [ - 'form_params' => [ - 'name' => $name, - ], - ]; + $this->client->addOption('form_params', ['name' => $name]); return new OperationResponse( $this->client->request( 'put', - "/applications/${applicationUuid}", - $options + "/applications/${applicationUuid}" ) ); } @@ -95,18 +90,16 @@ public function getAllTags($applicationUuid) public function createTag($applicationUuid, $name, $color) { - $options = [ - 'form_params' => [ - 'name' => $name, - 'color' => $color, - ], + $params = [ + 'name' => $name, + 'color' => $color, ]; + $this->client->addOption('form_params', $params); return new OperationResponse( $this->client->request( 'post', - "/applications/${applicationUuid}/tags", - $options + "/applications/${applicationUuid}/tags" ) ); } diff --git a/src/Endpoints/Code.php b/src/Endpoints/Code.php index aa57e4fc..853c86f5 100644 --- a/src/Endpoints/Code.php +++ b/src/Endpoints/Code.php @@ -39,17 +39,12 @@ public function getAll($applicationUuid) public function switch($environmentUuid, $branch) { - $options = [ - 'form_params' => [ - 'branch' => $branch, - ], - ]; + $this->client->addOption('form_params', ['branch' => $branch]); return new OperationResponse( $this->client->request( 'post', - "/environments/${environmentUuid}/code/actions/switch", - $options + "/environments/${environmentUuid}/code/actions/switch" ) ); } @@ -64,18 +59,16 @@ public function switch($environmentUuid, $branch) public function deploy($environmentFromUuid, $environmentToUuid, $commitMessage = null) { - $options = [ - 'form_params' => [ - 'source' => $environmentFromUuid, - 'message' => $commitMessage, - ], + $params = [ + 'source' => $environmentFromUuid, + 'message' => $commitMessage, ]; + $this->client->addOption('form_params', $params); return new OperationResponse( $this->client->request( 'post', - "/environments/${environmentToUuid}/code", - $options + "/environments/${environmentToUuid}/code" ) ); } diff --git a/src/Endpoints/Crons.php b/src/Endpoints/Crons.php index 421ca2fd..b7098374 100644 --- a/src/Endpoints/Crons.php +++ b/src/Endpoints/Crons.php @@ -60,17 +60,16 @@ public function get($environmentUuid, $cronId) public function create($environmentUuid, $command, $frequency, $label, $serverId = null) { - $options = [ - 'form_params' => [ - 'command' => $command, - 'frequency' => $frequency, - 'label' => $label, - 'server_id' => $serverId - ], + $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", $options) + $this->client->request('post', "/environments/${environmentUuid}/crons") ); } @@ -88,17 +87,16 @@ public function create($environmentUuid, $command, $frequency, $label, $serverId public function update($environmentUuid, $cronId, $command, $frequency, $label, $serverId = null) { - $options = [ - 'form_params' => [ - 'command' => $command, - 'frequency' => $frequency, - 'label' => $label, - 'server_id' => $serverId - ], + $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}", $options) + $this->client->request('post', "/environments/${environmentUuid}/crons/${cronId}") ); } diff --git a/src/Endpoints/Databases.php b/src/Endpoints/Databases.php index d4f471d5..34826439 100644 --- a/src/Endpoints/Databases.php +++ b/src/Endpoints/Databases.php @@ -38,14 +38,11 @@ public function getAll($applicationUuid) */ public function create($applicationUuid, $name) { - $options = [ - 'form_params' => [ - 'name' => $name, - ], - ]; + + $this->client->addOption('form_params', ['name' => $name]); return new OperationResponse( - $this->client->request('post', "/applications/${applicationUuid}/databases", $options) + $this->client->request('post', "/applications/${applicationUuid}/databases") ); } @@ -93,15 +90,14 @@ public function truncate($applicationUuid, $name) */ public function copy($environmentFromUuid, $dbName, $environmentToUuid) { - $options = [ - 'form_params' => [ - 'name' => $dbName, - 'source' => $environmentFromUuid, - ], + $params = [ + 'name' => $dbName, + 'source' => $environmentFromUuid, ]; + $this->client->addOption('form_params', $params); return new OperationResponse( - $this->client->request('post', "/environments/${environmentToUuid}/databases", $options) + $this->client->request('post', "/environments/${environmentToUuid}/databases") ); } } diff --git a/src/Endpoints/Domains.php b/src/Endpoints/Domains.php index 76d38ad4..a05701ad 100644 --- a/src/Endpoints/Domains.php +++ b/src/Endpoints/Domains.php @@ -58,14 +58,10 @@ public function get($environmentUuid, $domain) public function create($environmentUuid, $hostname) { - $options = [ - 'form_params' => [ - 'hostname' => $hostname, - ], - ]; + $this->client->addOption('form_params', ['hostname' => $hostname]); return new OperationResponse( - $this->client->request('post', "/environments/${environmentUuid}/domains", $options) + $this->client->request('post', "/environments/${environmentUuid}/domains") ); } @@ -93,17 +89,12 @@ public function delete($environmentUuid, $domain) public function purge($environmentUuid, array $domains) { - $options = [ - 'form_params' => [ - 'domains' => $domains, - ], - ]; + $this->client->addOption('form_params', ['domains' => $domains]); return new OperationResponse( $this->client->request( 'post', - "/environments/${environmentUuid}/domains/actions/clear-varnish", - $options + "/environments/${environmentUuid}/domains/actions/clear-varnish" ) ); } diff --git a/src/Endpoints/Environments.php b/src/Endpoints/Environments.php index b8789f0c..2e409ec2 100644 --- a/src/Endpoints/Environments.php +++ b/src/Endpoints/Environments.php @@ -23,14 +23,11 @@ class Environments extends CloudApiBase implements CloudApiInterface */ public function copyFiles($environmentUuidFrom, $environmentUuidTo) { - $options = [ - 'form_params' => [ - 'source' => $environmentUuidFrom, - ], - ]; + + $this->client->addOption('form_params', ['source' => $environmentUuidFrom]); return new OperationResponse( - $this->client->request('post', "/environments/${environmentUuidTo}/files", $options) + $this->client->request('post', "/environments/${environmentUuidTo}/files") ); } @@ -76,15 +73,12 @@ public function getAll($applicationUuid) public function update($environmentUuid, array $config) { - $options = [ - 'form_params' => $config, - ]; + $this->client->addOption('form_params', $config); return new OperationResponse( $this->client->request( 'put', - "/environments/${environmentUuid}", - $options + "/environments/${environmentUuid}" ) ); } @@ -99,17 +93,12 @@ public function update($environmentUuid, array $config) public function rename($environmentUuid, $label) { - $options = [ - 'form_params' => [ - 'label' => $label, - ], - ]; + $this->client->addOption('form_params', ['label' => $label]); return new OperationResponse( $this->client->request( 'post', - "/environments/${environmentUuid}/actions/change-label", - $options + "/environments/${environmentUuid}/actions/change-label" ) ); } @@ -136,17 +125,12 @@ public function enableLiveDev($environmentUuid) public function disableLiveDev($environmentUuid) { - $options = [ - 'form_params' => [ - 'discard' => 1, - ], - ]; + $this->client->addOption('form_params', ['discard' => 1]); return new OperationResponse( $this->client->request( 'post', - "/environments/${environmentUuid}/livedev/actions/disable", - $options + "/environments/${environmentUuid}/livedev/actions/disable" ) ); } @@ -194,19 +178,17 @@ public function disableProductionMode($environmentUuid) */ public function create($applicationUuid, $label, $branch, array $databases) { - $options = [ - 'form_params' => [ - 'label' => $label, - 'branch' => $branch, - 'databases' => $databases, - ], + $params = [ + 'label' => $label, + 'branch' => $branch, + 'databases' => $databases, ]; + $this->client->addOption('form_params', $params); return new OperationResponse( $this->client->request( 'post', - "/applications/${applicationUuid}/environments", - $options + "/applications/${applicationUuid}/environments" ) ); } diff --git a/src/Endpoints/IdentityProviders.php b/src/Endpoints/IdentityProviders.php index 130f7d8d..a9a97e7f 100644 --- a/src/Endpoints/IdentityProviders.php +++ b/src/Endpoints/IdentityProviders.php @@ -106,20 +106,18 @@ public function enable($idpUuid) public function update($idpUuid, $label, $entityId, $ssoUrl, $certificate) { - $options = [ - 'form_params' => [ - 'label' => $label, - 'entity_id' => $entityId, - 'sso_url' => $ssoUrl, - 'certificate' => $certificate, - ], + $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}", - $options + "/identity-providers/${idpUuid}" ) ); } diff --git a/src/Endpoints/Ides.php b/src/Endpoints/Ides.php index 9914e6f1..5269ddde 100644 --- a/src/Endpoints/Ides.php +++ b/src/Endpoints/Ides.php @@ -56,14 +56,10 @@ public function get($ideUuid) public function create($applicationUuid, $name) { - $options = [ - 'form_params' => [ - 'name' => $name, - ], - ]; + $this->client->addOption('form_params', ['name' => $name]); return new OperationResponse( - $this->client->request('post', "/applications/${applicationUuid}/ides", $options) + $this->client->request('post', "/applications/${applicationUuid}/ides") ); } diff --git a/src/Endpoints/LogForwardingDestinations.php b/src/Endpoints/LogForwardingDestinations.php index d86c428e..f9553572 100644 --- a/src/Endpoints/LogForwardingDestinations.php +++ b/src/Endpoints/LogForwardingDestinations.php @@ -61,18 +61,17 @@ public function get($environmentUuid, $destinationId) public function create($environmentUuid, $label, $sources, $consumer, $credentials, $address) { - $options = [ - 'form_params' => [ - 'label' => $label, - 'sources' => $sources, - 'consumer' => $consumer, - 'credentials' => $credentials, - 'address' => $address - ], + $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", $options) + $this->client->request('post', "/environments/${environmentUuid}/log-forwarding-destinations") ); } @@ -139,21 +138,19 @@ public function enable($environmentUuid, $destId) public function update($environmentUuid, $destId, $label, $sources, $consumer, $creds, $address) { - $options = [ - 'form_params' => [ - 'label' => $label, - 'sources' => $sources, - 'consumer' => $consumer, - 'credentials' => $creds, - 'address' => $address - ], + $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}", - $options + "/environments/${environmentUuid}/log-forwarding-destinations/${destId}" ) ); } diff --git a/src/Endpoints/Organizations.php b/src/Endpoints/Organizations.php index f05e9e93..bb04c953 100644 --- a/src/Endpoints/Organizations.php +++ b/src/Endpoints/Organizations.php @@ -148,14 +148,11 @@ public function getTeams($organizationUuid) */ public function inviteAdmin($organizationUuid, $email) { - $options = [ - 'form_params' => [ - 'email' => $email, - ], - ]; + + $this->client->addOption('form_params', ['email' => $email]); return new OperationResponse( - $this->client->request('post', "/organizations/${organizationUuid}/admin-invites", $options) + $this->client->request('post', "/organizations/${organizationUuid}/admin-invites") ); } } diff --git a/src/Endpoints/Roles.php b/src/Endpoints/Roles.php index de7cd3b0..c14f06c3 100644 --- a/src/Endpoints/Roles.php +++ b/src/Endpoints/Roles.php @@ -51,16 +51,15 @@ public function get($roleUuid) */ public function create($organizationUuid, $name, array $permissions, $description = null) { - $options = [ - 'form_params' => [ - 'name' => $name, - 'permissions' => $permissions, - 'description' => $description, - ], + $params = [ + 'name' => $name, + 'permissions' => $permissions, + 'description' => $description, ]; + $this->client->addOption('form_params', $params); return new OperationResponse( - $this->client->request('post', "/organizations/${organizationUuid}/roles", $options) + $this->client->request('post', "/organizations/${organizationUuid}/roles") ); } @@ -73,14 +72,11 @@ public function create($organizationUuid, $name, array $permissions, $descriptio */ public function update($roleUuid, array $permissions) { - $options = [ - 'form_params' => [ - 'permissions' => $permissions, - ], - ]; + + $this->client->addOption('form_params', ['permissions' => $permissions]); return new OperationResponse( - $this->client->request('put', "/roles/${roleUuid}", $options) + $this->client->request('put', "/roles/${roleUuid}") ); } diff --git a/src/Endpoints/Servers.php b/src/Endpoints/Servers.php index 42a61f47..1083a1d6 100644 --- a/src/Endpoints/Servers.php +++ b/src/Endpoints/Servers.php @@ -42,11 +42,12 @@ 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}", - $config + "/environments/${environmentUuid}/servers/${serverId}" ) ); } diff --git a/src/Endpoints/SslCertificates.php b/src/Endpoints/SslCertificates.php index 1e585b39..9287eee7 100644 --- a/src/Endpoints/SslCertificates.php +++ b/src/Endpoints/SslCertificates.php @@ -62,19 +62,18 @@ public function get($environmentUuid, $certificateId) public function create($envUuid, $label, $cert, $key, $ca = null, $csr = null, $legacy = false) { - $options = [ - 'form_params' => [ - 'label' => $label, - 'certificate' => $cert, - 'private_key' => $key, - 'ca_certificates' => $ca, - 'csr_id' => $csr, - 'legacy' => $legacy - ], + $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", $options) + $this->client->request('post', "/environments/${envUuid}/ssl/certificates") ); } diff --git a/src/Endpoints/Teams.php b/src/Endpoints/Teams.php index 62f80b7c..d8fe094a 100644 --- a/src/Endpoints/Teams.php +++ b/src/Endpoints/Teams.php @@ -24,14 +24,11 @@ class Teams extends CloudApiBase implements CloudApiInterface */ public function create($organizationUuid, $name) { - $options = [ - 'form_params' => [ - 'name' => $name, - ], - ]; + + $this->client->addOption('form_params', ['name' => $name]); return new OperationResponse( - $this->client->request('post', "/organizations/${organizationUuid}/teams", $options) + $this->client->request('post', "/organizations/${organizationUuid}/teams") ); } @@ -56,14 +53,11 @@ public function getAll() */ public function rename($teamUuid, $name) { - $options = [ - 'form_params' => [ - 'name' => $name, - ], - ]; + + $this->client->addOption('form_params', ['name' => $name]); return new OperationResponse( - $this->client->request('put', "/teams/${teamUuid}", $options) + $this->client->request('put', "/teams/${teamUuid}") ); } @@ -90,14 +84,11 @@ public function delete($teamUuid) */ public function addApplication($teamUuid, $applicationUuid) { - $options = [ - 'form_params' => [ - 'uuid' => $applicationUuid, - ], - ]; + + $this->client->addOption('form_params', ['uuid' => $applicationUuid]); return new OperationResponse( - $this->client->request('post', "/teams/${teamUuid}/applications", $options) + $this->client->request('post', "/teams/${teamUuid}/applications") ); } @@ -111,15 +102,14 @@ public function addApplication($teamUuid, $applicationUuid) */ public function invite($teamUuid, $email, $roles) { - $options = [ - 'form_params' => [ - 'email' => $email, - 'roles' => $roles - ], + $params = [ + 'email' => $email, + 'roles' => $roles ]; + $this->client->addOption('form_params', $params); return new OperationResponse( - $this->client->request('post', "/teams/${teamUuid}/invites", $options) + $this->client->request('post', "/teams/${teamUuid}/invites") ); } diff --git a/src/Endpoints/Variables.php b/src/Endpoints/Variables.php index d8a23858..35c93024 100644 --- a/src/Endpoints/Variables.php +++ b/src/Endpoints/Variables.php @@ -56,15 +56,14 @@ public function get($environmentUuid, $name) */ public function create($environmentUuid, $name, $value) { - $options = [ - 'form_params' => [ - 'name' => $name, - 'value' => $value, - ], + $params = [ + 'name' => $name, + 'value' => $value, ]; + $this->client->addOption('form_params', $params); return new OperationResponse( - $this->client->request('post', "/environments/${environmentUuid}/variables", $options) + $this->client->request('post', "/environments/${environmentUuid}/variables") ); } @@ -78,15 +77,14 @@ public function create($environmentUuid, $name, $value) */ public function update($environmentUuid, $name, $value) { - $options = [ - 'form_params' => [ - 'name' => $name, - 'value' => $value, - ], + $params = [ + 'name' => $name, + 'value' => $value, ]; + $this->client->addOption('form_params', $params); return new OperationResponse( - $this->client->request('put', "/environments/${environmentUuid}/variables/${name}", $options) + $this->client->request('put', "/environments/${environmentUuid}/variables/${name}") ); } diff --git a/tests/Endpoints/ApplicationsTest.php b/tests/Endpoints/ApplicationsTest.php index a7487d12..07fe235e 100644 --- a/tests/Endpoints/ApplicationsTest.php +++ b/tests/Endpoints/ApplicationsTest.php @@ -74,8 +74,14 @@ public function testRenameApplication() $application = new Applications($client); $result = $application->rename('8ff6c046-ec64-4ce4-bea6-27845ec18600', "My application's new name"); - $this->assertInstanceOf('\AcquiaCloudApi\Response\OperationResponse', $result); + $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); } @@ -109,8 +115,15 @@ public function testCreateTag() $application = new Applications($client); $result = $application->createTag('8ff6c046-ec64-4ce4-bea6-27845ec18600', "deloitte", "orange"); - $this->assertInstanceOf('\AcquiaCloudApi\Response\OperationResponse', $result); + $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 062a2a4d..c3b5a9f2 100644 --- a/tests/Endpoints/ClientTest.php +++ b/tests/Endpoints/ClientTest.php @@ -75,4 +75,38 @@ 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 e113552c..b9b044cd 100644 --- a/tests/Endpoints/CodeTest.php +++ b/tests/Endpoints/CodeTest.php @@ -43,6 +43,13 @@ 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); } @@ -60,6 +67,14 @@ 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 276effc8..0dc65d25 100644 --- a/tests/Endpoints/CronsTest.php +++ b/tests/Endpoints/CronsTest.php @@ -76,6 +76,16 @@ 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); } @@ -95,6 +105,16 @@ 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 5ddba6cd..4ed9d6e6 100644 --- a/tests/Endpoints/DatabasesTest.php +++ b/tests/Endpoints/DatabasesTest.php @@ -47,6 +47,14 @@ 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); } @@ -60,6 +68,13 @@ 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); } @@ -74,7 +89,6 @@ 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); } @@ -88,7 +102,6 @@ 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 b51054a2..e28738fe 100644 --- a/tests/Endpoints/DomainsTest.php +++ b/tests/Endpoints/DomainsTest.php @@ -70,6 +70,13 @@ 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 920e3b78..0bc61ba0 100644 --- a/tests/Endpoints/EnvironmentsTest.php +++ b/tests/Endpoints/EnvironmentsTest.php @@ -74,9 +74,15 @@ public function testModifyEnvironment() $environment = new Environments($client); $result = $environment->update('24-a47ac10b-58cc-4372-a567-0e02b2c3d470', ['version' => '7.2']); - $this->assertInstanceOf('\AcquiaCloudApi\Response\OperationResponse', $result); + $params = [ + 'form_params' => [ + 'version' => '7.2' + ], + ]; + $this->assertEquals($params, $client->getOptions()); - $this->assertEquals('The environment configuration is being updated.', $result->message); + $this->assertInstanceOf('\AcquiaCloudApi\Response\OperationResponse', $result); + $this->assertEquals('The environment configuration is being updated.', $result->message); } public function testRenameEnvironment() @@ -89,8 +95,14 @@ public function testRenameEnvironment() $environment = new Environments($client); $result = $environment->rename('24-a47ac10b-58cc-4372-a567-0e02b2c3d470', 'Alpha'); - $this->assertInstanceOf('\AcquiaCloudApi\Response\OperationResponse', $result); + $params = [ + 'form_params' => [ + 'label' => 'Alpha' + ], + ]; + $this->assertEquals($params, $client->getOptions()); + $this->assertInstanceOf('\AcquiaCloudApi\Response\OperationResponse', $result); $this->assertEquals('Changing environment label.', $result->message); } @@ -112,8 +124,19 @@ public function testCreateCDEnvironment() ] ); - $this->assertInstanceOf('\AcquiaCloudApi\Response\OperationResponse', $result); + $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); } @@ -128,7 +151,6 @@ 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 fa213b59..1990018f 100644 --- a/tests/Endpoints/FilesTest.php +++ b/tests/Endpoints/FilesTest.php @@ -19,6 +19,14 @@ 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 3a0857e5..e1a2706d 100644 --- a/tests/Endpoints/IdentityProviderTest.php +++ b/tests/Endpoints/IdentityProviderTest.php @@ -67,7 +67,6 @@ 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); } @@ -81,7 +80,6 @@ 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); } @@ -95,7 +93,6 @@ 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); } @@ -114,8 +111,17 @@ public function testUpdateLogForwardingDestination() "-----BEGIN CERTIFICATE-----...-----END CERTIFICATE-----" ); - $this->assertInstanceOf('\AcquiaCloudApi\Response\OperationResponse', $result); + $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 f00bd6bd..7d88f462 100644 --- a/tests/Endpoints/IdesTest.php +++ b/tests/Endpoints/IdesTest.php @@ -65,8 +65,14 @@ public function testCreateIde() 'My new IDE' ); - $this->assertInstanceOf('\AcquiaCloudApi\Response\OperationResponse', $result); + $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 b7bf0680..eb87fe83 100644 --- a/tests/Endpoints/InsightsTest.php +++ b/tests/Endpoints/InsightsTest.php @@ -163,7 +163,6 @@ public function testIgnoreAlert() ); $this->assertInstanceOf('\AcquiaCloudApi\Response\OperationResponse', $result); - $this->assertEquals('Alert ignored.', $result->message); } @@ -180,7 +179,6 @@ public function testRestoreAlert() ); $this->assertInstanceOf('\AcquiaCloudApi\Response\OperationResponse', $result); - $this->assertEquals('Alert restored.', $result->message); } @@ -194,7 +192,6 @@ 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); } @@ -208,7 +205,6 @@ 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 3fd823a3..5725b0ab 100644 --- a/tests/Endpoints/LiveDevTest.php +++ b/tests/Endpoints/LiveDevTest.php @@ -18,7 +18,6 @@ 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); } @@ -31,8 +30,14 @@ public function testLiveDevDisable() $environment = new Environments($client); $result = $environment->disableLiveDev('14-0c7e79ab-1c4a-424e-8446-76ae8be7e851'); - $this->assertInstanceOf('\AcquiaCloudApi\Response\OperationResponse', $result); + $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 eadade0e..fb32a9c5 100644 --- a/tests/Endpoints/LogForwardingTest.php +++ b/tests/Endpoints/LogForwardingTest.php @@ -77,8 +77,23 @@ public function testCreateLogForwardingDestination() 'example.com:1234' ); - $this->assertInstanceOf('\AcquiaCloudApi\Response\OperationResponse', $result); + $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); } @@ -106,7 +121,6 @@ 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); } @@ -120,7 +134,6 @@ 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); } @@ -141,8 +154,23 @@ public function testUpdateLogForwardingDestination() 'example.com:1234' ); - $this->assertInstanceOf('\AcquiaCloudApi\Response\OperationResponse', $result); + $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 08ef5aed..279e815b 100644 --- a/tests/Endpoints/OrganizationsTest.php +++ b/tests/Endpoints/OrganizationsTest.php @@ -87,8 +87,14 @@ public function testCreateOrganizationAdminInvite() $organization = new Organizations($client); $result = $organization->inviteAdmin('14-0c7e79ab-1c4a-424e-8446-76ae8be7e851', 'user@example.com'); - $this->assertInstanceOf('\AcquiaCloudApi\Response\OperationResponse', $result); + $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 a1c0ec5c..561df5f1 100644 --- a/tests/Endpoints/RolesTest.php +++ b/tests/Endpoints/RolesTest.php @@ -69,6 +69,18 @@ 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); } @@ -95,6 +107,15 @@ 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 ffcd129d..a1014161 100644 --- a/tests/Endpoints/ServersTest.php +++ b/tests/Endpoints/ServersTest.php @@ -73,8 +73,14 @@ public function testUpdateServer() ['memcache' => 128] ); - $this->assertInstanceOf('\AcquiaCloudApi\Response\OperationResponse', $result); + $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 2f433411..2760c5ea 100644 --- a/tests/Endpoints/SslCertificatesTest.php +++ b/tests/Endpoints/SslCertificatesTest.php @@ -77,8 +77,19 @@ public function testCreateSslCertificate() false ); - $this->assertInstanceOf('\AcquiaCloudApi\Response\OperationResponse', $result); + $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); } @@ -92,7 +103,6 @@ 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); } @@ -106,7 +116,6 @@ 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); } @@ -120,7 +129,6 @@ 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 d8625e8c..0527a94f 100644 --- a/tests/Endpoints/TeamsTest.php +++ b/tests/Endpoints/TeamsTest.php @@ -65,8 +65,18 @@ public function testCreateTeamInvite() ['access permissions', 'access servers'] ); - $this->assertInstanceOf('\AcquiaCloudApi\Response\OperationResponse', $result); + $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); } @@ -79,8 +89,14 @@ public function testCreateTeam() $organization = new Teams($client); $result = $organization->create('8ff6c046-ec64-4ce4-bea6-27845ec18600', 'Mega Team'); - $this->assertInstanceOf('\AcquiaCloudApi\Response\OperationResponse', $result); + $params = [ + 'form_params' => [ + 'name' => 'Mega Team' + ], + ]; + $this->assertEquals($params, $client->getOptions()); + $this->assertInstanceOf('\AcquiaCloudApi\Response\OperationResponse', $result); $this->assertEquals("Team created.", $result->message); } @@ -93,8 +109,14 @@ public function testRenameTeam() $team = new Teams($client); $result = $team->rename('14-0c7e79ab-1c4a-424e-8446-76ae8be7e851', 'My Cool Application'); - $this->assertInstanceOf('\AcquiaCloudApi\Response\OperationResponse', $result); + $params = [ + 'form_params' => [ + 'name' => 'My Cool Application' + ], + ]; + $this->assertEquals($params, $client->getOptions()); + $this->assertInstanceOf('\AcquiaCloudApi\Response\OperationResponse', $result); $this->assertEquals("Team renamed.", $result->message); } @@ -108,7 +130,6 @@ public function testDeleteTeam() $result = $team->delete('14-0c7e79ab-1c4a-424e-8446-76ae8be7e851'); $this->assertInstanceOf('\AcquiaCloudApi\Response\OperationResponse', $result); - $this->assertEquals("Removed team.", $result->message); } @@ -124,8 +145,14 @@ public function testAddApplicationToTeam() '14-0c7e79ab-1c4a-424e-8446-76ae8be7e851' ); - $this->assertInstanceOf('\AcquiaCloudApi\Response\OperationResponse', $result); + $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 d31ed431..89480ec7 100644 --- a/tests/Endpoints/VariablesTest.php +++ b/tests/Endpoints/VariablesTest.php @@ -59,6 +59,14 @@ 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); } @@ -75,8 +83,15 @@ public function testUpdateVariable() 'value' ); - $this->assertInstanceOf('\AcquiaCloudApi\Response\OperationResponse', $result); + $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 b5585110..db65cc39 100644 --- a/tests/Endpoints/VarnishTest.php +++ b/tests/Endpoints/VarnishTest.php @@ -20,8 +20,17 @@ public function testPurgeVarnish() ['example.com', 'www.example.com'] ); - $this->assertInstanceOf('\AcquiaCloudApi\Response\OperationResponse', $result); + $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); } }