PersonTest.php 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. <?php
  2. namespace App\Tests\Application\Person;
  3. use App\Entity\Person\Person;
  4. use App\Entity\Access\Access;
  5. use App\Entity\Organization\Organization;
  6. use App\Entity\Organization\Settings;
  7. use App\Entity\Public\PublicEvent;
  8. use App\Enum\Organization\PrincipalTypeEnum;
  9. use App\Enum\Organization\SettingsProductEnum;
  10. use App\Tests\Application\OtWebTestCase;
  11. use App\Tests\Fixture\Factory\Access\AccessFactory;
  12. use App\Tests\Fixture\Factory\Organization\OrganizationFactory;
  13. use App\Tests\Fixture\Factory\Organization\SettingsFactory;
  14. use App\Tests\Fixture\Factory\Person\PersonFactory;
  15. use App\Tests\Fixture\PersonFixtures;
  16. use Zenstruck\Foundry\Factory;
  17. use Zenstruck\Foundry\Proxy;
  18. use App\Enum\Organization\LegalEnum;
  19. class PersonTest extends OtWebTestCase
  20. {
  21. public function testPersonGet(): void
  22. {
  23. $this->loginAs($this->user);
  24. $this->get('/api/people/' . $this->user->getPerson()->getId());
  25. $this->validateCollectionSchema(Person::class);
  26. $this->assertJsonContains([
  27. '@context' => '/api/contexts/Person',
  28. '@id' => '/api/people/' . $this->user->getPerson()->getId(),
  29. '@type' => 'Person',
  30. 'username' => 'username'
  31. ]);
  32. }
  33. // public function testPersonGetHasNoRole(): void {
  34. // // User has not the required role
  35. // $this->user->setRoles([]);
  36. // $this->user->save();
  37. // $this->loginAs($this->user);
  38. // $this->get('/api/people/' . $this->user->getPerson()->getId());
  39. // $this->validateCollectionSchema(Person::class, 403);
  40. // $this->assertJsonContains([
  41. // "hydra:description" => "Access Denied."
  42. // ]);
  43. // }
  44. // public function testPersonGetCollection(): void {
  45. // $this->loginAs($this->user);
  46. // $this->get('/api/peoples');
  47. // $this->assertResponseStatusCodeSame(404);
  48. // }
  49. // public function testPersonPut(): void {
  50. // $this->loginAs($this->user);
  51. // $this->put('/api/people/' . $this->user->getPerson()->getId(), []);
  52. // // Expects : 405 Method Not Allowed
  53. // $this->assertResponseStatusCodeSame(405);
  54. // }
  55. // public function testPersonPost(): void {
  56. // $this->loginAs($this->user);
  57. // $this->post('/api/people/' . $this->user->getPerson()->getId(), []);
  58. // // Expects : 405 Method Not Allowed
  59. // $this->assertResponseStatusCodeSame(405);
  60. // }
  61. // public function testPersonDelete(): void {
  62. // $this->loginAs($this->user);
  63. // $this->delete('/api/people/' . $this->user->getPerson()->getId());
  64. // // Expects : 405 Method Not Allowed
  65. // $this->assertResponseStatusCodeSame(405);
  66. // }
  67. }