| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103 |
- <?php
- namespace App\Tests\Application\Education;
- use App\Tests\Application\OtWebTestCase;
- class EducationTimingTest extends OtWebTestCase
- {
- /**
- * TODO : revenir sur ces tests qui ne sont pas à jour
- * dû à des conflits de roles.
- */
- public function testEducationTimingResource()
- {
- $this->logger->info("\033[1;34mStarting test... get education Timings collection as an admin\033[0m");
- $this->loginAs($this->user);
- $this->get('/api/education_timings');
- $this->assertResponseStatusCodeSame(200);
- $this->assertJsonContains([
- 'hydra:member' => [
- [
- 'organization' => '/api/organizations/1',
- 'timing' => 45,
- ],
- ],
- ]);
- $this->logger->info("\033[1;32mTest 'get education Timings collection as an admin' succeed\033[0m");
- $this->logger->info("\033[1;34mStarting test... create an education timings as an admin\033[0m");
- $this->loginAs($this->user);
- $this->post('/api/education_timings', [
- 'timing' => 60,
- ]);
- $this->assertResponseStatusCodeSame(201);
- $this->assertJsonContains([
- '@context' => '/api/contexts/EducationTiming',
- '@id' => '/api/education_timings/3',
- '@type' => 'EducationTiming',
- 'id' => 3,
- 'timing' => 60,
- 'organization' => '/api/organizations/1',
- 'educationStudents' => [],
- 'educationCurriculums' => [],
- ]);
- $this->logger->info("\033[1;32mTest 'get education Timings collection as an admin' succeed\033[0m");
- $this->logger->info("\033[1;34mStarting test... change an education timing as an admin\033[0m");
- $this->loginAs($this->user);
- $this->put('/api/education_timings/1', [
- 'timing' => 60,
- ]);
- $this->logger->info("\033[1;32mTest 'change an education timing as an admin' succeed\033[0m");
- $this->logger->info("\033[1;34mStarting test... delete an education timing as an admin\033[0m");
- $this->loginAs($this->user);
- $this->delete('/api/education_timings/1');
- $this->logger->info("\033[1;32mTest 'delete an education timing as an admin' succeed\033[0m");
- $this->logger->info("\033[1;34mStarting test... change an education timing as an non admin\033[0m");
- $this->loginAsStudent($this->user);
- $this->put('/api/education_timings/1', [
- 'timing' => 60,
- ]);
- $this->assertResponseStatusCodeSame(404);
- $this->logger->info("\033[1;32mTest 'change an education timing as an admin' succeed\033[0m");
- $this->logger->info("\033[1;34mStarting test... delete an education timing as an non admin\033[0m");
- $this->loginAsStudent($this->user);
- $this->delete('/api/education_timings/1');
- $this->assertResponseStatusCodeSame(404);
- $this->logger->info("\033[1;32mTest 'delete an education timing as an non-admin' succeed\033[0m");
- $this->logger->info("\033[1;34mStarting test... intru of organization try to get an education timings\033[0m");
- $this->loginAsintruOfRoot($this->user);
- $this->get('/api/education_timings/1');
- $this->assertResponseStatusCodeSame(404);
- $this->logger->info("\033[1;32mTest 'intru of organization try to get an education timings' succeed\033[0m");
- $this->logger->info("\033[1;34mStarting test... intru of organization try to put an education timings\033[0m");
- $this->loginAsintruOfRoot($this->user);
- $this->put('/api/education_timings/1', [
- 'timing' => 60,
- 'organization' => '/api/organizations/1',
- ]);
- $this->assertResponseStatusCodeSame(404);
- $this->logger->info("\033[1;32mTest 'intru of organization try to put an education timings' succeed\033[0m");
- $this->logger->info("\033[1;34mStarting test... intru of organization try to delete an education timings\033[0m");
- $this->loginAsintruOfRoot($this->user);
- $this->delete('/api/education_timings/1');
- $this->assertResponseStatusCodeSame(404);
- $this->logger->info("\033[1;32mTest 'intru of organization try to delete an education timings' succeed\033[0m");
- $this->logger->info("\033[1;34mStarting test... intru of organization try to post an education timings\033[0m");
- $this->loginAsintruOfRoot($this->user);
- $this->post('/api/education_timings', [
- 'timing' => 45,
- 'organization' => '/api/organizations/1',
- ]);
- $this->assertResponseStatusCodeSame(400);
- $this->logger->info("\033[1;32mTest 'intru of organization try to post an education timings' succeed\033[0m");
- }
- }
|