mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2026-04-04 12:03:44 +00:00
- Introduced `AccompanyingPeriodWorkEvaluationDocumentSubjectConverter` for converting entities into audit subjects. - Added `AccompanyingPeriodWorkEvaluationDocumentSubjectDisplayer` for translating and displaying audit subjects. - Added necessary translation keys for display messages. - Implemented unit tests for both the converter and displayer to ensure correctness and reliability. - Updated `AccompanyingPeriodWorkSubjectConverter` to handle related accompanying periods.
92 lines
3.4 KiB
PHP
92 lines
3.4 KiB
PHP
<?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\PersonBundle\Tests\Audit\SubjectConverter;
|
|
|
|
use Chill\MainBundle\Audit\Subject;
|
|
use Chill\MainBundle\Audit\SubjectBag;
|
|
use Chill\MainBundle\Audit\SubjectConverterManagerInterface;
|
|
use Chill\PersonBundle\Audit\SubjectConverter\AccompanyingPeriodWorkEvaluationDocumentSubjectConverter;
|
|
use Chill\PersonBundle\Entity\AccompanyingPeriod\AccompanyingPeriodWork;
|
|
use Chill\PersonBundle\Entity\AccompanyingPeriod\AccompanyingPeriodWorkEvaluation;
|
|
use Chill\PersonBundle\Entity\AccompanyingPeriod\AccompanyingPeriodWorkEvaluationDocument;
|
|
use PHPUnit\Framework\TestCase;
|
|
use Prophecy\PhpUnit\ProphecyTrait;
|
|
|
|
/**
|
|
* @internal
|
|
*
|
|
* @coversNothing
|
|
*/
|
|
class AccompanyingPeriodWorkEvaluationDocumentSubjectConverterTest extends TestCase
|
|
{
|
|
use ProphecyTrait;
|
|
|
|
private AccompanyingPeriodWorkEvaluationDocumentSubjectConverter $converter;
|
|
|
|
protected function setUp(): void
|
|
{
|
|
$this->converter = new AccompanyingPeriodWorkEvaluationDocumentSubjectConverter();
|
|
}
|
|
|
|
public function testSupportsConvert(): void
|
|
{
|
|
$this->assertTrue($this->converter->supportsConvert($this->prophesize(AccompanyingPeriodWorkEvaluationDocument::class)->reveal()));
|
|
$this->assertFalse($this->converter->supportsConvert(new \stdClass()));
|
|
}
|
|
|
|
public function testConvert(): void
|
|
{
|
|
$document = $this->prophesize(AccompanyingPeriodWorkEvaluationDocument::class);
|
|
$document->getId()->willReturn(123);
|
|
|
|
$evaluation = $this->prophesize(AccompanyingPeriodWorkEvaluation::class);
|
|
$work = $this->prophesize(AccompanyingPeriodWork::class);
|
|
|
|
$document->getAccompanyingPeriodWorkEvaluation()->willReturn($evaluation->reveal());
|
|
$evaluation->getAccompanyingPeriodWork()->willReturn($work->reveal());
|
|
|
|
$subjectConverterManager = $this->prophesize(SubjectConverterManagerInterface::class);
|
|
|
|
$workSubject = new Subject('accompanying_period_work', ['id' => 456]);
|
|
$workBag = new SubjectBag($workSubject);
|
|
|
|
$subjectConverterManager->getSubjectsForEntity($work->reveal(), false)->willReturn($workBag);
|
|
|
|
$this->converter->setSubjectConverterManager($subjectConverterManager->reveal());
|
|
|
|
$result = $this->converter->convert($document->reveal());
|
|
|
|
$this->assertSame('accompanying_period_work_evaluation_document', $result->subject->type);
|
|
$this->assertSame(['id' => 123], $result->subject->identifiers);
|
|
|
|
$this->assertCount(1, $result->associatedSubjects);
|
|
$this->assertSame($workSubject, $result->associatedSubjects[0]);
|
|
}
|
|
|
|
public function testConvertWithoutEvaluation(): void
|
|
{
|
|
$document = $this->prophesize(AccompanyingPeriodWorkEvaluationDocument::class);
|
|
$document->getId()->willReturn(123);
|
|
$document->getAccompanyingPeriodWorkEvaluation()->willReturn(null);
|
|
|
|
$result = $this->converter->convert($document->reveal());
|
|
|
|
$this->assertSame('accompanying_period_work_evaluation_document', $result->subject->type);
|
|
$this->assertEmpty($result->associatedSubjects);
|
|
}
|
|
|
|
public function testGetDefaultPriority(): void
|
|
{
|
|
$this->assertSame(10, AccompanyingPeriodWorkEvaluationDocumentSubjectConverter::getDefaultPriority());
|
|
}
|
|
}
|