-
Notifications
You must be signed in to change notification settings - Fork 47
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixes #120: Keeping case intact. (#126)
- Loading branch information
Showing
3 changed files
with
54 additions
and
58 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,7 +17,6 @@ class ApiCommandTest extends CommandTestBase { | |
|
||
public function setUp($output = NULL): void { | ||
parent::setUp($output); | ||
putenv('ACQUIA_CLI_USE_COMMAND_CACHE=0'); | ||
putenv('ACQUIA_CLI_USE_CLOUD_API_SPEC_CACHE=1'); | ||
} | ||
|
||
|
@@ -74,17 +73,16 @@ public function testApiCommandExecutionForHttpPost(): void { | |
public function providerTestApiCommandDefinitionParameters(): array { | ||
$api_accounts_ssh_keys_list_usage = 'api:accounts:ssh-keys-list --from="-7d" --to="-1d" --sort="field1,-field2" --limit="10" --offset="10" '; | ||
return [ | ||
['0', '0', 'api:accounts:ssh-keys-list', 'get', $api_accounts_ssh_keys_list_usage], | ||
['1', '0', 'api:accounts:ssh-keys-list', 'get', $api_accounts_ssh_keys_list_usage], | ||
['1', '1', 'api:accounts:ssh-keys-list', 'get', $api_accounts_ssh_keys_list_usage], | ||
['1', '1', 'api:environments:domains-clear-varnish', 'post', '12-d314739e-296f-11e9-b210-d663bd873d93 --domains="domain1.example.com,domain2.example.com"'], | ||
['0', 'api:accounts:ssh-keys-list', 'get', $api_accounts_ssh_keys_list_usage], | ||
['1', 'api:accounts:ssh-keys-list', 'get', $api_accounts_ssh_keys_list_usage], | ||
['1', 'api:accounts:ssh-keys-list', 'get', $api_accounts_ssh_keys_list_usage], | ||
['1', 'api:environments:domains-clear-varnish', 'post', '12-d314739e-296f-11e9-b210-d663bd873d93 --domains="domain1.example.com,domain2.example.com"'], | ||
]; | ||
} | ||
|
||
/** | ||
* @dataProvider providerTestApiCommandDefinitionParameters | ||
* | ||
* @param $use_command_cache | ||
* @param $use_spec_cache | ||
* @param $command_name | ||
* @param $method | ||
|
@@ -93,9 +91,8 @@ public function providerTestApiCommandDefinitionParameters(): array { | |
* @throws \Psr\Cache\InvalidArgumentException | ||
* @group noCache | ||
*/ | ||
public function testApiCommandDefinitionParameters($use_spec_cache, $use_command_cache, $command_name, $method, $usage): void { | ||
public function testApiCommandDefinitionParameters($use_spec_cache, $command_name, $method, $usage): void { | ||
putenv('ACQUIA_CLI_USE_CLOUD_API_SPEC_CACHE=' . $use_spec_cache); | ||
putenv('ACQUIA_CLI_USE_COMMAND_CACHE=' . $use_command_cache); | ||
|
||
$this->command = $this->getApiCommandByName($command_name); | ||
$resource = $this->getResourceFromSpec($this->command->getPath(), $method); | ||
|
@@ -105,20 +102,21 @@ public function testApiCommandDefinitionParameters($use_spec_cache, $use_command | |
$this->assertEquals($expected_command_name, $this->command->getName()); | ||
|
||
foreach ($resource['parameters'] as $parameter) { | ||
$param_name = strtolower(str_replace('#/components/parameters/', '', $parameter['$ref'])); | ||
$param_key = str_replace('#/components/parameters/', '', $parameter['$ref']); | ||
$param = $this->getCloudApiSpec()['components']['parameters'][$param_key]; | ||
$this->assertTrue( | ||
$this->command->getDefinition()->hasOption($param_name) || | ||
$this->command->getDefinition()->hasArgument($param_name), | ||
"Command $expected_command_name does not have expected argument or option $param_name" | ||
$this->command->getDefinition()->hasOption($param['name']) || | ||
$this->command->getDefinition()->hasArgument($param['name']), | ||
"Command $expected_command_name does not have expected argument or option {$param['name']}" | ||
); | ||
} | ||
$this->assertStringContainsString($usage, $this->command->getUsages()[0]); | ||
} | ||
|
||
public function providerTestApiCommandDefinitionRequestBody(): array { | ||
return [ | ||
['1', 'api:accounts:ssh-key-create', 'post', 'api:accounts:ssh-key-create "mykey" "ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAklOUpkDHrfHY17SbrmTIpNLTGK9Tjom/BWDSUGPl+nafzlHDTYW7hdI4yZ5ew18JH4JW9jbhUFrviQzM7xlELEVf4h9lFX5QVkbPppSwg0cda3Pbv7kOdJ/MTyBlWXFCR+HAo3FXRitBqxiX1nKhXpHAZsMciLq8V6RjsNAQwdsdMFvSlVK/7XAt3FaoJoAsncM1Q9x5+3V0Ww68/eIFmb1zuUFljQJKprrX88XypNDvjYNby6vw/Pb0rwert/EnmZ+AW4OZPnTPI89ZPmVMLuayrD2cE86Z/il8b+gw3r3+1nKatmIkjn2so1d01QraTlMqVSsbxNrRFi9wrf+M7Q== [email protected]" '], | ||
['1', 'api:environments:domains-clear-varnish', 'post', 'api:environments:domains-clear-varnish 12-d314739e-296f-11e9-b210-d663bd873d93 --domains="domain1.example.com,domain2.example.com" '], | ||
['api:accounts:ssh-key-create', 'post', 'api:accounts:ssh-key-create "mykey" "ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAklOUpkDHrfHY17SbrmTIpNLTGK9Tjom/BWDSUGPl+nafzlHDTYW7hdI4yZ5ew18JH4JW9jbhUFrviQzM7xlELEVf4h9lFX5QVkbPppSwg0cda3Pbv7kOdJ/MTyBlWXFCR+HAo3FXRitBqxiX1nKhXpHAZsMciLq8V6RjsNAQwdsdMFvSlVK/7XAt3FaoJoAsncM1Q9x5+3V0Ww68/eIFmb1zuUFljQJKprrX88XypNDvjYNby6vw/Pb0rwert/EnmZ+AW4OZPnTPI89ZPmVMLuayrD2cE86Z/il8b+gw3r3+1nKatmIkjn2so1d01QraTlMqVSsbxNrRFi9wrf+M7Q== [email protected]" '], | ||
['api:environments:domains-clear-varnish', 'post', 'api:environments:domains-clear-varnish 12-d314739e-296f-11e9-b210-d663bd873d93 --domains="domain1.example.com,domain2.example.com" '], | ||
]; | ||
} | ||
|
||
|
@@ -131,14 +129,13 @@ public function providerTestApiCommandDefinitionRequestBody(): array { | |
* | ||
* @throws \Psr\Cache\InvalidArgumentException | ||
*/ | ||
public function testApiCommandDefinitionRequestBody($use_command_cache, $command_name, $method, $usage): void { | ||
public function testApiCommandDefinitionRequestBody($command_name, $method, $usage): void { | ||
$this->command = $this->getApiCommandByName($command_name); | ||
$resource = $this->getResourceFromSpec($this->command->getPath(), $method); | ||
foreach ($resource['requestBody']['content']['application/json']['example'] as $key => $value) { | ||
$param_name = strtolower($key); | ||
$this->assertTrue($this->command->getDefinition()->hasArgument($param_name) || $this->command->getDefinition() | ||
->hasOption($param_name), | ||
"Command {$this->command->getName()} does not have expected argument or option $param_name"); | ||
foreach ($resource['requestBody']['content']['application/json']['example'] as $prop_key => $value) { | ||
$this->assertTrue($this->command->getDefinition()->hasArgument($prop_key) || $this->command->getDefinition() | ||
->hasOption($prop_key), | ||
"Command {$this->command->getName()} does not have expected argument or option $prop_key"); | ||
} | ||
$this->assertStringContainsString($usage, $this->command->getUsages()[0]); | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters