function testShouldThrowExceptionForInvalidProductTable() { $this->setExpectedException('Zend_Db_Statement_Exception'); $this->query(sprintf("INSERT INTO `ps_product` ( `reference` ) values ( '%s' )", 'foobar123')); $productID = $this->getReadAdapter()->lastInsertId(); $this->mappingsImporterFromData('sku, make, model, year foobar123, honda, civic, 2000')->setProductTable('invalid')->setProductSkuField('reference')->setProductIdField('id_product')->import(); $product = new VF_Product(); $product->setId($productID); $fitments = $product->getFitModels(); $this->assertEquals('honda civic 2000', $fitments[0]->__toString(), 'should add fitment to product'); }
function testShouldImportFitments() { $this->query("INSERT INTO test_catalog_product_entity ( `sku` ) values ( 'sku123' )"); $productID = $this->getReadAdapter()->lastInsertId(); $file = sys_get_temp_dir() . '/' . uniqid(); $data = "sku,make,model,year\n"; $data .= "sku123,Honda,Civic,2000"; file_put_contents($file, $data); $command = __DIR__ . '/vfmagento importfitments --product-table=test_catalog_product_entity ' . $file; `{$command}`; $product = new VF_Product(); $product->setId($productID); $fitments = $product->getFitModels(); $this->assertEquals('Honda Civic 2000', $fitments[0]->__toString(), 'should import fitment'); }
function testShouldImportPrestaShop() { $this->query(sprintf("INSERT INTO `ps_product` ( `reference` ) values ( '%s' )", 'foobar123')); $productID1 = $this->getReadAdapter()->lastInsertId(); $this->query(sprintf("INSERT INTO `ps_product` ( `reference` ) values ( '%s' )", 'foobar456')); $productID2 = $this->getReadAdapter()->lastInsertId(); $this->mappingsImporterFromData('sku, make, model, year foo*, honda, civic, 2000')->setProductTable('ps_product')->setProductSkuField('reference')->setProductIdField('id_product')->import(); $product1 = new VF_Product(); $product1->setId($productID1); $product2 = new VF_Product(); $product2->setId($productID2); $fitments = $product1->getFitModels(); $this->assertEquals('honda civic 2000', $fitments[0]->__toString(), 'should add fitment to product'); $fitments = $product2->getFitModels(); $this->assertEquals('honda civic 2000', $fitments[0]->__toString(), 'should add fitment to product'); }