mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-21 07:03:49 +00:00
fix some tests for person bundle
This commit is contained in:
@@ -20,18 +20,16 @@
|
||||
|
||||
namespace Chill\PersonBundle\Tests\Controller;
|
||||
|
||||
//ini_set('memory_limit', '-1');
|
||||
|
||||
use Chill\PersonBundle\Entity\Person;
|
||||
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
|
||||
use Chill\MainBundle\Test\PrepareClientTrait;
|
||||
|
||||
|
||||
/**
|
||||
* Test the edition of persons
|
||||
*
|
||||
* As I am logged in as "center a_social"
|
||||
*
|
||||
* @author Julien Fastré <julien.fastre@champs-libres.coop>
|
||||
*/
|
||||
class PersonControllerUpdateTest extends WebTestCase
|
||||
{
|
||||
@@ -71,8 +69,8 @@ class PersonControllerUpdateTest extends WebTestCase
|
||||
$this->em->persist($this->person);
|
||||
$this->em->flush();
|
||||
|
||||
$this->editUrl = '/en/person/'.$this->person->getId().'/general/edit';
|
||||
$this->viewUrl = '/en/person/'.$this->person->getId().'/general';
|
||||
$this->editUrl = '/fr/person/'.$this->person->getId().'/general/edit';
|
||||
$this->viewUrl = '/fr/person/'.$this->person->getId().'/general';
|
||||
|
||||
$this->client = $this->getClientAuthenticated();
|
||||
}
|
||||
@@ -104,10 +102,10 @@ class PersonControllerUpdateTest extends WebTestCase
|
||||
public function testHiddenFielsArePresent()
|
||||
{
|
||||
$crawler = $this->client->request('GET', $this->editUrl);
|
||||
|
||||
|
||||
$configurables = array('placeOfBirth', 'phonenumber', 'email',
|
||||
'countryOfBirth', 'nationality', 'spokenLanguages', 'maritalStatus');
|
||||
$form = $crawler->selectButton('Submit')->form(); //;
|
||||
$form = $crawler->selectButton('Enregistrer')->form(); //;
|
||||
|
||||
foreach($configurables as $key) {
|
||||
$this->assertTrue($form->has('chill_personbundle_person['.$key.']'));
|
||||
@@ -162,18 +160,18 @@ class PersonControllerUpdateTest extends WebTestCase
|
||||
{
|
||||
$crawler = $this->client->request('GET', $this->editUrl);
|
||||
|
||||
$form = $crawler->selectButton('Submit')
|
||||
$form = $crawler->selectButton('Enregistrer')
|
||||
->form();
|
||||
//transform countries into value if needed
|
||||
switch ($field) {
|
||||
case 'nationality':
|
||||
case 'countryOfBirth':
|
||||
if ($value !== NULL) {
|
||||
if (FALSE === empty($value)) {
|
||||
$country = $this->em->getRepository('ChillMainBundle:Country')
|
||||
->findOneByCountryCode($value);
|
||||
$transformedValue = $country->getId();
|
||||
} else {
|
||||
$transformedValue = NULL;
|
||||
$transformedValue = '';
|
||||
}
|
||||
break;
|
||||
default:
|
||||
@@ -208,7 +206,7 @@ class PersonControllerUpdateTest extends WebTestCase
|
||||
$crawler = $this->client->request('GET', $this->editUrl);
|
||||
$selectedLanguages = array('en', 'an', 'bbj');
|
||||
|
||||
$form = $crawler->selectButton('Submit')
|
||||
$form = $crawler->selectButton('Enregistrer')
|
||||
->form();
|
||||
$form->get('chill_personbundle_person[spokenLanguages]')
|
||||
->setValue($selectedLanguages);
|
||||
@@ -238,7 +236,7 @@ class PersonControllerUpdateTest extends WebTestCase
|
||||
{
|
||||
$crawler = $this->client->request('GET', $this->editUrl);
|
||||
|
||||
$form = $crawler->selectButton('Submit')
|
||||
$form = $crawler->selectButton('Enregistrer')
|
||||
->form();
|
||||
$form->get('chill_personbundle_person['.$field.']')
|
||||
->setValue($value);
|
||||
@@ -264,7 +262,7 @@ class PersonControllerUpdateTest extends WebTestCase
|
||||
['lastName' , 'random Value', function(Person $person) { return $person->getLastName(); } ],
|
||||
['placeOfBirth', 'none place', function(Person $person) { return $person->getPlaceOfBirth(); }],
|
||||
['birthdate', '15-12-1980', function(Person $person) { return $person->getBirthdate()->format('d-m-Y'); }],
|
||||
['phonenumber', '0123456789', function(Person $person) { return $person->getPhonenumber(); }],
|
||||
['phonenumber', '+32123456789', function(Person $person) { return $person->getPhonenumber(); }],
|
||||
['memo', 'jfkdlmq jkfldmsq jkmfdsq', function(Person $person) { return $person->getMemo(); }],
|
||||
['countryOfBirth', 'BE', function(Person $person) { return $person->getCountryOfBirth()->getCountryCode(); }],
|
||||
['nationality', 'FR', function(Person $person) { return $person->getNationality()->getCountryCode(); }],
|
||||
@@ -275,7 +273,6 @@ class PersonControllerUpdateTest extends WebTestCase
|
||||
['countryOfBirth', NULL, function(Person $person) { return $person->getCountryOfBirth(); }],
|
||||
['nationality', NULL, function(Person $person) { return $person->getNationality(); }],
|
||||
['gender', Person::FEMALE_GENDER, function(Person $person) { return $person->getGender(); }],
|
||||
['maritalStatus', NULL, function(Person $person) {return $person->getMaritalStatus(); }]
|
||||
);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user