Skip to content

Commit 93e4639

Browse files
Return value from RemoteFilesystem->copy
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
1 parent fca75b0 commit 93e4639

File tree

2 files changed

+11
-12
lines changed

2 files changed

+11
-12
lines changed

src/ACFProInstaller/RemoteFilesystem.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ public function copy(
5959
$progress = true,
6060
$options = []
6161
) {
62-
parent::copy(
62+
return parent::copy(
6363
$originUrl,
6464
$this->acfFileUrl,
6565
$fileName,

tests/ACFProInstaller/RemoteFilesystemTest.php

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,29 +9,28 @@ class RemoteFilesystemTest extends \PHPUnit_Framework_TestCase
99

1010
protected function setUp()
1111
{
12-
$this->io = $this->getMockBuilder('Composer\IO\IOInterface')->getMock();
13-
$this->config = $this->getMockBuilder('Composer\Config')->getMock();
12+
$this->io = $this->getMock('Composer\IO\IOInterface');
1413
}
1514

1615
public function testExtendsComposerRemoteFilesystem()
1716
{
1817
$this->assertInstanceOf(
1918
'Composer\Util\RemoteFilesystem',
20-
new RemoteFilesystem('', $this->io, $this->config)
19+
new RemoteFilesystem('', $this->io)
2120
);
2221
}
2322

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

28-
// Expect an Exception
29-
$this->setExpectedException(
30-
'Composer\Downloader\TransportException',
31-
$acfFileUrl
30+
$this->assertTrue(
31+
$rfs->copy('http://example.org', 'does-not-exist', $file)
3232
);
33-
34-
$rfs = new RemoteFilesystem($acfFileUrl, $this->io, $this->config);
35-
$rfs->copy('orginUrl', 'fileUrl', 'fileName');
33+
$this->assertFileExists($file);
34+
unlink($file);
3635
}
3736
}

0 commit comments

Comments
 (0)