You are here

public function GenerateThemeTest::testDevSnapshot in Drupal 10

Tests the generate-theme command on a dev snapshot of Drupal core.

File

core/tests/Drupal/Tests/Core/Command/GenerateThemeTest.php, line 127

Class

GenerateThemeTest
Tests the generate-theme commands.

Namespace

Drupal\Tests\Core\Command

Code

public function testDevSnapshot() {

  // Do not rely on \Drupal::VERSION: change the version to a development
  // snapshot version number, to simulate using a branch snapshot of core.
  $starterkit_info_yml = $this
    ->getWorkspaceDirectory() . '/core/themes/starterkit_theme/starterkit_theme.info.yml';
  $info = Yaml::decode(file_get_contents($starterkit_info_yml));
  $info['version'] = '9.4.0-dev';
  file_put_contents($starterkit_info_yml, Yaml::encode($info));
  $process = $this
    ->generateThemeFromStarterkit();
  $result = $process
    ->run();
  $this
    ->assertEquals('Theme generated successfully to themes/test_custom_theme', trim($process
    ->getOutput()), $process
    ->getErrorOutput());
  $this
    ->assertSame(0, $result);
  $theme_path_relative = 'themes/test_custom_theme';
  $info = $this
    ->assertThemeExists($theme_path_relative);
  self::assertArrayNotHasKey('hidden', $info);
  self::assertArrayHasKey('generator', $info);
  self::assertMatchesRegularExpression('/^starterkit_theme\\:9.4.0-dev#[0-9a-f]+$/', $info['generator']);
}