Add attachments to workflow

This commit is contained in:
2025-02-03 21:15:00 +00:00
parent 9e191f1b5b
commit 37227a3aeb
106 changed files with 3455 additions and 619 deletions

View File

@@ -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');

View File

@@ -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());
}
}