17 private $testComposerHome =
__DIR__ .
'/_files/composer_home';
20 private $fixturesDir =
__DIR__ .
'/_files/';
23 private $originalComposerHome;
30 $this->fileDriver =
new File();
31 $this->originalComposerHome = getenv(
'COMPOSER_HOME');
32 putenv(
'COMPOSER_HOME');
37 if ($this->originalComposerHome) {
38 putenv(
'COMPOSER_HOME=' . $this->originalComposerHome);
42 if (
is_dir($this->testComposerHome)) {
43 $this->fileDriver->deleteDirectory($this->testComposerHome);
47 public function testCreate()
50 $dirListMock = $this->getMockBuilder(DirectoryList::class)->disableOriginalConstructor()->getMock();
51 $composerJsonFinderMock = $this->getMockBuilder(ComposerJsonFinder::class)
52 ->disableOriginalConstructor()
55 $composerJsonPath = $this->fixturesDir .
'composer.json';
57 $dirListMock->expects($this->once())
59 ->willReturn($this->testComposerHome);
60 $composerJsonFinderMock->expects($this->once())
61 ->method(
'findComposerJson')
62 ->willReturn($composerJsonPath);
66 ComposerFactory::class,
68 'directoryList' => $dirListMock,
69 'composerJsonFinder' => $composerJsonFinderMock
73 $this->assertInstanceOf(\Composer\Composer::class,
$factory->create());
defined('TESTS_BP')||define('TESTS_BP' __DIR__