You are here

public function DefaultsSectionStorageTest::testGetSectionListFromId in Drupal 8

@covers ::getSectionListFromId

@dataProvider providerTestGetSectionListFromId

@expectedDeprecation \Drupal\layout_builder\SectionStorageInterface::getSectionListFromId() is deprecated in Drupal 8.7.0 and will be removed before Drupal 9.0.0. The section list should be derived from context. See https://www.drupal.org/node/3016262.

@group legacy

File

core/modules/layout_builder/tests/src/Unit/DefaultsSectionStorageTest.php, line 168

Class

DefaultsSectionStorageTest
@coversDefaultClass \Drupal\layout_builder\Plugin\SectionStorage\DefaultsSectionStorage

Namespace

Drupal\Tests\layout_builder\Unit

Code

public function testGetSectionListFromId($success, $expected_entity_id, $value) {
  if ($expected_entity_id) {
    $entity_storage = $this
      ->prophesize(EntityStorageInterface::class);
    $entity_storage
      ->load($expected_entity_id)
      ->willReturn('the_return_value');
    $this->entityTypeManager
      ->getDefinition('entity_view_display')
      ->willReturn(new EntityType([
      'id' => 'entity_view_display',
    ]));
    $this->entityTypeManager
      ->getStorage('entity_view_display')
      ->willReturn($entity_storage
      ->reveal());
  }
  else {
    $this->entityTypeManager
      ->getDefinition('entity_view_display')
      ->shouldNotBeCalled();
    $this->entityTypeManager
      ->getStorage('entity_view_display')
      ->shouldNotBeCalled();
  }
  if (!$success) {
    $this
      ->expectException(\InvalidArgumentException::class);
  }
  $result = $this->plugin
    ->getSectionListFromId($value);
  if ($success) {
    $this
      ->assertEquals('the_return_value', $result);
  }
}