Fix tests with capitalization

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

View File

@@ -177,9 +177,11 @@ class PersonControllerCreateTest extends WebTestCase
$this->assertTrue($form->has(self::CENTER_INPUT),
'The page contains a "center" input');
$centerInput = $form->get(self::CENTER_INPUT);
/*
$availableValues = $centerInput->availableOptionValues();
$lastCenterInputValue = end($availableValues);
$centerInput->setValue($lastCenterInputValue);
*/
$client->submit($form);
@@ -205,7 +207,7 @@ class PersonControllerCreateTest extends WebTestCase
$form = $this->fillAValidCreationForm($form, 'Charline', 'dd');
$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");
//inversion
@@ -213,7 +215,7 @@ class PersonControllerCreateTest extends WebTestCase
$form = $this->fillAValidCreationForm($form, 'dd', 'Charline');
$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");
}

View File

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

View File

@@ -26,7 +26,6 @@ use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
/**
* Test Person search
*
* @author Julien Fastré <julien.fastre@champs-libres.coop>
*/
class PersonSearchTest extends WebTestCase
{
@@ -38,7 +37,7 @@ class PersonSearchTest extends WebTestCase
'q' => '@person Depardieu'
));
$this->assertRegExp('/Depardieu/', $crawler->filter('.list-with-period')->text());
$this->assertRegExp('/DEPARDIEU/', $crawler->filter('.list-with-period')->text());
}
public function testExpectedNamed()
@@ -49,61 +48,61 @@ class PersonSearchTest extends WebTestCase
'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()
{
$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()
{
$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()
{
$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()
{
$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');
$this->assertRegExp('/Manço/', $crawlerNoSpecial->filter('.list-with-period')->text());
$this->assertRegExp('/MANÇO/', $crawlerNoSpecial->filter('.list-with-period')->text());
}
public function testSearchByFirstName()
{
$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()
{
$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()
{
$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()
@@ -154,7 +153,7 @@ class PersonSearchTest extends WebTestCase
$crawler = $this->generateCrawlerForSearch('@person birthdate:1948-12-27 lastname:(Van Snick)');
$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()
@@ -181,12 +180,12 @@ class PersonSearchTest extends WebTestCase
$this->markTestSkipped("skipped until adapted to new fixtures");
$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');
$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');
@@ -206,10 +205,10 @@ class PersonSearchTest extends WebTestCase
$crawlerCanSee = $this->generateCrawlerForSearch('Gérard', 'center a_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');
$this->assertNotRegExp('/Depardieu/', $crawlerCannotSee->text(),
'center b_social may see "Depardieu" in center b');
$this->assertNotRegExp('/DEPARDIEU/', $crawlerCannotSee->text(),
'center b_social may not see "Depardieu" in center b');
}