mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-23 16:13:50 +00:00
fixup! Add message handling for public view creation
This commit is contained in:
@@ -20,6 +20,7 @@ use Chill\MainBundle\Workflow\Messenger\PostPublicViewMessage;
|
||||
use Chill\MainBundle\Workflow\Messenger\PostPublicViewMessageHandler;
|
||||
use Chill\MainBundle\Workflow\WorkflowTransitionContextDTO;
|
||||
use Chill\ThirdPartyBundle\Entity\ThirdParty;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Prophecy\PhpUnit\ProphecyTrait;
|
||||
use Psr\Log\NullLogger;
|
||||
@@ -77,6 +78,19 @@ class PostPublicViewMessageHandlerTest extends TestCase
|
||||
return $registry;
|
||||
}
|
||||
|
||||
private function buildEntityManager(bool $mustBeFlushed = false): EntityManagerInterface
|
||||
{
|
||||
$entityManager = $this->prophesize(EntityManagerInterface::class);
|
||||
$flush = $entityManager->flush();
|
||||
$entityManager->clear()->shouldBeCalled();
|
||||
|
||||
if ($mustBeFlushed) {
|
||||
$flush->shouldBeCalled();
|
||||
}
|
||||
|
||||
return $entityManager->reveal();
|
||||
}
|
||||
|
||||
public function testHandleTransitionToPostViewSuccessful(): void
|
||||
{
|
||||
$entityWorkflow = new EntityWorkflow();
|
||||
@@ -90,7 +104,7 @@ class PostPublicViewMessageHandlerTest extends TestCase
|
||||
$repository = $this->prophesize(EntityWorkflowSendViewRepository::class);
|
||||
$repository->find(6)->willReturn($view);
|
||||
|
||||
$handler = new PostPublicViewMessageHandler($repository->reveal(), $this->buildRegistry(), new NullLogger());
|
||||
$handler = new PostPublicViewMessageHandler($repository->reveal(), $this->buildRegistry(), new NullLogger(), $this->buildEntityManager(true));
|
||||
|
||||
$handler(new PostPublicViewMessage(6));
|
||||
|
||||
@@ -115,7 +129,7 @@ class PostPublicViewMessageHandlerTest extends TestCase
|
||||
$repository = $this->prophesize(EntityWorkflowSendViewRepository::class);
|
||||
$repository->find(6)->willReturn($view);
|
||||
|
||||
$handler = new PostPublicViewMessageHandler($repository->reveal(), $this->buildRegistry(), new NullLogger());
|
||||
$handler = new PostPublicViewMessageHandler($repository->reveal(), $this->buildRegistry(), new NullLogger(), $this->buildEntityManager());
|
||||
|
||||
$handler(new PostPublicViewMessage(6));
|
||||
|
||||
@@ -136,7 +150,7 @@ class PostPublicViewMessageHandlerTest extends TestCase
|
||||
$repository = $this->prophesize(EntityWorkflowSendViewRepository::class);
|
||||
$repository->find(6)->willReturn($view);
|
||||
|
||||
$handler = new PostPublicViewMessageHandler($repository->reveal(), $this->buildRegistry(), new NullLogger());
|
||||
$handler = new PostPublicViewMessageHandler($repository->reveal(), $this->buildRegistry(), new NullLogger(), $this->buildEntityManager());
|
||||
|
||||
$handler(new PostPublicViewMessage(6));
|
||||
|
||||
|
Reference in New Issue
Block a user