Fix tests and bugs
modifié: core/lib/Thelia/Core/FileFormat/Formatting/AbstractFormatter.php modifié: core/lib/Thelia/Core/FileFormat/Formatting/FormatterData.php modifié: core/lib/Thelia/ImportExport/Export/Type/CustomerExport.php modifié: core/lib/Thelia/Tests/Controller/ImportControllerTest.php modifié: core/lib/Thelia/Tests/ImportExport/Export/CustomerExportTest.php
This commit is contained in:
@@ -31,7 +31,7 @@ abstract class AbstractFormatter implements FormatInterface, FormatterInterface
|
||||
protected $logger;
|
||||
|
||||
/** @var array */
|
||||
protected $order;
|
||||
protected $order = array();
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
@@ -54,7 +54,7 @@ abstract class AbstractFormatter implements FormatInterface, FormatterInterface
|
||||
|
||||
public function checkOrders(array $values)
|
||||
{
|
||||
foreach ($this->order as $order) {
|
||||
foreach ($this->getOrder() as $order) {
|
||||
if (!array_key_exists($order, $values)) {
|
||||
throw new \ErrorException(
|
||||
$this->translator->trans(
|
||||
|
||||
@@ -77,12 +77,6 @@ class FormatterData
|
||||
*/
|
||||
public function setData(array $data)
|
||||
{
|
||||
if (empty($this->aliases)) {
|
||||
$this->data = $data;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
$this->data = $this->applyAliases($data, $this->aliases);
|
||||
|
||||
return $this;
|
||||
|
||||
@@ -224,16 +224,15 @@ class CustomerExport extends ExportHandler
|
||||
$lastOrderDate = null;
|
||||
$lastOrder = null;
|
||||
$lastOrderCurrencyCode = null;
|
||||
$lastOrderId = 0;
|
||||
|
||||
$defaultCurrency = Currency::getDefaultCurrency();
|
||||
$defaultCurrencyCode = $defaultCurrency
|
||||
->setLocale($locale)
|
||||
->getCode()
|
||||
;
|
||||
|
||||
if (empty($defaultCurrencyCode)) {
|
||||
$defaultCurrencyCode = $defaultCurrency
|
||||
->setLocale($defaultLocale)
|
||||
->getCode()
|
||||
;
|
||||
}
|
||||
@@ -256,9 +255,10 @@ class CustomerExport extends ExportHandler
|
||||
/** @var \DateTime $date */
|
||||
$date = $currentOrder->getCreatedAt();
|
||||
|
||||
if (null === $lastOrderDate || $date > $lastOrderDate) {
|
||||
if (null === $lastOrderDate || ($date >= $lastOrderDate && $lastOrderId < $currentOrder->getId())) {
|
||||
$lastOrder = $currentOrder;
|
||||
$lastOrderDate = $date;
|
||||
$lastOrderId = $currentOrder->getId();
|
||||
}
|
||||
|
||||
$orders->next();
|
||||
@@ -269,13 +269,11 @@ class CustomerExport extends ExportHandler
|
||||
|
||||
$orderCurrency = $lastOrder->getCurrency();
|
||||
$lastOrderCurrencyCode = $orderCurrency
|
||||
->setLocale($locale)
|
||||
->getCode()
|
||||
;
|
||||
|
||||
if (empty($lastOrderCurrencyCode)) {
|
||||
$lastOrderCurrencyCode = $orderCurrency
|
||||
->setLocale($defaultLocale)
|
||||
->getCode()
|
||||
;
|
||||
}
|
||||
|
||||
@@ -116,7 +116,11 @@ class ImportControllerTrait extends ControllerTestBase
|
||||
$handler = $this
|
||||
->getMock(
|
||||
"\\Thelia\\ImportExport\\Import\\ImportHandler",
|
||||
[],
|
||||
[
|
||||
"getMandatoryColumns",
|
||||
"retrieveFromFormatterData",
|
||||
"getHandledTypes"
|
||||
],
|
||||
[
|
||||
$this->container
|
||||
]
|
||||
@@ -157,7 +161,11 @@ class ImportControllerTrait extends ControllerTestBase
|
||||
$handler = $this
|
||||
->getMock(
|
||||
"\\Thelia\\ImportExport\\Import\\ImportHandler",
|
||||
[],
|
||||
[
|
||||
"getMandatoryColumns",
|
||||
"retrieveFromFormatterData",
|
||||
"getHandledTypes"
|
||||
],
|
||||
[
|
||||
$this->container
|
||||
]
|
||||
@@ -204,7 +212,11 @@ class ImportControllerTrait extends ControllerTestBase
|
||||
$handler = $this
|
||||
->getMock(
|
||||
"\\Thelia\\ImportExport\\Import\\ImportHandler",
|
||||
[],
|
||||
[
|
||||
"getMandatoryColumns",
|
||||
"retrieveFromFormatterData",
|
||||
"getHandledTypes"
|
||||
],
|
||||
[
|
||||
$this->container
|
||||
]
|
||||
|
||||
@@ -100,6 +100,7 @@ class CustomerExportTest extends \PHPUnit_Framework_TestCase
|
||||
$lastOrder = OrderQuery::create()
|
||||
->filterByCustomer($customer)
|
||||
->orderByCreatedAt(Criteria::DESC)
|
||||
->orderById(Criteria::DESC)
|
||||
->findOne()
|
||||
;
|
||||
|
||||
@@ -135,15 +136,7 @@ class CustomerExportTest extends \PHPUnit_Framework_TestCase
|
||||
->filterByCustomer($customer)
|
||||
->filterByAddress1($rawData[$i]["address1"])
|
||||
->filterByAddress2($rawData[$i]["address2"])
|
||||
->_if(empty($rawData[$i]["address2"]))
|
||||
->_or()
|
||||
->filterByAddress2(null, Criteria::ISNULL)
|
||||
->_endif()
|
||||
->filterByAddress3($rawData[$i]["address3"])
|
||||
->_if(empty($rawData[$i]["address2"]))
|
||||
->_or()
|
||||
->filterByAddress2(null, Criteria::ISNULL)
|
||||
->_endif()
|
||||
->filterByFirstname($rawData[$i]["address_first_name"])
|
||||
->filterByLastname($rawData[$i]["address_last_name"])
|
||||
->filterByCountryId(
|
||||
@@ -163,20 +156,28 @@ class CustomerExportTest extends \PHPUnit_Framework_TestCase
|
||||
->filterByCellphone($rawData[$i]["cellphone"])
|
||||
->_if(empty($rawData[$i]["cellphone"]))
|
||||
->_or()
|
||||
->filterByCompany(null, Criteria::ISNULL)
|
||||
->filterByCellphone(null, Criteria::ISNULL)
|
||||
->_endif()
|
||||
->filterByPhone($rawData[$i]["phone"])
|
||||
->_if(empty($rawData[$i]["phone"]))
|
||||
->_or()
|
||||
->filterByPhone(null, Criteria::ISNULL)
|
||||
->_endif()
|
||||
->filterByLabel($rawData[$i]["label"])
|
||||
->_if(empty($rawData[$i]["label"]))
|
||||
->_or()
|
||||
->filterByLabel(null, Criteria::ISNULL)
|
||||
->_endif()
|
||||
->filterByTitleId(
|
||||
CustomerTitleI18nQuery::create()
|
||||
->filterByLocale($lang->getLocale())
|
||||
->findOneByShort($rawData[$i]["address_title"])
|
||||
->getId()
|
||||
)
|
||||
->find()
|
||||
->findOne()
|
||||
;
|
||||
|
||||
$this->assertEquals(1, $address->count());
|
||||
$this->assertNotNull($address);
|
||||
|
||||
$rowKeys = array_keys($rawData[$i]);
|
||||
sort($rowKeys);
|
||||
|
||||
Reference in New Issue
Block a user