CotisationTest.php 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. <?php
  2. namespace App\Tests\Application\Cotisation;
  3. use App\Tests\Application\OtWebTestCase;
  4. class CotisationTest extends OtWebTestCase
  5. {
  6. public function testGetCotisationId(): void
  7. {
  8. $this->logger->info("\033[1;34mStarting test... Get a cotisation by id as ad admin\033[0m");
  9. $this->loginAs($this->user);
  10. $this->get('/api/cotisations/1');
  11. $this->assertResponseStatusCodeSame(200);
  12. $this->assertJsonContains([
  13. '@context' => '/api/contexts/Cotisation',
  14. '@id' => '/api/cotisations/1',
  15. '@type' => 'Cotisation',
  16. 'organizationId' => 1,
  17. 'alertState' => 'ADVERTISINGINSURANCE',
  18. 'cotisationYear' => 2024,
  19. ]);
  20. $this->logger->info("\033[1;32mTest 'Get a cotisation by id as ad admin' succeed\033[0m");
  21. $this->logger->info("\033[1;34mStarting test... Get a cotisation by id as an non admin\033[0m");
  22. $this->loginAsStudent($this->user);
  23. $this->get('/api/cotisations/1');
  24. $this->assertResponseStatusCodeSame(403);
  25. $this->logger->info("\033[1;32mTest 'Get a cotisation by id as an non admin' succeed\033[0m");
  26. $this->logger->info("\033[1;34mStarting test... Put a cotisation by id as an admin\033[0m");
  27. $this->loginAs($this->user);
  28. $this->put('/api/cotisations/1', [
  29. 'alertState' => 'ADVERTISINGINSURANCE',
  30. 'cotisationYear' => 2024,
  31. ]);
  32. $this->assertResponseStatusCodeSame(405);
  33. $this->logger->info("\033[1;32mTest 'Put a cotisation by id as an admin' succeed\033[0m");
  34. $this->logger->info("\033[1;34mStarting test... Delete a cotisation by id as an admin\033[0m");
  35. $this->loginAs($this->user);
  36. $this->delete('/api/cotisations/1');
  37. $this->assertResponseStatusCodeSame(405);
  38. $this->logger->info("\033[1;32mTest 'Delete a cotisation by id as an admin' succeed\033[0m");
  39. }
  40. }