mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-24 16:43:48 +00:00
cs: Fix code style (safe rules only).
This commit is contained in:
@@ -1,14 +1,29 @@
|
||||
<?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 Chill\PersonBundle\Tests\Controller;
|
||||
|
||||
use Chill\PersonBundle\Entity\Household\Household;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Chill\MainBundle\Test\PrepareClientTrait;
|
||||
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
|
||||
use Chill\PersonBundle\Entity\Household\Household;
|
||||
use DateInterval;
|
||||
use DateTime;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use Symfony\Bundle\FrameworkBundle\KernelBrowser;
|
||||
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use function array_pop;
|
||||
use function shuffle;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
* @coversNothing
|
||||
*/
|
||||
class HouseholdControllerTest extends WebTestCase
|
||||
{
|
||||
use PrepareClientTrait;
|
||||
@@ -20,50 +35,35 @@ class HouseholdControllerTest extends WebTestCase
|
||||
$this->client = $this->getClientAuthenticated();
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider generateValidHouseholdIds
|
||||
*/
|
||||
public function testSummary($householdId)
|
||||
public function generateValidHouseholdIds()
|
||||
{
|
||||
$this->client->request(
|
||||
Request::METHOD_GET,
|
||||
"/fr/person/household/{$householdId}/summary"
|
||||
);
|
||||
self::bootKernel();
|
||||
$em = self::$container->get(EntityManagerInterface::class);
|
||||
|
||||
$this->assertResponseIsSuccessful();
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider generateValidHouseholdIds
|
||||
*/
|
||||
public function testEditMetadata($householdId)
|
||||
{
|
||||
|
||||
$crawler = $this->client->request(
|
||||
Request::METHOD_GET,
|
||||
"/fr/person/household/{$householdId}/summary",
|
||||
[
|
||||
'edit' => true
|
||||
]
|
||||
);
|
||||
|
||||
$this->assertResponseIsSuccessful();
|
||||
|
||||
$form = $crawler->filter('#form_household_comment_confirm')
|
||||
->form();
|
||||
|
||||
$form['household[commentMembers][comment]'] = "This is a text **generated** by automatic tests";
|
||||
$form['household[waitingForBirth]']->tick();
|
||||
$form['household[waitingForBirthDate]'] = (new \DateTime('today'))
|
||||
->add(new \DateInterval('P1M'))->format('Y-m-d');
|
||||
|
||||
$this->client->submit($form);
|
||||
|
||||
$this->assertResponseRedirects("/fr/person/household/{$householdId}/summary");
|
||||
$ids = $em->createQuery(
|
||||
'SELECT DISTINCT h.id FROM ' . Household::class . ' h ' .
|
||||
'JOIN h.members m ' .
|
||||
'JOIN m.person p ' .
|
||||
'JOIN p.center c ' .
|
||||
'WHERE c.name = :center'
|
||||
)
|
||||
->setParameter('center', 'Center A')
|
||||
->setMaxResults(100)
|
||||
->getScalarResult();
|
||||
|
||||
shuffle($ids);
|
||||
|
||||
yield [array_pop($ids)['id']];
|
||||
|
||||
yield [array_pop($ids)['id']];
|
||||
|
||||
yield [array_pop($ids)['id']];
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider generateValidHouseholdIds
|
||||
*
|
||||
* @param mixed $householdId
|
||||
*/
|
||||
public function testAddresses($householdId)
|
||||
{
|
||||
@@ -73,11 +73,12 @@ class HouseholdControllerTest extends WebTestCase
|
||||
);
|
||||
|
||||
$this->assertResponseIsSuccessful();
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider generateValidHouseholdIds
|
||||
*
|
||||
* @param mixed $householdId
|
||||
*/
|
||||
public function testAddressMove($householdId)
|
||||
{
|
||||
@@ -91,26 +92,48 @@ class HouseholdControllerTest extends WebTestCase
|
||||
// ici, il faudrait tester la requête POST
|
||||
}
|
||||
|
||||
public function generateValidHouseholdIds()
|
||||
/**
|
||||
* @dataProvider generateValidHouseholdIds
|
||||
*
|
||||
* @param mixed $householdId
|
||||
*/
|
||||
public function testEditMetadata($householdId)
|
||||
{
|
||||
self::bootKernel();
|
||||
$em = self::$container->get(EntityManagerInterface::class);
|
||||
$crawler = $this->client->request(
|
||||
Request::METHOD_GET,
|
||||
"/fr/person/household/{$householdId}/summary",
|
||||
[
|
||||
'edit' => true,
|
||||
]
|
||||
);
|
||||
|
||||
$ids = $em->createQuery("SELECT DISTINCT h.id FROM ".Household::class." h ".
|
||||
"JOIN h.members m ".
|
||||
"JOIN m.person p ".
|
||||
"JOIN p.center c ".
|
||||
"WHERE c.name = :center"
|
||||
)
|
||||
->setParameter('center', "Center A")
|
||||
->setMaxResults(100)
|
||||
->getScalarResult()
|
||||
;
|
||||
$this->assertResponseIsSuccessful();
|
||||
|
||||
\shuffle($ids);
|
||||
$form = $crawler->filter('#form_household_comment_confirm')
|
||||
->form();
|
||||
|
||||
yield [ \array_pop($ids)['id'] ];
|
||||
yield [ \array_pop($ids)['id'] ];
|
||||
yield [ \array_pop($ids)['id'] ];
|
||||
$form['household[commentMembers][comment]'] = 'This is a text **generated** by automatic tests';
|
||||
$form['household[waitingForBirth]']->tick();
|
||||
$form['household[waitingForBirthDate]'] = (new DateTime('today'))
|
||||
->add(new DateInterval('P1M'))->format('Y-m-d');
|
||||
|
||||
$this->client->submit($form);
|
||||
|
||||
$this->assertResponseRedirects("/fr/person/household/{$householdId}/summary");
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider generateValidHouseholdIds
|
||||
*
|
||||
* @param mixed $householdId
|
||||
*/
|
||||
public function testSummary($householdId)
|
||||
{
|
||||
$this->client->request(
|
||||
Request::METHOD_GET,
|
||||
"/fr/person/household/{$householdId}/summary"
|
||||
);
|
||||
|
||||
$this->assertResponseIsSuccessful();
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user