Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Observer/View/BlockToHtmlAfter.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public function __construct(
*/
public function execute(Observer $observer)
{
if (!$this->config->isEnabled() && !$this->config->isPageBuilderPreloadEnabled()) {
if (!$this->config->isEnabled() || !$this->config->isPageBuilderPreloadEnabled()) {
return;
}

Expand Down
19 changes: 8 additions & 11 deletions Test/Unit/Observer/View/BlockToHtmlAfterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ protected function setUp(): void

public function testDoesNothingWhenBothConfigsDisabled(): void
{
// Note: The condition is: if (!isEnabled && !isPageBuilderPreloadEnabled)
$this->configMock->method('isEnabled')->willReturn(false);
$this->configMock->method('isPageBuilderPreloadEnabled')->willReturn(false);

Expand Down Expand Up @@ -158,34 +157,32 @@ public function testIgnoresImagesWithoutPreloadAttribute(): void
$this->subject->execute($this->observerMock);
}

public function testExecutesWhenOnlyModuleEnabled(): void
public function testDoesNothingWhenOnlyModuleEnabled(): void
{
// Master 'Enabled' switch alone is not sufficient - the pagebuilder_content
// toggle must also be on, matching every other observer in this module.
$this->configMock->method('isEnabled')->willReturn(true);
$this->configMock->method('isPageBuilderPreloadEnabled')->willReturn(false);

$html = '<img src="/media/test.jpg" preload="Yes" data-element="desktop_image">';
$this->transport->setHtml($html);

$preloadMock = $this->createMock(Preload::class);
$this->preloadFactoryMock->method('create')->willReturn($preloadMock);

$this->linkStoreMock->expects($this->once())->method('add');
$this->linkStoreMock->expects($this->never())->method('add');

$this->subject->execute($this->observerMock);
}

public function testExecutesWhenOnlyPageBuilderPreloadEnabled(): void
public function testDoesNothingWhenOnlyPageBuilderPreloadEnabled(): void
{
// pagebuilder_content toggle alone is not sufficient if the master
// 'Enabled' switch is off - it must act as a full kill-switch.
$this->configMock->method('isEnabled')->willReturn(false);
$this->configMock->method('isPageBuilderPreloadEnabled')->willReturn(true);

$html = '<img src="/media/test.jpg" preload="Yes" data-element="desktop_image">';
$this->transport->setHtml($html);

$preloadMock = $this->createMock(Preload::class);
$this->preloadFactoryMock->method('create')->willReturn($preloadMock);

$this->linkStoreMock->expects($this->once())->method('add');
$this->linkStoreMock->expects($this->never())->method('add');

$this->subject->execute($this->observerMock);
}
Expand Down
Loading