mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-07 18:44:08 +00:00
tests/ChillPersonBundle: use mutualized getClientAuthenticated()
This commit is contained in:
parent
3445335b2d
commit
53813f8f29
@ -24,12 +24,14 @@ namespace Chill\PersonBundle\Tests\Controller;
|
||||
|
||||
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
|
||||
use Symfony\Component\DomCrawler\Form;
|
||||
use Chill\MainBundle\Test\PrepareClientTrait;
|
||||
|
||||
/**
|
||||
* Test creation and deletion for persons
|
||||
*/
|
||||
class PersonControllerCreateTest extends WebTestCase
|
||||
{
|
||||
use PrepareClientTrait;
|
||||
|
||||
const FIRSTNAME_INPUT = 'chill_personbundle_person_creation[firstName]';
|
||||
const LASTNAME_INPUT = "chill_personbundle_person_creation[lastName]";
|
||||
@ -39,20 +41,12 @@ class PersonControllerCreateTest extends WebTestCase
|
||||
const CENTER_INPUT = "chill_personbundle_person_creation[center]";
|
||||
|
||||
const LONG_TEXT = "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer nec odio. Praesent libero. Sed cursus ante dapibus diam. Sed nisi. Nulla quis sem at nibh elementum imperdiet. Duis sagittis ipsum. Praesent mauris. Fusce nec tellus sed augue semper porta. Mauris massa. Vestibulum lacinia arcu eget nulla. Class aptent taciti sociosq. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer nec odio. Praesent libero. Sed cursus ante dapibus diam. Sed nisi. Nulla quis sem at nibh elementum imperdiet. Duis sagittis ipsum. Praesent mauris. Fusce nec tellus sed augue semper porta.Mauris massa. Vestibulum lacinia arcu eget nulla. Class aptent taciti sociosq.";
|
||||
|
||||
/**
|
||||
* return an authenticated client, useful for submitting form
|
||||
*
|
||||
* @return \Symfony\Component\BrowserKit\Client
|
||||
*/
|
||||
private function getAuthenticatedClient($username = 'center a_social')
|
||||
|
||||
public function setUp()
|
||||
{
|
||||
return static::createClient(array(), array(
|
||||
'PHP_AUTH_USER' => $username,
|
||||
'PHP_AUTH_PW' => 'password',
|
||||
));
|
||||
$this->client = $this::getClientAuthenticated();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @param Form $creationForm
|
||||
@ -76,8 +70,8 @@ class PersonControllerCreateTest extends WebTestCase
|
||||
*/
|
||||
public function testAddAPersonPage()
|
||||
{
|
||||
$client = $this->getAuthenticatedClient();
|
||||
|
||||
$client = $this->client;
|
||||
$crawler = $client->request('GET', '/fr/person/new');
|
||||
|
||||
$this->assertTrue($client->getResponse()->isSuccessful(),
|
||||
@ -122,7 +116,7 @@ class PersonControllerCreateTest extends WebTestCase
|
||||
*/
|
||||
public function testFirstnameTooLong(Form $form)
|
||||
{
|
||||
$client = $this->getAuthenticatedClient();
|
||||
$client = $this-client;
|
||||
$this->fillAValidCreationForm($form);
|
||||
$form->get(self::FIRSTNAME_INPUT)->setValue(mb_substr(self::LONG_TEXT, 0, 256));
|
||||
$crawler = $client->submit($form);
|
||||
@ -171,7 +165,7 @@ class PersonControllerCreateTest extends WebTestCase
|
||||
public function testValidForm(Form $form)
|
||||
{
|
||||
$this->fillAValidCreationForm($form);
|
||||
$client = $this->getAuthenticatedClient();
|
||||
$client = $this->client;
|
||||
$client->submit($form);
|
||||
|
||||
$this->assertTrue($client->getResponse()->isRedirect(),
|
||||
@ -198,7 +192,7 @@ class PersonControllerCreateTest extends WebTestCase
|
||||
*/
|
||||
public function testPersonViewAccessible($personId)
|
||||
{
|
||||
$client = $this->getAuthenticatedClient();
|
||||
$client = $this->client;
|
||||
$client->request('GET', '/fr/person/'.$personId.'/general');
|
||||
|
||||
$this->assertTrue($client->getResponse()->isSuccessful(),
|
||||
@ -212,7 +206,7 @@ class PersonControllerCreateTest extends WebTestCase
|
||||
*/
|
||||
public function testValidFormWithMultiCenterUser()
|
||||
{
|
||||
$client = $this->getAuthenticatedClient('multi_center');
|
||||
$client = $this->getClientAuthenticated('multi_center');
|
||||
|
||||
$crawler = $client->request('GET', '/fr/person/new');
|
||||
|
||||
@ -242,7 +236,7 @@ class PersonControllerCreateTest extends WebTestCase
|
||||
|
||||
public function testReviewExistingDetectionInversedLastNameWithFirstName()
|
||||
{
|
||||
$client = $this->getAuthenticatedClient();
|
||||
$client = $this->client;
|
||||
|
||||
$crawler = $client->request('GET', '/fr/person/new');
|
||||
|
||||
|
@ -24,6 +24,7 @@ namespace Chill\PersonBundle\Tests\Controller;
|
||||
|
||||
use Chill\PersonBundle\Entity\Person;
|
||||
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
|
||||
use Chill\MainBundle\Test\PrepareClientTrait;
|
||||
|
||||
/**
|
||||
* Test the edition of persons
|
||||
@ -34,6 +35,8 @@ use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
|
||||
*/
|
||||
class PersonControllerUpdateTest extends WebTestCase
|
||||
{
|
||||
use PrepareClientTrait;
|
||||
|
||||
/** @var \Doctrine\ORM\EntityManagerInterface The entity manager */
|
||||
private $em;
|
||||
|
||||
@ -71,10 +74,7 @@ class PersonControllerUpdateTest extends WebTestCase
|
||||
$this->editUrl = '/en/person/'.$this->person->getId().'/general/edit';
|
||||
$this->viewUrl = '/en/person/'.$this->person->getId().'/general';
|
||||
|
||||
$this->client = static::createClient(array(), array(
|
||||
'PHP_AUTH_USER' => 'center a_social',
|
||||
'PHP_AUTH_PW' => 'password',
|
||||
));
|
||||
$this->client = $this->getClientAuthenticated();
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
x
Reference in New Issue
Block a user