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()
|
public function testExpected()
|
||||||
{
|
{
|
||||||
$client = $this->getAuthenticatedClient();
|
$client = $this->getAuthenticatedClient();
|
||||||
|
|
||||||
$crawler = $client->request('GET', '/fr/search', array(
|
$crawler = $client->request('GET', '/fr/search', array(
|
||||||
'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()
|
||||||
{
|
{
|
||||||
$client = $this->getAuthenticatedClient();
|
$client = $this->getAuthenticatedClient();
|
||||||
|
|
||||||
$crawler = $client->request('GET', '/fr/search', array(
|
$crawler = $client->request('GET', '/fr/search', array(
|
||||||
'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()
|
||||||
{
|
{
|
||||||
$crawlerSpecial = $this->generateCrawlerForSearch('@person firstname:Gérard');
|
$crawlerSpecial = $this->generateCrawlerForSearch('@person firstname:Gérard');
|
||||||
|
|
||||||
$this->assertRegExp('/Gérard/', $crawlerSpecial->filter('.list-with-period')->text());
|
$this->assertRegExp('/Gérard/', $crawlerSpecial->filter('.list-with-period')->text());
|
||||||
|
|
||||||
|
|
||||||
$crawlerNoSpecial = $this->generateCrawlerForSearch('@person firstname:Gerard');
|
$crawlerNoSpecial = $this->generateCrawlerForSearch('@person firstname:Gerard');
|
||||||
|
|
||||||
$this->assertRegExp('/Gérard/', $crawlerNoSpecial->filter('.list-with-period')->text());
|
$this->assertRegExp('/Gérard/', $crawlerNoSpecial->filter('.list-with-period')->text());
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testSearchCombineLastnameAndNationality()
|
public function testSearchCombineLastnameAndNationality()
|
||||||
{
|
{
|
||||||
$crawler = $this->generateCrawlerForSearch('@person lastname:Depardieu nationality:RU');
|
$crawler = $this->generateCrawlerForSearch('@person lastname:Depardieu nationality:RU');
|
||||||
|
|
||||||
$this->assertRegExp('/Gérard/', $crawler->filter('.list-with-period')->text());
|
$this->assertRegExp('/Gérard/', $crawler->filter('.list-with-period')->text());
|
||||||
//if this is a AND clause, Jean Depardieu should not appears
|
//if this is a AND clause, Jean Depardieu should not appears
|
||||||
$this->assertNotRegExp('/Jean/', $crawler->filter('.list-with-period')->text(),
|
$this->assertNotRegExp('/Jean/', $crawler->filter('.list-with-period')->text(),
|
||||||
"assert clause firstname and nationality are AND");
|
"assert clause firstname and nationality are AND");
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testSearchCombineLastnameAndFirstName()
|
public function testSearchCombineLastnameAndFirstName()
|
||||||
{
|
{
|
||||||
$crawler = $this->generateCrawlerForSearch('@person lastname:Depardieu firstname:Jean');
|
$crawler = $this->generateCrawlerForSearch('@person lastname:Depardieu firstname:Jean');
|
||||||
|
|
||||||
$this->assertRegExp('/Depardieu/', $crawler->filter('.list-with-period')->text());
|
$this->assertRegExp('/Depardieu/', $crawler->filter('.list-with-period')->text());
|
||||||
//if this is a AND clause, Jean Depardieu should not appears
|
//if this is a AND clause, Jean Depardieu should not appears
|
||||||
$this->assertNotRegExp('/Gérard/', $crawler->filter('.list-with-period')->text(),
|
$this->assertNotRegExp('/Gérard/', $crawler->filter('.list-with-period')->text(),
|
||||||
"assert clause firstname and nationality are AND");
|
"assert clause firstname and nationality are AND");
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testSearchBirthdate()
|
public function testSearchBirthdate()
|
||||||
{
|
{
|
||||||
$crawler = $this->generateCrawlerForSearch('@person birthdate:1948-12-27');
|
$crawler = $this->generateCrawlerForSearch('@person birthdate:1948-12-27');
|
||||||
|
|
||||||
$this->assertRegExp('/Gérard/', $crawler->filter('.list-with-period')->text());
|
$this->assertRegExp('/Gérard/', $crawler->filter('.list-with-period')->text());
|
||||||
$this->assertRegExp('/Bart/', $crawler->filter('.list-with-period')->text());
|
$this->assertRegExp('/Bart/', $crawler->filter('.list-with-period')->text());
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testSearchCombineBirthdateAndLastName()
|
public function testSearchCombineBirthdateAndLastName()
|
||||||
{
|
{
|
||||||
$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()
|
||||||
{
|
{
|
||||||
$crawler = $this->generateCrawlerForSearch('@person gender:woman lastname:(Depardieu)');
|
$crawler = $this->generateCrawlerForSearch('@person gender:woman lastname:(Depardieu)');
|
||||||
|
|
||||||
$this->assertRegExp('/Charline/', $crawler->filter('.list-with-period')->text());
|
$this->assertRegExp('/Charline/', $crawler->filter('.list-with-period')->text());
|
||||||
$this->assertNotRegExp('/Gérard/', $crawler->filter('.list-with-period')->text());
|
$this->assertNotRegExp('/Gérard/', $crawler->filter('.list-with-period')->text());
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testSearchMultipleTrigramUseAndClauseInDefault()
|
public function testSearchMultipleTrigramUseAndClauseInDefault()
|
||||||
{
|
{
|
||||||
$crawler = $this->generateCrawlerForSearch('@person cha dep');
|
$crawler = $this->generateCrawlerForSearch('@person cha dep');
|
||||||
|
|
||||||
$this->assertRegExp('/Charline/', $crawler->filter('.list-with-period')->text());
|
$this->assertRegExp('/Charline/', $crawler->filter('.list-with-period')->text());
|
||||||
$this->assertNotRegExp('/Gérard/', $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());
|
$this->assertNotRegExp('/Jean/', $crawler->filter('.list-with-period')->text());
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testDefaultAccented()
|
public function testDefaultAccented()
|
||||||
{
|
{
|
||||||
$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');
|
||||||
|
|
||||||
$this->assertRegExp('/Étienne/', $crawlerSpecial->filter('.list-with-period')->text());
|
$this->assertRegExp('/Étienne/', $crawlerSpecial->filter('.list-with-period')->text());
|
||||||
|
|
||||||
|
|
||||||
$crawlerNoSpecial = $this->generateCrawlerForSearch('@person etienne');
|
$crawlerNoSpecial = $this->generateCrawlerForSearch('@person etienne');
|
||||||
|
|
||||||
$this->assertRegExp('/Étienne/', $crawlerNoSpecial->filter('.list-with-period')->text());
|
$this->assertRegExp('/Étienne/', $crawlerNoSpecial->filter('.list-with-period')->text());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* test that person which a user cannot see are not displayed in results
|
* 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');
|
$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('/Gérard/', $crawlerCanSee->text(),
|
$this->assertRegExp('/Depardieu/', $crawlerCanSee->text(),
|
||||||
'center a_social may see "Gérard" in center a');
|
'center a_social may see "Depardieu" in center a');
|
||||||
$this->assertRegExp('/Aucune personne ne correspond aux termes de recherche/',
|
$this->assertNotRegExp('/Depardieu/', $crawlerCannotSee->text(),
|
||||||
$crawlerCannotSee->text(),
|
'center b_social may see "Depardieu" in center b');
|
||||||
'center b_social may not see any "Gérard" associated to center b');
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private function generateCrawlerForSearch($pattern, $username = 'center a_social')
|
private function generateCrawlerForSearch($pattern, $username = 'center a_social')
|
||||||
{
|
{
|
||||||
$client = $this->getAuthenticatedClient($username);
|
$client = $this->getAuthenticatedClient($username);
|
||||||
|
|
||||||
$crawler = $client->request('GET', '/fr/search', array(
|
$crawler = $client->request('GET', '/fr/search', array(
|
||||||
'q' => $pattern,
|
'q' => $pattern,
|
||||||
));
|
));
|
||||||
|
|
||||||
$this->assertTrue($client->getResponse()->isSuccessful());
|
$this->assertTrue($client->getResponse()->isSuccessful());
|
||||||
|
|
||||||
return $crawler;
|
return $crawler;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @return \Symfony\Component\BrowserKit\Client
|
* @return \Symfony\Component\BrowserKit\Client
|
||||||
*/
|
*/
|
||||||
private function getAuthenticatedClient($username = 'center a_social')
|
private function getAuthenticatedClient($username = 'center a_social')
|
||||||
|
Loading…
x
Reference in New Issue
Block a user