Issue #3041107 by tim.plunkett, Wim Leers, xjm: Remove EntityDisplaySectionsTest in favor of a full suite of REST/HAL tests
parent
4e7959f886
commit
fe95def3b5
|
@ -0,0 +1,31 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Drupal\Tests\layout_builder\Functional\Hal;
|
||||||
|
|
||||||
|
use Drupal\Tests\layout_builder\Functional\Rest\LayoutBuilderEntityViewDisplayResourceTestBase;
|
||||||
|
use Drupal\Tests\rest\Functional\AnonResourceTestTrait;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @group layout_builder
|
||||||
|
* @group rest
|
||||||
|
*/
|
||||||
|
class LayoutBuilderEntityViewDisplayHalJsonAnonTest extends LayoutBuilderEntityViewDisplayResourceTestBase {
|
||||||
|
|
||||||
|
use AnonResourceTestTrait;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
public static $modules = ['hal'];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
protected static $format = 'hal_json';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
protected static $mimeType = 'application/hal+json';
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,26 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Drupal\Tests\layout_builder\Functional\Hal;
|
||||||
|
|
||||||
|
use Drupal\FunctionalTests\Hal\EntityViewDisplayHalJsonAnonTest;
|
||||||
|
use Drupal\Tests\rest\Functional\BasicAuthResourceTestTrait;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @group layout_builder
|
||||||
|
* @group rest
|
||||||
|
*/
|
||||||
|
class LayoutBuilderEntityViewDisplayHalJsonBasicAuthTest extends EntityViewDisplayHalJsonAnonTest {
|
||||||
|
|
||||||
|
use BasicAuthResourceTestTrait;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
public static $modules = ['basic_auth'];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
protected static $auth = 'basic_auth';
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,20 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Drupal\Tests\layout_builder\Functional\Hal;
|
||||||
|
|
||||||
|
use Drupal\Tests\rest\Functional\CookieResourceTestTrait;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @group layout_builder
|
||||||
|
* @group rest
|
||||||
|
*/
|
||||||
|
class LayoutBuilderEntityViewDisplayHalJsonCookieTest extends LayoutBuilderEntityViewDisplayHalJsonAnonTest {
|
||||||
|
|
||||||
|
use CookieResourceTestTrait;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
protected static $auth = 'cookie';
|
||||||
|
|
||||||
|
}
|
|
@ -1,61 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
namespace Drupal\Tests\layout_builder\Functional\Rest;
|
|
||||||
|
|
||||||
use Drupal\Core\Entity\Entity\EntityViewDisplay;
|
|
||||||
use Drupal\Core\Url;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Tests that default layout sections are not exposed via the REST API.
|
|
||||||
*
|
|
||||||
* @group layout_builder
|
|
||||||
* @group rest
|
|
||||||
*/
|
|
||||||
class EntityDisplaySectionsTest extends LayoutRestTestBase {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritdoc}
|
|
||||||
*/
|
|
||||||
protected static $resourceConfigId = 'entity.entity_view_display';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Tests the normalization does not contain layout sections.
|
|
||||||
*/
|
|
||||||
public function testLayoutEntityDisplay() {
|
|
||||||
$display_id = 'node.bundle_with_section_field.default';
|
|
||||||
$display = EntityViewDisplay::load($display_id);
|
|
||||||
|
|
||||||
// Assert the display has 1 section.
|
|
||||||
$this->assertCount(1, $display->getThirdPartySetting('layout_builder', 'sections'));
|
|
||||||
$response = $this->request(
|
|
||||||
'GET',
|
|
||||||
Url::fromRoute(
|
|
||||||
'rest.entity.entity_view_display.GET',
|
|
||||||
['entity_view_display' => 'node.bundle_with_section_field.default'])
|
|
||||||
);
|
|
||||||
$this->assertResourceResponse(
|
|
||||||
200,
|
|
||||||
FALSE,
|
|
||||||
$response,
|
|
||||||
[
|
|
||||||
'config:core.entity_view_display.node.bundle_with_section_field.default',
|
|
||||||
'config:rest.resource.entity.entity_view_display',
|
|
||||||
'config:rest.settings',
|
|
||||||
'http_response',
|
|
||||||
],
|
|
||||||
[
|
|
||||||
'user.permissions',
|
|
||||||
],
|
|
||||||
FALSE,
|
|
||||||
'MISS'
|
|
||||||
);
|
|
||||||
$response_data = $this->getDecodedContents($response);
|
|
||||||
$this->assertSame($display_id, $response_data['id']);
|
|
||||||
// Ensure the sections are not present in the serialized data, but other
|
|
||||||
// Layout Builder data is.
|
|
||||||
$this->assertArrayHasKey('layout_builder', $response_data['third_party_settings']);
|
|
||||||
$this->assertArrayNotHasKey('sections', $response_data['third_party_settings']['layout_builder']);
|
|
||||||
$this->assertEquals(['enabled' => TRUE, 'allow_custom' => TRUE], $response_data['third_party_settings']['layout_builder']);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -0,0 +1,25 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Drupal\Tests\layout_builder\Functional\Rest;
|
||||||
|
|
||||||
|
use Drupal\Tests\rest\Functional\AnonResourceTestTrait;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @group layout_builder
|
||||||
|
* @group rest
|
||||||
|
*/
|
||||||
|
class LayoutBuilderEntityViewDisplayJsonAnonTest extends LayoutBuilderEntityViewDisplayResourceTestBase {
|
||||||
|
|
||||||
|
use AnonResourceTestTrait;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
protected static $format = 'json';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
protected static $mimeType = 'application/json';
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,35 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Drupal\Tests\layout_builder\Functional\Rest;
|
||||||
|
|
||||||
|
use Drupal\Tests\rest\Functional\BasicAuthResourceTestTrait;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @group layout_builder
|
||||||
|
* @group rest
|
||||||
|
*/
|
||||||
|
class LayoutBuilderEntityViewDisplayJsonBasicAuthTest extends LayoutBuilderEntityViewDisplayResourceTestBase {
|
||||||
|
|
||||||
|
use BasicAuthResourceTestTrait;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
public static $modules = ['basic_auth'];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
protected static $format = 'json';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
protected static $mimeType = 'application/json';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
protected static $auth = 'basic_auth';
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,30 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Drupal\Tests\layout_builder\Functional\Rest;
|
||||||
|
|
||||||
|
use Drupal\Tests\rest\Functional\CookieResourceTestTrait;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @group layout_builder
|
||||||
|
* @group rest
|
||||||
|
*/
|
||||||
|
class LayoutBuilderEntityViewDisplayJsonCookieTest extends LayoutBuilderEntityViewDisplayResourceTestBase {
|
||||||
|
|
||||||
|
use CookieResourceTestTrait;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
protected static $format = 'json';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
protected static $mimeType = 'application/json';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
protected static $auth = 'cookie';
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,46 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
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}
|
||||||
|
*/
|
||||||
|
public 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;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,27 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Drupal\Tests\layout_builder\Functional\Rest;
|
||||||
|
|
||||||
|
use Drupal\Tests\rest\Functional\AnonResourceTestTrait;
|
||||||
|
use Drupal\Tests\rest\Functional\EntityResource\XmlEntityNormalizationQuirksTrait;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @group layout_builder
|
||||||
|
* @group rest
|
||||||
|
*/
|
||||||
|
class LayoutBuilderEntityViewDisplayXmlAnonTest extends LayoutBuilderEntityViewDisplayResourceTestBase {
|
||||||
|
|
||||||
|
use AnonResourceTestTrait;
|
||||||
|
use XmlEntityNormalizationQuirksTrait;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
protected static $format = 'xml';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
protected static $mimeType = 'text/xml; charset=UTF-8';
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,37 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Drupal\Tests\layout_builder\Functional\Rest;
|
||||||
|
|
||||||
|
use Drupal\Tests\rest\Functional\BasicAuthResourceTestTrait;
|
||||||
|
use Drupal\Tests\rest\Functional\EntityResource\XmlEntityNormalizationQuirksTrait;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @group layout_builder
|
||||||
|
* @group rest
|
||||||
|
*/
|
||||||
|
class LayoutBuilderEntityViewDisplayXmlBasicAuthTest extends LayoutBuilderEntityViewDisplayResourceTestBase {
|
||||||
|
|
||||||
|
use BasicAuthResourceTestTrait;
|
||||||
|
use XmlEntityNormalizationQuirksTrait;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
public static $modules = ['basic_auth'];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
protected static $format = 'xml';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
protected static $mimeType = 'text/xml; charset=UTF-8';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
protected static $auth = 'basic_auth';
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,32 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Drupal\Tests\layout_builder\Functional\Rest;
|
||||||
|
|
||||||
|
use Drupal\Tests\rest\Functional\CookieResourceTestTrait;
|
||||||
|
use Drupal\Tests\rest\Functional\EntityResource\XmlEntityNormalizationQuirksTrait;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @group layout_builder
|
||||||
|
* @group rest
|
||||||
|
*/
|
||||||
|
class LayoutBuilderEntityViewDisplayXmlCookieTest extends LayoutBuilderEntityViewDisplayResourceTestBase {
|
||||||
|
|
||||||
|
use CookieResourceTestTrait;
|
||||||
|
use XmlEntityNormalizationQuirksTrait;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
protected static $format = 'xml';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
protected static $mimeType = 'text/xml; charset=UTF-8';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
protected static $auth = 'cookie';
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in New Issue