LayoutDisplayTest.php in Drupal 9        
                          
                  
                        
  
  
  
  
File
  core/modules/layout_builder/tests/src/Functional/LayoutDisplayTest.php
  
    View source  
  <?php
namespace Drupal\Tests\layout_builder\Functional;
use Drupal\Tests\BrowserTestBase;
class LayoutDisplayTest extends BrowserTestBase {
  
  protected static $modules = [
    'field_ui',
    'layout_builder',
    'block',
    'node',
  ];
  
  protected $defaultTheme = 'stark';
  
  protected function setUp() : void {
    parent::setUp();
    $this
      ->createContentType([
      'type' => 'bundle_with_section_field',
    ]);
    $this
      ->createNode([
      'type' => 'bundle_with_section_field',
    ]);
    $this
      ->drupalLogin($this
      ->drupalCreateUser([
      'configure any layout',
      'administer node display',
      'administer display modes',
    ], 'foobar'));
  }
  
  public function testMultipleViewModes() {
    $assert_session = $this
      ->assertSession();
    $page = $this
      ->getSession()
      ->getPage();
    $field_ui_prefix = 'admin/structure/types/manage/bundle_with_section_field/display';
    
    $this
      ->drupalGet("{$field_ui_prefix}/default");
    $page
      ->checkField('layout[enabled]');
    $page
      ->pressButton('Save');
    $page
      ->checkField('layout[allow_custom]');
    $page
      ->pressButton('Save');
    $this
      ->drupalGet('node/1');
    $assert_session
      ->pageTextNotContains('Powered by Drupal');
    $this
      ->drupalGet('node/1/layout');
    $assert_session
      ->linkExists('Add block');
    $this
      ->clickLink('Add block');
    $assert_session
      ->linkExists('Powered by Drupal');
    $this
      ->clickLink('Powered by Drupal');
    $page
      ->pressButton('Add block');
    $page
      ->pressButton('Save');
    $assert_session
      ->pageTextContains('Powered by Drupal');
    
    $this
      ->drupalGet('admin/structure/display-modes/view/add/node');
    $page
      ->fillField('label', 'New');
    $page
      ->fillField('id', 'new');
    $page
      ->pressButton('Save');
    
    $this
      ->drupalGet("{$field_ui_prefix}/default");
    $page
      ->checkField('display_modes_custom[new]');
    $page
      ->pressButton('Save');
    
    $this
      ->drupalGet("{$field_ui_prefix}/new");
    $page
      ->checkField('layout[enabled]');
    $page
      ->pressButton('Save');
    $page
      ->uncheckField('layout[enabled]');
    $page
      ->pressButton('Save');
    $page
      ->pressButton('Confirm');
    
    $this
      ->drupalGet('node/1');
    $assert_session
      ->pageTextContains('Powered by Drupal');
  }
}
 
Classes
        
  
  
      
      
         
      
                  | Name   | Description | 
    
    
          
                  | LayoutDisplayTest | Tests functionality of the entity view display with regard to Layout Builder. |