X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;f=tests%2Fphpunit%2FWebTest%2FExport%2FExportCiviSeleniumTestCase.php;h=b52b745892d8444e278a068be698d19952d56dc3;hb=ef10e0b52408ba266239a859756d757a10348228;hp=e596c60ecaf506639fbd3faaba3f01cec0f3e0ca;hpb=58a50b22e20f112fdbfc7e50f18353c311ceb1ae;p=civicrm-core.git diff --git a/tests/phpunit/WebTest/Export/ExportCiviSeleniumTestCase.php b/tests/phpunit/WebTest/Export/ExportCiviSeleniumTestCase.php index e596c60eca..b52b745892 100644 --- a/tests/phpunit/WebTest/Export/ExportCiviSeleniumTestCase.php +++ b/tests/phpunit/WebTest/Export/ExportCiviSeleniumTestCase.php @@ -1,7 +1,7 @@ click($selector); - // Because it tends to cause problems, all uses of sleep() must be justified in comments - // Sleep should never be used for wait for anything to load from the server - // FIXME: consider doing the following assertion in a while loop - // with a more reasonable sleep time of 2 seconds per loop iteration - sleep(20); - - // File was downloaded? - $this->assertTrue(file_exists($file), "CSV {$file} was not downloaded."); - return $file; + // Wait for file to be downloaded + for ($i=1; $i<15; ++$i) { + sleep(2); + if (file_exists($file)) { + return $file; + } + } + // Timeout + $this->fail("CSV {$file} was not downloaded."); } /** - * Function to read CSV file and fire provided assertions. + * Read CSV file and fire provided assertions. * - * @params string $file file path of CSV file. - * @params array $checkHeaders check first row of csv + * @param string $file file path of CSV file. + * @param array $checkColumns check first row of csv * independent of index. - * @params array $checkRows array of header and rows according to row index + * @param array $checkRows array of header and rows according to row index * eg: array( * 1 => array( // Row index 1 @@ -88,11 +82,10 @@ class ExportCiviSeleniumTestCase extends CiviSeleniumTestCase { * 'Last Name' => 'mayekar' * ), * ); - * @params int $rowCount count rows (excluding header row). - * @params array $settings used for override settings. + * @param int $rowCount count rows (excluding header row). + * @param array $settings used for override settings. */ - function reviewCSV($file, $checkColumns = array( - ), $checkRows = array(), $rowCount = 0, $settings = array()) { + public function reviewCSV($file, $checkColumns = array(), $checkRows = array(), $rowCount = 0, $settings = array()) { // Check file exists before proceed. $this->assertTrue(($file && file_exists($file)), "Not able to locate {$file}."); @@ -160,4 +153,3 @@ class ExportCiviSeleniumTestCase extends CiviSeleniumTestCase { } } } -