Skip to content

Commit

Permalink
Merge pull request #110 from mikemeier/master
Browse files Browse the repository at this point in the history
Fix parse_url expects string, resource given error
  • Loading branch information
aztech-dev authored Jul 19, 2016
2 parents 383742d + 8115d96 commit 28b7c0e
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
8 changes: 8 additions & 0 deletions src/Resource/Resource.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,10 @@ public function canBeProcessedInPlace($context)
*/
public function getContextForProcessInSinglePlace()
{
if (!is_string($this->original)) {
return null;
}

if (!$this->isLocal()) {
return null;
}
Expand All @@ -101,6 +105,10 @@ public function getContextForProcessInSinglePlace()
*/
private function isLocal()
{
if (!is_string($this->original)) {
return false;
}

$data = parse_url($this->original);

return isset($data['path']);
Expand Down
14 changes: 12 additions & 2 deletions tests/Tests/Resource/ResourceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,19 @@ public function testGetTargetAndOriginal()
public function testCanBeProcessedInPlace($expected, $context, $original, $target)
{
$resource = new Resource($original, $target);
$result = $resource->canBeProcessedInPlace($context);

$this->assertInternalType('boolean', $resource->canBeProcessedInPlace($context));
$this->assertEquals($expected, $resource->canBeProcessedInPlace($context));
$this->assertInternalType('boolean', $result);
$this->assertEquals($expected, $result);
}

public function testGetContextForProcessInSinglePlace()
{
$resource = new Resource(fopen(__FILE__, 'rb'), 'file1');
$this->assertNull($resource->getContextForProcessInSinglePlace());

$resource = new Resource('/path/to/file1', 'file1');
$this->assertEquals('/path/to', $resource->getContextForProcessInSinglePlace());
}

public function provideProcessInPlaceData()
Expand Down

0 comments on commit 28b7c0e

Please sign in to comment.