| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697 |
- <?php
- namespace App\Tests\Application\Person;
- use AppBundle\Entity\Person\Person;
- use App\Tests\Application\OtWebTestCase;
- class PersonTest extends OtWebTestCase
- {
- public function testPersonGetCollection(): 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);
- }
- public function testPersonGetHasNoRole(): void
- {
- $this->loginAsStudent($this->user);
- $this->get('/api/people/' . $this->user->getPerson()->getId());
- $this->validateCollectionSchema(Person::class, 404);
- $this->assertJsonContains([
- "hydra:description" => "This route does not aim to be called."
- ]);
- }
- }
|