home = self::getUniqueTmpDirectory(); $this->config = new Config(); $this->config->merge([ 'config' => [ 'home' => $this->home, ], ]); $this->networkEnv = Platform::getEnv('COMPOSER_DISABLE_NETWORK'); } protected function tearDown(): void { parent::tearDown(); $fs = new Filesystem; $fs->removeDirectory($this->home); if ($this->networkEnv === false) { Platform::clearEnv('COMPOSER_DISABLE_NETWORK'); } else { Platform::putEnv('COMPOSER_DISABLE_NETWORK', $this->networkEnv); } } public function testGetRootIdentifierFromRemote(): void { $process = $this->getProcessExecutorMock(); $io = $this->getMockBuilder(IOInterface::class)->getMock(); $driver = new GitDriver(['url' => 'https://example.org/acme.git'], $io, $this->config, $this->getHttpDownloaderMock(), $process); $stdout = <<expects([[ 'cmd' => 'git remote show origin', 'stdout' => $stdout, ]]); $this->assertSame('main', $driver->getRootIdentifier()); } public function testGetRootIdentifierFromLocalWithNetworkDisabled(): void { Platform::putEnv('COMPOSER_DISABLE_NETWORK', '1'); $process = $this->getProcessExecutorMock(); $io = $this->getMockBuilder(IOInterface::class)->getMock(); $driver = new GitDriver(['url' => 'https://example.org/acme.git'], $io, $this->config, $this->getHttpDownloaderMock(), $process); $stdout = <<expects([[ 'cmd' => 'git branch --no-color', 'stdout' => $stdout, ]]); $this->assertSame('main', $driver->getRootIdentifier()); } }