LayoutBuilderEntityViewDisplayResourceTestBase.php

Same filename in other branches
  1. 9 core/modules/layout_builder/tests/src/Functional/Rest/LayoutBuilderEntityViewDisplayResourceTestBase.php
  2. 8.9.x core/modules/layout_builder/tests/src/Functional/Rest/LayoutBuilderEntityViewDisplayResourceTestBase.php
  3. 11.x core/modules/layout_builder/tests/src/Functional/Rest/LayoutBuilderEntityViewDisplayResourceTestBase.php

Namespace

Drupal\Tests\layout_builder\Functional\Rest

File

core/modules/layout_builder/tests/src/Functional/Rest/LayoutBuilderEntityViewDisplayResourceTestBase.php

View source
<?php

declare (strict_types=1);
namespace Drupal\Tests\layout_builder\Functional\Rest;

use Drupal\FunctionalTests\Rest\EntityViewDisplayResourceTestBase;
use Drupal\layout_builder\Plugin\SectionStorage\OverridesSectionStorage;

/**
 * Provides a base class for testing LayoutBuilderEntityViewDisplay resources.
 */
abstract class LayoutBuilderEntityViewDisplayResourceTestBase extends EntityViewDisplayResourceTestBase {
    
    /**
     * {@inheritdoc}
     */
    protected static $modules = [
        'layout_builder',
    ];
    
    /**
     * {@inheritdoc}
     */
    protected function createEntity() {
        
        /** @var \Drupal\layout_builder\Entity\LayoutBuilderEntityViewDisplay $entity */
        $entity = parent::createEntity();
        $entity->enableLayoutBuilder()
            ->setOverridable()
            ->save();
        $this->assertCount(1, $entity->getThirdPartySetting('layout_builder', 'sections'));
        return $entity;
    }
    
    /**
     * {@inheritdoc}
     */
    protected function getExpectedNormalizedEntity() {
        $expected = parent::getExpectedNormalizedEntity();
        array_unshift($expected['dependencies']['module'], 'layout_builder');
        $expected['hidden'][OverridesSectionStorage::FIELD_NAME] = TRUE;
        $expected['third_party_settings']['layout_builder'] = [
            'enabled' => TRUE,
            'allow_custom' => TRUE,
        ];
        return $expected;
    }

}

Classes

Title Deprecated Summary
LayoutBuilderEntityViewDisplayResourceTestBase Provides a base class for testing LayoutBuilderEntityViewDisplay resources.

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.