1
0
Fork 0
mirror of https://github.com/composer/composer synced 2025-05-09 00:22:53 +00:00

Make FileDownloader always download file first in vendor-dir/composer/$tmp instead of next to install path to avoid issues with custom installers not being loaded when downloading on first install, and use cleanup method properly

This commit is contained in:
Jordi Boggiano 2020-03-28 20:38:50 +01:00
parent 918768fc54
commit 1b1d59ee6c
No known key found for this signature in database
GPG key ID: 7BBD42C429EC80BC
6 changed files with 70 additions and 32 deletions

View file

@ -16,6 +16,8 @@ use Composer\Test\TestCase;
class ArchiveDownloaderTest extends TestCase
{
protected $config;
public function testGetFileName()
{
$packageMock = $this->getMockBuilder('Composer\Package\PackageInterface')->getMock();
@ -28,8 +30,13 @@ class ArchiveDownloaderTest extends TestCase
$method = new \ReflectionMethod($downloader, 'getFileName');
$method->setAccessible(true);
$this->config->expects($this->any())
->method('get')
->with('vendor-dir')
->will($this->returnValue('/vendor'));
$first = $method->invoke($downloader, $packageMock, '/path');
$this->assertRegExp('#/path_[a-z0-9]+\.js#', $first);
$this->assertRegExp('#/vendor/composer/[a-z0-9]+\.js#', $first);
$this->assertSame($first, $method->invoke($downloader, $packageMock, '/path'));
}
@ -158,8 +165,8 @@ class ArchiveDownloaderTest extends TestCase
'Composer\Downloader\ArchiveDownloader',
array(
$io = $this->getMockBuilder('Composer\IO\IOInterface')->getMock(),
$config = $this->getMockBuilder('Composer\Config')->getMock(),
new \Composer\Util\HttpDownloader($io, $config),
$this->config = $this->getMockBuilder('Composer\Config')->getMock(),
new \Composer\Util\HttpDownloader($io, $this->config),
)
);
}