From 68ebba6f5748ef00a166393192f51dbc613b4656 Mon Sep 17 00:00:00 2001 From: tesladethray Date: Tue, 10 Jan 2017 17:54:32 -0800 Subject: [PATCH] Removed framework check from remote-type commands --- CHANGELOG.md | 1 + src/Commands/Remote/DrushCommand.php | 8 ---- src/Commands/Remote/SSHBaseCommand.php | 25 ---------- src/Commands/Remote/WPCommand.php | 8 ---- tests/features/drush.feature | 5 -- tests/features/wp-cli.feature | 5 -- .../Commands/Remote/DummyCommand.php | 14 ++---- .../Commands/Remote/SSHBaseCommandTest.php | 46 ++----------------- 8 files changed, 7 insertions(+), 105 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 05468bc9d..5b9f889ac 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ All notable changes to this project will be documented in this file. This projec ## MASTER ### Added - Added `--to=` option to `backup:get` to allow specifying of a local download location. (#1520) +- Removed framework type check from `drush` and `wp` commands. (#1521) ## 1.0.0-beta.2 - 2017-01-10 ### Fixed diff --git a/src/Commands/Remote/DrushCommand.php b/src/Commands/Remote/DrushCommand.php index ad59722b8..7665d6d90 100755 --- a/src/Commands/Remote/DrushCommand.php +++ b/src/Commands/Remote/DrushCommand.php @@ -14,14 +14,6 @@ class DrushCommand extends SSHBaseCommand */ protected $command = 'drush'; - /** - * @inheritdoc - */ - protected $valid_frameworks = [ - 'drupal', - 'drupal8', - ]; - /** * Runs a Drush command remotely on a site's environment. * diff --git a/src/Commands/Remote/SSHBaseCommand.php b/src/Commands/Remote/SSHBaseCommand.php index bbb77985a..c60782e49 100755 --- a/src/Commands/Remote/SSHBaseCommand.php +++ b/src/Commands/Remote/SSHBaseCommand.php @@ -22,10 +22,6 @@ abstract class SSHBaseCommand extends TerminusCommand implements SiteAwareInterf * @var string Name of the command to be run as it will be used on server */ protected $command = ''; - /** - * @var array - */ - protected $valid_frameworks = []; /** * @var Site */ @@ -91,7 +87,6 @@ function ($buffer) use ($output) { protected function validateEnvironment($site, $environment) { $this->validateConnectionMode($environment->get('connection_mode')); - $this->validateFramework($site->get('framework')); } /** @@ -109,26 +104,6 @@ protected function validateConnectionMode($mode) } } - /** - * Validates the framework being used - * - * @param string $framework - * @throws TerminusException - */ - protected function validateFramework($framework) - { - if (!in_array($framework, $this->valid_frameworks)) { - throw new TerminusException( - 'The {command} command is only available on sites running {frameworks}. The framework for this site is {framework}.', - [ - 'command' => $this->command, - 'frameworks' => implode(', ', $this->valid_frameworks), - 'framework' => $framework, - ] - ); - } - } - /** * Gets the command-line args * diff --git a/src/Commands/Remote/WPCommand.php b/src/Commands/Remote/WPCommand.php index d9b4e2f15..8b3034a5e 100755 --- a/src/Commands/Remote/WPCommand.php +++ b/src/Commands/Remote/WPCommand.php @@ -14,14 +14,6 @@ class WPCommand extends SSHBaseCommand */ protected $command = 'wp'; - /** - * @inheritdoc - */ - protected $valid_frameworks = [ - 'wordpress', - 'wordpress_network', - ]; - /** * Runs a WP-CLI command remotely on a site's environment. * diff --git a/tests/features/drush.feature b/tests/features/drush.feature index e76c8bada..d6dd867a1 100644 --- a/tests/features/drush.feature +++ b/tests/features/drush.feature @@ -12,8 +12,3 @@ Feature: Running Drush Commands on a Drupal Site When I run: terminus drush [[test_site_name]].dev -- version Then I should get: "Terminus is in test mode" And I should get: "drush version" - - @vcr wp.yml - Scenario: Running a drush command on a Wordpress site is not possible - When I run: terminus drush [[test_site_name]].dev -- status - Then I should see an error message: The drush command is only available on sites running drupal, drupal8. The framework for this site is wordpress. diff --git a/tests/features/wp-cli.feature b/tests/features/wp-cli.feature index 56d892dcc..9625a3551 100644 --- a/tests/features/wp-cli.feature +++ b/tests/features/wp-cli.feature @@ -12,8 +12,3 @@ Feature: Running WP-CLI Commands on a Drupal Site When I run: terminus wp [[test_site_name]].dev -- cli version Then I should get: "Terminus is in test mode" And I should get: "wp cli version" - - @vcr drush.yml - Scenario: Running a WP-CLI command on a Drupal site is not possible - When I run: terminus wp [[test_site_name]].dev -- cli version - Then I should see an error message: The wp command is only available on sites running wordpress, wordpress_network. The framework for this site is drupal8. diff --git a/tests/unit_tests/Commands/Remote/DummyCommand.php b/tests/unit_tests/Commands/Remote/DummyCommand.php index 412b2d44f..ec116945f 100644 --- a/tests/unit_tests/Commands/Remote/DummyCommand.php +++ b/tests/unit_tests/Commands/Remote/DummyCommand.php @@ -11,22 +11,14 @@ */ class DummyCommand extends SSHBaseCommand { + /** + * @var string + */ protected $command = 'dummy'; - protected $unavailable_commands = [ - 'avoided' => 'alternative', - 'no-alternative' => '', - ]; - - protected $valid_frameworks = [ - 'framework-a', - 'framework-b', - ]; - public function dummyCommand($site_env_id, array $dummy_args) { $this->prepareEnvironment($site_env_id); - return $this->executeCommand($dummy_args); } } diff --git a/tests/unit_tests/Commands/Remote/SSHBaseCommandTest.php b/tests/unit_tests/Commands/Remote/SSHBaseCommandTest.php index 97262758a..23634b16b 100644 --- a/tests/unit_tests/Commands/Remote/SSHBaseCommandTest.php +++ b/tests/unit_tests/Commands/Remote/SSHBaseCommandTest.php @@ -32,7 +32,6 @@ public function testExecuteCommand() { $dummy_output = 'dummy output'; $options = ['arg1', 'arg2',]; - $framework_name = 'framework-a'; $site_name = 'site name'; $mode = 'sftp'; $command = 'dummy ' . implode(' ', $options); @@ -44,11 +43,10 @@ public function testExecuteCommand() ->willReturn($mode); $this->site->expects($this->any())->method('get') ->withConsecutive( - [$this->equalTo('framework'),], [$this->equalTo('name'),], [$this->equalTo('name'),] ) - ->willReturnOnConsecutiveCalls($framework_name, $site_name, $site_name); + ->willReturnOnConsecutiveCalls($site_name, $site_name); $this->logger->expects($this->once()) ->method('log') ->with( @@ -77,7 +75,6 @@ public function testExecuteCommandNonzeroStatus() { $dummy_output = 'dummy output'; $options = ['arg1', 'arg2',]; - $framework_name = 'framework-a'; $site_name = 'site name'; $mode = 'sftp'; $status_code = 1; @@ -90,11 +87,10 @@ public function testExecuteCommandNonzeroStatus() ->willReturn($mode); $this->site->expects($this->any())->method('get') ->withConsecutive( - [$this->equalTo('framework'),], [$this->equalTo('name'),], [$this->equalTo('name'),] ) - ->willReturnOnConsecutiveCalls($framework_name, $site_name, $site_name); + ->willReturnOnConsecutiveCalls($site_name, $site_name); $this->environment->expects($this->once()) ->method('sendCommandViaSsh') ->with($this->equalTo($command)) @@ -118,40 +114,6 @@ public function testExecuteCommandNonzeroStatus() $this->assertNull($out); } - /** - * Tests command execution when attempting to execute with an invalid framework - */ - public function testExecuteCommandInvalidFramework() - { - $options = ['arg1', 'arg2',]; - $framework_name = 'framework'; - $site_name = 'site name'; - $mode = 'sftp'; - - $this->environment->expects($this->once()) - ->method('get') - ->with($this->equalTo('connection_mode')) - ->willReturn($mode); - $this->site->expects($this->any())->method('get') - ->withConsecutive( - [$this->equalTo('framework'),], - [$this->equalTo('name'),] - ) - ->willReturnOnConsecutiveCalls($framework_name, $site_name); - $this->logger->expects($this->never()) - ->method('log'); - $this->environment->expects($this->never()) - ->method('sendCommandViaSsh'); - - $this->setExpectedException( - TerminusException::class, - "The dummy command is only available on sites running framework-a, framework-b. The framework for this site is $framework_name." - ); - - $out = $this->command->dummyCommand("$site_name.env", $options); - $this->assertNull($out); - } - /** * Tests command execution when in git mode */ @@ -159,7 +121,6 @@ public function testExecuteCommandInGitMode() { $dummy_output = 'dummy output'; $options = ['arg1', 'arg2',]; - $framework_name = 'framework-a'; $site_name = 'site name'; $mode = 'git'; $status_code = 0; @@ -180,11 +141,10 @@ public function testExecuteCommandInGitMode() ); $this->site->expects($this->any())->method('get') ->withConsecutive( - [$this->equalTo('framework'),], [$this->equalTo('name'),], [$this->equalTo('name'),] ) - ->willReturnOnConsecutiveCalls($framework_name, $site_name, $site_name); + ->willReturnOnConsecutiveCalls($site_name, $site_name); $this->logger->expects($this->at(1)) ->method('log') ->with(