| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166 |
- <?php
- namespace App\Tests\Application\Education;
- use App\Entity\Education\Cycle;
- use App\Tests\Application\OtWebTestCase;
- class CycleTest extends OtWebTestCase
- {
- public function testCycleCollection()
- {
- $this->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"
- ]);
- }
- }
|