mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-21 07:03:49 +00:00
tests/ChillPersonBundle: use mutualized getClientAuthenticated()
This commit is contained in:
@@ -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');
|
||||
|
||||
|
Reference in New Issue
Block a user