mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-21 07:03:49 +00:00
fix cs and add test
This commit is contained in:
@@ -1,14 +1,51 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Chill is a software for social workers
|
||||
*
|
||||
* For the full copyright and license information, please view
|
||||
* the LICENSE file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Controller;
|
||||
|
||||
use Chill\MainBundle\Test\PrepareClientTrait;
|
||||
use DateTime;
|
||||
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
* @coversNothing
|
||||
*/
|
||||
class PermissionApiControllerTest extends WebTestCase
|
||||
{
|
||||
use PrepareClientTrait;
|
||||
|
||||
public function testDenormalizingObject()
|
||||
{
|
||||
$client = $this->getClientAuthenticated();
|
||||
|
||||
$client->request(
|
||||
'POST',
|
||||
'/api/1.0/main/permissions/info.json',
|
||||
[], // parameters
|
||||
[], // files
|
||||
[], // server
|
||||
json_encode([
|
||||
'object' => [
|
||||
'datetime' => '1969-07-09T00:00:00+0100',
|
||||
],
|
||||
'class' => DateTime::class,
|
||||
'roles' => ['FOO_ROLE'],
|
||||
])
|
||||
);
|
||||
|
||||
$this->assertResponseIsSuccessful();
|
||||
|
||||
$data = json_decode($client->getResponse()->getContent(), true);
|
||||
$this->assertFalse($data['roles']['FOO_ROLE']);
|
||||
}
|
||||
|
||||
public function testNullObject()
|
||||
{
|
||||
$client = $this->getClientAuthenticated();
|
||||
@@ -19,18 +56,17 @@ class PermissionApiControllerTest extends WebTestCase
|
||||
[], // parameters
|
||||
[], // files
|
||||
[], // server
|
||||
\json_encode([
|
||||
json_encode([
|
||||
'object' => null,
|
||||
'class' => null,
|
||||
'roles' => ['ROLE_USER', 'ROLE_ADMIN']
|
||||
'roles' => ['ROLE_USER', 'ROLE_ADMIN'],
|
||||
])
|
||||
);
|
||||
|
||||
$this->assertResponseIsSuccessful();
|
||||
|
||||
$data = \json_decode($client->getResponse()->getContent(), true);
|
||||
$data = json_decode($client->getResponse()->getContent(), true);
|
||||
$this->assertTrue($data['roles']['ROLE_USER']);
|
||||
$this->assertFalse($data['roles']['ROLE_ADMIN']);
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user