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