function GenerateThemeTest::testGeneratingFromAnotherTheme

Same name in this branch
  1. 10 core/tests/Drupal/BuildTests/Command/GenerateThemeTest.php \Drupal\BuildTests\Command\GenerateThemeTest::testGeneratingFromAnotherTheme()
Same name and namespace in other branches
  1. 9 core/tests/Drupal/Tests/Core/Command/GenerateThemeTest.php \Drupal\Tests\Core\Command\GenerateThemeTest::testGeneratingFromAnotherTheme()
  2. 11.x core/tests/Drupal/Tests/Core/Command/GenerateThemeTest.php \Drupal\Tests\Core\Command\GenerateThemeTest::testGeneratingFromAnotherTheme()
  3. 11.x core/tests/Drupal/BuildTests/Command/GenerateThemeTest.php \Drupal\BuildTests\Command\GenerateThemeTest::testGeneratingFromAnotherTheme()

Tests generating a theme from another Starterkit enabled theme.

File

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

Class

GenerateThemeTest
Tests the generate-theme commands.

Namespace

Drupal\Tests\Core\Command

Code

public function testGeneratingFromAnotherTheme() {
    // Do not rely on \Drupal::VERSION: change the version to a concrete version
    // number, to simulate using a tagged core release.
    $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';
    file_put_contents($starterkit_info_yml, Yaml::encode($info));
    $process = $this->generateThemeFromStarterkit();
    $exit_code = $process->run();
    $this->assertSame('Theme generated successfully to themes/test_custom_theme', trim($process->getOutput()), $process->getErrorOutput());
    $this->assertSame(0, $exit_code);
    $install_command = [
        $this->php,
        'core/scripts/drupal',
        'generate-theme',
        'generated_from_another_theme',
        '--name="Generated from another theme"',
        '--description="Custom theme generated from a theme other than starterkit_theme"',
        '--starterkit=test_custom_theme',
    ];
    $process = new Process($install_command);
    $exit_code = $process->run();
    $this->assertSame('Theme generated successfully to themes/generated_from_another_theme', trim($process->getOutput()), $process->getErrorOutput());
    $this->assertSame(0, $exit_code);
    // Confirm readme is rewritten.
    $readme_file = $this->getWorkspaceDirectory() . '/themes/generated_from_another_theme/README.md';
    $this->assertSame('generated_from_another_theme theme, generated from test_custom_theme. Additional information on generating themes can be found in the [Starterkit documentation](https://www.drupal.org/docs/core-modules-and-themes/core-themes/starterkit-theme).', file_get_contents($readme_file));
}

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