mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-19 08:44:24 +00:00
66 lines
2.4 KiB
PHP
66 lines
2.4 KiB
PHP
<?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::$container
|
|
->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());
|
|
}
|
|
}
|