| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293 |
- <?php
- namespace App\Tests\Application\Billing;
- use App\Tests\Application\OtWebTestCase;
- class ResidenceAreaTest extends OtWebTestCase
- {
- // todo : attention certain tests ne se passent pas comme prévu : probleme de droit
- public function testGetResidenceArea(): void
- {
- $this->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);
- }
- }
|