mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-07 18:44:08 +00:00
fix tests about PdfSignedMessageHandler.php
This commit is contained in:
parent
c939ff4a4e
commit
4933d2251c
@ -53,7 +53,6 @@ final readonly class PdfSignedMessageHandler implements MessageHandlerInterface
|
|||||||
|
|
||||||
$this->entityManager->wrapInTransaction(function () use ($storedObject, $message, $signature) {
|
$this->entityManager->wrapInTransaction(function () use ($storedObject, $message, $signature) {
|
||||||
$this->storedObjectManager->write($storedObject, $message->content);
|
$this->storedObjectManager->write($storedObject, $message->content);
|
||||||
|
|
||||||
$this->signatureStepStateChanger->markSignatureAsSigned($signature, $message->signatureZoneIndex);
|
$this->signatureStepStateChanger->markSignatureAsSigned($signature, $message->signatureZoneIndex);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -25,6 +25,8 @@ use Chill\MainBundle\Workflow\WorkflowTransitionContextDTO;
|
|||||||
use Chill\PersonBundle\Entity\Person;
|
use Chill\PersonBundle\Entity\Person;
|
||||||
use Doctrine\ORM\EntityManagerInterface;
|
use Doctrine\ORM\EntityManagerInterface;
|
||||||
use PHPUnit\Framework\TestCase;
|
use PHPUnit\Framework\TestCase;
|
||||||
|
use Prophecy\Argument;
|
||||||
|
use Prophecy\PhpUnit\ProphecyTrait;
|
||||||
use Psr\Log\NullLogger;
|
use Psr\Log\NullLogger;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -34,6 +36,8 @@ use Psr\Log\NullLogger;
|
|||||||
*/
|
*/
|
||||||
class PdfSignedMessageHandlerTest extends TestCase
|
class PdfSignedMessageHandlerTest extends TestCase
|
||||||
{
|
{
|
||||||
|
use ProphecyTrait;
|
||||||
|
|
||||||
public function testThatObjectIsWrittenInStoredObjectManagerHappyScenario(): void
|
public function testThatObjectIsWrittenInStoredObjectManagerHappyScenario(): void
|
||||||
{
|
{
|
||||||
// a dummy stored object
|
// a dummy stored object
|
||||||
@ -91,10 +95,19 @@ class PdfSignedMessageHandlerTest extends TestCase
|
|||||||
|
|
||||||
private function buildEntityManager(bool $willFlush): EntityManagerInterface
|
private function buildEntityManager(bool $willFlush): EntityManagerInterface
|
||||||
{
|
{
|
||||||
$em = $this->createMock(EntityManagerInterface::class);
|
$em = $this->prophesize(EntityManagerInterface::class);
|
||||||
$em->expects($willFlush ? $this->once() : $this->never())->method('flush');
|
$clear = $em->clear();
|
||||||
$em->expects($willFlush ? $this->once() : $this->never())->method('clear');
|
$wrap = $em->wrapInTransaction(Argument::type('callable'))->will(function ($args) {
|
||||||
|
$callable = $args[0];
|
||||||
|
|
||||||
return $em;
|
return call_user_func($callable);
|
||||||
|
});
|
||||||
|
|
||||||
|
if ($willFlush) {
|
||||||
|
$clear->shouldBeCalled();
|
||||||
|
$wrap->shouldBeCalled();
|
||||||
|
}
|
||||||
|
|
||||||
|
return $em->reveal();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user