diff --git a/core/lib/Thelia/Core/DependencyInjection/Loader/XmlFileLoader.php b/core/lib/Thelia/Core/DependencyInjection/Loader/XmlFileLoader.php index b98cc9204..727ad6b22 100644 --- a/core/lib/Thelia/Core/DependencyInjection/Loader/XmlFileLoader.php +++ b/core/lib/Thelia/Core/DependencyInjection/Loader/XmlFileLoader.php @@ -368,14 +368,6 @@ class XmlFileLoader extends FileLoader ); } - $classInstance = new $class($this->container); - - if (!$classInstance instanceof ExportHandler) { - throw new \ErrorException( - "The class \"$class\" must extend Thelia\\ImportExport\\Export\\ExportHandler" - ); - } - $category = ExportCategoryQuery::create()->findOneByRef($categoryRef); if (null === $category) { @@ -505,14 +497,6 @@ class XmlFileLoader extends FileLoader ); } - $classInstance = new $class($this->container); - - if (!$classInstance instanceof ImportHandler) { - throw new \ErrorException( - "The class \"$class\" must extend Thelia\\ImportImport\\ImportHandler" - ); - } - $category = ImportCategoryQuery::create()->findOneByRef($categoryRef); if (null === $category) { diff --git a/core/lib/Thelia/ImportExport/Export/Type/MailingExport.php b/core/lib/Thelia/ImportExport/Export/Type/MailingExport.php index aa2be5303..f42c9b3b3 100644 --- a/core/lib/Thelia/ImportExport/Export/Type/MailingExport.php +++ b/core/lib/Thelia/ImportExport/Export/Type/MailingExport.php @@ -16,6 +16,7 @@ use Thelia\Core\FileFormat\FormatType; use Thelia\Core\Translation\Translator; use Thelia\ImportExport\Export\ExportHandler; use Thelia\Model\CustomerQuery; +use Thelia\Model\Lang; use Thelia\Model\Map\CustomerTableMap; use Thelia\Model\Map\NewsletterTableMap; use Thelia\Model\NewsletterQuery; @@ -32,7 +33,7 @@ class MailingExport extends ExportHandler * * The method builds */ - public function buildFormatterData() + public function buildFormatterData(Lang $lang) { $translator = Translator::getInstance(); diff --git a/core/lib/Thelia/Tests/ImportExport/Export/ProductPricesExportTest.php b/core/lib/Thelia/Tests/ImportExport/Export/ProductPricesExportTest.php new file mode 100644 index 000000000..fa74938f0 --- /dev/null +++ b/core/lib/Thelia/Tests/ImportExport/Export/ProductPricesExportTest.php @@ -0,0 +1,89 @@ + + */ +class ProductPricesExportTest extends \PHPUnit_Framework_TestCase +{ + public function testQuery() + { + new Translator(new Container()); + $export = new ProductPricesExport(new Container()); + + $data = $export->buildFormatterData(Lang::getDefaultLanguage()); + + $keys = ["attributes","currency","ean","price","promo_price","ref","title"]; + + $rawData = $data->getData(); + + $max = count($rawData); + + /** + * If there's more that 50 entries, + * just pick 50, it would be faster and as tested as if we test 1000 entries. + */ + if ($max > 50) { + $max = 50; + } + + for ($i = 0; $i < $max; ++$i) + { + $row = $rawData[$i]; + + $rowKeys = array_keys($row); + + $this->assertTrue(sort($rowKeys)); + $this->assertEquals($keys, $rowKeys); + + $pse = ProductSaleElementsQuery::create() + ->findOneByRef($row["ref"]) + ; + + $this->assertNotNull($pse); + $this->assertEquals($pse->getEanCode(),$row["ean"]); + + $currency = CurrencyQuery::create()->findOneByCode($row["currency"]); + $this->assertNotNull($currency); + + $price = $pse->getPricesByCurrency($currency); + $this->assertEquals($price->getPrice(), $row["price"]); + $this->assertEquals($price->getPromoPrice(), $row["promo_price"]); + $this->assertEquals($pse->getProduct()->getTitle(), $row["title"]); + + $attributeCombinations = $pse->getAttributeCombinations(); + $attributes = []; + + foreach ($attributeCombinations as $attributeCombination) { + $attributes[] = $attributeCombination->getAttributeAv()->getTitle(); + } + + $rowAttributes = explode(",", $row["attributes"]); + + sort($rowAttributes); + sort($attributes); + + $this->assertEquals($attributes, $rowAttributes); + } + } +} \ No newline at end of file