mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-24 03:04:22 +00:00
53 lines
1.5 KiB
PHP
53 lines
1.5 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\TicketBundle\Tests\Action\Ticket\Handler;
|
|
|
|
use Chill\TicketBundle\Action\Ticket\CreateTicketCommand;
|
|
use Chill\TicketBundle\Action\Ticket\Handler\CreateTicketCommandHandler;
|
|
use Chill\TicketBundle\Entity\StateEnum;
|
|
use Chill\TicketBundle\Entity\Ticket;
|
|
use PHPUnit\Framework\TestCase;
|
|
use Symfony\Component\Clock\MockClock;
|
|
|
|
/**
|
|
* @internal
|
|
*
|
|
* @coversNothing
|
|
*/
|
|
class CreateTicketCommandHandlerTest extends TestCase
|
|
{
|
|
private function getHandler(): CreateTicketCommandHandler
|
|
{
|
|
return new CreateTicketCommandHandler(new MockClock());
|
|
}
|
|
|
|
public function testHandleWithoutReference(): void
|
|
{
|
|
$command = new CreateTicketCommand();
|
|
$actual = ($this->getHandler())($command);
|
|
|
|
self::assertInstanceOf(Ticket::class, $actual);
|
|
self::assertEquals('', $actual->getExternalRef());
|
|
self::assertEquals(StateEnum::OPEN, $actual->getState());
|
|
}
|
|
|
|
public function testHandleWithReference(): void
|
|
{
|
|
$command = new CreateTicketCommand($ref = 'external-ref');
|
|
$actual = ($this->getHandler())($command);
|
|
|
|
self::assertInstanceOf(Ticket::class, $actual);
|
|
self::assertEquals($ref, $actual->getExternalRef());
|
|
self::assertEquals(StateEnum::OPEN, $actual->getState());
|
|
}
|
|
}
|