Ejemplo n.º 1
0
 function testWithRandomizeFilenameOff()
 {
     $expectedOutputFilePath = ExporterEngine::getNakedPath(TestHelper::getFileSystemTmpPath('happy-path.csv'));
     $input = TestHelper::getFixtureInput('happy-path.php');
     $exporter = new FormExporter('dsn', 'tableName', 'data', [], $this->logger);
     $exporter->setExporterEngine(new FileSystemExporterEngine(TestHelper::getFileSystemTmpPath('happy-path.csv'), $this->logger, $randomizeFileName = false));
     $csvFilePath = TestHelper::invokeNonPublicMethod($exporter, 'exportResult', [$input]);
     $this->assertEquals($expectedOutputFilePath, $csvFilePath);
     $this->assertFileExists($expectedOutputFilePath);
 }
Ejemplo n.º 2
0
 /**
  * @param array $queryResult
  * @return string
  * @throws InvalidInputException
  */
 protected function exportResult(array $queryResult)
 {
     if (!$queryResult) {
         throw new InvalidInputException("No results were returned for the given criteria.");
     }
     if (!isset($queryResult[0])) {
         throw new InvalidInputException("Input Array a list of Results since 0'th index does not exist");
     }
     $transformedResult = $this->extractDataRows($queryResult);
     if (!$transformedResult) {
         throw new InvalidInputException("No valid rows found during transformation");
     }
     if ($this->someRowsHaveExtraColumns) {
         $transformedResult = $this->reconcileWithColumnNamesList($this->canonicalColumnNamesList, $transformedResult);
     }
     $outputFilePath = $this->exportEngine->writeCsv(array_keys($this->canonicalColumnNamesList), $transformedResult);
     return $outputFilePath;
 }
Ejemplo n.º 3
0
 /**
  * S3Exporter constructor.
  * @param string $s3ObjectPath Ex: 's3://mybucket/my/object.txt'
  * @param S3Client $s3Client
  * @param LoggerInterface $logger
  * @param bool $randomizeOutputFileName
  */
 public function __construct($s3ObjectPath, S3Client $s3Client, LoggerInterface $logger, $randomizeOutputFileName = true)
 {
     $this->s3Client = $s3Client;
     parent::__construct($s3ObjectPath, $logger, $randomizeOutputFileName);
 }
 /**
  * FileSystemExporter constructor.
  * @param LoggerInterface $logger
  */
 public function __construct($exportPath, LoggerInterface $logger, $randomizeOutputFileName = true)
 {
     parent::__construct($exportPath, $logger, $randomizeOutputFileName);
 }