mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-21 23:23:51 +00:00
add many2many relation between socialIssue and accompanying period + api endpoint
This commit is contained in:
@@ -0,0 +1,55 @@
|
||||
<?php
|
||||
|
||||
namespace Chill\PersonBundle\Tests\Controller;
|
||||
|
||||
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Chill\MainBundle\Test\PrepareClientTrait;
|
||||
|
||||
class SocialIssueApiControllerTest extends WebTestCase
|
||||
{
|
||||
use PrepareClientTrait;
|
||||
|
||||
public function setUp()
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
self::bootKernel();
|
||||
}
|
||||
|
||||
public function testList(): array
|
||||
{
|
||||
$client = $this->getClientAuthenticated();
|
||||
$client->request(Request::METHOD_GET, '/api/1.0/person/social-work/social-issue.json');
|
||||
|
||||
$this->assertEquals(200, $client->getResponse()->getStatusCode());
|
||||
|
||||
$data = \json_decode($client->getResponse()->getContent(), true);
|
||||
|
||||
$this->assertGreaterThan(0, $data['count']);
|
||||
$this->assertGreaterThan(0, count($data['results']));
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* @depends testList
|
||||
*/
|
||||
public function testItem(array $data): void
|
||||
{
|
||||
$socialIssues = $data['results'];
|
||||
shuffle($socialIssues);
|
||||
$socialIssue = \array_pop($socialIssues);
|
||||
|
||||
|
||||
$client = $this->getClientAuthenticated();
|
||||
$client->request(Request::METHOD_GET, sprintf('/api/1.0/person/social-work/social-issue/%d.json', $socialIssue['id']));
|
||||
|
||||
$this->assertEquals(200, $client->getResponse()->getStatusCode());
|
||||
|
||||
$data = \json_decode($client->getResponse()->getContent(), true);
|
||||
|
||||
$this->assertArrayHasKey('id', $data);
|
||||
$this->assertArrayHasKey('type', $data);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user