mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-07 18:44:08 +00:00
fix creating a new AccompanyingPeriodWorkEvaluationDocument when replacing the document (the workflow was lost)
This commit is contained in:
parent
a4e3ffbe27
commit
f92cef02cf
11
CHANGELOG.md
11
CHANGELOG.md
@ -11,6 +11,15 @@ and this project adheres to
|
||||
## Unreleased
|
||||
|
||||
<!-- write down unreleased development here -->
|
||||
|
||||
## Test releases
|
||||
|
||||
### 2022-05-30
|
||||
|
||||
* fix creating a new AccompanyingPeriodWorkEvaluationDocument when replacing the document (the workflow was lost)
|
||||
|
||||
### 2022-05-27
|
||||
|
||||
* [storedobject] add title field on StoredObject entity + use it in activity documents (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/604)
|
||||
* [main] add a "read more..." on comment embeddable when overflown (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/604)
|
||||
* [person] add closing motive to closed acc course (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/603)
|
||||
@ -28,8 +37,6 @@ and this project adheres to
|
||||
* [address] can add extra address info even if noAddress (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/576)
|
||||
|
||||
|
||||
## Test releases
|
||||
|
||||
### 2022-05-06
|
||||
|
||||
* [person] add civility when creating a person (with the on-the-fly component or in the php form) (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/557)
|
||||
|
@ -232,6 +232,14 @@ const store = createStore({
|
||||
return;
|
||||
}
|
||||
|
||||
let doc = evaluation.documents.find(d => d.key === payload.oldDocument.key);
|
||||
|
||||
if (typeof doc === 'undefined') {
|
||||
console.error('doc not found');
|
||||
}
|
||||
|
||||
doc.storedObject = payload.document.storedObject;
|
||||
return;
|
||||
let newDocument = Object.assign(
|
||||
payload.document, {
|
||||
key: evaluation.documents.length + 1,
|
||||
|
@ -35,6 +35,6 @@ final class AccompanyingPeriodOriginNormalizer implements NormalizerInterface
|
||||
|
||||
public function supportsNormalization($data, $format = null): bool
|
||||
{
|
||||
return $data instanceof Origin && $format === 'json';
|
||||
return $data instanceof Origin && 'json' === $format;
|
||||
}
|
||||
}
|
||||
|
@ -13,8 +13,6 @@ namespace Chill\PersonBundle\Serializer\Normalizer;
|
||||
|
||||
use Chill\PersonBundle\Entity\AccompanyingPeriod\AccompanyingPeriodWorkEvaluation;
|
||||
use Chill\PersonBundle\Entity\AccompanyingPeriod\AccompanyingPeriodWorkEvaluationDocument;
|
||||
use Chill\PersonBundle\Repository\AccompanyingPeriod\AccompanyingPeriodWorkRepository;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use Symfony\Component\Serializer\Normalizer\AbstractNormalizer;
|
||||
use Symfony\Component\Serializer\Normalizer\ContextAwareDenormalizerInterface;
|
||||
use Symfony\Component\Serializer\Normalizer\DenormalizerAwareInterface;
|
||||
@ -35,18 +33,6 @@ class AccompanyingPeriodWorkEvaluationDenormalizer implements ContextAwareDenorm
|
||||
|
||||
use ObjectToPopulateTrait;
|
||||
|
||||
private EntityManagerInterface $em;
|
||||
|
||||
private AccompanyingPeriodWorkRepository $workRepository;
|
||||
|
||||
public function __construct(
|
||||
AccompanyingPeriodWorkRepository $workRepository,
|
||||
EntityManagerInterface $em
|
||||
) {
|
||||
$this->workRepository = $workRepository;
|
||||
$this->em = $em;
|
||||
}
|
||||
|
||||
public function denormalize($data, $type, $format = null, array $context = [])
|
||||
{
|
||||
$evaluation = $this->denormalizer->denormalize($data, $type, $format, array_merge(
|
||||
|
@ -0,0 +1,140 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Serializer\Normalizer;
|
||||
|
||||
use Chill\DocStoreBundle\Entity\StoredObject;
|
||||
use Chill\PersonBundle\Entity\AccompanyingPeriod\AccompanyingPeriodWorkEvaluation;
|
||||
use Chill\PersonBundle\Entity\AccompanyingPeriod\AccompanyingPeriodWorkEvaluationDocument;
|
||||
use Chill\PersonBundle\Serializer\Normalizer\AccompanyingPeriodWorkEvaluationDenormalizer;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use ReflectionProperty;
|
||||
use Symfony\Component\Serializer\Normalizer\AbstractNormalizer;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
* @coversNothing
|
||||
*/
|
||||
final class AccompanyingPeriodWorkEvaluationDenormalizerTest extends TestCase
|
||||
{
|
||||
private const ENCODED_DATA = ' {
|
||||
"type": "accompanying_period_work_evaluation",
|
||||
"key": 0,
|
||||
"evaluation": {
|
||||
"id": 100,
|
||||
"type": "social_work_evaluation"
|
||||
},
|
||||
"startDate": {
|
||||
"datetime": "2022-04-29T00:00:00+02:00"
|
||||
},
|
||||
"endDate": null,
|
||||
"maxDate": null,
|
||||
"warningInterval": "P0D",
|
||||
"comment": "",
|
||||
"documents": [
|
||||
{
|
||||
"type": "accompanying_period_work_evaluation_document",
|
||||
"id": 1,
|
||||
"storedObject": {
|
||||
"creationDate": {
|
||||
"datetime": "2022-05-30T21:22:47+0200"
|
||||
},
|
||||
"datas": [],
|
||||
"filename": "ZeoWSjqVc2qN1XUHptTV6S",
|
||||
"id": 11,
|
||||
"iv": [
|
||||
89,
|
||||
164,
|
||||
162,
|
||||
48,
|
||||
155,
|
||||
159,
|
||||
69,
|
||||
135,
|
||||
191,
|
||||
241,
|
||||
241,
|
||||
8,
|
||||
17,
|
||||
56,
|
||||
183,
|
||||
224
|
||||
],
|
||||
"keyInfos": {
|
||||
"alg": "A256CBC",
|
||||
"ext": true,
|
||||
"k": "uW4d7si_hi--VQHxi76ZllKQiYzaEJYGN8KBrWXxi7s",
|
||||
"key_ops": [
|
||||
"encrypt",
|
||||
"decrypt"
|
||||
],
|
||||
"kty": "oct"
|
||||
},
|
||||
"title": "",
|
||||
"type": "application/vnd.oasis.opendocument.text",
|
||||
"uuid": "b9dd9eff-a7cf-4a29-89e3-57efc9ed215b"
|
||||
},
|
||||
"title": "test",
|
||||
"key": 2,
|
||||
"workflows_availables": [
|
||||
{
|
||||
"name": "vendee_internal",
|
||||
"text": "Suivi CD85"
|
||||
}
|
||||
],
|
||||
"workflows": []
|
||||
}
|
||||
],
|
||||
"id": 382
|
||||
}';
|
||||
|
||||
public function testAssociatedDocumentIsTheSame()
|
||||
{
|
||||
$this->markTestIncomplete('not yet finished');
|
||||
$evaluation = new AccompanyingPeriodWorkEvaluation();
|
||||
$doc = new AccompanyingPeriodWorkEvaluationDocument();
|
||||
$doc->setStoredObject($storedObject = new StoredObject());
|
||||
$reflectionProperty = new ReflectionProperty(AccompanyingPeriodWorkEvaluationDocument::class, 'id');
|
||||
$reflectionProperty->setAccessible(true);
|
||||
$reflectionProperty->setValue($doc, 1);
|
||||
|
||||
$evaluation->addDocument($doc);
|
||||
|
||||
$data = json_decode(self::ENCODED_DATA);
|
||||
$context =
|
||||
[AbstractNormalizer::OBJECT_TO_POPULATE => $evaluation, 'groups' => ['write']];
|
||||
|
||||
$denormalizer = new AccompanyingPeriodWorkEvaluationDenormalizer();
|
||||
|
||||
/*
|
||||
$this->assertTrue(
|
||||
$denormalizer->supportsDenormalization(
|
||||
$data,
|
||||
AccompanyingPeriodWorkEvaluation::class,
|
||||
'json',
|
||||
$context
|
||||
)
|
||||
);
|
||||
*/
|
||||
|
||||
$denormalizedEvaluation = $denormalizer->denormalize(
|
||||
$data,
|
||||
AccompanyingPeriodWorkEvaluation::class,
|
||||
'json',
|
||||
$context
|
||||
);
|
||||
|
||||
$this->assertSame($evaluation, $denormalizedEvaluation);
|
||||
$this->assertCount(1, $evaluation->getDocuments());
|
||||
$this->assertSame($doc, $evaluation->getDocuments()->first());
|
||||
$this->assertNotSame($storedObject, $evaluation->getDocuments()->first()->getStoredObject());
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user