diff --git a/Tests/Controller/ReportControllerTest.php b/Tests/Controller/ReportControllerTest.php index 682fd7414..5ca7e9847 100644 --- a/Tests/Controller/ReportControllerTest.php +++ b/Tests/Controller/ReportControllerTest.php @@ -440,123 +440,4 @@ class ReportControllerTest extends WebTestCase ->getDate()); } - /** - * Test that in the general export page there is an Export reports link - * that leads to export/report/select/type - * - * @return \Symfony\Component\DomCrawler\Link The link to the the - * form use for selecting which type of report to export - */ - public function testLinkToTheExportReport() - { - $client = $this->getAuthenticatedClient(); - $crawlerReportExportPage = $client->request('GET', '/fr/export'); - - if (! $client->getResponse()->isSuccessful()) { - var_dump($crawlerReportExportPage->html()); - throw new \RuntimeException('The get request at export page failed'); - } - - $link = $crawlerReportExportPage->selectLink("Export reports")->link(); - $this->assertInstanceOf('Symfony\Component\DomCrawler\Link', $link, - "There is a \"export reports\" link in the export menu"); - - $this->assertContains("export/report/select/type", $link->getUri(), - "The \"export reports\" link in the export menu points to export/report/select/type"); - - return $link; - } - - /** - * Test the export form for selecting the type of report to export : - * - follow the given link ( export/report/select/type ) - * - choose randomly a type of report (CustomFieldsGroup) - * - submit the form - * - * @return Integer The id of the type of report selected (CFGroup) - * @depends testLinkToTheExportReport - */ - public function testFormForExportAction(Link $link) - { - $client = $this->getAuthenticatedClient(); - $crawlerExportReportPage = $client->click($link); - - $form = $crawlerExportReportPage->selectButton("Export this kind of reports")->form(); - - $this->assertInstanceOf('Symfony\Component\DomCrawler\Form', $form, - 'I can see a form with a button "Export this kind of reports" '); - - $this->assertGreaterThan(1, count($form->get(self::REPORT_NAME_FIELD) - ->availableOptionValues()), - "I can choose between report types"); - - $possibleOptionsValue = $form->get(self::REPORT_NAME_FIELD) - ->availableOptionValues(); - - - $cfGroupId = $possibleOptionsValue[array_rand($possibleOptionsValue)]; - - $form->get(self::REPORT_NAME_FIELD)->setValue($cfGroupId); - - $client->submit($form); - - $this->assertTrue($client->getResponse()->isRedirect()); - - $client->followRedirect(); - - return $cfGroupId; - } - - /** - * Test the output of the export action : - * - check if a csv file is well received - * - check if the csv is well formated (if each row has the same number of - * cells) - * - check if the number of data rows (not the header) of the csv file is - * as expected (number of report of this type) - * - * @param Int The id of the type of report selected (CFGroup) - * @depends testFormForExportAction - */ - public function testCSVExportAction($cfGroupId) - { - $client = $this->getAuthenticatedClient(); - - $client->request('GET', 'fr/export/report/cfgroup/'. - static::$group->getId()); - $response = $client->getResponse(); - - $this->assertTrue( - strpos($response->headers->get('Content-Type'),'text/csv') !== false, - 'The csv file is well received'); - - $content = $response->getContent(); - $rows = str_getcsv($content, "\n"); - - $headerRow = array_pop($rows); - $header = str_getcsv($headerRow); - $headerSize = sizeof($header); - $numberOfRows = 0; - - foreach ($rows as $row) { - $rowContent = str_getcsv($row); - - $this->assertTrue( - sizeof($rowContent) == $headerSize, - 'Each row of the csv contains the good number of elements (' - . 'regarding to the first row'); - - $numberOfRows ++; - } - - $cfGroup = static::$em->getRepository('ChillCustomFieldsBundle:CustomFieldsGroup')->find($cfGroupId); - $reports = static::$em->getRepository('ChillReportBundle:Report') - ->findByCFGroup($cfGroup); - - $this->markTestSkipped(); - $this->assertEquals( - $numberOfRows, sizeof($reports), - 'The csv file has a number of row equivalent than the number of reports in the db' - ); - } }