Fix tests with capitalization

This commit is contained in:
Julien Fastré 2021-10-14 14:01:18 +00:00
parent a75f4015c7
commit 4f940b44ad
6 changed files with 66 additions and 65 deletions

View File

@ -141,7 +141,6 @@ class LoadActivity extends AbstractFixture implements OrderedFixtureInterface, C
$ref = 'activity_'.$person->getFullnameCanonical(); $ref = 'activity_'.$person->getFullnameCanonical();
for($i = 0; $i < $activityNbr; $i ++) { for($i = 0; $i < $activityNbr; $i ++) {
print "Creating an activity type for : ".$person." (ref: ".$ref.") \n";
$activity = $this->newRandomActivity($person); $activity = $this->newRandomActivity($person);
$manager->persist($activity); $manager->persist($activity);
} }

View File

@ -177,9 +177,11 @@ class PersonControllerCreateTest extends WebTestCase
$this->assertTrue($form->has(self::CENTER_INPUT), $this->assertTrue($form->has(self::CENTER_INPUT),
'The page contains a "center" input'); 'The page contains a "center" input');
$centerInput = $form->get(self::CENTER_INPUT); $centerInput = $form->get(self::CENTER_INPUT);
/*
$availableValues = $centerInput->availableOptionValues(); $availableValues = $centerInput->availableOptionValues();
$lastCenterInputValue = end($availableValues); $lastCenterInputValue = end($availableValues);
$centerInput->setValue($lastCenterInputValue); $centerInput->setValue($lastCenterInputValue);
*/
$client->submit($form); $client->submit($form);
@ -205,7 +207,7 @@ class PersonControllerCreateTest extends WebTestCase
$form = $this->fillAValidCreationForm($form, 'Charline', 'dd'); $form = $this->fillAValidCreationForm($form, 'Charline', 'dd');
$client->submit($form); $client->submit($form);
$this->assertContains('Depardieu', $client->getCrawler()->text(), $this->assertContains('DEPARDIEU', $client->getCrawler()->text(),
"check that the page has detected the lastname of a person existing in database"); "check that the page has detected the lastname of a person existing in database");
//inversion //inversion
@ -213,7 +215,7 @@ class PersonControllerCreateTest extends WebTestCase
$form = $this->fillAValidCreationForm($form, 'dd', 'Charline'); $form = $this->fillAValidCreationForm($form, 'dd', 'Charline');
$client->submit($form); $client->submit($form);
$this->assertContains('Depardieu', $client->getCrawler()->text(), $this->assertContains('DEPARDIEU', $client->getCrawler()->text(),
"check that the page has detected the lastname of a person existing in database"); "check that the page has detected the lastname of a person existing in database");
} }

View File

@ -30,38 +30,38 @@ class PersonControllerViewTest extends WebTestCase
{ {
/** @var \Doctrine\ORM\EntityManagerInterface The entity manager */ /** @var \Doctrine\ORM\EntityManagerInterface The entity manager */
private $em; private $em;
/** @var Person A person used on which to run the test */ /** @var Person A person used on which to run the test */
private $person; private $person;
/** @var String The url to view the person details */ /** @var String The url to view the person details */
private $viewUrl; private $viewUrl;
public function setUp() public function setUp()
{ {
static::bootKernel(); static::bootKernel();
$this->em = static::$kernel->getContainer() $this->em = static::$kernel->getContainer()
->get('doctrine.orm.entity_manager'); ->get('doctrine.orm.entity_manager');
$center = $this->em->getRepository('ChillMainBundle:Center') $center = $this->em->getRepository('ChillMainBundle:Center')
->findOneBy(array('name' => 'Center A')); ->findOneBy(array('name' => 'Center A'));
$this->person = (new Person()) $this->person = (new Person())
->setLastName("Tested Person") ->setLastName("Tested Person")
->setFirstName("Réginald") ->setFirstName("Réginald")
->setCenter($center) ->setCenter($center)
->setGender(Person::MALE_GENDER); ->setGender(Person::MALE_GENDER);
$this->em->persist($this->person); $this->em->persist($this->person);
$this->em->flush(); $this->em->flush();
$this->viewUrl = '/en/person/'.$this->person->getId().'/general'; $this->viewUrl = '/en/person/'.$this->person->getId().'/general';
} }
/** /**
* Test if the view page is accessible * Test if the view page is accessible
* *
* @group configurable_fields * @group configurable_fields
*/ */
public function testViewPerson() public function testViewPerson()
@ -70,20 +70,20 @@ class PersonControllerViewTest extends WebTestCase
'PHP_AUTH_USER' => 'center a_social', 'PHP_AUTH_USER' => 'center a_social',
'PHP_AUTH_PW' => 'password', 'PHP_AUTH_PW' => 'password',
)); ));
$crawler = $client->request('GET', $this->viewUrl); $crawler = $client->request('GET', $this->viewUrl);
$response = $client->getResponse(); $response = $client->getResponse();
$this->assertTrue($response->isSuccessful()); $this->assertTrue($response->isSuccessful());
$this->assertGreaterThan(0, $crawler->filter('html:contains("Tested Person")')->count()); $this->assertGreaterThan(0, $crawler->filter('html:contains("TESTED PERSON")')->count());
$this->assertGreaterThan(0, $crawler->filter('html:contains("Réginald")')->count()); $this->assertGreaterThan(0, $crawler->filter('html:contains("Réginald")')->count());
$this->assertContains('Email addresses', $crawler->text()); $this->assertContains('Email addresses', $crawler->text());
$this->assertContains('Phonenumber', $crawler->text()); $this->assertContains('Phonenumber', $crawler->text());
$this->assertContains('Langues parlées', $crawler->text()); $this->assertContains('Langues parlées', $crawler->text());
$this->assertContains(/* Etat */ 'civil', $crawler->text()); $this->assertContains(/* Etat */ 'civil', $crawler->text());
} }
/** /**
* Test if the view page of a given person is not accessible for a user * Test if the view page of a given person is not accessible for a user
* of another center of the person * of another center of the person
@ -94,26 +94,26 @@ class PersonControllerViewTest extends WebTestCase
'PHP_AUTH_USER' => 'center b_social', 'PHP_AUTH_USER' => 'center b_social',
'PHP_AUTH_PW' => 'password', 'PHP_AUTH_PW' => 'password',
)); ));
$client->request('GET', $this->viewUrl); $client->request('GET', $this->viewUrl);
$this->assertEquals(403, $client->getResponse()->getStatusCode(), $this->assertEquals(403, $client->getResponse()->getStatusCode(),
"The view page of a person of a center A must not be accessible for user of center B"); "The view page of a person of a center A must not be accessible for user of center B");
} }
/** /**
* Reload the person from the db * Reload the person from the db
*/ */
protected function refreshPerson() protected function refreshPerson()
{ {
$this->person = $this->em->getRepository('ChillPersonBundle:Person') $this->person = $this->em->getRepository('ChillPersonBundle:Person')
->find($this->person->getId()); ->find($this->person->getId());
} }
public function tearDown() public function tearDown()
{ {
$this->refreshPerson(); $this->refreshPerson();
$this->em->remove($this->person); $this->em->remove($this->person);
$this->em->flush(); $this->em->flush();
} }
} }

View File

@ -26,7 +26,6 @@ use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
/** /**
* Test Person search * Test Person search
* *
* @author Julien Fastré <julien.fastre@champs-libres.coop>
*/ */
class PersonSearchTest extends WebTestCase class PersonSearchTest extends WebTestCase
{ {
@ -38,7 +37,7 @@ class PersonSearchTest extends WebTestCase
'q' => '@person Depardieu' 'q' => '@person Depardieu'
)); ));
$this->assertRegExp('/Depardieu/', $crawler->filter('.list-with-period')->text()); $this->assertRegExp('/DEPARDIEU/', $crawler->filter('.list-with-period')->text());
} }
public function testExpectedNamed() public function testExpectedNamed()
@ -49,61 +48,61 @@ class PersonSearchTest extends WebTestCase
'q' => '@person Depardieu', 'name' => 'person_regular' 'q' => '@person Depardieu', 'name' => 'person_regular'
)); ));
$this->assertRegExp('/Depardieu/', $crawler->filter('.list-with-period')->text()); $this->assertRegExp('/DEPARDIEU/', $crawler->filter('.list-with-period')->text());
} }
public function testSearchByLastName() public function testSearchByLastName()
{ {
$crawler = $this->generateCrawlerForSearch('@person lastname:Depardieu'); $crawler = $this->generateCrawlerForSearch('@person lastname:Depardieu');
$this->assertRegExp('/Depardieu/', $crawler->filter('.list-with-period')->text()); $this->assertRegExp('/DEPARDIEU/', $crawler->filter('.list-with-period')->text());
} }
public function testSearchByFirstNameLower() public function testSearchByFirstNameLower()
{ {
$crawler = $this->generateCrawlerForSearch('@person firstname:Gérard'); $crawler = $this->generateCrawlerForSearch('@person firstname:Gérard');
$this->assertRegExp('/Depardieu/', $crawler->filter('.list-with-period')->text()); $this->assertRegExp('/DEPARDIEU/', $crawler->filter('.list-with-period')->text());
} }
public function testSearchByFirstNamePartim() public function testSearchByFirstNamePartim()
{ {
$crawler = $this->generateCrawlerForSearch('@person firstname:Ger'); $crawler = $this->generateCrawlerForSearch('@person firstname:Ger');
$this->assertRegExp('/Depardieu/', $crawler->filter('.list-with-period')->text()); $this->assertRegExp('/DEPARDIEU/', $crawler->filter('.list-with-period')->text());
} }
public function testLastNameAccentued() public function testLastNameAccentued()
{ {
$crawlerSpecial = $this->generateCrawlerForSearch('@person lastname:manço'); $crawlerSpecial = $this->generateCrawlerForSearch('@person lastname:manço');
$this->assertRegExp('/Manço/', $crawlerSpecial->filter('.list-with-period')->text()); $this->assertRegExp('/MANÇO/', $crawlerSpecial->filter('.list-with-period')->text());
$crawlerNoSpecial = $this->generateCrawlerForSearch('@person lastname:manco'); $crawlerNoSpecial = $this->generateCrawlerForSearch('@person lastname:manco');
$this->assertRegExp('/Manço/', $crawlerNoSpecial->filter('.list-with-period')->text()); $this->assertRegExp('/MANÇO/', $crawlerNoSpecial->filter('.list-with-period')->text());
} }
public function testSearchByFirstName() public function testSearchByFirstName()
{ {
$crawler = $this->generateCrawlerForSearch('@person firstname:Jean'); $crawler = $this->generateCrawlerForSearch('@person firstname:Jean');
$this->assertRegExp('/Depardieu/', $crawler->filter('.list-with-period')->text()); $this->assertRegExp('/DEPARDIEU/', $crawler->filter('.list-with-period')->text());
} }
public function testSearchByFirstNameLower2() public function testSearchByFirstNameLower2()
{ {
$crawler = $this->generateCrawlerForSearch('@person firstname:jean'); $crawler = $this->generateCrawlerForSearch('@person firstname:jean');
$this->assertRegExp('/Depardieu/', $crawler->filter('.list-with-period')->text()); $this->assertRegExp('/DEPARDIEU/', $crawler->filter('.list-with-period')->text());
} }
public function testSearchByFirstNamePartim2() public function testSearchByFirstNamePartim2()
{ {
$crawler = $this->generateCrawlerForSearch('@person firstname:ean'); $crawler = $this->generateCrawlerForSearch('@person firstname:ean');
$this->assertRegExp('/Depardieu/', $crawler->filter('.list-with-period')->text()); $this->assertRegExp('/DEPARDIEU/', $crawler->filter('.list-with-period')->text());
} }
public function testSearchByFirstNameAccented() public function testSearchByFirstNameAccented()
@ -154,7 +153,7 @@ class PersonSearchTest extends WebTestCase
$crawler = $this->generateCrawlerForSearch('@person birthdate:1948-12-27 lastname:(Van Snick)'); $crawler = $this->generateCrawlerForSearch('@person birthdate:1948-12-27 lastname:(Van Snick)');
$this->assertRegExp('/Bart/', $crawler->filter('.list-with-period')->text()); $this->assertRegExp('/Bart/', $crawler->filter('.list-with-period')->text());
$this->assertNotRegExp('/Depardieu/', $crawler->filter('.list-with-period')->text()); $this->assertNotRegExp('/DEPARDIEU/', $crawler->filter('.list-with-period')->text());
} }
public function testSearchCombineGenderAndLastName() public function testSearchCombineGenderAndLastName()
@ -181,12 +180,12 @@ class PersonSearchTest extends WebTestCase
$this->markTestSkipped("skipped until adapted to new fixtures"); $this->markTestSkipped("skipped until adapted to new fixtures");
$crawlerSpecial = $this->generateCrawlerForSearch('@person manço'); $crawlerSpecial = $this->generateCrawlerForSearch('@person manço');
$this->assertRegExp('/Manço/', $crawlerSpecial->filter('.list-with-period')->text()); $this->assertRegExp('/MANÇO/', $crawlerSpecial->filter('.list-with-period')->text());
$crawlerNoSpecial = $this->generateCrawlerForSearch('@person manco'); $crawlerNoSpecial = $this->generateCrawlerForSearch('@person manco');
$this->assertRegExp('/Manço/', $crawlerNoSpecial->filter('.list-with-period')->text()); $this->assertRegExp('/MANÇO/', $crawlerNoSpecial->filter('.list-with-period')->text());
$crawlerSpecial = $this->generateCrawlerForSearch('@person Étienne'); $crawlerSpecial = $this->generateCrawlerForSearch('@person Étienne');
@ -206,10 +205,10 @@ class PersonSearchTest extends WebTestCase
$crawlerCanSee = $this->generateCrawlerForSearch('Gérard', 'center a_social'); $crawlerCanSee = $this->generateCrawlerForSearch('Gérard', 'center a_social');
$crawlerCannotSee = $this->generateCrawlerForSearch('Gérard', 'center b_social'); $crawlerCannotSee = $this->generateCrawlerForSearch('Gérard', 'center b_social');
$this->assertRegExp('/Depardieu/', $crawlerCanSee->text(), $this->assertRegExp('/DEPARDIEU/', $crawlerCanSee->text(),
'center a_social may see "Depardieu" in center a'); 'center a_social may see "Depardieu" in center a');
$this->assertNotRegExp('/Depardieu/', $crawlerCannotSee->text(), $this->assertNotRegExp('/DEPARDIEU/', $crawlerCannotSee->text(),
'center b_social may see "Depardieu" in center b'); 'center b_social may not see "Depardieu" in center b');
} }

View File

@ -1,20 +1,20 @@
<?php <?php
/* /*
* Chill is a software for social workers * Chill is a software for social workers
* *
* Copyright (C) 2014, Champs Libres Cooperative SCRLFS, <http://www.champs-libres.coop> * Copyright (C) 2014, Champs Libres Cooperative SCRLFS, <http://www.champs-libres.coop>
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as * it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the * published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version. * License, or (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details. * GNU Affero General Public License for more details.
* *
* You should have received a copy of the GNU Affero General Public License * You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
@ -35,11 +35,9 @@ class LoadCustomField extends AbstractFixture implements OrderedFixtureInterface
{ {
return 15001; return 15001;
} }
public function load(ObjectManager $manager) public function load(ObjectManager $manager)
{ {
echo "loading CustomField...\n";
$cFTypes = [ $cFTypes = [
array('type' => 'text', 'options' => array('maxLength' => '255')), array('type' => 'text', 'options' => array('maxLength' => '255')),
array('type' => 'text', 'options' => array('maxLength' => '1000')), array('type' => 'text', 'options' => array('maxLength' => '1000')),
@ -78,7 +76,6 @@ class LoadCustomField extends AbstractFixture implements OrderedFixtureInterface
]; ];
for($i=0; $i <= 25; $i++) { for($i=0; $i <= 25; $i++) {
echo "CustomField {$i}\n";
$cFType = $cFTypes[rand(0,sizeof($cFTypes) - 1)]; $cFType = $cFTypes[rand(0,sizeof($cFTypes) - 1)];
$customField = (new CustomField()) $customField = (new CustomField())
@ -92,17 +89,17 @@ class LoadCustomField extends AbstractFixture implements OrderedFixtureInterface
$manager->persist($customField); $manager->persist($customField);
} }
$this->createExpectedFields($manager); $this->createExpectedFields($manager);
$manager->flush(); $manager->flush();
} }
private function createExpectedFields(ObjectManager $manager) private function createExpectedFields(ObjectManager $manager)
{ {
//report logement //report logement
$reportLogement = $this->getReference('cf_group_report_logement'); $reportLogement = $this->getReference('cf_group_report_logement');
$houseTitle = (new CustomField()) $houseTitle = (new CustomField())
->setSlug('house_title') ->setSlug('house_title')
->setType('title') ->setType('title')
@ -112,7 +109,7 @@ class LoadCustomField extends AbstractFixture implements OrderedFixtureInterface
->setCustomFieldsGroup($reportLogement) ->setCustomFieldsGroup($reportLogement)
; ;
$manager->persist($houseTitle); $manager->persist($houseTitle);
$hasLogement = (new CustomField()) $hasLogement = (new CustomField())
->setSlug('has_logement') ->setSlug('has_logement')
->setName(array('fr' => 'Logement actuel')) ->setName(array('fr' => 'Logement actuel'))
@ -143,13 +140,13 @@ class LoadCustomField extends AbstractFixture implements OrderedFixtureInterface
'active' => true 'active' => true
) )
] ]
)) ))
->setOrdering(20) ->setOrdering(20)
->setCustomFieldsGroup($reportLogement) ->setCustomFieldsGroup($reportLogement)
; ;
$manager->persist($hasLogement); $manager->persist($hasLogement);
$descriptionLogement = (new CustomField()) $descriptionLogement = (new CustomField())
->setSlug('house-desc') ->setSlug('house-desc')
->setName(array('fr' => 'Plaintes éventuelles sur le logement')) ->setName(array('fr' => 'Plaintes éventuelles sur le logement'))
@ -159,11 +156,11 @@ class LoadCustomField extends AbstractFixture implements OrderedFixtureInterface
->setCustomFieldsGroup($reportLogement) ->setCustomFieldsGroup($reportLogement)
; ;
$manager->persist($descriptionLogement); $manager->persist($descriptionLogement);
//report problems //report problems
$reportEducation = $this->getReference('cf_group_report_education'); $reportEducation = $this->getReference('cf_group_report_education');
$title = (new CustomField()) $title = (new CustomField())
->setSlug('title') ->setSlug('title')
->setType('title') ->setType('title')
@ -173,7 +170,7 @@ class LoadCustomField extends AbstractFixture implements OrderedFixtureInterface
->setCustomFieldsGroup($reportEducation) ->setCustomFieldsGroup($reportEducation)
; ;
$manager->persist($title); $manager->persist($title);
$educationLevel = (new CustomField()) $educationLevel = (new CustomField())
->setSlug('level') ->setSlug('level')
->setName(array('fr' => 'Niveau du plus haut diplôme')) ->setName(array('fr' => 'Niveau du plus haut diplôme'))
@ -209,14 +206,14 @@ class LoadCustomField extends AbstractFixture implements OrderedFixtureInterface
'active' => true 'active' => true
) )
] ]
)) ))
->setOrdering(20) ->setOrdering(20)
->setCustomFieldsGroup($reportEducation) ->setCustomFieldsGroup($reportEducation)
; ;
$manager->persist($educationLevel); $manager->persist($educationLevel);
} }
} }

View File

@ -92,15 +92,19 @@ class LoadReports extends AbstractFixture implements OrderedFixtureInterface, Co
->findOneBy(array('firstName' => 'Charline', 'lastName' => 'DEPARDIEU')) ->findOneBy(array('firstName' => 'Charline', 'lastName' => 'DEPARDIEU'))
; ;
$report = (new Report()) if (NULL !== $charline) {
$report = (new Report())
->setPerson($charline) ->setPerson($charline)
->setCFGroup($this->getReference('cf_group_report_logement')) ->setCFGroup($this->getReference('cf_group_report_logement'))
->setDate(new \DateTime('2015-01-05')) ->setDate(new \DateTime('2015-01-05'))
->setScope($this->getReference('scope_social')) ->setScope($this->getReference('scope_social'))
; ;
$this->fillReport($report); $this->fillReport($report);
$manager->persist($report); $manager->persist($report);
} else {
print("WARNING: Charline DEPARDIEU not found in database");
}
} }
/** /**