Skip to content
Open

Dev #384

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
14 changes: 0 additions & 14 deletions src/Domain/Subscription/Service/Manager/SubscribePageManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,13 @@
use PhpList\Core\Domain\Subscription\Model\SubscribePageData;
use PhpList\Core\Domain\Subscription\Repository\SubscriberPageDataRepository;
use PhpList\Core\Domain\Subscription\Repository\SubscriberPageRepository;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
use Symfony\Contracts\Translation\TranslatorInterface;

class SubscribePageManager
{
public function __construct(
private readonly SubscriberPageRepository $pageRepository,
private readonly SubscriberPageDataRepository $pageDataRepository,
private readonly EntityManagerInterface $entityManager,
private readonly TranslatorInterface $translator,
) {
}

Expand All @@ -35,17 +32,6 @@ public function createPage(string $title, bool $active = false, ?Administrator $
return $page;
}

public function getPage(int $id): SubscribePage
{
/** @var SubscribePage|null $page */
$page = $this->pageRepository->find($id);
if (!$page) {
throw new NotFoundHttpException($this->translator->trans('Subscribe page not found'));
}

return $page;
}

public function updatePage(
SubscribePage $page,
?string $title = null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@
use PhpList\Core\Domain\Subscription\Service\Manager\SubscribePageManager;
use PHPUnit\Framework\MockObject\MockObject;
use PHPUnit\Framework\TestCase;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
use Symfony\Component\Translation\Translator;

class SubscribePageManagerTest extends TestCase
{
Expand All @@ -33,7 +31,6 @@ protected function setUp(): void
pageRepository: $this->pageRepository,
pageDataRepository: $this->pageDataRepository,
entityManager: $this->entityManager,
translator: new Translator('en'),
);
}

Expand All @@ -53,34 +50,6 @@ public function testCreatePageCreatesAndSaves(): void
$this->assertSame($owner, $page->getOwner());
}

public function testGetPageReturnsPage(): void
{
$page = new SubscribePage();
$this->pageRepository
->expects($this->once())
->method('find')
->with(123)
->willReturn($page);

$result = $this->manager->getPage(123);

$this->assertSame($page, $result);
}

public function testGetPageThrowsWhenNotFound(): void
{
$this->pageRepository
->expects($this->once())
->method('find')
->with(999)
->willReturn(null);

$this->expectException(NotFoundHttpException::class);
$this->expectExceptionMessage('Subscribe page not found');

$this->manager->getPage(999);
}

public function testUpdatePageUpdatesProvidedFieldsAndFlushes(): void
{
$originalOwner = new Administrator();
Expand Down
Loading