public function testExtractFileOverwritesExistingFileIfSpecified()
{
$key = uniqid();
$pharPath = $this->getTestDir() . '/phar-extractor-overwrite-' . $key . '.phar';
$relativeFilePath = 'path/to/file-' . $key . '.txt';
$extractedFilePath = sys_get_temp_dir() . '/jolinotif/' . $relativeFilePath;
$this->generatePhar($pharPath, $relativeFilePath, $key, false);
$this->assertTrue(is_file($pharPath));
exec('php ' . $pharPath);
\Phar::unlinkArchive($pharPath);
$this->generatePhar($pharPath, $relativeFilePath, 'new content', true);
$this->assertTrue(is_file($pharPath));
exec('php ' . $pharPath);
\Phar::unlinkArchive($pharPath);
$this->assertTrue(is_file($extractedFilePath));
$this->assertSame('new content', file_get_contents($extractedFilePath));
unlink($extractedFilePath);
}