function ConfirmClassyCopiesTest::testClassyHashes

Same name in other branches
  1. 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\Theme

Code

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");
        }
    }
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.