Skip to content

Commit

Permalink
Fix deleted blocks (from composer) still visible
Browse files Browse the repository at this point in the history
  • Loading branch information
gremo authored and franmomu committed Apr 18, 2021
1 parent 9167dd5 commit 9964f8b
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/Admin/Extension/CreateSnapshotAdminExtension.php
Expand Up @@ -41,6 +41,11 @@ public function postPersist(AdminInterface $admin, $object)
$this->sendMessage($object);
}

public function postRemove(AdminInterface $admin, $object)
{
$this->sendMessage($object);
}

/**
* @param PageInterface $object
*/
Expand Down
20 changes: 20 additions & 0 deletions tests/Admin/Extension/CreateSnapshotAdminExtensionTest.php
Expand Up @@ -95,4 +95,24 @@ public function testPostPersistOnBlock(): void
$extension = new CreateSnapshotAdminExtension($backend);
$extension->postPersist($admin, $block);
}

public function testPostRemoveOnBlock(): void
{
$page = $this->createMock(PageInterface::class);
$page->expects($this->once())->method('getId')->willReturn(42);

$block = $this->createMock(PageBlockInterface::class);
$block->expects($this->once())->method('getPage')->willReturn($page);

$admin = $this->createStub(AdminInterface::class);

$backend = $this->createMock(BackendInterface::class);
$backend->expects($this->once())->method('createAndPublish')->with(
'sonata.page.create_snapshot',
['pageId' => 42]
);

$extension = new CreateSnapshotAdminExtension($backend);
$extension->postRemove($admin, $block);
}
}

0 comments on commit 9964f8b

Please sign in to comment.