| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204 |
- <?php
- namespace App\Tests\Application\Organization;
- use App\Enum\Core\TimeZoneEnum;
- use App\Enum\Education\AdvancedEducationNotationTypeEnum;
- use App\Enum\Education\PeriodicityEnum;
- use App\Enum\Organization\BulletinCriteriaSortEnum;
- use App\Enum\Organization\SendToBulletinEnum;
- use App\Tests\Application\OtWebTestCase;
- class ParametersTest extends OtWebTestCase
- {
- public function testGetParametersCollection(): void
- {
- $this->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."
- // ]);
- // }
- }
|