Skip to content

Commit

Permalink
Merge pull request #100 from drbyte/php71
Browse files Browse the repository at this point in the history
Add basic changes to allow php71
  • Loading branch information
adamwathan authored Jul 28, 2016
2 parents 58e3c07 + 77cd98f commit 7e9e028
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 6 deletions.
7 changes: 5 additions & 2 deletions cli/Valet/Brew.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ function installed($formula)
*/
function hasInstalledPhp()
{
return $this->installed('php70')
return $this->installed('php71')
|| $this->installed('php70')
|| $this->installed('php56')
|| $this->installed('php55');
}
Expand Down Expand Up @@ -137,7 +138,9 @@ function linkedPhp()

$resolvedPath = $this->files->readLink('/usr/local/bin/php');

if (strpos($resolvedPath, 'php70') !== false) {
if (strpos($resolvedPath, 'php71') !== false) {
return 'php71';
} elseif (strpos($resolvedPath, 'php70') !== false) {
return 'php70';
} elseif (strpos($resolvedPath, 'php56') !== false) {
return 'php56';
Expand Down
9 changes: 6 additions & 3 deletions cli/Valet/PhpFpm.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ public function __construct(Brew $brew, CommandLine $cli, Filesystem $files)
*/
public function install()
{
if (! $this->brew->installed('php70') &&
if (! $this->brew->installed('php71') &&
! $this->brew->installed('php70') &&
! $this->brew->installed('php56') &&
! $this->brew->installed('php55')) {
$this->brew->ensureInstalled('php70', $this->taps);
Expand Down Expand Up @@ -83,7 +84,7 @@ public function restart()
*/
public function stop()
{
$this->brew->stopService('php55', 'php56', 'php70');
$this->brew->stopService('php55', 'php56', 'php70', 'php71');
}

/**
Expand All @@ -93,7 +94,9 @@ public function stop()
*/
public function fpmConfigPath()
{
if ($this->brew->linkedPhp() === 'php70') {
if ($this->brew->linkedPhp() === 'php71') {
return '/usr/local/etc/php/7.1/php-fpm.d/www.conf';
} elseif ($this->brew->linkedPhp() === 'php70') {
return '/usr/local/etc/php/7.0/php-fpm.d/www.conf';
} elseif ($this->brew->linkedPhp() === 'php56') {
return '/usr/local/etc/php/5.6/php-fpm.conf';
Expand Down
5 changes: 4 additions & 1 deletion tests/BrewTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,18 +66,21 @@ public function test_installed_returns_false_when_given_formula_is_not_installed
public function test_has_installed_php_indicates_if_php_is_installed_via_brew()
{
$brew = Mockery::mock(Brew::class.'[installed]', [new CommandLine, new Filesystem]);
$brew->shouldReceive('installed')->once()->with('php70')->andReturn(true);
$brew->shouldReceive('installed')->once()->with('php71')->andReturn(true);
$brew->shouldReceive('installed')->with('php70')->andReturn(true);
$brew->shouldReceive('installed')->with('php56')->andReturn(true);
$brew->shouldReceive('installed')->with('php55')->andReturn(true);
$this->assertTrue($brew->hasInstalledPhp());

$brew = Mockery::mock(Brew::class.'[installed]', [new CommandLine, new Filesystem]);
$brew->shouldReceive('installed')->once()->with('php70')->andReturn(true);
$brew->shouldReceive('installed')->with('php71')->andReturn(false);
$brew->shouldReceive('installed')->with('php56')->andReturn(false);
$brew->shouldReceive('installed')->with('php55')->andReturn(false);
$this->assertTrue($brew->hasInstalledPhp());

$brew = Mockery::mock(Brew::class.'[installed]', [new CommandLine, new Filesystem]);
$brew->shouldReceive('installed')->once()->with('php71')->andReturn(false);
$brew->shouldReceive('installed')->once()->with('php70')->andReturn(false);
$brew->shouldReceive('installed')->once()->with('php56')->andReturn(false);
$brew->shouldReceive('installed')->once()->with('php55')->andReturn(false);
Expand Down

0 comments on commit 7e9e028

Please sign in to comment.