chill-bundles/src/Bundle/ChillPersonBundle/Tests/Controller/PersonDuplicateControllerViewTest.php
2021-11-30 13:54:58 +01:00

79 lines
2.6 KiB
PHP

<?php
/**
* Chill is a software for social workers
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*/
declare(strict_types=1);
namespace Chill\PersonBundle\Tests\Controller;
use Chill\PersonBundle\Entity\Person;
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
/**
* @internal
* @coversNothing
*/
final class PersonDuplicateControllerViewTest extends WebTestCase
{
public function setUp()
{
self::bootKernel();
$this->em = self::$container
->get('doctrine.orm.entity_manager');
$center = $this->em->getRepository('ChillMainBundle:Center')
->findOneBy(['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 = self::createClient([], [
'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());
}
}