LayoutBuilderThemeSuggestionsTest.php in Drupal 10
File
core/modules/layout_builder/tests/src/Functional/LayoutBuilderThemeSuggestionsTest.php
View source
<?php
namespace Drupal\Tests\layout_builder\Functional;
use Drupal\layout_builder\Entity\LayoutBuilderEntityViewDisplay;
use Drupal\Tests\BrowserTestBase;
class LayoutBuilderThemeSuggestionsTest extends BrowserTestBase {
protected static $modules = [
'layout_builder',
'node',
'layout_builder_theme_suggestions_test',
];
protected $defaultTheme = 'classy';
protected function setUp() : void {
parent::setUp();
$this
->createContentType([
'type' => 'bundle_with_section_field',
'name' => 'Bundle with section field',
]);
LayoutBuilderEntityViewDisplay::load('node.bundle_with_section_field.default')
->enableLayoutBuilder()
->setOverridable()
->save();
$this
->createNode([
'type' => 'bundle_with_section_field',
'title' => 'A node title',
'body' => [
[
'value' => 'This is content that the template should not render',
],
],
]);
$this
->drupalLogin($this
->drupalCreateUser([
'configure any layout',
]));
}
public function testLayoutListSuggestion() {
$page = $this
->getSession()
->getPage();
$assert_session = $this
->assertSession();
$this
->drupalGet('node/1/layout');
$page
->clickLink('Add section');
$assert_session
->pageTextContains('layout_builder_theme_suggestions_test_preprocess_item_list__layouts');
}
public function testFieldBlockViewModeTemplates() {
$assert_session = $this
->assertSession();
$this
->drupalGet('node/1');
$assert_session
->elementExists('css', '.block-layout-builder');
$assert_session
->pageTextContains('I am a field template for a specific view mode!');
$assert_session
->pageTextNotContains('This is content that the template should not render');
}
}