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()); } }