From 93e4639825b21076a0d4d26720250187fee35a4c Mon Sep 17 00:00:00 2001 From: Philipp Baschke Date: Sat, 23 Apr 2016 17:51:45 +0200 Subject: [PATCH] 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 --- src/ACFProInstaller/RemoteFilesystem.php | 2 +- .../ACFProInstaller/RemoteFilesystemTest.php | 21 +++++++++---------- 2 files changed, 11 insertions(+), 12 deletions(-) diff --git a/src/ACFProInstaller/RemoteFilesystem.php b/src/ACFProInstaller/RemoteFilesystem.php index cdd36a6..d934b02 100644 --- a/src/ACFProInstaller/RemoteFilesystem.php +++ b/src/ACFProInstaller/RemoteFilesystem.php @@ -59,7 +59,7 @@ public function copy( $progress = true, $options = [] ) { - parent::copy( + return parent::copy( $originUrl, $this->acfFileUrl, $fileName, diff --git a/tests/ACFProInstaller/RemoteFilesystemTest.php b/tests/ACFProInstaller/RemoteFilesystemTest.php index d4d1529..7a7426c 100644 --- a/tests/ACFProInstaller/RemoteFilesystemTest.php +++ b/tests/ACFProInstaller/RemoteFilesystemTest.php @@ -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); } }