Ejemplo n.º 1
0
// =========== Variables ===========
// Pour limiter l'export aux catégories présentes dans un fichier flux CSV, indiquer ici son emplacement / URL
//$activeCatsCsvFilePath 	= "feeds/BfWork/client-2014-11-24_16-47.csv";
//$exportFilePath 		= __DIR__ . "/Export/ClientActiveCats.csv";
// Sinon, utiliser les variables ci-dessous
$activeCatsCsvFilePath = "";
$exportFilePath = __DIR__ . "/Export/ClientCatMapping.csv";
// =========== Setup context ===========
require 'bootstrap.php';
$argv = $GLOBALS["argv"];
$cliParams = new CliParams();
$cliParams->parse($argv);
$iniParams = new IniParams($cliParams->getConfigFilePath());
$logger = LoggerFactory::getNullLogger();
$db = new Db($iniParams->get("dbHostReadOnly"), $iniParams->get("dbNameReadOnly"), $iniParams->get("dbUserReadOnly"), $iniParams->get("dbPassReadOnly"), $logger);
// =========== Get active cat list from CSV ===========
$activeCatsIds = array();
if ($activeCatsCsvFilePath !== "") {
    $csvFile = new CsvFile($activeCatsCsvFilePath, "\t");
    $activeCatsIds = array();
    foreach ($csvFile->getAll() as $csvLine) {
        $activeCatsIds[] = $csvLine->categories_categories_id;
    }
    $activeCatsIds = array_unique($activeCatsIds);
}
// =========== Get and process categories, then create CSV ===========
$okCategoriesDataProvider = new OkCategoriesDataProvider($db, 1);
// 1 = français
$csvCatMapper = new CsvCategoryMapper($okCategoriesDataProvider, $activeCatsIds, $exportFilePath, "\t");
$csvCatMapper->createFile();
// @codeCoverageIgnoreEnd
Ejemplo n.º 2
0
 /**
  * @expectedException \InvalidArgumentException
  */
 public function testCreateFileThrowException()
 {
     $csvCatMapper = new CsvCategoryMapper($this->dataProvider, array(), "/forbidden.txt", "\t");
     $csvCatMapper->createFile();
 }