diff --git a/core/modules/layout_builder/tests/src/Unit/BlockComponentRenderArrayTest.php b/core/modules/layout_builder/tests/src/Unit/BlockComponentRenderArrayTest.php index e7082d968c..99816cdb4e 100644 --- a/core/modules/layout_builder/tests/src/Unit/BlockComponentRenderArrayTest.php +++ b/core/modules/layout_builder/tests/src/Unit/BlockComponentRenderArrayTest.php @@ -10,7 +10,6 @@ use Drupal\Core\Cache\Cache; use Drupal\Core\DependencyInjection\ContainerBuilder; use Drupal\Core\Entity\EntityInterface; -use Drupal\Core\Logger\LoggerChannel; use Drupal\Core\Plugin\Context\ContextHandlerInterface; use Drupal\Core\Render\PreviewFallbackInterface; use Drupal\Core\Session\AccountInterface; @@ -22,6 +21,7 @@ use Drupal\layout_builder\SectionComponent; use Drupal\Tests\UnitTestCase; use Prophecy\Argument; +use Psr\Log\LoggerInterface; /** * @coversDefaultClass \Drupal\layout_builder\EventSubscriber\BlockComponentRenderArray @@ -68,12 +68,12 @@ protected function setUp(): void { $this->blockManager = $this->prophesize(BlockManagerInterface::class); $this->account = $this->prophesize(AccountInterface::class); - $this->logger = new LoggerChannel('layout_builder'); + $this->logger = $this->prophesize(LoggerInterface::class); $container = new ContainerBuilder(); $container->set('plugin.manager.block', $this->blockManager->reveal()); $container->set('context.handler', $this->prophesize(ContextHandlerInterface::class)); - $container->set('logger.channel.layout_builder', $this->logger); + $container->set('logger.channel.layout_builder', $this->logger->reveal()); \Drupal::setContainer($container); } @@ -120,7 +120,7 @@ public function testOnBuildRender($refinable_dependent_access) { $in_preview = FALSE; $event = new SectionComponentBuildRenderArrayEvent($component, $contexts, $in_preview); - $subscriber = new BlockComponentRenderArray($this->account->reveal(), $this->logger); + $subscriber = new BlockComponentRenderArray($this->account->reveal(), $this->logger->reveal()); $expected_build = [ '#theme' => 'block', @@ -191,7 +191,7 @@ public function testOnBuildRenderWithoutPreviewFallbackString($refinable_depende $in_preview = FALSE; $event = new SectionComponentBuildRenderArrayEvent($component, $contexts, $in_preview); - $subscriber = new BlockComponentRenderArray($this->account->reveal(), $this->logger); + $subscriber = new BlockComponentRenderArray($this->account->reveal(), $this->logger->reveal()); $translation = $this->prophesize(TranslationInterface::class); $translation->translateString(Argument::type(TranslatableMarkup::class)) @@ -264,7 +264,7 @@ public function testOnBuildRenderDenied($refinable_dependent_access) { $in_preview = FALSE; $event = new SectionComponentBuildRenderArrayEvent($component, $contexts, $in_preview); - $subscriber = new BlockComponentRenderArray($this->account->reveal(), $this->logger); + $subscriber = new BlockComponentRenderArray($this->account->reveal(), $this->logger->reveal()); $expected_build = []; $expected_cache = [ @@ -323,7 +323,7 @@ public function testOnBuildRenderInPreview($refinable_dependent_access) { $in_preview = TRUE; $event = new SectionComponentBuildRenderArrayEvent($component, $contexts, $in_preview); - $subscriber = new BlockComponentRenderArray($this->account->reveal(), $this->logger); + $subscriber = new BlockComponentRenderArray($this->account->reveal(), $this->logger->reveal()); $expected_build = [ '#theme' => 'block', @@ -380,7 +380,7 @@ public function testOnBuildRenderInPreviewEmptyBuild() { $component = new SectionComponent('some-uuid', 'some-region', ['id' => 'some_block_id']); $event = new SectionComponentBuildRenderArrayEvent($component, [], TRUE); - $subscriber = new BlockComponentRenderArray($this->account->reveal(), $this->logger); + $subscriber = new BlockComponentRenderArray($this->account->reveal(), $this->logger->reveal()); $translation = $this->prophesize(TranslationInterface::class); $translation->translateString(Argument::type(TranslatableMarkup::class)) ->willReturn($placeholder_string); @@ -440,7 +440,7 @@ public function testOnBuildRenderEmptyBuild() { $component = new SectionComponent('some-uuid', 'some-region', ['id' => 'some_block_id']); $event = new SectionComponentBuildRenderArrayEvent($component, [], FALSE); - $subscriber = new BlockComponentRenderArray($this->account->reveal(), $this->logger); + $subscriber = new BlockComponentRenderArray($this->account->reveal(), $this->logger->reveal()); $expected_build = []; @@ -488,7 +488,7 @@ public function testOnBuildRenderEmptyBuildWithCacheTags() { $component = new SectionComponent('some-uuid', 'some-region', ['id' => 'some_block_id']); $event = new SectionComponentBuildRenderArrayEvent($component, [], FALSE); - $subscriber = new BlockComponentRenderArray($this->account->reveal(), $this->logger); + $subscriber = new BlockComponentRenderArray($this->account->reveal(), $this->logger->reveal()); $expected_build = []; @@ -518,7 +518,7 @@ public function testOnBuildRenderNoBlock() { $in_preview = FALSE; $event = new SectionComponentBuildRenderArrayEvent($component, $contexts, $in_preview); - $subscriber = new BlockComponentRenderArray($this->account->reveal(), $this->logger); + $subscriber = new BlockComponentRenderArray($this->account->reveal(), $this->logger->reveal()); $expected_build = []; $expected_cache = [ diff --git a/core/modules/layout_builder/tests/src/Unit/SectionRenderTest.php b/core/modules/layout_builder/tests/src/Unit/SectionRenderTest.php index 8a401f23af..73ff7c6236 100644 --- a/core/modules/layout_builder/tests/src/Unit/SectionRenderTest.php +++ b/core/modules/layout_builder/tests/src/Unit/SectionRenderTest.php @@ -12,7 +12,6 @@ use Drupal\Core\Layout\LayoutDefinition; use Drupal\Core\Layout\LayoutInterface; use Drupal\Core\Layout\LayoutPluginManagerInterface; -use Drupal\Core\Logger\LoggerChannel; use Drupal\Core\Plugin\Context\ContextHandlerInterface; use Drupal\Core\Plugin\Context\ContextRepositoryInterface; use Drupal\Core\Plugin\ContextAwarePluginInterface; @@ -23,6 +22,7 @@ use Drupal\layout_builder\SectionComponent; use Drupal\Tests\UnitTestCase; use Prophecy\Argument; +use Psr\Log\LoggerInterface; /** * @coversDefaultClass \Drupal\layout_builder\Section @@ -84,10 +84,10 @@ protected function setUp(): void { $this->contextRepository = $this->prophesize(ContextRepositoryInterface::class); // @todo Refactor this into some better tests in https://www.drupal.org/node/2942605. $this->eventDispatcher = (new \ReflectionClass(ContainerAwareEventDispatcher::class))->newInstanceWithoutConstructor(); - $this->logger = new LoggerChannel('layout_builder'); + $this->logger = $this->prophesize(LoggerInterface::class); $this->account = $this->prophesize(AccountInterface::class); - $subscriber = new BlockComponentRenderArray($this->account->reveal(), $this->logger); + $subscriber = new BlockComponentRenderArray($this->account->reveal(), $this->logger->reveal()); $this->eventDispatcher->addSubscriber($subscriber); $layout = $this->prophesize(LayoutInterface::class); @@ -102,7 +102,7 @@ protected function setUp(): void { $container->set('context.handler', $this->contextHandler->reveal()); $container->set('context.repository', $this->contextRepository->reveal()); $container->set('event_dispatcher', $this->eventDispatcher); - $container->set('logger.channel.layout_builder', $this->logger); + $container->set('logger.channel.layout_builder', $this->logger->reveal()); \Drupal::setContainer($container); }