mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-07-01 22:46:13 +00:00
Fix test with authorization: search for not presence of Depardieu
This tests fails as multiple "Gerard" may be present in database.
This commit is contained in:
parent
71c22b9c06
commit
b88c01365d
@ -33,165 +33,165 @@ class PersonSearchTest extends WebTestCase
|
||||
public function testExpected()
|
||||
{
|
||||
$client = $this->getAuthenticatedClient();
|
||||
|
||||
|
||||
$crawler = $client->request('GET', '/fr/search', array(
|
||||
'q' => '@person Depardieu'
|
||||
));
|
||||
|
||||
|
||||
$this->assertRegExp('/Depardieu/', $crawler->filter('.list-with-period')->text());
|
||||
}
|
||||
|
||||
|
||||
public function testExpectedNamed()
|
||||
{
|
||||
$client = $this->getAuthenticatedClient();
|
||||
|
||||
|
||||
$crawler = $client->request('GET', '/fr/search', array(
|
||||
'q' => '@person Depardieu', 'name' => 'person_regular'
|
||||
));
|
||||
|
||||
|
||||
$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());
|
||||
}
|
||||
|
||||
|
||||
public function testSearchByFirstNameLower()
|
||||
{
|
||||
$crawler = $this->generateCrawlerForSearch('@person firstname:Gérard');
|
||||
|
||||
|
||||
$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());
|
||||
}
|
||||
|
||||
|
||||
public function testLastNameAccentued()
|
||||
{
|
||||
$crawlerSpecial = $this->generateCrawlerForSearch('@person lastname:manço');
|
||||
|
||||
|
||||
$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());
|
||||
}
|
||||
|
||||
|
||||
public function testSearchByFirstName()
|
||||
{
|
||||
$crawler = $this->generateCrawlerForSearch('@person firstname:Jean');
|
||||
|
||||
|
||||
$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());
|
||||
}
|
||||
|
||||
|
||||
public function testSearchByFirstNamePartim2()
|
||||
{
|
||||
$crawler = $this->generateCrawlerForSearch('@person firstname:ean');
|
||||
|
||||
|
||||
$this->assertRegExp('/Depardieu/', $crawler->filter('.list-with-period')->text());
|
||||
}
|
||||
|
||||
|
||||
public function testSearchByFirstNameAccented()
|
||||
{
|
||||
$crawlerSpecial = $this->generateCrawlerForSearch('@person firstname:Gérard');
|
||||
|
||||
|
||||
$this->assertRegExp('/Gérard/', $crawlerSpecial->filter('.list-with-period')->text());
|
||||
|
||||
|
||||
|
||||
|
||||
$crawlerNoSpecial = $this->generateCrawlerForSearch('@person firstname:Gerard');
|
||||
|
||||
|
||||
$this->assertRegExp('/Gérard/', $crawlerNoSpecial->filter('.list-with-period')->text());
|
||||
}
|
||||
|
||||
|
||||
public function testSearchCombineLastnameAndNationality()
|
||||
{
|
||||
$crawler = $this->generateCrawlerForSearch('@person lastname:Depardieu nationality:RU');
|
||||
|
||||
|
||||
$this->assertRegExp('/Gérard/', $crawler->filter('.list-with-period')->text());
|
||||
//if this is a AND clause, Jean Depardieu should not appears
|
||||
$this->assertNotRegExp('/Jean/', $crawler->filter('.list-with-period')->text(),
|
||||
"assert clause firstname and nationality are AND");
|
||||
}
|
||||
|
||||
|
||||
public function testSearchCombineLastnameAndFirstName()
|
||||
{
|
||||
$crawler = $this->generateCrawlerForSearch('@person lastname:Depardieu firstname:Jean');
|
||||
|
||||
|
||||
$this->assertRegExp('/Depardieu/', $crawler->filter('.list-with-period')->text());
|
||||
//if this is a AND clause, Jean Depardieu should not appears
|
||||
$this->assertNotRegExp('/Gérard/', $crawler->filter('.list-with-period')->text(),
|
||||
"assert clause firstname and nationality are AND");
|
||||
}
|
||||
|
||||
|
||||
public function testSearchBirthdate()
|
||||
{
|
||||
$crawler = $this->generateCrawlerForSearch('@person birthdate:1948-12-27');
|
||||
|
||||
|
||||
$this->assertRegExp('/Gérard/', $crawler->filter('.list-with-period')->text());
|
||||
$this->assertRegExp('/Bart/', $crawler->filter('.list-with-period')->text());
|
||||
}
|
||||
|
||||
|
||||
public function testSearchCombineBirthdateAndLastName()
|
||||
{
|
||||
$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());
|
||||
}
|
||||
|
||||
|
||||
public function testSearchCombineGenderAndLastName()
|
||||
{
|
||||
$crawler = $this->generateCrawlerForSearch('@person gender:woman lastname:(Depardieu)');
|
||||
|
||||
|
||||
$this->assertRegExp('/Charline/', $crawler->filter('.list-with-period')->text());
|
||||
$this->assertNotRegExp('/Gérard/', $crawler->filter('.list-with-period')->text());
|
||||
}
|
||||
|
||||
|
||||
public function testSearchMultipleTrigramUseAndClauseInDefault()
|
||||
{
|
||||
$crawler = $this->generateCrawlerForSearch('@person cha dep');
|
||||
|
||||
|
||||
$this->assertRegExp('/Charline/', $crawler->filter('.list-with-period')->text());
|
||||
$this->assertNotRegExp('/Gérard/', $crawler->filter('.list-with-period')->text());
|
||||
$this->assertNotRegExp('/Jean/', $crawler->filter('.list-with-period')->text());
|
||||
}
|
||||
|
||||
|
||||
public function testDefaultAccented()
|
||||
{
|
||||
$crawlerSpecial = $this->generateCrawlerForSearch('@person manço');
|
||||
|
||||
|
||||
$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());
|
||||
|
||||
|
||||
$crawlerSpecial = $this->generateCrawlerForSearch('@person Étienne');
|
||||
|
||||
|
||||
$this->assertRegExp('/Étienne/', $crawlerSpecial->filter('.list-with-period')->text());
|
||||
|
||||
|
||||
|
||||
|
||||
$crawlerNoSpecial = $this->generateCrawlerForSearch('@person etienne');
|
||||
|
||||
|
||||
$this->assertRegExp('/Étienne/', $crawlerNoSpecial->filter('.list-with-period')->text());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* test that person which a user cannot see are not displayed in results
|
||||
*/
|
||||
@ -199,30 +199,29 @@ class PersonSearchTest extends WebTestCase
|
||||
{
|
||||
$crawlerCanSee = $this->generateCrawlerForSearch('Gérard', 'center a_social');
|
||||
$crawlerCannotSee = $this->generateCrawlerForSearch('Gérard', 'center b_social');
|
||||
|
||||
$this->assertRegExp('/Gérard/', $crawlerCanSee->text(),
|
||||
'center a_social may see "Gérard" in center a');
|
||||
$this->assertRegExp('/Aucune personne ne correspond aux termes de recherche/',
|
||||
$crawlerCannotSee->text(),
|
||||
'center b_social may not see any "Gérard" associated to center b');
|
||||
|
||||
|
||||
$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');
|
||||
|
||||
}
|
||||
|
||||
|
||||
private function generateCrawlerForSearch($pattern, $username = 'center a_social')
|
||||
{
|
||||
$client = $this->getAuthenticatedClient($username);
|
||||
|
||||
|
||||
$crawler = $client->request('GET', '/fr/search', array(
|
||||
'q' => $pattern,
|
||||
));
|
||||
|
||||
|
||||
$this->assertTrue($client->getResponse()->isSuccessful());
|
||||
|
||||
|
||||
return $crawler;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @return \Symfony\Component\BrowserKit\Client
|
||||
*/
|
||||
private function getAuthenticatedClient($username = 'center a_social')
|
||||
|
Loading…
x
Reference in New Issue
Block a user