public function PanelsStorageTest::testLoad in Panels 8.4
Same name and namespace in other branches
- 8.3 tests/src/Unit/PanelsStorageTest.php \Drupal\Tests\panels\Unit\PanelsStorageTest::testLoad()
@covers ::load
File
- tests/
src/ Unit/ PanelsStorageTest.php, line 76
Class
- PanelsStorageTest
- Tests the PageManagerPanelsStorage service.
Namespace
Drupal\Tests\panels\UnitCode
public function testLoad() {
// Make sure that the contexts are passed down (or not).
$this->pageVariant
->getContexts()
->willReturn([]);
$this->panelsDisplay
->setContexts([])
->shouldBeCalledTimes(1);
$this->storage
->load('id_exists')
->willReturn($this->pageVariant
->reveal());
$this->storage
->load('doesnt_exist')
->willReturn(NULL);
$this->storage
->load('not_a_panel')
->willReturn($this->pageVariantNotPanels
->reveal());
$panels_storage = new PageManagerPanelsStorage([], '', [], $this->entityTypeManager
->reveal());
// Test the success condition.
$this
->assertSame($this->panelsDisplay
->reveal(), $panels_storage
->load('id_exists'));
// Should be NULL if it doesn't exist.
$this
->assertNull($panels_storage
->load('doesnt_exist'));
// Should also be NULL if it's not a PanelsDisplayVariant.
$this
->assertNull($panels_storage
->load('not_a_panel'));
}