mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-09-06 23:04:58 +00:00
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:
47
src/Bundle/ChillTicketBundle/tests/Entity/TicketTest.php
Normal file
47
src/Bundle/ChillTicketBundle/tests/Entity/TicketTest.php
Normal 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());
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user