mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-07 18:44:08 +00:00
Unit testf for duplicate person
Signed-off-by: Mathieu Jaumotte <mathieu.jaumotte@champs-libres.coop>
This commit is contained in:
parent
3bcb5fb3dd
commit
e841e9015c
@ -0,0 +1,65 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Chill\PersonBundle\Tests\Controller;
|
||||||
|
|
||||||
|
use Chill\PersonBundle\Entity\Person;
|
||||||
|
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
|
||||||
|
|
||||||
|
class PersonDuplicateControllerViewTest extends WebTestCase
|
||||||
|
{
|
||||||
|
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 Persan")
|
||||||
|
->setFirstName("Réginal")
|
||||||
|
->setCenter($center)
|
||||||
|
->setGender(Person::MALE_GENDER);
|
||||||
|
$this->em->persist($this->person);
|
||||||
|
|
||||||
|
$this->person2 = (new Person())
|
||||||
|
->setLastName("Tested Person")
|
||||||
|
->setFirstName("Réginald")
|
||||||
|
->setCenter($center)
|
||||||
|
->setGender(Person::MALE_GENDER);
|
||||||
|
$this->em->persist($this->person2);
|
||||||
|
|
||||||
|
$this->em->flush();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testViewDuplicatePerson()
|
||||||
|
{
|
||||||
|
$client = static::createClient(array(), array(
|
||||||
|
'PHP_AUTH_USER' => 'center a_social',
|
||||||
|
'PHP_AUTH_PW' => 'password',
|
||||||
|
));
|
||||||
|
|
||||||
|
$crawler = $client->request('GET', '/en/person/'.$this->person->getId().'/duplicate/view');
|
||||||
|
$response = $client->getResponse();
|
||||||
|
$this->assertTrue($response->isSuccessful());
|
||||||
|
|
||||||
|
$this->assertGreaterThan(0, $crawler->filter('html:contains("Find duplicate")')->count());
|
||||||
|
$this->assertGreaterThan(0, $crawler->filter('html:contains("Réginal")')->count());
|
||||||
|
$this->assertGreaterThan(0, $crawler->filter('html:contains("Réginald")')->count());
|
||||||
|
|
||||||
|
$crawler = $client->request('GET', '/en/person/'.$this->person->getId().'/duplicate/'.$this->person2->getId().'/confirm');
|
||||||
|
$response = $client->getResponse();
|
||||||
|
$this->assertTrue($response->isSuccessful());
|
||||||
|
|
||||||
|
$this->assertGreaterThan(0, $crawler->filter('html:contains("Old person")')->count());
|
||||||
|
$this->assertGreaterThan(0, $crawler->filter('html:contains("New person")')->count());
|
||||||
|
|
||||||
|
$crawler = $client->request('POST', '/en/person/'.$this->person->getId().'/duplicate/'.$this->person2->getId().'/confirm', [
|
||||||
|
'chill_personbundle_person_confirm_duplicate[confirm]' => 1
|
||||||
|
]);
|
||||||
|
$response = $client->getResponse();
|
||||||
|
$this->assertTrue($response->isSuccessful());
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user