Skip to content

Commit

Permalink
Prevent to go to createByPage methode on Page deletion (#1721)
Browse files Browse the repository at this point in the history
Co-authored-by: geraud <gbourdin@partitech.com>
  • Loading branch information
GeraudBourdin and geraud committed Nov 19, 2023
1 parent f00641b commit 1ba9484
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/Admin/Extension/CreateSnapshotAdminExtension.php
Expand Up @@ -40,6 +40,10 @@ public function postPersist(AdminInterface $admin, object $object): void

public function postRemove(AdminInterface $admin, object $object): void
{
if ($object instanceof PageInterface) {
return;
}

$this->createByPage($object);
}

Expand Down
12 changes: 12 additions & 0 deletions tests/Admin/Extension/CreateSnapshotAdminExtensionTest.php
Expand Up @@ -88,6 +88,18 @@ public function testPostRemoveOnBlock(): void
$extension->postRemove($admin, $block);
}

public function testPostRemoveOnPage(): void
{
$page = $this->createMock(PageInterface::class);
$admin = $this->createStub(AdminInterface::class);
$createSnapshotByPage = $this->createMock(CreateSnapshotByPageInterface::class);

$createSnapshotByPage->expects(static::never())->method('createByPage');

$extension = new CreateSnapshotAdminExtension($createSnapshotByPage);
$extension->postRemove($admin, $page);
}

public function testCreateSnapshotByPage(): void
{
$admin = $this->createMock(AdminInterface::class);
Expand Down

0 comments on commit 1ba9484

Please sign in to comment.