mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-07-26 10:37:45 +00:00
first commit
This commit is contained in:
parent
58119b3de0
commit
9aba4ea8f6
@ -36,56 +36,58 @@ class AccompanyingPeriodConfidentialTest extends WebTestCase
|
|||||||
public function setUp()
|
public function setUp()
|
||||||
{
|
{
|
||||||
$this->client = static::createClient([], [
|
$this->client = static::createClient([], [
|
||||||
'PHP_AUTH_USER' => 'fred',
|
'PHP_AUTH_USER' => 'multi_center',
|
||||||
'PHP_AUTH_PW' => 'password',
|
'PHP_AUTH_PW' => 'password',
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function dataGenerateRandomAccompanyingCourse()
|
public function dataGenerateRandomAccompanyingCourse()
|
||||||
{
|
{
|
||||||
$maxGenerated = 3;
|
// $maxGenerated = 3;
|
||||||
$maxResults = $maxGenerated * 8;
|
// $maxResults = $maxGenerated * 8;
|
||||||
|
|
||||||
static::bootKernel();
|
// static::bootKernel();
|
||||||
$em = static::$kernel->getContainer()->get('doctrine.orm.entity_manager');
|
// $em = static::$kernel->getContainer()->get('doctrine.orm.entity_manager');
|
||||||
$center = $em->getRepository(Center::class)
|
// $center = $em->getRepository(Center::class)
|
||||||
->findOneBy(['name' => 'Center A']);
|
// ->findOneBy(['name' => 'Center A']);
|
||||||
|
|
||||||
$qb = $em->createQueryBuilder();
|
// $qb = $em->createQueryBuilder();
|
||||||
$personIds = $qb
|
// $personIds = $qb
|
||||||
->select('p.id')
|
// ->select('p.id')
|
||||||
->distinct(true)
|
// ->distinct(true)
|
||||||
->from(Person::class, 'p')
|
// ->from(Person::class, 'p')
|
||||||
->join('p.accompanyingPeriodParticipations', 'participation')
|
// ->join('p.accompanyingPeriodParticipations', 'participation')
|
||||||
->join('participation.accompanyingPeriod', 'ap')
|
// ->join('participation.accompanyingPeriod', 'ap')
|
||||||
->andWhere(
|
// ->andWhere(
|
||||||
$qb->expr()->eq('ap.step', ':step')
|
// $qb->expr()->eq('ap.step', ':step')
|
||||||
)
|
// )
|
||||||
->andWhere(
|
// ->andWhere(
|
||||||
$qb->expr()->eq('ap.confidential', ':confidential')
|
// $qb->expr()->eq('ap.confidential', ':confidential')
|
||||||
)
|
// )
|
||||||
->setParameter('step', AccompanyingPeriod::STEP_CONFIRMED)
|
// ->setParameter('step', AccompanyingPeriod::STEP_CONFIRMED)
|
||||||
->setParameter('confidential', true)
|
// ->setParameter('confidential', true)
|
||||||
->setMaxResults($maxResults)
|
// ->setMaxResults($maxResults)
|
||||||
->getQuery()
|
// ->getQuery()
|
||||||
->getScalarResult();
|
// ->getScalarResult();
|
||||||
|
|
||||||
// create a random order
|
// // create a random order
|
||||||
shuffle($personIds);
|
// shuffle($personIds);
|
||||||
|
|
||||||
$nbGenerated = 0;
|
// $nbGenerated = 0;
|
||||||
|
|
||||||
while ($nbGenerated < $maxGenerated) {
|
// while ($nbGenerated < $maxGenerated) {
|
||||||
$id = array_pop($personIds)['id'];
|
// $id = array_pop($personIds)['id'];
|
||||||
|
|
||||||
$person = $em->getRepository(Person::class)
|
// $person = $em->getRepository(Person::class)
|
||||||
->find($id);
|
// ->find($id);
|
||||||
$periods = $person->getAccompanyingPeriods();
|
// $periods = $person->getAccompanyingPeriods();
|
||||||
|
|
||||||
yield [array_pop($personIds)['id'], $periods[array_rand($periods)]->getId()];
|
// yield [array_pop($personIds)['id'], $periods[array_rand($periods)]->getId()];
|
||||||
|
|
||||||
++$nbGenerated;
|
// ++$nbGenerated;
|
||||||
}
|
// }
|
||||||
|
|
||||||
|
yield [3744];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -93,19 +95,19 @@ class AccompanyingPeriodConfidentialTest extends WebTestCase
|
|||||||
*/
|
*/
|
||||||
public function testRemoveUserWhenConfidential(int $periodId)
|
public function testRemoveUserWhenConfidential(int $periodId)
|
||||||
{
|
{
|
||||||
$period = self::$container->get(AccompanyingPeriodRepository::class)
|
static::bootKernel();
|
||||||
->find($periodId);
|
|
||||||
$em = static::$kernel->getContainer()->get('doctrine.orm.entity_manager');
|
$em = static::$kernel->getContainer()->get('doctrine.orm.entity_manager');
|
||||||
|
$period = $em->getRepository(AccompanyingPeriod::class)
|
||||||
|
->find($periodId);
|
||||||
|
|
||||||
$isConfidential = $period->isConfidential();
|
$isConfidential = $period->isConfidential();
|
||||||
$step = $period->getStep();
|
$step = $period->getStep();
|
||||||
|
|
||||||
$initialUser = $period->getUser();
|
$initialUser = $period->getUser();
|
||||||
|
|
||||||
$user = new stdClass();
|
$user = new \stdClass();
|
||||||
$user->id = 0;
|
$user->id = "NULL";
|
||||||
$user->type = 'user';
|
$user->type = 'user';
|
||||||
dump($user);
|
|
||||||
|
|
||||||
$this->client->request(
|
$this->client->request(
|
||||||
Request::METHOD_PATCH,
|
Request::METHOD_PATCH,
|
||||||
@ -117,9 +119,7 @@ class AccompanyingPeriodConfidentialTest extends WebTestCase
|
|||||||
);
|
);
|
||||||
$response = $this->client->getResponse();
|
$response = $this->client->getResponse();
|
||||||
|
|
||||||
// if ($isConfidential === true && $step === 'CONFIRMED') {
|
|
||||||
$this->assertEquals(422, $response->getStatusCode());
|
$this->assertEquals(422, $response->getStatusCode());
|
||||||
// }
|
|
||||||
|
|
||||||
$this->assertEquals(200, $response->getStatusCode());
|
$this->assertEquals(200, $response->getStatusCode());
|
||||||
$period = $em->getRepository(AccompanyingPeriod::class)
|
$period = $em->getRepository(AccompanyingPeriod::class)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user