Skip to content
This repository has been archived by the owner on Sep 5, 2020. It is now read-only.

Commit

Permalink
Fixed an issue where binaries paths would be shared between connections
Browse files Browse the repository at this point in the history
  • Loading branch information
Anahkiasen committed Dec 8, 2014
1 parent cbf020b commit 2e444da
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 5 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Expand Up @@ -15,6 +15,7 @@
- Fixed incorrect replacing of slashs and backslashes outside of paths
- Fixed ability to pass an unexisting release to the Rollback task
- Fixed a bug where using SVN would cause Rocketeer to execute empty commands during cloning
- Fixed an issue where binaries paths would be shared between connections

2.0.3 - 2014-11-12
------------------
Expand Down
18 changes: 15 additions & 3 deletions src/Rocketeer/Traits/BashModules/Binaries.php
Expand Up @@ -84,7 +84,7 @@ public function artisan()
public function which($binary, $fallback = null, $prompt = true)
{
$locations = array(
$this->localStorage->get('paths.'.$binary),
$this->localStorage->get($this->getBinaryStoragePath($binary)),
$this->paths->getPath($binary),
$binary,
);
Expand Down Expand Up @@ -137,9 +137,9 @@ protected function whichFrom($binary, array $locations)
// Store found location or remove it if invalid
if (!$this->local) {
if ($location) {
$this->localStorage->set('paths.'.$binary, $location);
$this->localStorage->set($this->getBinaryStoragePath($binary), $location);
} else {
$this->localStorage->forget('paths.'.$binary);
$this->localStorage->forget($this->getBinaryStoragePath($binary));
}
}

Expand Down Expand Up @@ -180,4 +180,16 @@ protected function versionCheck($version, $operator = '>=')

return false;
}

/**
* Get the path in which to store/retrieve a binary's path
*
* @param string $binary
*
* @return string
*/
protected function getBinaryStoragePath($binary)
{
return 'paths.'.$this->connections->getConnection().'.'.$binary;
}
}
27 changes: 25 additions & 2 deletions tests/Traits/BashModules/BinariesTest.php
Expand Up @@ -37,10 +37,33 @@ public function testStoredPathsAreInvalidatedIfIncorrect()
->shouldReceive('runRaw')->andReturn('false');
}, false);

$this->localStorage->set('paths.composer', 'foobar');
$this->localStorage->set('paths.production.composer', 'foobar');

$this->assertEquals('composer', $this->task->which('composer'));
$this->assertNull($this->localStorage->get('paths.composer'));
$this->assertNull($this->localStorage->get('paths.production.composer'));
}

public function testPathsAreScopedToConnection()
{
$this->mock('rocketeer.remote', 'Remote', function ($mock) {
return $mock
->shouldReceive('run')->with(['which'], Mockery::any())->andReturn(null)
->shouldReceive('run')->with(['which composer'], Mockery::any())->andReturn(null)
->shouldReceive('run')->with(['which production'], Mockery::any())->andReturnUsing(function ($a, $b) {
$b('production');
})
->shouldReceive('run')->with(['which staging'], Mockery::any())->andReturnUsing(function ($a, $b) {
$b('staging');
})
->shouldReceive('runRaw')->andReturn('false');
}, false);

$this->localStorage->set('paths.production.composer', 'production');
$this->localStorage->set('paths.staging.composer', 'staging');

$this->assertEquals('production', $this->task->which('composer'));
$this->connections->setConnection('staging');
$this->assertEquals('staging', $this->task->which('composer'));
}

public function testCanSetPathToPhpAndArtisan()
Expand Down

0 comments on commit 2e444da

Please sign in to comment.