Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reenabled self:console in PHP 7.1 #1664

Merged
merged 1 commit into from
Mar 15, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
All notable changes to this project will be documented in this file. This project adheres to [Semantic Versioning](http://semver.org)

## MASTER
### Changed
- Reenabled the `self:console` command in PHP 7.1. (#1664)
### Fixed
- Corrected typo in `aliases` command which prevented the authorization hook from working on it. (#1663)

Expand Down
2 changes: 1 addition & 1 deletion config/constants.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
---

# App
TERMINUS_VERSION: '1.1.1'
TERMINUS_VERSION: '1.1.2-dev'

# Connectivity
TERMINUS_HOST: 'terminus.pantheon.io'
Expand Down
6 changes: 0 additions & 6 deletions src/Commands/Self/ConsoleCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,9 @@ class ConsoleCommand extends TerminusCommand implements SiteAwareInterface
* @usage Opens an interactive PHP console within Terminus.
* @usage <site> Opens an interactive PHP console within Terminus and loads <site> as $site.
* @usage <site>.<env> Opens an interactive PHP console within Terminus and loads <site> and its <env> environment as $site and $env.
*
* @todo Remove the version check when PSYSH is updated to work in PHP 7.1.
*/
public function console($site_env = null)
{
if ((version_compare(PHP_VERSION, '7.1.0') >= 0) || (boolean)$this->getConfig()->get('test_mode_pass')) {
$this->log()->error('This command is not compatible with PHP 7.1.');
return;
}
list($site, $env) = $this->getOptionalSiteEnv($site_env, null);
eval(\Psy\sh());
}
Expand Down
54 changes: 0 additions & 54 deletions tests/unit_tests/Commands/Self/ConsoleCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,68 +28,14 @@ public function setUp()

$this->command = new ConsoleCommand();
$this->command->setSites($this->sites);

// We do not expect to use the config object in 7.1+
if (!$this->isRunningVersion71()) {
$this->config = $this->getMockBuilder(TerminusConfig::class)
->disableOriginalConstructor()
->getMock();
$this->command->setConfig($this->config);
}
}

/**
* Tests the self:console command
*
* @todo Remove the check and incomplete from this test when PSYSH is updated to work with PHP 7.1.
*/
public function testConsole()
{
if ($this->isRunningVersion71()) {
$this->markTestIncomplete('Incompatible message only printed on PHP >= 7.1.');
}

$this->config->expects($this->once())
->method('get')
->with($this->equalTo('test_mode_pass'))
->willReturn(false);
$out = $this->command->console('site.env');
$this->assertNull($out);
}

/**
* Testing the self:console command when in an incompatible PHP version
*
* @todo Remove this test when PSYSH is updated to work with PHP 7.1.
*/
public function testConsoleIncompatibleMessage()
{
$logger = $this->getMockBuilder(LoggerInterface::class)
->disableOriginalConstructor()
->getMock();

if (!$this->isRunningVersion71()) {
$this->config->expects($this->once())
->method('get')
->with($this->equalTo('test_mode_pass'))
->willReturn(true);
}
$logger->expects($this->once())
->method('error')
->with($this->equalTo('This command is not compatible with PHP 7.1.'));

$this->command->setLogger($logger);
$out = $this->command->console('site.env');
$this->assertNull($out);
}

/**
* Determines whether the code is being run by PHP 7.1
*
* @return boolean
*/
private function isRunningVersion71()
{
return (version_compare(PHP_VERSION, '7.1.0') >= 0);
}
}