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); } }