mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-12 13:24:25 +00:00
add tests for UserApiController
This commit is contained in:
parent
abe012de60
commit
a43e6c12a0
@ -0,0 +1,49 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Chill\MainBundle\Tests\Controller;
|
||||||
|
|
||||||
|
use Chill\MainBundle\Test\PrepareClientTrait;
|
||||||
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
|
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
|
||||||
|
|
||||||
|
class UserApiControllerTest extends WebTestCase
|
||||||
|
{
|
||||||
|
use PrepareClientTrait;
|
||||||
|
|
||||||
|
public function testIndex()
|
||||||
|
{
|
||||||
|
$client = $this->getClientAuthenticated();
|
||||||
|
|
||||||
|
$client->request(Request::METHOD_GET, '/api/1.0/main/user.json');
|
||||||
|
|
||||||
|
$this->assertResponseIsSuccessful();
|
||||||
|
|
||||||
|
$data = \json_decode($client->getResponse()->getContent(), true);
|
||||||
|
$this->assertTrue(\array_key_exists('count', $data));
|
||||||
|
$this->assertGreaterThan(0, $data['count']);
|
||||||
|
$this->assertTrue(\array_key_exists('results', $data));
|
||||||
|
|
||||||
|
return $data['results'][0];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @depends testIndex
|
||||||
|
*/
|
||||||
|
public function testEntity($existingUser)
|
||||||
|
{
|
||||||
|
$client = $this->getClientAuthenticated();
|
||||||
|
|
||||||
|
$client->request(Request::METHOD_GET, '/api/1.0/main/user/'.$existingUser['id'].'.json');
|
||||||
|
|
||||||
|
$this->assertResponseIsSuccessful();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testWhoami()
|
||||||
|
{
|
||||||
|
$client = $this->getClientAuthenticated();
|
||||||
|
|
||||||
|
$client->request(Request::METHOD_GET, '/api/1.0/main/whoami.json');
|
||||||
|
|
||||||
|
$this->assertResponseIsSuccessful();
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user