| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455 |
- <?php
- namespace App\Tests\Application\Person;
- use App\Tests\Application\OtWebTestCase;
- use AppBundle\Entity\Person\Person;
- use Monolog\Logger;
- class PersonTest extends OtWebTestCase
- {
- public function testPersonGetCollection(): void
- {
- $this->logger->info("\033[1;34mStarting test... Retrieve the list of all accesses for an admin user\033[0m");
- $this->loginAs($this->user);
- $this->get('/api/accesses');
- $this->assertResponseStatusCodeSame(200);
- $this->logger->info("\033[1;32mTest 'testPersonGetCollection' succeed\033[0m");
- // $this->logger->info("\033[1;34mStarting test: Retrieve the access of an admin user\033[0m");
- // $this->loginAs($this->user);
- // $this->get('/api/admin-access/' . $this->user->getId());
- // $this->assertResponseStatusCodeSame(200);
- // $this->logger->info("\033[1;32mTest 'tesGetAdminAccess' succeed\033[0m");
- $this->logger->info("\033[1;34mStarting test: admin can change the access infos of a user\033[0m");
- $this->loginAs($this->user);
- $this->put('/api/accesses/2', [
- 'username' => 'nouveau username',
- ]);
- $this->assertResponseStatusCodeSame(200);
- $this->logger->info("\033[1;32mTest 'testPersonPut' succeed\033[0m");
- $this->logger->info("\033[1;34mStarting test: a student can't access the list of all accesses\033[0m");
- $this->loginAsStudent($this->user);
- $this->get('/api/accesses');
- $this->assertResponseStatusCodeSame(200);
- $this->logger->info("\033[1;32mTest 'testStudentUnableToAcceedAllAccesses' succeed\033[0m");
- $this->logger->info("\033[1;34mStarting test: a non admin role can't access the info of an admin user\033[0m");
- $this->loginAsStudent($this->user);
- $this->get('/api/admin-access/1');
- $this->validateCollectionSchema(Person::class, 404);
- $this->assertJsonContains([
- 'hydra:description' => 'Not Found',
- ]);
- $this->logger->info("\033[1;32mTest 'testPersonUnableToAcceddAdminInfo' succeed\033[0m");
- // il faudra relancer les fixtures après ce test
- $this->logger->info("\033[1;34mStarting test: delete an user as an admin\033[0m");
- $this->loginAs($this->user);
- $this->delete('/api/accesses/2');
- $this->assertResponseStatusCodeSame(204);
- $this->logger->info("\033[1;32mTest 'delete an user as an admin' succeed\033[0m");
- }
- }
|