cs: Fix code style (safe rules only).

This commit is contained in:
Pol Dellaiera
2021-11-23 14:06:38 +01:00
parent 149d7ce991
commit 8f96a1121d
1223 changed files with 65199 additions and 64625 deletions

View File

@@ -1,102 +1,114 @@
<?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\TaskBundle\Tests\Controller;
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
use Chill\MainBundle\Entity\Center;
use Chill\MainBundle\Tests\TestHelper;
use Faker;
use Chill\MainBundle\Entity\Center;
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
use function array_filter;
use function array_rand;
/**
* @internal
* @coversNothing
*/
class SingleTaskControllerTest extends WebTestCase
{
/**
*
* @var Faker\Generator
*/
protected $faker;
protected function setUp()
{
self::bootKernel();
$this->faker = Faker\Factory::create('fr');
}
public function testNew()
{
$client = static::createClient(
[],
TestHelper::getAuthenticatedClientOptions()
);
$person = $this->getRandomPerson('Center A');
$crawler = $client->request('GET', '/fr/task/single-task/new', [
'person_id' => $person->getId(),
]);
var_dump($crawler->text());
$this->assertTrue($client->getResponse()->isSuccessful());
$form = $crawler->selectButton('Envoi')->form();
$title = $this->faker->sentence;
$circles = $form->get('circle')
->availableOptionsValues();
$client->submit($form, [
'title' => $title,
'circle' => $circles[array_rand($circles)],
]);
$this->assertTrue($client->getResponse()->isRedirect(sprintf(
'/fr/task/task/list/%d',
$person->getId()
)));
$crawler = $client->followRedirect();
$this->assertContains(
$title,
$crawler->text(),
'Assert that newly created task title is shown in list page'
);
}
/**
*
* @param mixed $centerName
*
* @return \Chill\PersonBundle\Entity\Person
*/
protected function getRandomPerson($centerName)
{
$em = self::$kernel
->getContainer()
->get('doctrine.orm.entity_manager')
;
->get('doctrine.orm.entity_manager');
$centers = $em
->getRepository(Center::class)
->findAll();
$center = \array_filter(
$centers,
function(Center $c) use ($centerName) {
return $centerName === $c->getName();
})[0];
$center = array_filter(
$centers,
function (Center $c) use ($centerName) {
return $c->getName() === $centerName;
}
)[0];
$ids = $em
->createQuery('SELECT p.id FROM ChillPersonBundle:Person p '
->createQuery(
'SELECT p.id FROM ChillPersonBundle:Person p '
. 'WHERE p.center = :center'
)
)
->setParameter('center', $center)
->getResult()
;
$id = $ids[\array_rand($ids)];
->getResult();
$id = $ids[array_rand($ids)];
return self::$kernel
->getContainer()
->get('doctrine.orm.entity_manager')
->getRepository(\Chill\PersonBundle\Entity\Person::class)
->find($id)
;
->find($id);
}
public function testNew()
{
$client = static::createClient(
array(),
TestHelper::getAuthenticatedClientOptions()
);
$person = $this->getRandomPerson('Center A');
$crawler = $client->request('GET', '/fr/task/single-task/new', [
'person_id' => $person->getId()
]);
var_dump($crawler->text());
$this->assertTrue($client->getResponse()->isSuccessful());
$form = $crawler->selectButton('Envoi')->form();
$title = $this->faker->sentence;
$circles = $form->get('circle')
->availableOptionsValues()
;
$client->submit($form, [
'title' => $title,
'circle' => $circles[\array_rand($circles)]
]);
$this->assertTrue($client->getResponse()->isRedirect(sprintf(
'/fr/task/task/list/%d', $person->getId())));
$crawler = $client->followRedirect();
$this->assertContains($title, $crawler->text(),
"Assert that newly created task title is shown in list page")
;
}
}

View File

@@ -1,9 +1,20 @@
<?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\TaskBundle\Tests\Controller;
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
/**
* @internal
* @coversNothing
*/
class TaskControllerTest extends WebTestCase
{
}