mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-23 18:54:24 +00:00
fix cs
This commit is contained in:
parent
95a7efa138
commit
95975fae55
@ -26,6 +26,26 @@ use Symfony\Component\DependencyInjection\ParameterBag\ParameterBag;
|
||||
*/
|
||||
final class PhonenumberHelperTest extends KernelTestCase
|
||||
{
|
||||
/**
|
||||
* @dataProvider formatPhonenumbers
|
||||
*/
|
||||
public function testFormatPhonenumbers(string $defaultCarrierCode, string $phoneNumber, string $expected)
|
||||
{
|
||||
$util = PhoneNumberUtil::getInstance();
|
||||
|
||||
$subject = new PhonenumberHelper(
|
||||
new ArrayAdapter(),
|
||||
new ParameterBag([
|
||||
'chill_main.phone_helper' => [
|
||||
'default_carrier_code' => $defaultCarrierCode,
|
||||
],
|
||||
]),
|
||||
new NullLogger()
|
||||
);
|
||||
|
||||
$this->assertEquals($expected, $subject->format($util->parse($phoneNumber)));
|
||||
}
|
||||
|
||||
public static function formatPhonenumbers()
|
||||
{
|
||||
yield [
|
||||
@ -53,6 +73,26 @@ final class PhonenumberHelperTest extends KernelTestCase
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider providePhoneNumbersToParse
|
||||
*/
|
||||
public function testParsePhonenumbers(string $defaultCarrierCode, string $phoneNumber, PhoneNumber $expected): void
|
||||
{
|
||||
$subject = new PhonenumberHelper(
|
||||
new ArrayAdapter(),
|
||||
new ParameterBag([
|
||||
'chill_main.phone_helper' => [
|
||||
'default_carrier_code' => $defaultCarrierCode,
|
||||
],
|
||||
]),
|
||||
new NullLogger()
|
||||
);
|
||||
|
||||
$actual = $subject->parse($phoneNumber);
|
||||
|
||||
self::assertTrue($expected->equals($actual));
|
||||
}
|
||||
|
||||
public static function providePhoneNumbersToParse(): iterable
|
||||
{
|
||||
$util = PhoneNumberUtil::getInstance();
|
||||
@ -75,44 +115,4 @@ final class PhonenumberHelperTest extends KernelTestCase
|
||||
$util->parse('+33228858040', 'FR'),
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider formatPhonenumbers
|
||||
*/
|
||||
public function testFormatPhonenumbers(string $defaultCarrierCode, string $phoneNumber, string $expected)
|
||||
{
|
||||
$util = PhoneNumberUtil::getInstance();
|
||||
|
||||
$subject = new PhonenumberHelper(
|
||||
new ArrayAdapter(),
|
||||
new ParameterBag([
|
||||
'chill_main.phone_helper' => [
|
||||
'default_carrier_code' => $defaultCarrierCode,
|
||||
],
|
||||
]),
|
||||
new NullLogger()
|
||||
);
|
||||
|
||||
$this->assertEquals($expected, $subject->format($util->parse($phoneNumber)));
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider providePhoneNumbersToParse
|
||||
*/
|
||||
public function testParsePhonenumbers(string $defaultCarrierCode, string $phoneNumber, PhoneNumber $expected): void
|
||||
{
|
||||
$subject = new PhonenumberHelper(
|
||||
new ArrayAdapter(),
|
||||
new ParameterBag([
|
||||
'chill_main.phone_helper' => [
|
||||
'default_carrier_code' => $defaultCarrierCode,
|
||||
],
|
||||
]),
|
||||
new NullLogger()
|
||||
);
|
||||
|
||||
$actual = $subject->parse($phoneNumber);
|
||||
|
||||
self::assertTrue($expected->equals($actual));
|
||||
}
|
||||
}
|
||||
|
@ -50,6 +50,27 @@ class FindCallerControllerTest extends TestCase
|
||||
self::assertEqualsCanonicalizing($expected, $actual);
|
||||
}
|
||||
|
||||
public static function provideFindCaller(): iterable
|
||||
{
|
||||
yield [
|
||||
'32486540600',
|
||||
[],
|
||||
['found' => false, 'name' => null],
|
||||
];
|
||||
|
||||
yield [
|
||||
'32486540600',
|
||||
[new Person()],
|
||||
['found' => true, 'name' => 'pppp'],
|
||||
]
|
||||
;
|
||||
yield [
|
||||
'32486540600',
|
||||
[new Person(), new Person()],
|
||||
['found' => true, 'name' => 'multiple'],
|
||||
];
|
||||
}
|
||||
|
||||
public function testFindCallerWithoutCallerArgument(): void
|
||||
{
|
||||
self::expectException(BadRequestHttpException::class);
|
||||
@ -83,27 +104,6 @@ class FindCallerControllerTest extends TestCase
|
||||
$controller->findCaller($request);
|
||||
}
|
||||
|
||||
public static function provideFindCaller(): iterable
|
||||
{
|
||||
yield [
|
||||
'32486540600',
|
||||
[],
|
||||
['found' => false, 'name' => null],
|
||||
];
|
||||
|
||||
yield [
|
||||
'32486540600',
|
||||
[new Person()],
|
||||
['found' => true, 'name' => 'pppp'],
|
||||
]
|
||||
;
|
||||
yield [
|
||||
'32486540600',
|
||||
[new Person(), new Person()],
|
||||
['found' => true, 'name' => 'multiple'],
|
||||
];
|
||||
}
|
||||
|
||||
private function buildController(array $personsFound): FindCallerController
|
||||
{
|
||||
$phonenumberHelper =
|
||||
|
@ -70,6 +70,24 @@ class ReplaceMotiveControllerTest extends KernelTestCase
|
||||
self::assertEquals(201, $response->getStatusCode());
|
||||
}
|
||||
|
||||
public static function generateMotiveId(): iterable
|
||||
{
|
||||
self::bootKernel();
|
||||
$em = self::getContainer()->get(EntityManagerInterface::class);
|
||||
|
||||
$motive = $em->createQuery('SELECT m FROM '.Motive::class.' m ')
|
||||
->setMaxResults(1)
|
||||
->getOneOrNullResult();
|
||||
|
||||
if (null === $motive) {
|
||||
throw new \RuntimeException('the motive table seems to be empty');
|
||||
}
|
||||
|
||||
self::ensureKernelShutdown();
|
||||
|
||||
yield [$motive->getId()];
|
||||
}
|
||||
|
||||
private function buildController(): ReplaceMotiveController
|
||||
{
|
||||
$security = $this->prophesize(Security::class);
|
||||
@ -92,22 +110,4 @@ class ReplaceMotiveControllerTest extends KernelTestCase
|
||||
$entityManager->reveal(),
|
||||
);
|
||||
}
|
||||
|
||||
public static function generateMotiveId(): iterable
|
||||
{
|
||||
self::bootKernel();
|
||||
$em = self::getContainer()->get(EntityManagerInterface::class);
|
||||
|
||||
$motive = $em->createQuery('SELECT m FROM '.Motive::class.' m ')
|
||||
->setMaxResults(1)
|
||||
->getOneOrNullResult();
|
||||
|
||||
if (null === $motive) {
|
||||
throw new \RuntimeException('the motive table seems to be empty');
|
||||
}
|
||||
|
||||
self::ensureKernelShutdown();
|
||||
|
||||
yield [$motive->getId()];
|
||||
}
|
||||
}
|
||||
|
@ -85,6 +85,32 @@ class SetAddresseesControllerTest extends KernelTestCase
|
||||
self::assertGreaterThan(0, count($asArray['violations']));
|
||||
}
|
||||
|
||||
public static function getContentData(): iterable
|
||||
{
|
||||
self::bootKernel();
|
||||
$entityManager = self::getContainer()->get(EntityManagerInterface::class);
|
||||
|
||||
$userGroup = $entityManager->createQuery('SELECT ug FROM '.UserGroup::class.' ug ')
|
||||
->setMaxResults(1)->getOneOrNullResult();
|
||||
|
||||
if (null === $userGroup) {
|
||||
throw new \RuntimeException('User group not existing in database');
|
||||
}
|
||||
|
||||
$user = $entityManager->createQuery('SELECT u FROM '.User::class.' u')
|
||||
->setMaxResults(1)->getOneOrNullResult();
|
||||
|
||||
if (null === $user) {
|
||||
throw new \RuntimeException('User not existing in database');
|
||||
}
|
||||
|
||||
self::ensureKernelShutdown();
|
||||
|
||||
yield [[['type' => 'user', 'id' => $user->getId()]]];
|
||||
yield [[['type' => 'user', 'id' => $user->getId()], ['type' => 'user_group', 'id' => $userGroup->getId()]]];
|
||||
yield [[['type' => 'user_group', 'id' => $userGroup->getId()]]];
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider getContentDataUnique
|
||||
*/
|
||||
@ -149,32 +175,6 @@ class SetAddresseesControllerTest extends KernelTestCase
|
||||
yield [['type' => 'user_group', 'id' => $userGroup->getId()]];
|
||||
}
|
||||
|
||||
public static function getContentData(): iterable
|
||||
{
|
||||
self::bootKernel();
|
||||
$entityManager = self::getContainer()->get(EntityManagerInterface::class);
|
||||
|
||||
$userGroup = $entityManager->createQuery('SELECT ug FROM '.UserGroup::class.' ug ')
|
||||
->setMaxResults(1)->getOneOrNullResult();
|
||||
|
||||
if (null === $userGroup) {
|
||||
throw new \RuntimeException('User group not existing in database');
|
||||
}
|
||||
|
||||
$user = $entityManager->createQuery('SELECT u FROM '.User::class.' u')
|
||||
->setMaxResults(1)->getOneOrNullResult();
|
||||
|
||||
if (null === $user) {
|
||||
throw new \RuntimeException('User not existing in database');
|
||||
}
|
||||
|
||||
self::ensureKernelShutdown();
|
||||
|
||||
yield [[['type' => 'user', 'id' => $user->getId()]]];
|
||||
yield [[['type' => 'user', 'id' => $user->getId()], ['type' => 'user_group', 'id' => $userGroup->getId()]]];
|
||||
yield [[['type' => 'user_group', 'id' => $userGroup->getId()]]];
|
||||
}
|
||||
|
||||
private function buildController(bool $willSave, bool $isValid): SetAddresseesController
|
||||
{
|
||||
$user = new User();
|
||||
|
@ -59,6 +59,57 @@ class TicketNormalizerTest extends KernelTestCase
|
||||
}
|
||||
}
|
||||
|
||||
public static function provideTickets(): iterable
|
||||
{
|
||||
yield [
|
||||
// this a nearly empty ticket
|
||||
new Ticket(),
|
||||
[
|
||||
'type' => 'ticket_ticket',
|
||||
'id' => null,
|
||||
'externalRef' => '',
|
||||
'currentPersons' => [],
|
||||
'currentAddressees' => [],
|
||||
'currentInputs' => [],
|
||||
'currentMotive' => null,
|
||||
'history' => [],
|
||||
],
|
||||
];
|
||||
|
||||
// ticket with more features
|
||||
$ticket = new Ticket();
|
||||
$ticket->setExternalRef('2134');
|
||||
$personHistory = new PersonHistory(new Person(), $ticket, new \DateTimeImmutable('2024-04-01T12:00:00'));
|
||||
$ticketHistory = new MotiveHistory(new Motive(), $ticket, new \DateTimeImmutable('2024-04-01T12:02:00'));
|
||||
$comment = new Comment('blabla test', $ticket);
|
||||
$comment->setCreatedAt(new \DateTimeImmutable('2024-04-01T12:04:00'));
|
||||
$comment->setCreatedBy(new User());
|
||||
$addresseeHistory = new AddresseeHistory(new User(), new \DateTimeImmutable('2024-04-01T12:05:00'), $ticket);
|
||||
$addresseeHistory->setEndDate(new \DateTimeImmutable('2024-04-01T12:06:00'));
|
||||
new AddresseeHistory(new UserGroup(), new \DateTimeImmutable('2024-04-01T12:07:00'), $ticket);
|
||||
|
||||
yield [
|
||||
$ticket,
|
||||
[
|
||||
'type' => 'ticket_ticket',
|
||||
'id' => null,
|
||||
'externalRef' => '2134',
|
||||
'currentPersons' => ['embedded'],
|
||||
'currentAddressees' => ['embedded'],
|
||||
'currentInputs' => [],
|
||||
'currentMotive' => ['type' => 'motive', 'id' => 0],
|
||||
'history' => [
|
||||
['event_type' => 'add_person'],
|
||||
['event_type' => 'set_motive'],
|
||||
['event_type' => 'add_comment'],
|
||||
['event_type' => 'add_addressee'],
|
||||
['event_type' => 'remove_addressee'],
|
||||
['event_type' => 'add_addressee'],
|
||||
],
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
private function buildNormalizer(): TicketNormalizer
|
||||
{
|
||||
$normalizer = $this->prophesize(NormalizerInterface::class);
|
||||
@ -120,55 +171,4 @@ class TicketNormalizerTest extends KernelTestCase
|
||||
|
||||
return $ticketNormalizer;
|
||||
}
|
||||
|
||||
public static function provideTickets(): iterable
|
||||
{
|
||||
yield [
|
||||
// this a nearly empty ticket
|
||||
new Ticket(),
|
||||
[
|
||||
'type' => 'ticket_ticket',
|
||||
'id' => null,
|
||||
'externalRef' => '',
|
||||
'currentPersons' => [],
|
||||
'currentAddressees' => [],
|
||||
'currentInputs' => [],
|
||||
'currentMotive' => null,
|
||||
'history' => [],
|
||||
],
|
||||
];
|
||||
|
||||
// ticket with more features
|
||||
$ticket = new Ticket();
|
||||
$ticket->setExternalRef('2134');
|
||||
$personHistory = new PersonHistory(new Person(), $ticket, new \DateTimeImmutable('2024-04-01T12:00:00'));
|
||||
$ticketHistory = new MotiveHistory(new Motive(), $ticket, new \DateTimeImmutable('2024-04-01T12:02:00'));
|
||||
$comment = new Comment('blabla test', $ticket);
|
||||
$comment->setCreatedAt(new \DateTimeImmutable('2024-04-01T12:04:00'));
|
||||
$comment->setCreatedBy(new User());
|
||||
$addresseeHistory = new AddresseeHistory(new User(), new \DateTimeImmutable('2024-04-01T12:05:00'), $ticket);
|
||||
$addresseeHistory->setEndDate(new \DateTimeImmutable('2024-04-01T12:06:00'));
|
||||
new AddresseeHistory(new UserGroup(), new \DateTimeImmutable('2024-04-01T12:07:00'), $ticket);
|
||||
|
||||
yield [
|
||||
$ticket,
|
||||
[
|
||||
'type' => 'ticket_ticket',
|
||||
'id' => null,
|
||||
'externalRef' => '2134',
|
||||
'currentPersons' => ['embedded'],
|
||||
'currentAddressees' => ['embedded'],
|
||||
'currentInputs' => [],
|
||||
'currentMotive' => ['type' => 'motive', 'id' => 0],
|
||||
'history' => [
|
||||
['event_type' => 'add_person'],
|
||||
['event_type' => 'set_motive'],
|
||||
['event_type' => 'add_comment'],
|
||||
['event_type' => 'add_addressee'],
|
||||
['event_type' => 'remove_addressee'],
|
||||
['event_type' => 'add_addressee'],
|
||||
],
|
||||
],
|
||||
];
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user