diff --git a/src/Form/PageVariantEditForm.php b/src/Form/PageVariantEditForm.php index 9cb711f..52865e0 100644 --- a/src/Form/PageVariantEditForm.php +++ b/src/Form/PageVariantEditForm.php @@ -345,7 +345,7 @@ class PageVariantEditForm extends PageVariantFormBase { $contexts = $page_variant->getContexts(); foreach ($contexts as $name => $context) { // Skip relationships - they get their own section. - if ($relationships[$name]) { + if (isset($relationships[$name])) { continue; } diff --git a/tests/src/Unit/ContextMapperTest.php b/tests/src/Unit/ContextMapperTest.php index fd8067c..9211551 100644 --- a/tests/src/Unit/ContextMapperTest.php +++ b/tests/src/Unit/ContextMapperTest.php @@ -14,6 +14,7 @@ use Drupal\Core\Plugin\Context\ContextDefinition; use Drupal\Core\TypedData\DataDefinition; use Drupal\Core\TypedData\Plugin\DataType\IntegerData; use Drupal\Core\TypedData\TypedDataManager; +use Drupal\ctools\TypedDataResolver; use Drupal\page_manager\Context\EntityLazyLoadContext; use Drupal\page_manager\ContextMapper; use Drupal\Tests\UnitTestCase; @@ -38,6 +39,11 @@ class ContextMapperTest extends UnitTestCase { protected $entityRepository; /** + * @var \Drupal\ctools\TypedDataResolver|\Prophecy\Prophecy\ProphecyInterface + */ + protected $typedDataResolver; + + /** * @var \Drupal\page_manager\ContextMapper */ protected $staticContext; @@ -50,7 +56,8 @@ class ContextMapperTest extends UnitTestCase { $this->typedDataManager = $this->prophesize(TypedDataManager::class); $this->entityRepository = $this->prophesize(EntityRepositoryInterface::class); - $this->staticContext = new ContextMapper($this->entityRepository->reveal()); + $this->typedDataResolver = $this->prophesize(TypedDataResolver::class); + $this->staticContext = new ContextMapper($this->entityRepository->reveal(), $this->typedDataResolver->reveal()); $container = new ContainerBuilder(); $container->set('typed_data_manager', $this->typedDataManager->reveal()); diff --git a/tests/src/Unit/PageVariantTest.php b/tests/src/Unit/PageVariantTest.php index cfe8ead..3cfff01 100644 --- a/tests/src/Unit/PageVariantTest.php +++ b/tests/src/Unit/PageVariantTest.php @@ -66,6 +66,7 @@ class PageVariantTest extends UnitTestCase { */ public function testGetContexts($static_contexts, $page_contexts, $expected) { $this->contextMapper->getContextValues([])->willReturn($static_contexts)->shouldBeCalledTimes(1); + $this->contextMapper->getRelationshipValues([], $expected)->willReturn([])->shouldBeCalledTimes(1); $this->page->getContexts()->willReturn($page_contexts)->shouldBeCalledTimes(1); $contexts = $this->pageVariant->getContexts(); @@ -100,6 +101,7 @@ class PageVariantTest extends UnitTestCase { */ public function testGetContextsAfterReset() { $this->contextMapper->getContextValues([])->willReturn([])->shouldBeCalledTimes(2); + $this->contextMapper->getRelationshipValues([], [])->willReturn([])->shouldBeCalledTimes(2); $this->page->getContexts()->willReturn([])->shouldBeCalledTimes(2); $expected = [];