mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-13 05:44:24 +00:00
Fix tests on person's controller
This commit is contained in:
parent
939a6753bd
commit
5314e7b501
@ -134,25 +134,6 @@ final class PersonControllerCreateTest extends WebTestCase
|
|||||||
return $form;
|
return $form;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Test if, for a given person if its person view page (at the url
|
|
||||||
* fr/person/$personID/general) is accessible.
|
|
||||||
*
|
|
||||||
* @param int|string $personId The is of the person
|
|
||||||
* @depends testValidForm
|
|
||||||
*/
|
|
||||||
public function testPersonViewAccessible(int|string $personId)
|
|
||||||
{
|
|
||||||
$client = $this->client;
|
|
||||||
$client->request('GET', '/fr/person/' . $personId . '/general');
|
|
||||||
|
|
||||||
$this->assertTrue(
|
|
||||||
$client->getResponse()->isSuccessful(),
|
|
||||||
'The person view page is accessible at the URL'
|
|
||||||
. '/{_locale}/person/{personID}/general'
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testReviewExistingDetectionInversedLastNameWithFirstName()
|
public function testReviewExistingDetectionInversedLastNameWithFirstName()
|
||||||
{
|
{
|
||||||
$client = $this->client;
|
$client = $this->client;
|
||||||
@ -162,23 +143,23 @@ final class PersonControllerCreateTest extends WebTestCase
|
|||||||
//test the page is loaded before continuing
|
//test the page is loaded before continuing
|
||||||
$this->assertTrue($client->getResponse()->isSuccessful());
|
$this->assertTrue($client->getResponse()->isSuccessful());
|
||||||
|
|
||||||
$form = $crawler->selectButton('Ajouter la personne')->form();
|
$form = $crawler->selectButton("Créer l'usager")->form();
|
||||||
$form = $this->fillAValidCreationForm($form, 'Charline', 'dd');
|
$form = $this->fillAValidCreationForm($form, 'Charline', 'dd');
|
||||||
$client->submit($form);
|
$client->submit($form);
|
||||||
|
|
||||||
$this->assertStringContainsString(
|
$this->assertStringContainsString(
|
||||||
'DEPARDIEU',
|
'usager a un nom similaire',
|
||||||
$client->getCrawler()->text(),
|
$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
|
||||||
$form = $crawler->selectButton('Ajouter la personne')->form();
|
$form = $crawler->selectButton("Créer l'usager")->form();
|
||||||
$form = $this->fillAValidCreationForm($form, 'dd', 'Charline');
|
$form = $this->fillAValidCreationForm($form, 'dd', 'Charline');
|
||||||
$client->submit($form);
|
$client->submit($form);
|
||||||
|
|
||||||
$this->assertStringContainsString(
|
$this->assertStringContainsString(
|
||||||
'DEPARDIEU',
|
'usager a un nom similaire',
|
||||||
$client->getCrawler()->text(),
|
$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'
|
||||||
);
|
);
|
||||||
@ -194,32 +175,12 @@ final class PersonControllerCreateTest extends WebTestCase
|
|||||||
$client = $this->client;
|
$client = $this->client;
|
||||||
$crawler = $client->request('GET', '/fr/person/new');
|
$crawler = $client->request('GET', '/fr/person/new');
|
||||||
|
|
||||||
$form = $crawler->selectButton('Ajouter la personne')->form();
|
$form = $crawler->selectButton("Créer l'usager")->form();
|
||||||
$this->fillAValidCreationForm($form);
|
$this->fillAValidCreationForm($form, uniqid(), uniqid());
|
||||||
$client = $this->client;
|
$client = $this->client;
|
||||||
$client->submit($form);
|
$client->submit($form);
|
||||||
|
|
||||||
$this->assertTrue(
|
self::assertResponseRedirects();
|
||||||
$client->getResponse()->isRedirect(),
|
|
||||||
'a valid form redirect to url /{_locale}/person/{personId}/general/edit'
|
|
||||||
);
|
|
||||||
$client->followRedirect();
|
|
||||||
|
|
||||||
// visualize regexp here : http://jex.im/regulex/#!embed=false&flags=&re=%2Ffr%2Fperson%2F[1-9][0-9]*%2Fgeneral%2Fedit%24
|
|
||||||
$this->assertMatchesRegularExpression(
|
|
||||||
'|/fr/person/[1-9][0-9]*/general/edit$|',
|
|
||||||
$client->getHistory()->current()->getUri(),
|
|
||||||
'a valid form redirect to url /{_locale}/person/{personId}/general/edit'
|
|
||||||
);
|
|
||||||
|
|
||||||
$regexPersonId = null;
|
|
||||||
preg_match(
|
|
||||||
'/person\\/([1-9][0-9]*)\\/general\\/edit$/',
|
|
||||||
$client->getHistory()->current()->getUri(),
|
|
||||||
$regexPersonId
|
|
||||||
);
|
|
||||||
|
|
||||||
return $regexPersonId[1];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -236,10 +197,10 @@ final class PersonControllerCreateTest extends WebTestCase
|
|||||||
$client->getResponse()->isSuccessful(),
|
$client->getResponse()->isSuccessful(),
|
||||||
'The page is accessible at the URL /{_locale}/person/new'
|
'The page is accessible at the URL /{_locale}/person/new'
|
||||||
);
|
);
|
||||||
$form = $crawler->selectButton('Ajouter la personne')->form();
|
$form = $crawler->selectButton("Créer l'usager")->form();
|
||||||
|
|
||||||
// create a very long name to avoid collision
|
// create a very long name to avoid collision
|
||||||
$this->fillAValidCreationForm($form, 'Carmela Girdana Assuntamente Castalle', 'rabbit');
|
$this->fillAValidCreationForm($form, uniqid(), uniqid());
|
||||||
|
|
||||||
$this->assertTrue(
|
$this->assertTrue(
|
||||||
$form->has(self::CENTER_INPUT),
|
$form->has(self::CENTER_INPUT),
|
||||||
@ -254,16 +215,7 @@ final class PersonControllerCreateTest extends WebTestCase
|
|||||||
|
|
||||||
$client->submit($form);
|
$client->submit($form);
|
||||||
|
|
||||||
$this->assertTrue(
|
self::assertResponseRedirects();
|
||||||
$client->getResponse()->isRedirect(),
|
|
||||||
'a valid form redirect to url /{_locale}/person/{personId}/general/edit'
|
|
||||||
);
|
|
||||||
$client->followRedirect();
|
|
||||||
$this->assertMatchesRegularExpression(
|
|
||||||
'|/fr/person/[1-9][0-9]*/general/edit$|',
|
|
||||||
$client->getHistory()->current()->getUri(),
|
|
||||||
'a valid form redirect to url /{_locale}/person/{personId}/general/edit'
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private function fillAValidCreationForm(
|
private function fillAValidCreationForm(
|
||||||
|
@ -71,9 +71,8 @@ final class PersonControllerViewTest extends WebTestCase
|
|||||||
]);
|
]);
|
||||||
|
|
||||||
$crawler = $client->request('GET', $this->viewUrl);
|
$crawler = $client->request('GET', $this->viewUrl);
|
||||||
$response = $client->getResponse();
|
|
||||||
|
|
||||||
$this->assertTrue($response->isSuccessful());
|
self::assertResponseIsSuccessful();
|
||||||
|
|
||||||
$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());
|
||||||
|
Loading…
x
Reference in New Issue
Block a user