mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-11-23 12:27:44 +00:00
Créer un point d'api de suggestion des usagers pour un ticket
This commit is contained in:
@@ -0,0 +1,70 @@
|
||||
<?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 Service\Ticket;
|
||||
|
||||
use Chill\PersonBundle\Entity\Person;
|
||||
use Chill\TicketBundle\Entity\CallerHistory;
|
||||
use Chill\TicketBundle\Entity\Ticket;
|
||||
use Chill\TicketBundle\Repository\PersonTicketACLAwareRepositoryInterface;
|
||||
use Chill\TicketBundle\Service\Ticket\SuggestPersonForTicket;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Prophecy\Argument;
|
||||
use Prophecy\PhpUnit\ProphecyTrait;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*
|
||||
* @coversNothing
|
||||
*/
|
||||
class SuggestPersonForTicketTest extends TestCase
|
||||
{
|
||||
use ProphecyTrait;
|
||||
|
||||
private \Prophecy\Prophecy\ObjectProphecy $repository;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
$this->repository = $this->prophesize(PersonTicketACLAwareRepositoryInterface::class);
|
||||
}
|
||||
|
||||
private function buildSuggestPersonForTicket(): SuggestPersonForTicket
|
||||
{
|
||||
return new SuggestPersonForTicket($this->repository->reveal());
|
||||
}
|
||||
|
||||
public function testSuggestPersonNoCaller()
|
||||
{
|
||||
$ticket = new Ticket();
|
||||
|
||||
assert(null === $ticket->getCaller());
|
||||
|
||||
$this->repository->findPersonPreviouslyAssociatedWithCaller(Argument::any())->shouldNotBeCalled();
|
||||
$suggester = $this->buildSuggestPersonForTicket();
|
||||
|
||||
self::assertEquals([], $suggester->suggestPerson($ticket));
|
||||
}
|
||||
|
||||
public function testSuggestPersonCaller()
|
||||
{
|
||||
$ticket = new Ticket();
|
||||
new CallerHistory($person = new Person(), $ticket);
|
||||
|
||||
assert($person === $ticket->getCaller());
|
||||
|
||||
$this->repository->findPersonPreviouslyAssociatedWithCaller($person, 0, 20)
|
||||
->willReturn($result = [new Person(), new Person()])
|
||||
->shouldBeCalledOnce();
|
||||
$suggester = $this->buildSuggestPersonForTicket();
|
||||
|
||||
self::assertEquals($result, $suggester->suggestPerson($ticket, 0, 20));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user