function GenerateThemeTest::testNoEdit
Same name in other branches
- 11.x core/tests/Drupal/BuildTests/Command/GenerateThemeTest.php \Drupal\BuildTests\Command\GenerateThemeTest::testNoEdit()
File
-
core/
tests/ Drupal/ BuildTests/ Command/ GenerateThemeTest.php, line 475
Class
- GenerateThemeTest
- Tests the generate-theme commands.
Namespace
Drupal\BuildTests\CommandCode
public function testNoEdit() : void {
$this->writeStarterkitConfig([
'no_edit' => [
'*no_edit_*',
],
]);
$fixture = <<<FIXTURE
# machine_name
starterkit_theme
# label
Starterkit theme
# machine_class_name
StarterkitTheme
# label_class_name
StarterkitTheme
FIXTURE;
file_put_contents($this->getWorkspaceDirectory() . '/core/themes/starterkit_theme/edit_fixture.txt', $fixture);
file_put_contents($this->getWorkspaceDirectory() . '/core/themes/starterkit_theme/no_edit_fixture.txt', $fixture);
file_put_contents($this->getWorkspaceDirectory() . '/core/themes/starterkit_theme/src/StarterkitThemePreRender.php', <<<PHP
<?php
namespace Drupal\\starterkit_theme;
use Drupal\\Core\\Security\\TrustedCallbackInterface;
/**
* Implements trusted prerender callbacks for the Starterkit theme.
*
* @internal
*/
class StarterkitThemePreRender implements TrustedCallbackInterface {
}
PHP
);
$tester = $this->runCommand([
'machine-name' => 'test_custom_theme',
'--name' => 'Test custom starterkit theme',
'--description' => 'Custom theme generated from a starterkit theme',
]);
$tester->assertCommandIsSuccessful($tester->getErrorOutput());
$this->assertThemeExists('themes/test_custom_theme');
$theme_path_absolute = $this->getWorkspaceDirectory() . '/themes/test_custom_theme';
self::assertFileExists($theme_path_absolute . '/no_edit_fixture.txt');
self::assertEquals($fixture, file_get_contents($theme_path_absolute . '/no_edit_fixture.txt'));
self::assertFileExists($theme_path_absolute . '/edit_fixture.txt');
self::assertEquals(<<<EDITED
# machine_name
test_custom_theme
# label
Test custom starterkit theme
# machine_class_name
TestCustomTheme
# label_class_name
TestCustomTheme
EDITED
, file_get_contents($theme_path_absolute . '/edit_fixture.txt'));
self::assertEquals(<<<EDITED
<?php
namespace Drupal\\test_custom_theme;
use Drupal\\Core\\Security\\TrustedCallbackInterface;
/**
* Implements trusted prerender callbacks for the Test custom starterkit theme.
*
* @internal
*/
class TestCustomThemePreRender implements TrustedCallbackInterface {
}
EDITED
, file_get_contents($theme_path_absolute . '/src/TestCustomThemePreRender.php'));
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.