public function testPrepareData()
 {
     $dataProvider = new ProductsFeedDataProvider($this->db, $this->okChannel->getLanguageId(), __DIR__ . "/Data/okProducts.csv", __DIR__ . "/Data/savedCsv.csv", $this->logger);
     $dataProvider->prepareData();
     $okProducts = $dataProvider->getOkProducts();
     $csvFile = new CsvFile(__DIR__ . "/Data/okProducts.csv", ";");
     $csvLines = $csvFile->getAll();
     $this->assertEquals(count($csvLines) - 1, count($okProducts));
     $okManufacturers = $dataProvider->getOkManufacturers();
     $this->assertEquals(2, count($okManufacturers));
 }
Ejemplo n.º 2
0
 private function buildProductsConnector($csvUrl)
 {
     $this->db = $this->getDbReadOnly();
     $this->okChannel = new OkChannel($this->iniParams->get("channelId"), $this->db);
     // General Concerns
     $localFeedPath = sprintf("%s/%s.xml", $this->getConnectorFilesDir(), $this->connectorRunId);
     $userLogger = $this->getUserLogger();
     // Data providers
     $intermediateCsvFile = sprintf("%s/%s.csv", $this->getProcessedFilesPath(), $this->connectorRunId);
     $dataProvider = new ProductsFeedDataProvider($this->db, $this->okChannel->getLanguageId(), $csvUrl, $intermediateCsvFile, $userLogger);
     $dataProvider->prepareData();
     // Exporter
     $xmlExporter = new Products($this->iniParams, $dataProvider->getOkProducts(), $dataProvider->getOkManufacturers(), $userLogger);
     return new XmlToLocalConnector($localFeedPath, $xmlExporter, $userLogger);
 }