public function ConfirmClassyCopiesTest::testClassyHashes in Drupal 10
Same name and namespace in other branches
- 8 core/tests/Drupal/KernelTests/Core/Theme/ConfirmClassyCopiesTest.php \Drupal\KernelTests\Core\Theme\ConfirmClassyCopiesTest::testClassyHashes()
- 9 core/tests/Drupal/KernelTests/Core/Theme/ConfirmClassyCopiesTest.php \Drupal\KernelTests\Core\Theme\ConfirmClassyCopiesTest::testClassyHashes()
Tests Classy's assets have not been altered.
File
- core/
tests/ Drupal/ KernelTests/ Core/ Theme/ ConfirmClassyCopiesTest.php, line 22
Class
- ConfirmClassyCopiesTest
- Confirms that theme assets copied from Classy have not been changed.
Namespace
Drupal\KernelTests\Core\ThemeCode
public function testClassyHashes() {
$theme_path = $this->container
->get('extension.list.theme')
->getPath('classy');
foreach ([
'images',
'css',
'js',
'templates',
] as $type => $sub_folder) {
$asset_path = "{$theme_path}/{$sub_folder}";
$directory = new \RecursiveDirectoryIterator($asset_path, \FilesystemIterator::CURRENT_AS_FILEINFO | \FilesystemIterator::SKIP_DOTS);
$iterator = new \RecursiveIteratorIterator($directory);
$this
->assertGreaterThan(0, iterator_count($iterator));
foreach ($iterator as $fileinfo) {
$filename = $fileinfo
->getFilename();
$this
->assertSame($this
->getClassyHash($sub_folder, $filename), md5_file($fileinfo
->getPathname()), "{$filename} has expected hash");
}
}
}