Problem/Motivation
As pointed out in #3091309-37: Broken context-aware block plugins throw an unexpected exception, there are 3+ ways to enable Layout Builder, often used within the same test class.
Proposed resolution
If the UI itself is what is being tested, use code like
$this->drupalGet('admin/structure/types/manage/bundle_with_section_field/display/default');
$page->checkField('layout[enabled]');
$page->pressButton('Save');
$page->checkField('layout[allow_custom]');
$page->pressButton('Save');
Otherwise, use code like
LayoutBuilderEntityViewDisplay::load('node.bundle_with_section_field.default')
->enableLayoutBuilder()
->setOverridable()
->save()
Remaining tasks
User interface changes
N/A
API changes
N/A
Data model changes
N/A
Release notes snippet
N/A
Issue fork drupal-3158916
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
singhrt commentedComment #3
singhrt commentedComment #12
danielvezaI've been working on this one, tests are now green. I've done the following:
I tried to keep the scope for this one small, we should open a follow up for converting the rest of the LB tests to use the new trait.
Comment #13
mstrelan commentedA few nits and one suggested parameter type change.
Comment #14
danielvezaAgreed with all the feedback. Pushed up a new commit to address them.
Comment #15
smustgrave commentedRefactoring appears good to me. New functions have typehint returns, tests all green so nothing appeared to break.
Comment #18
catchCommitted/pushed to 11.x and cherry-picked to 10.3.x, thanks!