PharWrapperTest.php in Drupal 8
File
core/tests/Drupal/KernelTests/Core/File/PharWrapperTest.php
View source
<?php
namespace Drupal\KernelTests\Core\File;
use Drupal\KernelTests\KernelTestBase;
class PharWrapperTest extends KernelTestBase {
public function testPharFile() {
$base = $this
->getDrupalRoot() . '/core/tests/fixtures/files';
$this
->assertFileNotExists("phar://{$base}/phar-1.phar/no-such-file.php");
$this
->assertFileExists("phar://{$base}/phar-1.phar/index.php");
$file_contents = file_get_contents("phar://{$base}/phar-1.phar/index.php");
$expected_hash = 'c7e7904ea573c5ebea3ef00bb08c1f86af1a45961fbfbeb1892ff4a98fd73ad5';
$this
->assertSame($expected_hash, hash('sha256', $file_contents));
$this
->expectException('TYPO3\\PharStreamWrapper\\Exception');
file_exists("phar://{$base}/image-2.jpg/index.php");
}
}