/** * Tests the action execution when saving is postponed. * * @covers ::execute */ public function testActionExecutionPostponed() { $this->entity->save()->shouldNotBeCalled(); $this->action->setContextValue('entity', $this->entity->reveal()); $this->action->execute(); $this->assertEquals($this->action->autoSaveContext(), ['entity'], 'Action returns the entity context name for auto saving.'); }
/** * Tests the action execution when a language is specified. * * @covers ::execute */ public function testActionExecutionWithLanguage() { $language = $this->prophesize(LanguageInterface::class); $language->getId()->willReturn('en'); $this->aliasStorage->save('node/1', 'about', 'en')->shouldBeCalledTimes(1); $this->action->setContextValue('source', 'node/1')->setContextValue('alias', 'about')->setContextValue('language', $language->reveal()); $this->action->execute(); }
/** * Tests the action execution with a saved entity. * * @covers ::execute */ public function testActionExecutionWithSavedEntity() { // Test that the alias is only saved once. $this->aliasStorage->save('test/1', 'about', 'en')->shouldBeCalledTimes(1); $entity = $this->getMockEntity(); $entity->isNew()->willReturn(FALSE)->shouldBeCalledTimes(1); // Test that existing entities are not saved again. $entity->save()->shouldNotBeCalled(); $this->action->setContextValue('entity', $entity->reveal())->setContextValue('alias', 'about'); $this->action->execute(); }
/** * @covers ::save * * @expectedException \Exception * @expectedExceptionMessage Page variant doesn't use a Panels display variant */ public function testSaveNotPanels() { $this->storage->load('not_a_panel')->willReturn($this->pageVariantNotPanels->reveal()); $this->panelsDisplay->setConfiguration(Argument::cetera())->shouldNotBeCalled(); $this->pageVariant->save()->shouldNotBeCalled(); $panels_display = $this->prophesize(PanelsDisplayVariant::class); $panels_display->getStorageId()->willReturn('not_a_panel'); $panels_display->getConfiguration()->shouldNotBeCalled(); $panels_storage = new PageManagerPanelsStorage([], '', [], $this->entityTypeManager->reveal()); $panels_storage->save($panels_display->reveal()); }