function GenerateThemeTest::testContribStarterkitDevSnapshotWithGitNotInstalled
Same name in this branch
- 10 core/tests/Drupal/BuildTests/Command/GenerateThemeTest.php \Drupal\BuildTests\Command\GenerateThemeTest::testContribStarterkitDevSnapshotWithGitNotInstalled()
Same name in other branches
- 9 core/tests/Drupal/Tests/Core/Command/GenerateThemeTest.php \Drupal\Tests\Core\Command\GenerateThemeTest::testContribStarterkitDevSnapshotWithGitNotInstalled()
- 11.x core/tests/Drupal/Tests/Core/Command/GenerateThemeTest.php \Drupal\Tests\Core\Command\GenerateThemeTest::testContribStarterkitDevSnapshotWithGitNotInstalled()
- 11.x core/tests/Drupal/BuildTests/Command/GenerateThemeTest.php \Drupal\BuildTests\Command\GenerateThemeTest::testContribStarterkitDevSnapshotWithGitNotInstalled()
Tests the generate-theme command on a theme with a dev version without git.
File
-
core/
tests/ Drupal/ Tests/ Core/ Command/ GenerateThemeTest.php, line 238
Class
- GenerateThemeTest
- Tests the generate-theme commands.
Namespace
Drupal\Tests\Core\CommandCode
public function testContribStarterkitDevSnapshotWithGitNotInstalled() : void {
// Change the version to a development snapshot version number, to simulate
// using a contrib theme as the starterkit.
$starterkit_info_yml = $this->getWorkspaceDirectory() . '/core/themes/starterkit_theme/starterkit_theme.info.yml';
$info = Yaml::decode(file_get_contents($starterkit_info_yml));
$info['core_version_requirement'] = '*';
$info['version'] = '7.x-dev';
file_put_contents($starterkit_info_yml, Yaml::encode($info));
// Avoid the core git commit from being considered the source theme's: move
// it out of core.
Process::fromShellCommandline('mv core/themes/starterkit_theme themes/', $this->getWorkspaceDirectory())
->run();
// Confirm that 'git' is available.
$output = [];
exec('git --help', $output, $status);
$this->assertEquals(0, $status);
// Modify our $PATH so that it begins with a path that contains an
// executable script named 'git' that always exits with 127, as if git were
// not found. Note that we run our tests using process isolation, so we do
// not need to restore the PATH when we are done.
$unavailableGitPath = $this->getWorkspaceDirectory() . '/bin';
mkdir($unavailableGitPath);
$bash = <<<SH
#!/bin/bash
exit 127
SH;
file_put_contents($unavailableGitPath . '/git', $bash);
chmod($unavailableGitPath . '/git', 0755);
// Confirm that 'git' is no longer available.
$env = [
'PATH' => $unavailableGitPath . ':' . getenv('PATH'),
'COLUMNS' => 80,
];
$process = new Process([
'git',
'--help',
], NULL, $env);
$process->run();
$this->assertEquals(127, $process->getExitCode(), 'Fake git used by process.');
$process = $this->generateThemeFromStarterkit($env);
$result = $process->run();
$this->assertEquals("[ERROR] The source theme starterkit_theme has a development version number \n (7.x-dev). Determining a specific commit is not possible because git is\n not installed. Either install git or use a tagged release to generate a\n theme.", trim($process->getOutput()), $process->getErrorOutput());
$this->assertSame(1, $result);
$this->assertFileDoesNotExist($this->getWorkspaceDirectory() . "/themes/test_custom_theme");
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.