You are here

public function PanelizerFieldPanelsStorageTest::testSaveFailed in Panelizer 8.4

Same name and namespace in other branches
  1. 8.5 tests/src/Unit/PanelizerFieldPanelsStorageTest.php \Drupal\Tests\panelizer\Unit\PanelizerFieldPanelsStorageTest::testSaveFailed()
  2. 8.3 tests/src/Unit/PanelizerFieldPanelsStorageTest.php \Drupal\Tests\panelizer\Unit\PanelizerFieldPanelsStorageTest::testSaveFailed()

@covers ::save

File

tests/src/Unit/PanelizerFieldPanelsStorageTest.php, line 182

Class

PanelizerFieldPanelsStorageTest
Tests the PanelizerFieldPanelsStorage service.

Namespace

Drupal\Tests\panelizer\Unit

Code

public function testSaveFailed() {
  $panels_display = $this
    ->prophesize(PanelsDisplayVariant::class);
  $panels_display
    ->getStorageId()
    ->willReturn('entity_type_id:123:view_mode');
  $entity = $this
    ->prophesize(FieldableEntityInterface::class);
  $this->panelizer
    ->setPanelsDisplay($entity
    ->reveal(), 'view_mode', NULL, $panels_display)
    ->willThrow(new PanelizerException("Save failed"));
  $this->storage
    ->load('123')
    ->willReturn($entity
    ->reveal())
    ->shouldBeCalled();
  $this
    ->expectException('Exception');
  $this
    ->expectExceptionMessage('Save failed');
  $this->panelsStorage
    ->save($panels_display
    ->reveal());
}