loginAs($this->user); $this->assertResponseIsSuccessful(); $this->get('/api/residence_areas'); $this->assertResponseStatusCodeSame(200); $this->assertJsonContains([ '@context' => '/api/contexts/ResidenceArea', '@id' => '/api/residence_areas', '@type' => 'hydra:Collection', 'hydra:totalItems' => 1, 'hydra:member' => [ ["label" => "Résidence 1"] ], ]); } public function testPostResidenceArea() { $this->loginAs($this->user); $this->assertResponseIsSuccessful(); $this->post('/api/residence_areas', [ 'label' => 'toto', 'billingSetting' => '/api/billing_settings/1' ]); $this->assertResponseStatusCodeSame(201); $this->assertJsonContains([ '@context' => '/api/contexts/ResidenceArea', '@type' => 'ResidenceArea', 'label' => 'toto' ]); } public function testPutResidenceArea() { $this->loginAs($this->user); $this->put('/api/residence_areas/1', [ 'label' => 'tata', ]); $this->assertResponseStatusCodeSame(200); $this->assertJsonContains([ '@context' => '/api/contexts/ResidenceArea', '@type' => 'ResidenceArea', 'label' => 'tata', 'billingSetting' => '/api/billing_settings/1' ]); } public function testDeleteResidenceArea() { $this->loginAs($this->user); $this->delete('/api/residence_areas/1'); $this->assertResponseStatusCodeSame(204); } /// change adminAccess to false and retest public function testGetResidenceCollectionWithBadRoles() { $this->loginAsStudent($this->user); $this->get('/api/residence_areas'); $this->assertResponseStatusCodeSame(403); } }