mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-09-26 16:45:01 +00:00
fix cs
This commit is contained in:
@@ -32,6 +32,17 @@ final class AddressControllerTest extends \Symfony\Bundle\FrameworkBundle\Test\W
|
||||
self::ensureKernelShutdown();
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider generateAddressIds
|
||||
*/
|
||||
public function testDuplicate(int $addressId)
|
||||
{
|
||||
$this->client = $this->getClientAuthenticated();
|
||||
$this->client->request('POST', "/api/1.0/main/address/{$addressId}/duplicate.json");
|
||||
|
||||
$this->assertResponseIsSuccessful('test that duplicate is successful');
|
||||
}
|
||||
|
||||
public static function generateAddressIds(): iterable
|
||||
{
|
||||
self::bootKernel();
|
||||
@@ -49,15 +60,4 @@ final class AddressControllerTest extends \Symfony\Bundle\FrameworkBundle\Test\W
|
||||
|
||||
self::ensureKernelShutdown();
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider generateAddressIds
|
||||
*/
|
||||
public function testDuplicate(int $addressId)
|
||||
{
|
||||
$this->client = $this->getClientAuthenticated();
|
||||
$this->client->request('POST', "/api/1.0/main/address/{$addressId}/duplicate.json");
|
||||
|
||||
$this->assertResponseIsSuccessful('test that duplicate is successful');
|
||||
}
|
||||
}
|
||||
|
@@ -25,6 +25,22 @@ final class AddressReferenceApiControllerTest extends WebTestCase
|
||||
{
|
||||
use PrepareClientTrait;
|
||||
|
||||
/**
|
||||
* @dataProvider provideData
|
||||
*/
|
||||
public function testSearch(int $postCodeId, string $pattern)
|
||||
{
|
||||
$client = $this->getClientAuthenticated();
|
||||
|
||||
$client->request(
|
||||
'GET',
|
||||
"/api/1.0/main/address-reference/by-postal-code/{$postCodeId}/search.json",
|
||||
['q' => $pattern]
|
||||
);
|
||||
|
||||
$this->assertResponseIsSuccessful();
|
||||
}
|
||||
|
||||
public static function provideData()
|
||||
{
|
||||
self::bootKernel();
|
||||
@@ -42,20 +58,4 @@ final class AddressReferenceApiControllerTest extends WebTestCase
|
||||
|
||||
yield [$postalCode->getId(), 'rue'];
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider provideData
|
||||
*/
|
||||
public function testSearch(int $postCodeId, string $pattern)
|
||||
{
|
||||
$client = $this->getClientAuthenticated();
|
||||
|
||||
$client->request(
|
||||
'GET',
|
||||
"/api/1.0/main/address-reference/by-postal-code/{$postCodeId}/search.json",
|
||||
['q' => $pattern]
|
||||
);
|
||||
|
||||
$this->assertResponseIsSuccessful();
|
||||
}
|
||||
}
|
||||
|
@@ -52,26 +52,6 @@ class AddressToReferenceMatcherControllerTest extends WebTestCase
|
||||
$this->assertEquals(Address::ADDR_REFERENCE_STATUS_REVIEWED, $address->getRefStatus());
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider addressUnsyncedProvider
|
||||
*/
|
||||
public function testSyncAddressWithReference(int $addressId): void
|
||||
{
|
||||
$client = $this->getClientAuthenticated();
|
||||
|
||||
$client->request('POST', "/api/1.0/main/address/reference-match/{$addressId}/sync-with-reference");
|
||||
|
||||
$this->assertResponseIsSuccessful();
|
||||
|
||||
$this->addressRepository = self::getContainer()->get(AddressRepository::class);
|
||||
$address = $this->addressRepository->find($addressId);
|
||||
|
||||
$this->assertEquals(Address::ADDR_REFERENCE_STATUS_MATCH, $address->getRefStatus());
|
||||
$this->assertEquals($address->getAddressReference()->getStreet(), $address->getStreet());
|
||||
$this->assertEquals($address->getAddressReference()->getStreetNumber(), $address->getStreetNumber());
|
||||
$this->assertEquals($address->getAddressReference()->getPoint()->toWKT(), $address->getPoint()->toWKT());
|
||||
}
|
||||
|
||||
public static function addressToReviewProvider(): iterable
|
||||
{
|
||||
self::bootKernel();
|
||||
@@ -98,6 +78,26 @@ class AddressToReferenceMatcherControllerTest extends WebTestCase
|
||||
self::ensureKernelShutdown();
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider addressUnsyncedProvider
|
||||
*/
|
||||
public function testSyncAddressWithReference(int $addressId): void
|
||||
{
|
||||
$client = $this->getClientAuthenticated();
|
||||
|
||||
$client->request('POST', "/api/1.0/main/address/reference-match/{$addressId}/sync-with-reference");
|
||||
|
||||
$this->assertResponseIsSuccessful();
|
||||
|
||||
$this->addressRepository = self::getContainer()->get(AddressRepository::class);
|
||||
$address = $this->addressRepository->find($addressId);
|
||||
|
||||
$this->assertEquals(Address::ADDR_REFERENCE_STATUS_MATCH, $address->getRefStatus());
|
||||
$this->assertEquals($address->getAddressReference()->getStreet(), $address->getStreet());
|
||||
$this->assertEquals($address->getAddressReference()->getStreetNumber(), $address->getStreetNumber());
|
||||
$this->assertEquals($address->getAddressReference()->getPoint()->toWKT(), $address->getPoint()->toWKT());
|
||||
}
|
||||
|
||||
public static function addressUnsyncedProvider(): iterable
|
||||
{
|
||||
self::bootKernel();
|
||||
|
@@ -55,6 +55,25 @@ class NewsItemControllerTest extends WebTestCase
|
||||
$em->flush();
|
||||
}
|
||||
|
||||
public function testList()
|
||||
{
|
||||
$client = $this->getClientAuthenticated('admin', 'password');
|
||||
$client->request('GET', '/fr/admin/news_item');
|
||||
|
||||
self::assertResponseIsSuccessful('News item admin page shows');
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider generateNewsItemIds
|
||||
*/
|
||||
public function testShowSingleItem(NewsItem $newsItem)
|
||||
{
|
||||
$client = $this->getClientAuthenticated('admin', 'password');
|
||||
$client->request('GET', "/fr/admin/news_item/{$newsItem->getId()}/view");
|
||||
|
||||
self::assertResponseIsSuccessful('Single news item admin page loads successfully');
|
||||
}
|
||||
|
||||
public static function generateNewsItemIds(): iterable
|
||||
{
|
||||
self::bootKernel();
|
||||
@@ -74,23 +93,4 @@ class NewsItemControllerTest extends WebTestCase
|
||||
|
||||
yield [$newsItem];
|
||||
}
|
||||
|
||||
public function testList()
|
||||
{
|
||||
$client = $this->getClientAuthenticated('admin', 'password');
|
||||
$client->request('GET', '/fr/admin/news_item');
|
||||
|
||||
self::assertResponseIsSuccessful('News item admin page shows');
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider generateNewsItemIds
|
||||
*/
|
||||
public function testShowSingleItem(NewsItem $newsItem)
|
||||
{
|
||||
$client = $this->getClientAuthenticated('admin', 'password');
|
||||
$client->request('GET', "/fr/admin/news_item/{$newsItem->getId()}/view");
|
||||
|
||||
self::assertResponseIsSuccessful('Single news item admin page loads successfully');
|
||||
}
|
||||
}
|
||||
|
@@ -51,27 +51,6 @@ class NewsItemsHistoryControllerTest extends WebTestCase
|
||||
self::ensureKernelShutdown();
|
||||
}
|
||||
|
||||
public static function generateNewsItemIds(): iterable
|
||||
{
|
||||
self::bootKernel();
|
||||
$em = self::getContainer()->get(EntityManagerInterface::class);
|
||||
|
||||
$news = new NewsItem();
|
||||
|
||||
$news->setContent('test content');
|
||||
$news->setTitle('Title');
|
||||
$news->setStartDate(new \DateTimeImmutable('yesterday'));
|
||||
|
||||
$em->persist($news);
|
||||
$em->flush();
|
||||
|
||||
static::$toDelete[] = [NewsItem::class, $news];
|
||||
|
||||
self::ensureKernelShutdown();
|
||||
|
||||
yield [$news->getId()];
|
||||
}
|
||||
|
||||
public function testList()
|
||||
{
|
||||
self::ensureKernelShutdown();
|
||||
@@ -94,4 +73,25 @@ class NewsItemsHistoryControllerTest extends WebTestCase
|
||||
|
||||
$this->assertResponseIsSuccessful('test that single news item page loads successfully');
|
||||
}
|
||||
|
||||
public static function generateNewsItemIds(): iterable
|
||||
{
|
||||
self::bootKernel();
|
||||
$em = self::getContainer()->get(EntityManagerInterface::class);
|
||||
|
||||
$news = new NewsItem();
|
||||
|
||||
$news->setContent('test content');
|
||||
$news->setTitle('Title');
|
||||
$news->setStartDate(new \DateTimeImmutable('yesterday'));
|
||||
|
||||
$em->persist($news);
|
||||
$em->flush();
|
||||
|
||||
static::$toDelete[] = [NewsItem::class, $news];
|
||||
|
||||
self::ensureKernelShutdown();
|
||||
|
||||
yield [$news->getId()];
|
||||
}
|
||||
}
|
||||
|
@@ -44,33 +44,6 @@ final class NotificationApiControllerTest extends WebTestCase
|
||||
self::$toDelete = [];
|
||||
}
|
||||
|
||||
public static function generateDataMarkAsRead()
|
||||
{
|
||||
self::bootKernel();
|
||||
$em = self::getContainer()->get(EntityManagerInterface::class);
|
||||
$userRepository = self::getContainer()->get(UserRepository::class);
|
||||
$userA = $userRepository->findOneBy(['username' => 'center a_social']);
|
||||
$userB = $userRepository->findOneBy(['username' => 'center b_social']);
|
||||
|
||||
$notification = new Notification();
|
||||
$notification
|
||||
->setMessage('Test generated')
|
||||
->setRelatedEntityClass(AccompanyingPeriod::class)
|
||||
->setRelatedEntityId(0)
|
||||
->setSender($userB)
|
||||
->addAddressee($userA)
|
||||
->setUpdatedAt(new \DateTimeImmutable());
|
||||
$em->persist($notification);
|
||||
$em->refresh($notification);
|
||||
$em->flush();
|
||||
|
||||
self::$toDelete[] = [Notification::class, $notification->getId()];
|
||||
|
||||
self::ensureKernelShutdown();
|
||||
|
||||
yield [$notification->getId()];
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider generateDataMarkAsRead
|
||||
*/
|
||||
@@ -99,4 +72,31 @@ final class NotificationApiControllerTest extends WebTestCase
|
||||
|
||||
$this->assertFalse($notification->isReadBy($user));
|
||||
}
|
||||
|
||||
public static function generateDataMarkAsRead()
|
||||
{
|
||||
self::bootKernel();
|
||||
$em = self::getContainer()->get(EntityManagerInterface::class);
|
||||
$userRepository = self::getContainer()->get(UserRepository::class);
|
||||
$userA = $userRepository->findOneBy(['username' => 'center a_social']);
|
||||
$userB = $userRepository->findOneBy(['username' => 'center b_social']);
|
||||
|
||||
$notification = new Notification();
|
||||
$notification
|
||||
->setMessage('Test generated')
|
||||
->setRelatedEntityClass(AccompanyingPeriod::class)
|
||||
->setRelatedEntityId(0)
|
||||
->setSender($userB)
|
||||
->addAddressee($userA)
|
||||
->setUpdatedAt(new \DateTimeImmutable());
|
||||
$em->persist($notification);
|
||||
$em->refresh($notification);
|
||||
$em->flush();
|
||||
|
||||
self::$toDelete[] = [Notification::class, $notification->getId()];
|
||||
|
||||
self::ensureKernelShutdown();
|
||||
|
||||
yield [$notification->getId()];
|
||||
}
|
||||
}
|
||||
|
@@ -24,17 +24,6 @@ final class SearchApiControllerTest extends WebTestCase
|
||||
{
|
||||
use PrepareClientTrait;
|
||||
|
||||
public static function generateSearchData()
|
||||
{
|
||||
yield ['per', ['person', 'thirdparty']];
|
||||
|
||||
yield ['per', ['thirdparty']];
|
||||
|
||||
yield ['per', ['person']];
|
||||
|
||||
yield ['fjklmeqjfkdqjklrmefdqjklm', ['person', 'thirdparty']];
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider generateSearchData
|
||||
*/
|
||||
@@ -50,4 +39,15 @@ final class SearchApiControllerTest extends WebTestCase
|
||||
|
||||
$this->assertResponseIsSuccessful();
|
||||
}
|
||||
|
||||
public static function generateSearchData()
|
||||
{
|
||||
yield ['per', ['person', 'thirdparty']];
|
||||
|
||||
yield ['per', ['thirdparty']];
|
||||
|
||||
yield ['per', ['person']];
|
||||
|
||||
yield ['fjklmeqjfkdqjklrmefdqjklm', ['person', 'thirdparty']];
|
||||
}
|
||||
}
|
||||
|
@@ -27,25 +27,6 @@ final class UserControllerTest extends WebTestCase
|
||||
{
|
||||
use PrepareClientTrait;
|
||||
|
||||
public static function dataGenerateUserId()
|
||||
{
|
||||
self::bootKernel();
|
||||
$em = self::getContainer()->get(EntityManagerInterface::class);
|
||||
/** @var UserPasswordHasherInterface::class $passwordHasher */
|
||||
$passwordHasher = self::getContainer()->get(UserPasswordHasherInterface::class);
|
||||
|
||||
$user = new User();
|
||||
$user->setUsername('Test_user '.uniqid());
|
||||
$user->setPassword($passwordHasher->hashPassword($user, 'password'));
|
||||
|
||||
$em->persist($user);
|
||||
$em->flush();
|
||||
|
||||
self::ensureKernelShutdown();
|
||||
|
||||
yield [$user->getId(), $user->getUsername()];
|
||||
}
|
||||
|
||||
public function testList()
|
||||
{
|
||||
$client = $this->getClientAuthenticatedAsAdmin();
|
||||
@@ -135,6 +116,25 @@ final class UserControllerTest extends WebTestCase
|
||||
$this->isPasswordValid($username, $newPassword);
|
||||
}
|
||||
|
||||
public static function dataGenerateUserId()
|
||||
{
|
||||
self::bootKernel();
|
||||
$em = self::getContainer()->get(EntityManagerInterface::class);
|
||||
/** @var UserPasswordHasherInterface::class $passwordHasher */
|
||||
$passwordHasher = self::getContainer()->get(UserPasswordHasherInterface::class);
|
||||
|
||||
$user = new User();
|
||||
$user->setUsername('Test_user '.uniqid());
|
||||
$user->setPassword($passwordHasher->hashPassword($user, 'password'));
|
||||
|
||||
$em->persist($user);
|
||||
$em->flush();
|
||||
|
||||
self::ensureKernelShutdown();
|
||||
|
||||
yield [$user->getId(), $user->getUsername()];
|
||||
}
|
||||
|
||||
protected function isPasswordValid($username, $password)
|
||||
{
|
||||
/** @var \Symfony\Component\PasswordHasher\Hasher\UserPasswordHasher $passwordEncoder */
|
||||
|
Reference in New Issue
Block a user