Commit 4d884c2d authored by Julien Fastré's avatar Julien Fastré
Browse files

remove tests for export

parent 2145bd2b
......@@ -440,123 +440,4 @@ class ReportControllerTest extends WebTestCase
* 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()) {
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)
"I can choose between report types");
$possibleOptionsValue = $form->get(self::REPORT_NAME_FIELD)
$cfGroupId = $possibleOptionsValue[array_rand($possibleOptionsValue)];
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/'.
$response = $client->getResponse();
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);
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')
$numberOfRows, sizeof($reports),
'The csv file has a number of row equivalent than the number of reports in the db'
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment