EnumTest.php 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. <?php
  2. namespace App\Tests\Application\Enum;
  3. use App\Tests\Application\OtWebTestCase;
  4. use Symfony\Component\HttpFoundation\Response;
  5. class EnumTest extends OtWebTestCase
  6. {
  7. public function testEnumResource()
  8. {
  9. $this->logger->info("\033[1;34mStarting test... get enum success\033[0m");
  10. $this->loginAs($this->user);
  11. $enumName = 'function';
  12. $this->get("/api/enum/$enumName");
  13. $this->assertResponseStatusCodeSame(Response::HTTP_OK);
  14. $this->assertResponseIsSuccessful();
  15. $this->logger->info("\033[1;32mTest 'get enum success' succeeded\033[0m");
  16. $this->logger->info("\033[1;34mStarting test... get enum not found\033[0m");
  17. $this->loginAs($this->user);
  18. $this->assertResponseIsSuccessful();
  19. $this->logger->info("\033[1;34mLogged in successfully\033[0m");
  20. $enumName = 'notfound';
  21. $this->get("/api/enum/$enumName");
  22. $this->assertResponseStatusCodeSame(Response::HTTP_NOT_FOUND);
  23. $this->logger->info("\033[1;32mTest 'get enum not found' succeeded\033[0m");
  24. $this->logger->info("\033[1;34mStarting test... get category enum\033[0m");
  25. $this->loginAs($this->user);
  26. $this->assertResponseIsSuccessful();
  27. $this->logger->info("\033[1;34mLogged in successfully\033[0m");
  28. $this->get('/api/enum/organization_category');
  29. $this->assertResponseStatusCodeSame(Response::HTTP_OK);
  30. $this->assertResponseIsSuccessful();
  31. $this->logger->info("\033[1;34mReceived status code 200\033[0m");
  32. $this->assertJsonContains([
  33. '@context' => '/api/contexts/Enum',
  34. '@id' => '/api/enum/organization_category',
  35. '@type' => 'Enum',
  36. 'name' => 'organization_category',
  37. 'items' => [
  38. 'PROFESSIONAL' => 'PROFESSIONAL',
  39. 'ARTISTIC_ENSEMBLE' => 'ARTISTIC_ENSEMBLE',
  40. 'SCHOOL_OF_ARTS' => 'SCHOOL_OF_ARTS',
  41. 'NETWORK' => 'NETWORK',
  42. 'ORGANIZER' => 'ORGANIZER',
  43. 'PERSON' => 'PERSON',
  44. 'OTHER' => 'OTHER',
  45. ],
  46. ]);
  47. $this->logger->info("\033[1;32mTest 'get category enum' succeeded\033[0m");
  48. }
  49. }