loginAs($this->user); $this->assertResponseIsSuccessful(); $this->get('/api/cycles'); $this->assertResponseStatusCodeSame(200); } public function testCycleById() { $this->loginAs($this->user); $this->assertResponseIsSuccessful(); $this->get('/api/cycles/1'); $this->assertResponseStatusCodeSame(200); $this->assertJsonContains([ 'label' => 'Cycle 1' ]); } public function testPutCycle() { $this->loginAs($this->user); $this->assertResponseIsSuccessful(); $this->put('/api/cycles/1', [ 'label' => 'new label' ]); $this->assertResponseStatusCodeSame(200); $this->assertJsonContains([ 'label' => 'new label' ]); } public function testDeleteCycle() { $this->loginAs($this->user); $this->assertResponseIsSuccessful(); $this->delete('/api/cycles/1'); $this->assertResponseStatusCodeSame(405); } public function testCycleWithBadTypeCycleEnum() { $this->loginAs($this->user); $this->assertResponseIsSuccessful(); $this->put('/api/cycles/1', [ 'cycleEnum' => 'bad type' ]); $this->assertResponseStatusCodeSame(400); } public function testCycleGetHasNoRole() { $this->loginAsStudent($this->user); $this->get('/api/cycles/1'); $this->validateCollectionSchema(Cycle::class, 403); $this->assertJsonContains([ "hydra:description" => "Access Denied." ]); } public function testWithNoROle() { $this->loginAsStudent($this->user); $this->get('/api/cycles'); $this->assertResponseStatusCodeSame(403); } public function testGetAsIntruder() { $this->loginAsintruOfRoot($this->user); $this->assertResponseIsSuccessful(); $this->get('/api/cycles/1'); $this->assertResponseStatusCodeSame(404); } public function testPutsAsIntruder() { $this->loginAsintruOfRoot($this->user); $this->assertResponseIsSuccessful(); $this->put('/api/cycles/1', [ 'label' => 'new label', 'organization' => '/api/organizations/1' ]); $this->assertResponseStatusCodeSame(404); $this->assertJsonContains([ "hydra:title" => "An error occurred", "hydra:description" => "Not Found" ]); } public function testDeleteAsIntruder() { $this->loginAsintruOfRoot($this->user); $this->assertResponseIsSuccessful(); $this->delete('/api/cycles/1'); $this->assertResponseStatusCodeSame(405); $this->assertJsonContains([ "hydra:title" => "An error occurred" ]); } public function testPostAsIntruder() { $this->loginAsintruOfRoot($this->user); $this->assertResponseIsSuccessful(); $this->post('/api/cycles', [ 'label' => 'new label', 'organization' => '/api/organizations/1' ]); $this->assertResponseStatusCodeSame(405); $this->assertJsonContains([ "hydra:title" => "An error occurred" ]); } }