logger->info("\033[1;34mStarting test... Get parameters as an admin\033[0m"); $this->loginAs($this->user); $this->get('/api/parameters/1'); $this->assertResponseStatusCodeSame(200); $this->logger->info("\033[1;32mTest 'testGetParametersCollection' succeed\033[0m"); $this->logger->info("\033[1;34mStarting test... Put parameters as an admin\033[0m"); $this->loginAs($this->user); $this->put('/api/parameters/1', [ 'bulletinCriteriaSort' => BulletinCriteriaSortEnum::ALPHANUM, 'advancedEducationNotationType' => AdvancedEducationNotationTypeEnum::BY_TEACHER, 'timezone' => TimeZoneEnum::INDIAN_REUNION, 'educationPeriodicity' => PeriodicityEnum::HALF, 'bulletinReceiver' => SendToBulletinEnum::STUDENTS_AND_THEIR_GUARDIANS, ]); $this->assertResponseStatusCodeSame(200); $this->logger->info("\033[1;32mTest 'Put parameters as an admin' succeed\033[0m"); $this->logger->info("\033[1;34mStarting test... put bad bulletin critieria sort\033[0m"); $this->loginAs($this->user); $this->put('/api/parameters/1', [ 'bulletinCriteriaSort' => 'BAD_CRITERIA_SORT', ]); $this->assertResponseStatusCodeSame(400); $this->logger->info("\033[1;32mTest 'testBadPutBulletinCriteriasort' succeed\033[0m"); $this->logger->info("\033[1;34mStarting test... put bad advances education notation type\033[0m"); $this->loginAs($this->user); $this->put('/api/parameters/1', [ 'bulletinCriteriaSort' => 'bad_advancedEducation', ]); $this->assertResponseStatusCodeSame(400); $this->logger->info("\033[1;32mTest 'put bad advances education notation type' succeed\033[0m"); $this->logger->info("\033[1;34mStarting test... delete paramaters as admin\033[0m"); $this->loginAs($this->user); $this->delete('/api/parameters/1'); $this->assertResponseStatusCodeSame(405); $this->logger->info("\033[1;32mTest 'delete paramaters as admin' succeed\033[0m"); $this->logger->info("\033[1;34mStarting test... put bad timezone\033[0m"); $this->loginAs($this->user); $this->put('/api/parameters/1', [ 'timezone' => 'bad_timezone', ]); $this->assertResponseStatusCodeSame(400); $this->logger->info("\033[1;32mTest 'put bad timezone' succeed\033[0m"); $this->logger->info("\033[1;34mStarting test... put bad periodicity\033[0m"); $this->loginAs($this->user); $this->put('/api/parameters/1', [ 'educationPeriodicity' => 'bad_periodicity', ]); $this->assertResponseStatusCodeSame(400); $this->logger->info("\033[1;32mTest 'put bad periodicity' succeed\033[0m"); $this->logger->info("\033[1;34mStarting test... get parameters as a non admin\033[0m"); $this->loginAsStudent($this->user); $this->get('/api/parameters/1'); $this->assertResponseStatusCodeSame(403); $this->logger->info("\033[1;32mTest 'get parameters as a non admin' succeed\033[0m"); $this->logger->info("\033[1;34mStarting test... put parameters as a non admin\033[0m"); $this->loginAsStudent($this->user); $this->put('/api/parameters/1', [ 'bulletinCriteriaSort' => BulletinCriteriaSortEnum::ALPHANUM, 'advancedEducationNotationType' => AdvancedEducationNotationTypeEnum::BY_TEACHER, 'timezone' => TimeZoneEnum::INDIAN_REUNION, 'educationPeriodicity' => PeriodicityEnum::HALF, 'bulletinReceiver' => SendToBulletinEnum::STUDENTS_AND_THEIR_GUARDIANS, ]); $this->assertResponseStatusCodeSame(403); $this->logger->info("\033[1;32mTest 'put parameters as a non admin' succeed\033[0m"); $this->logger->info("\033[1;34mStarting test... intru of organization try to acceed parameters info\033[0m"); $this->loginAsintruOfRoot($this->user); $this->get('/api/parameters/1'); $this->assertResponseStatusCodeSame(403); $this->assertJsonContains([ 'hydra:description' => 'Access Denied.', ]); $this->logger->info("\033[1;32mTest 'intru try to acceed param infos' succeed\033[0m"); } // public function testPutMethode(): void // { // $this->loginAs($this->user); // $this->put('/api/parameters/1', [ // 'bulletinCriteriaSort' => BulletinCriteriaSortEnum::ALPHANUM, // 'advancedEducationNotationType' => AdvancedEducationNotationTypeEnum::BY_TEACHER, // 'timezone' => TimeZoneEnum::INDIAN_REUNION, // 'educationPeriodicity' => PeriodicityEnum::HALF, // 'bulletinReceiver' => SendToBulletinEnum::STUDENTS_AND_THEIR_GUARDIANS // ]); // $this->assertResponseStatusCodeSame(200); // } // public function testBadPutBulletinCriteriasort() // { // $this->loginAs($this->user); // $this->put('/api/parameters/1', [ // 'bulletinCriteriaSort' => 'BAD_CRITERIA_SORT' // ]); // $this->assertResponseStatusCodeSame(400); // } // public function testBadadvancedEducationNotationType() // { // $this->loginAs($this->user); // $this->put('/api/parameters/1', [ // 'bulletinCriteriaSort' => 'bad_advancedEducation' // ]); // $this->assertResponseStatusCodeSame(400); // } // public function testDeleteParameters() // { // $this->loginAs($this->user); // $this->delete('/api/parameters/1'); // $this->assertResponseStatusCodeSame(405); // } // public function testBadTimeZone() // { // $this->loginAs($this->user); // $this->put('/api/parameters/1', [ // 'timezone' => 'bad_timezone' // ]); // $this->assertResponseStatusCodeSame(400); // } // public function testBadPeridicity() // { // $this->loginAs($this->user); // $this->put('/api/parameters/1', [ // 'educationPeriodicity' => 'bad_periodicity' // ]); // $this->assertResponseStatusCodeSame(400); // } // public function testGetParamatersWithBadRoles() // { // $this->loginAsStudent($this->user); // $this->get('/api/parameters/1'); // $this->assertResponseStatusCodeSame(403); // } // public function testPutParametersWithBadRoles() // { // $this->loginAsStudent($this->user); // $this->put('/api/parameters/1', [ // 'bulletinCriteriaSort' => BulletinCriteriaSortEnum::ALPHANUM, // 'advancedEducationNotationType' => AdvancedEducationNotationTypeEnum::BY_TEACHER, // 'timezone' => TimeZoneEnum::INDIAN_REUNION, // 'educationPeriodicity' => PeriodicityEnum::HALF, // 'bulletinReceiver' => SendToBulletinEnum::STUDENTS_AND_THEIR_GUARDIANS // ]); // $this->assertResponseStatusCodeSame(403); // } // public function testGetCollectionWithintruOfOrganization() // { // $this->loginAsintruOfRoot($this->user); // $this->get('/api/parameters/1'); // $this->assertResponseStatusCodeSame(403); // $this->assertJsonContains([ // "hydra:description" => "Access Denied." // ]); // } }