Implement functionality to replace ticket's motive

The commit introduces several features related to ticket motive management in the Chill-TicketBundle:
- Adds capability to replace a ticket's motive with a new one.
- Provides ticket motive history management features.
- Implements relevant changes in Controller, Action Handler, and Entity levels.
- Incorporates new API endpoints and updates the API specification file for the new feature.
- Includes tests to ensure the new functionality works as expected.
This commit is contained in:
2024-04-17 21:41:30 +02:00
parent a9760b323f
commit 670b8eb82b
8 changed files with 467 additions and 0 deletions

View File

@@ -0,0 +1,47 @@
<?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\TicketBundle\Tests\Entity;
use Chill\TicketBundle\Entity\Motive;
use Chill\TicketBundle\Entity\MotiveHistory;
use Chill\TicketBundle\Entity\Ticket;
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
/**
* @internal
*
* @coversNothing
*/
class TicketTest extends KernelTestCase
{
public function testGetMotive(): void
{
$ticket = new Ticket();
$motive = new Motive();
self::assertNull($ticket->getMotive());
$history = new MotiveHistory($motive, $ticket);
$ticket->addMotiveHistory($history);
self::assertSame($motive, $ticket->getMotive());
self::assertCount(1, $ticket->getMotiveHistories());
// replace motive
$motive2 = new Motive();
$history->setEndDate(new \DateTimeImmutable());
$ticket->addMotiveHistory(new MotiveHistory($motive2, $ticket));
self::assertCount(2, $ticket->getMotiveHistories());
self::assertSame($motive2, $ticket->getMotive());
}
}