/** * Test that admin can delete a given company * * @depends testUpdateCompany * * @param Company $company */ public function testSuccessDeleteCompany(Company $company) { $client = $this->connectUser(self::USER_ADMIN, self::USER_PASSWORD); $originalCompanyNb = $this->getTotalCompany(); $url = $this->generateRoute('admin_delete_company', array('id' => $company->getId())); $client->request('DELETE', $url); $this->assertRedirectTo($client, 'admin_show_all_company', array(), 'admin should be redirect to company dashboard when successfully delete a company'); $crawler = $client->followRedirect(); $this->assertStatusCode(200, $client); $newCompanyNb = $this->getTotalCompany(); $this->assertEquals($originalCompanyNb - 1, $newCompanyNb, 'It should delete the given Company in db when admin delete company'); $this->assertFlashMessageContains($crawler, "L'entreprise " . $company->getName() . " a été correctement supprimée"); }