| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081 |
- <?php
- namespace App\Tests\Application\Person;
- use App\Entity\Person\Person;
- use App\Tests\Application\OtWebTestCase;
- class PersonTest extends OtWebTestCase
- {
- public function testPersonGet(): void
- {
- $this->loginAs($this->user);
- $this->get('/api/people/'.$this->user->getPerson()->getId());
- $this->validateCollectionSchema(Person::class);
- $this->assertJsonContains([
- '@context' => '/api/contexts/Person',
- '@id' => '/api/people/'.$this->user->getPerson()->getId(),
- '@type' => 'Person',
- 'username' => 'username',
- ]);
- }
- public function testPersonGetHasNoRole(): void
- {
- // User has not the required role
- $this->user->setRoles([]);
- $this->user->save();
- $this->loginAs($this->user);
- $this->get('/api/people/'.$this->user->getPerson()->getId());
- $this->validateCollectionSchema(Person::class, 403);
- $this->assertJsonContains([
- 'hydra:description' => 'Access Denied.',
- ]);
- }
- public function testPersonGetCollection(): void
- {
- $this->loginAs($this->user);
- $this->get('/api/peoples');
- $this->assertResponseStatusCodeSame(404);
- }
- public function testPersonPut(): void
- {
- $this->loginAs($this->user);
- $this->put('/api/people/'.$this->user->getPerson()->getId(), []);
- // Expects : 405 Method Not Allowed
- $this->assertResponseStatusCodeSame(405);
- }
- public function testPersonPost(): void
- {
- $this->loginAs($this->user);
- $this->post('/api/people/'.$this->user->getPerson()->getId(), []);
- // Expects : 405 Method Not Allowed
- $this->assertResponseStatusCodeSame(405);
- }
- public function testPersonDelete(): void
- {
- $this->loginAs($this->user);
- $this->delete('/api/people/'.$this->user->getPerson()->getId());
- // Expects : 405 Method Not Allowed
- $this->assertResponseStatusCodeSame(405);
- }
- }
|