예제 #1
0
function testDecimal()
{
    $decimal = new Decimal(LoggerFactory::getNullLogger());
    $decimal->set(5.6);
    if (!$decimal->isValid()) {
        echo "\nInvalid decimal separator !";
    } else {
        echo "\nValid decimal separator";
    }
    echo "\n";
}
예제 #2
0
 public function testGenerateXml()
 {
     $xmlExporter = new CategoriesSeed("/media/truecrypt1/projects/client/p/main/E7/ConnectorsSets/OkToBf/CategoryMapping/client.csv", LoggerFactory::getNullLogger());
     $xmlFile = __DIR__ . "/Data/Exports/categoriesSeeds.xml";
     $xmlExporter->generateXml($xmlFile);
     $this->assertFileExists($xmlFile);
     // retrieves XmlData
     $xmlDocument = new \DOMDocument();
     $xmlDocument->load($xmlFile);
     $xpath = new \DOMXpath($xmlDocument);
     $ProductCategoryNodes = $xpath->query("ProductCategory");
     $ProductCategoryArray = array();
     foreach ($ProductCategoryNodes as $productCategory) {
         $ProductCategoryArray[] = simplexml_import_dom($productCategory);
     }
     $ProductCategoryRollupNodes = $xpath->query("ProductCategoryRollup");
     $ProductCategoryRollupArray = array();
     foreach ($ProductCategoryRollupNodes as $productCategoryRollup) {
         $ProductCategoryRollupArray[] = simplexml_import_dom($productCategoryRollup);
     }
     $e7MegaMenuCategoryMemberNodes = $xpath->query("E7MegaMenuCategoryMember");
     $e7MegaMenuCategoryMemberArray = array();
     foreach ($e7MegaMenuCategoryMemberNodes as $e7MegaMenuCategoryMember) {
         $e7MegaMenuCategoryMemberArray[] = simplexml_import_dom($e7MegaMenuCategoryMember);
     }
     $rootCategories = array("BF_CATEGORY_ROOT", "ZDE_RESERV");
     // Root catalog categories
     // Check for appropriate amount of entities
     $this->assertEquals(count($ProductCategoryArray), count($ProductCategoryRollupArray));
     $numberOfLevelOneCat = 0;
     foreach ($ProductCategoryArray as $productCategory) {
         if (in_array($productCategory["primaryParentCategoryId"]->__toString(), $rootCategories)) {
             $numberOfLevelOneCat++;
         }
     }
     $this->assertEquals($numberOfLevelOneCat, count($e7MegaMenuCategoryMemberArray));
     // ProductCategory : check that no children comes after his parent
     $parents = $rootCategories;
     foreach ($ProductCategoryArray as $productCategory) {
         $this->assertContains($productCategory["primaryParentCategoryId"]->__toString(), $parents);
         $parents[] = $productCategory["productCategoryId"]->__toString();
     }
     // Check that no Category without sequence number made it into the Xml
     foreach ($ProductCategoryRollupArray as $productCategoryRollup) {
         $this->assertFalse(empty($productCategoryRollup["sequenceNum"]->__toString()));
     }
 }
예제 #3
0
 public static function getDb()
 {
     $iniParams = self::getIniParams();
     $logger = LoggerFactory::getNullLogger();
     return new Db($iniParams->get("dbHostFullAuth"), $iniParams->get("dbNameFullAuth"), $iniParams->get("dbUserFullAuth"), $iniParams->get("dbPassFullAuth"), $logger);
 }
예제 #4
0
use E7\Actors\Client\Objects\OkCategoryList;
use E7\Actors\Client\CategoryMapper\CsvCategoryMapper;
// =========== 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");
예제 #5
0
 public function testNullLogger()
 {
     $this->log = LoggerFactory::getNullLogger();
     $this->log->error("logging to the null handler... making a more significant test is obviously difficult !");
 }