mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-23 16:13:50 +00:00
Add attachments to workflow
This commit is contained in:
@@ -20,6 +20,7 @@ use Chill\MainBundle\Workflow\EntityWorkflowManager;
|
||||
use Chill\MainBundle\Workflow\EntityWorkflowWithPublicViewInterface;
|
||||
use Chill\MainBundle\Workflow\Messenger\PostPublicViewMessage;
|
||||
use Chill\MainBundle\Workflow\Templating\EntityWorkflowViewMetadataDTO;
|
||||
use Chill\PersonBundle\Entity\AccompanyingPeriod;
|
||||
use Chill\ThirdPartyBundle\Entity\ThirdParty;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
@@ -189,6 +190,11 @@ class WorkflowViewSendPublicControllerTest extends TestCase
|
||||
throw new \BadMethodCallException('not implemented');
|
||||
}
|
||||
|
||||
public function getRelatedAccompanyingPeriod(EntityWorkflow $entityWorkflow): ?AccompanyingPeriod
|
||||
{
|
||||
throw new \BadMethodCallException('not implemented');
|
||||
}
|
||||
|
||||
public function getRelatedObjects(object $object): array
|
||||
{
|
||||
throw new \BadMethodCallException('not implemented');
|
||||
|
@@ -0,0 +1,66 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/*
|
||||
* Chill is a software for social workers
|
||||
*
|
||||
* For the full copyright and license information, please view
|
||||
* the LICENSE file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Chill\MainBundle\Tests\Workflow\Attachment;
|
||||
|
||||
use Chill\DocStoreBundle\Entity\StoredObject;
|
||||
use Chill\DocStoreBundle\GenericDoc\GenericDocDTO;
|
||||
use Chill\DocStoreBundle\GenericDoc\ManagerInterface;
|
||||
use Chill\MainBundle\Entity\Workflow\EntityWorkflow;
|
||||
use Chill\MainBundle\Entity\Workflow\EntityWorkflowAttachment;
|
||||
use Chill\MainBundle\Workflow\Attachment\AddAttachmentAction;
|
||||
use Chill\MainBundle\Workflow\Attachment\AddAttachmentRequestDTO;
|
||||
use Chill\PersonBundle\Entity\AccompanyingPeriod;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*
|
||||
* @coversNothing
|
||||
*/
|
||||
class AddAttachmentActionTest extends TestCase
|
||||
{
|
||||
private EntityManagerInterface $entityManagerMock;
|
||||
private AddAttachmentAction $addAttachmentAction;
|
||||
|
||||
private ManagerInterface $manager;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
$this->entityManagerMock = $this->createMock(EntityManagerInterface::class);
|
||||
$this->manager = $this->createMock(ManagerInterface::class);
|
||||
$this->addAttachmentAction = new AddAttachmentAction($this->entityManagerMock, $this->manager);
|
||||
}
|
||||
|
||||
public function testInvokeCreatesAndPersistsEntityWorkflowAttachment(): void
|
||||
{
|
||||
$entityWorkflow = new EntityWorkflow();
|
||||
$dto = new AddAttachmentRequestDTO($entityWorkflow);
|
||||
$dto->relatedGenericDocKey = 'doc_key';
|
||||
$dto->relatedGenericDocIdentifiers = ['id' => 1];
|
||||
$this->manager->method('buildOneGenericDoc')->willReturn($g = new GenericDocDTO('doc_key', ['id' => 1], new \DateTimeImmutable(), new AccompanyingPeriod()));
|
||||
$this->manager->method('fetchStoredObject')->with($g)->willReturn($storedObject = new StoredObject());
|
||||
|
||||
$this->entityManagerMock
|
||||
->expects($this->once())
|
||||
->method('persist')
|
||||
->with($this->isInstanceOf(EntityWorkflowAttachment::class));
|
||||
|
||||
$result = $this->addAttachmentAction->__invoke($dto);
|
||||
|
||||
$this->assertInstanceOf(EntityWorkflowAttachment::class, $result);
|
||||
$this->assertSame('doc_key', $result->getRelatedGenericDocKey());
|
||||
$this->assertSame(['id' => 1], $result->getRelatedGenericDocIdentifiers());
|
||||
$this->assertSame($entityWorkflow, $result->getEntityWorkflow());
|
||||
$this->assertSame($storedObject, $result->getProxyStoredObject());
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user