fileDriver = new File(); $this->originalComposerHome = getenv('COMPOSER_HOME'); putenv('COMPOSER_HOME'); } public function tearDown() { if ($this->originalComposerHome) { putenv('COMPOSER_HOME=' . $this->originalComposerHome); } // Composer home directory is created one level up from where composer.json is. if (is_dir($this->testComposerHome)) { $this->fileDriver->deleteDirectory($this->testComposerHome); } } public function testCreate() { $objectManager = new ObjectManager($this); $dirListMock = $this->getMockBuilder(DirectoryList::class)->disableOriginalConstructor()->getMock(); $composerJsonFinderMock = $this->getMockBuilder(ComposerJsonFinder::class) ->disableOriginalConstructor() ->getMock(); $composerJsonPath = $this->fixturesDir . 'composer.json'; $dirListMock->expects($this->once()) ->method('getPath') ->willReturn($this->testComposerHome); $composerJsonFinderMock->expects($this->once()) ->method('findComposerJson') ->willReturn($composerJsonPath); /** @var ComposerFactory $factory */ $factory = $objectManager->getObject( ComposerFactory::class, [ 'directoryList' => $dirListMock, 'composerJsonFinder' => $composerJsonFinderMock ] ); $this->assertInstanceOf(\Composer\Composer::class, $factory->create()); } }