| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178 |
- <?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 testEducationTimingsCollection()
- {
- $this->loginAs($this->user);
- $this->get('/api/education_timings');
- $this->assertResponseIsSuccessful();
- $this->assertResponseStatusCodeSame(200);
- $this->assertJsonContains([
- 'hydra:member' => [
- [
- 'organization' => '/api/organizations/1',
- 'timing' => 45
- ]
- ]
- ]);
- }
- public function testEducationTimingsCreate()
- {
- $this->loginAs($this->user);
- $this->assertResponseIsSuccessful();
- $this->post('/api/education_timings', [
- "timing" => 60,
- ]);
- $this->assertResponseStatusCodeSame(201);
-
- // $responseContent = $this->client->getResponse()->getContent();
- // echo "\nResponse after POST: " . $responseContent;
- $this->assertJsonContains([
- '@context' => '/api/contexts/EducationTiming',
- '@id' => '/api/education_timings/3',
- '@type' => 'EducationTiming',
- "id" => 3,
- 'timing' => 60,
- 'organization' => '/api/organizations/1',
- 'educationStudents' => [],
- 'educationCurriculums' => [],
- ]);
- }
- public function testPutEducationTimings()
- {
- $this->loginAs($this->user);
- $this->assertResponseIsSuccessful();
- $this->put('/api/education_timings/1', [
- "timing" => 60,
- ]);
- }
- public function testDeleteEducationTimings()
- {
- $this->loginAs($this->user);
- $this->assertResponseIsSuccessful();
- $this->delete('/api/education_timings/1');
- }
- public function testPutWithNoRoles()
- {
- // attention : vériier que l'on a pas les droits
- $this->loginAsStudent($this->user);
- $this->assertResponseIsSuccessful();
- $this->put('/api/education_timings/1', [
- "timing" => 60,
- ]);
- // erreur
- $this->assertResponseStatusCodeSame(200);
- }
- public function testDeleteWithNoRoles()
- {
- // attention : vériier que l'on a pas les droits
- $this->loginAsStudent($this->user);
- $this->assertResponseIsSuccessful();
- $this->delete('/api/education_timings/1');
- $this->assertResponseStatusCodeSame(204);
- }
- // attention un eleve ne peut pas créer/modifier un educationTiming
- // public function testPostWithNoRoles()
- // {
- // // attention : vériier que l'on a pas les droits
- // $this->loginAsStudent($this->user);
- // $this->assertResponseIsSuccessful();
- // $this->put('/api/education_timings/1', [
- // "timing" => 60,
- // ]);
- // $this->assertResponseStatusCodeSame(404);
- // }
- public function testgetFromOtherOrganization()
- {
- $this->loginAsintruOfRoot($this->user);
- $this->assertResponseIsSuccessful();
- $this->get('/api/education_timings/1');
- $this->assertResponseStatusCodeSame(404);
- }
- public function testPutFromOtherOrganization()
- {
- $this->loginAsintruOfRoot($this->user);
- $this->assertResponseIsSuccessful();
- $this->put('/api/education_timings/1', [
- "timing" => 60,
- "organization" => "/api/organizations/1",
- ]);
- // not found -> l'id de cet educationTiming n'existe pas dans l'organisation de l'intru
- $this->assertResponseStatusCodeSame(404);
- }
- public function testDeleteFromOtherOrganization()
- {
- $this->loginAsintruOfRoot($this->user);
- $this->assertResponseIsSuccessful();
- $this->delete('/api/education_timings/1');
- $this->assertResponseStatusCodeSame(404);
- }
- public function testPostFromOtherOrganization()
- {
- $this->loginAsintruOfRoot($this->user);
- $this->assertResponseIsSuccessful();
- $this->post('/api/education_timings', [
- "timing" => 45,
- "organization" => "/api/organizations/1",
- ]);
- $this->assertResponseStatusCodeSame(400);
- }
- }
|