|
|
@@ -1,6 +1,7 @@
|
|
|
<?php
|
|
|
|
|
|
namespace App\Tests\Application\Person;
|
|
|
+use App\Entity\Person\Person;
|
|
|
use App\Entity\Access\Access;
|
|
|
use App\Entity\Organization\Organization;
|
|
|
use App\Entity\Organization\Settings;
|
|
|
@@ -8,7 +9,6 @@ use App\Entity\Public\PublicEvent;
|
|
|
use App\Enum\Organization\PrincipalTypeEnum;
|
|
|
use App\Enum\Organization\SettingsProductEnum;
|
|
|
use App\Tests\Application\OtWebTestCase;
|
|
|
-use App\Entity\Person;
|
|
|
use App\Tests\Fixture\Factory\Access\AccessFactory;
|
|
|
use App\Tests\Fixture\Factory\Organization\OrganizationFactory;
|
|
|
use App\Tests\Fixture\Factory\Organization\SettingsFactory;
|
|
|
@@ -21,9 +21,7 @@ use App\Enum\Organization\LegalEnum;
|
|
|
class PersonTest extends OtWebTestCase
|
|
|
{
|
|
|
private Proxy | Person $person;
|
|
|
- private Proxy | Organization $organization;
|
|
|
private Proxy | Access $access;
|
|
|
- private Proxy | Settings $settings;
|
|
|
|
|
|
protected function setFixtures(): void
|
|
|
{
|
|
|
@@ -34,20 +32,20 @@ class PersonTest extends OtWebTestCase
|
|
|
]
|
|
|
);
|
|
|
|
|
|
- $this->organization = OrganizationFactory::createOne([
|
|
|
+ $organization = OrganizationFactory::createOne([
|
|
|
'legalStatus' => LegalEnum::ASSOCIATION_LAW_1901()->getValue(),
|
|
|
'principalType' => PrincipalTypeEnum::ARTISTIC_EDUCATION_ONLY()->getValue(),
|
|
|
'name' => 'My Organization'
|
|
|
]);
|
|
|
|
|
|
- $this->settings = SettingsFactory::createOne([
|
|
|
+ SettingsFactory::createOne([
|
|
|
'product' => SettingsProductEnum::ARTIST(),
|
|
|
- 'organization' => $this->organization
|
|
|
+ 'organization' => $organization
|
|
|
]);
|
|
|
|
|
|
$this->access = AccessFactory::createOne([
|
|
|
'person' => $this->person,
|
|
|
- 'organization' => $this->organization,
|
|
|
+ 'organization' => $organization,
|
|
|
'roles' => ['ROLE_USERS_VIEW']
|
|
|
]);
|
|
|
}
|
|
|
@@ -68,19 +66,53 @@ class PersonTest extends OtWebTestCase
|
|
|
]);
|
|
|
}
|
|
|
|
|
|
+ public function testPersonGetHasNoRole(): void {
|
|
|
+ $this->access->setRoles([]);
|
|
|
+ $this->access->save();
|
|
|
+
|
|
|
+ $this->loginAs($this->access);
|
|
|
+
|
|
|
+ $this->get('/api/people/' . $this->person->getId());
|
|
|
+
|
|
|
+ $this->validateCollectionSchema(Person::class, 403);
|
|
|
+
|
|
|
+ $this->assertJsonContains([
|
|
|
+ "hydra:description" => "Access Denied."
|
|
|
+ ]);
|
|
|
+ }
|
|
|
+
|
|
|
public function testPersonGetCollection(): void {
|
|
|
- // TODO: get collection is not permitted
|
|
|
+ $this->loginAs($this->access);
|
|
|
+
|
|
|
+ $this->get('/api/peoples');
|
|
|
+
|
|
|
+ $this->assertResponseStatusCodeSame(404);
|
|
|
}
|
|
|
|
|
|
public function testPersonPut(): void {
|
|
|
- // TODO: put is not permitted
|
|
|
+ $this->loginAs($this->access);
|
|
|
+
|
|
|
+ $this->put('/api/people/' . $this->person->getId(), []);
|
|
|
+
|
|
|
+ // Expects : 405 Method Not Allowed
|
|
|
+ $this->assertResponseStatusCodeSame(405);
|
|
|
}
|
|
|
|
|
|
public function testPersonPost(): void {
|
|
|
- // TODO: post is not permitted
|
|
|
+ $this->loginAs($this->access);
|
|
|
+
|
|
|
+ $this->post('/api/people/' . $this->person->getId(), []);
|
|
|
+
|
|
|
+ // Expects : 405 Method Not Allowed
|
|
|
+ $this->assertResponseStatusCodeSame(405);
|
|
|
}
|
|
|
|
|
|
public function testPersonDelete(): void {
|
|
|
- // TODO: delete is not permitted
|
|
|
+ $this->loginAs($this->access);
|
|
|
+
|
|
|
+ $this->delete('/api/people/' . $this->person->getId());
|
|
|
+
|
|
|
+ // Expects : 405 Method Not Allowed
|
|
|
+ $this->assertResponseStatusCodeSame(405);
|
|
|
}
|
|
|
}
|