|
@@ -1,6 +1,6 @@
|
|
|
<?php
|
|
<?php
|
|
|
-
|
|
|
|
|
namespace App\Tests\Application\Person;
|
|
namespace App\Tests\Application\Person;
|
|
|
|
|
+
|
|
|
use App\Entity\Person\Person;
|
|
use App\Entity\Person\Person;
|
|
|
use App\Entity\Access\Access;
|
|
use App\Entity\Access\Access;
|
|
|
use App\Entity\Organization\Organization;
|
|
use App\Entity\Organization\Organization;
|
|
@@ -20,59 +20,31 @@ use App\Enum\Organization\LegalEnum;
|
|
|
|
|
|
|
|
class PersonTest extends OtWebTestCase
|
|
class PersonTest extends OtWebTestCase
|
|
|
{
|
|
{
|
|
|
- private Proxy | Person $person;
|
|
|
|
|
- private Proxy | Access $access;
|
|
|
|
|
-
|
|
|
|
|
- protected function setFixtures(): void
|
|
|
|
|
- {
|
|
|
|
|
- $this->person = PersonFactory::createOne(
|
|
|
|
|
- [
|
|
|
|
|
- 'username' => 'username',
|
|
|
|
|
- 'password' => 'password'
|
|
|
|
|
- ]
|
|
|
|
|
- );
|
|
|
|
|
-
|
|
|
|
|
- $organization = OrganizationFactory::createOne([
|
|
|
|
|
- 'legalStatus' => LegalEnum::ASSOCIATION_LAW_1901()->getValue(),
|
|
|
|
|
- 'principalType' => PrincipalTypeEnum::ARTISTIC_EDUCATION_ONLY()->getValue(),
|
|
|
|
|
- 'name' => 'My Organization'
|
|
|
|
|
- ]);
|
|
|
|
|
-
|
|
|
|
|
- SettingsFactory::createOne([
|
|
|
|
|
- 'product' => SettingsProductEnum::ARTIST(),
|
|
|
|
|
- 'organization' => $organization
|
|
|
|
|
- ]);
|
|
|
|
|
-
|
|
|
|
|
- $this->access = AccessFactory::createOne([
|
|
|
|
|
- 'person' => $this->person,
|
|
|
|
|
- 'organization' => $organization,
|
|
|
|
|
- 'roles' => ['ROLE_USERS_VIEW']
|
|
|
|
|
- ]);
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
public function testPersonGet(): void
|
|
public function testPersonGet(): void
|
|
|
{
|
|
{
|
|
|
- $this->loginAs($this->access);
|
|
|
|
|
|
|
+ $this->loginAs($this->user);
|
|
|
|
|
|
|
|
- $this->get('/api/people/' . $this->person->getId());
|
|
|
|
|
|
|
+ $this->get('/api/people/' . $this->user->getPerson()->getId());
|
|
|
|
|
|
|
|
$this->validateCollectionSchema(Person::class);
|
|
$this->validateCollectionSchema(Person::class);
|
|
|
|
|
|
|
|
$this->assertJsonContains([
|
|
$this->assertJsonContains([
|
|
|
'@context' => '/api/contexts/Person',
|
|
'@context' => '/api/contexts/Person',
|
|
|
- '@id' => '/api/people/' . $this->person->getId(),
|
|
|
|
|
|
|
+ '@id' => '/api/people/' . $this->user->getPerson()->getId(),
|
|
|
'@type' => 'Person',
|
|
'@type' => 'Person',
|
|
|
'username' => 'username'
|
|
'username' => 'username'
|
|
|
]);
|
|
]);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
public function testPersonGetHasNoRole(): void {
|
|
public function testPersonGetHasNoRole(): void {
|
|
|
- $this->access->setRoles([]);
|
|
|
|
|
- $this->access->save();
|
|
|
|
|
|
|
|
|
|
- $this->loginAs($this->access);
|
|
|
|
|
|
|
+ // User has not the required role
|
|
|
|
|
+ $this->user->setRoles([]);
|
|
|
|
|
+ $this->user->save();
|
|
|
|
|
+
|
|
|
|
|
+ $this->loginAs($this->user);
|
|
|
|
|
|
|
|
- $this->get('/api/people/' . $this->person->getId());
|
|
|
|
|
|
|
+ $this->get('/api/people/' . $this->user->getPerson()->getId());
|
|
|
|
|
|
|
|
$this->validateCollectionSchema(Person::class, 403);
|
|
$this->validateCollectionSchema(Person::class, 403);
|
|
|
|
|
|
|
@@ -82,7 +54,7 @@ class PersonTest extends OtWebTestCase
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
public function testPersonGetCollection(): void {
|
|
public function testPersonGetCollection(): void {
|
|
|
- $this->loginAs($this->access);
|
|
|
|
|
|
|
+ $this->loginAs($this->user);
|
|
|
|
|
|
|
|
$this->get('/api/peoples');
|
|
$this->get('/api/peoples');
|
|
|
|
|
|
|
@@ -90,27 +62,27 @@ class PersonTest extends OtWebTestCase
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
public function testPersonPut(): void {
|
|
public function testPersonPut(): void {
|
|
|
- $this->loginAs($this->access);
|
|
|
|
|
|
|
+ $this->loginAs($this->user);
|
|
|
|
|
|
|
|
- $this->put('/api/people/' . $this->person->getId(), []);
|
|
|
|
|
|
|
+ $this->put('/api/people/' . $this->user->getPerson()->getId(), []);
|
|
|
|
|
|
|
|
// Expects : 405 Method Not Allowed
|
|
// Expects : 405 Method Not Allowed
|
|
|
$this->assertResponseStatusCodeSame(405);
|
|
$this->assertResponseStatusCodeSame(405);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
public function testPersonPost(): void {
|
|
public function testPersonPost(): void {
|
|
|
- $this->loginAs($this->access);
|
|
|
|
|
|
|
+ $this->loginAs($this->user);
|
|
|
|
|
|
|
|
- $this->post('/api/people/' . $this->person->getId(), []);
|
|
|
|
|
|
|
+ $this->post('/api/people/' . $this->user->getPerson()->getId(), []);
|
|
|
|
|
|
|
|
// Expects : 405 Method Not Allowed
|
|
// Expects : 405 Method Not Allowed
|
|
|
$this->assertResponseStatusCodeSame(405);
|
|
$this->assertResponseStatusCodeSame(405);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
public function testPersonDelete(): void {
|
|
public function testPersonDelete(): void {
|
|
|
- $this->loginAs($this->access);
|
|
|
|
|
|
|
+ $this->loginAs($this->user);
|
|
|
|
|
|
|
|
- $this->delete('/api/people/' . $this->person->getId());
|
|
|
|
|
|
|
+ $this->delete('/api/people/' . $this->user->getPerson()->getId());
|
|
|
|
|
|
|
|
// Expects : 405 Method Not Allowed
|
|
// Expects : 405 Method Not Allowed
|
|
|
$this->assertResponseStatusCodeSame(405);
|
|
$this->assertResponseStatusCodeSame(405);
|