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 { $this->loginAs($this->access); $this->get('/api/people/' . $this->person->getId()); $this->validateCollectionSchema(Person::class); $this->assertJsonContains([ '@context' => '/api/contexts/Person', '@id' => '/api/people/' . $this->person->getId(), '@type' => 'Person', 'username' => 'username' ]); } 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 { $this->loginAs($this->access); $this->get('/api/peoples'); $this->assertResponseStatusCodeSame(404); } public function testPersonPut(): void { $this->loginAs($this->access); $this->put('/api/people/' . $this->person->getId(), []); // Expects : 405 Method Not Allowed $this->assertResponseStatusCodeSame(405); } public function testPersonPost(): void { $this->loginAs($this->access); $this->post('/api/people/' . $this->person->getId(), []); // Expects : 405 Method Not Allowed $this->assertResponseStatusCodeSame(405); } public function testPersonDelete(): void { $this->loginAs($this->access); $this->delete('/api/people/' . $this->person->getId()); // Expects : 405 Method Not Allowed $this->assertResponseStatusCodeSame(405); } }