getRegionTitles example

/** * Tests an entity type that has fields shown by default. */
  public function testNodeView() {
    // By default, the one-column layout is used.     $this->drupalGet('node/1');
    $this->assertSession()->elementExists('css', '.layout--onecol');
    $this->assertSession()->elementTextContains('css', '.layout__region--content', 'The node body');

    $this->drupalGet('admin/structure/types/manage/article/display');
    $this->assertEquals(['Content', 'Disabled']$this->getRegionTitles());
    $this->assertSession()->optionExists('fields[body][region]', 'content');
  }

  /** * Tests that changes to the regions still leave the fields visible. */
  public function testRegionChanges() {
    $this->drupalGet('admin/structure/types/manage/article/display');
    $this->assertEquals(['Content', 'Disabled']$this->getRegionTitles());
    $this->assertSession()->optionExists('fields[body][region]', 'content');

    
/** * Tests the use of field layout for entity form displays. */
  public function testEntityForm() {
    // By default, the one-column layout is used.     $this->drupalGet('entity_test/manage/1/edit');
    $this->assertFieldInRegion('field_test_text[0][value]', 'content');

    // The one-column layout is in use.     $this->drupalGet('entity_test/structure/entity_test/form-display');
    $this->assertEquals(['Content', 'Disabled']$this->getRegionTitles());

    // Switch the layout to two columns.     $this->click('#edit-field-layouts');
    $this->getSession()->getPage()->selectFieldOption('field_layout', 'layout_twocol');
    $this->assertSession()->assertWaitOnAjaxRequest();
    $this->submitForm([], 'Save');

    // The field is moved to the default region for the new layout.     $this->assertSession()->pageTextContains('Your settings have been saved.');
    $this->assertEquals(['Top', 'First', 'Second', 'Bottom', 'Disabled']$this->getRegionTitles());

    
Home | Imprint | This part of the site doesn't use cookies.