Skip to content

Commit

Permalink
Return value from RemoteFilesystem->copy
Browse files Browse the repository at this point in the history
RemoteFilesystem did not return the value from parent::copy and would
fail the improved unit test (inspired by the unit test for the copy
method of composer).

See:
https://github.com/composer/composer/blob/master/tests/Composer/Test/Util/RemoteFilesystemTest.php
  • Loading branch information
PhilippBaschke committed Apr 23, 2016
1 parent fca75b0 commit 93e4639
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 12 deletions.
2 changes: 1 addition & 1 deletion src/ACFProInstaller/RemoteFilesystem.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public function copy(
$progress = true,
$options = []
) {
parent::copy(
return parent::copy(
$originUrl,
$this->acfFileUrl,
$fileName,
Expand Down
21 changes: 10 additions & 11 deletions tests/ACFProInstaller/RemoteFilesystemTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,29 +9,28 @@ class RemoteFilesystemTest extends \PHPUnit_Framework_TestCase

protected function setUp()
{
$this->io = $this->getMockBuilder('Composer\IO\IOInterface')->getMock();
$this->config = $this->getMockBuilder('Composer\Config')->getMock();
$this->io = $this->getMock('Composer\IO\IOInterface');
}

public function testExtendsComposerRemoteFilesystem()
{
$this->assertInstanceOf(
'Composer\Util\RemoteFilesystem',
new RemoteFilesystem('', $this->io, $this->config)
new RemoteFilesystem('', $this->io)
);
}

// Inspired by testCopy of Composer
public function testCopyUsesAcfFileUrl()
{
$acfFileUrl = 'acfFileUrl';
$acfFileUrl = 'file://'.__FILE__;
$rfs = new RemoteFilesystem($acfFileUrl, $this->io);
$file = tempnam(sys_get_temp_dir(), 'pb');

// Expect an Exception
$this->setExpectedException(
'Composer\Downloader\TransportException',
$acfFileUrl
$this->assertTrue(
$rfs->copy('http://example.org', 'does-not-exist', $file)
);

$rfs = new RemoteFilesystem($acfFileUrl, $this->io, $this->config);
$rfs->copy('orginUrl', 'fileUrl', 'fileName');
$this->assertFileExists($file);
unlink($file);
}
}

0 comments on commit 93e4639

Please sign in to comment.