-
Notifications
You must be signed in to change notification settings - Fork 212
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
CRM-8048: Do not skip Magento customers if some data is not matched t…
…o Oro (#9208) * CRM-8048: Do not skip Magento customers if some data is not matched to Oro - added country_text to Order, Cart and Customer addresses - country text is set in data converter by country id received from magento - if country is found, than country_text is set to null - if there is no country country_text is rendered instead in address book * CRM-8048: Do not skip Magento customers if some data is not matched to Oro - added unit and functional test for changed functionality - fixed installer version * CRM-8048: Do not skip Magento customers if some data is not matched to Oro - fixed failing tests * CRM-8048: Do not skip Magento customers if some data is not matched to Oro - fixed test name * CRM-8048: Do not skip Magento customers if some data is not matched to Oro - reverted incorrect test namespaces to get CI green
- Loading branch information
1 parent
4259e47
commit d15cdd0
Showing
29 changed files
with
671 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
<?php | ||
|
||
namespace Oro\Bundle\MagentoBundle\Entity; | ||
|
||
use Doctrine\ORM\Mapping as ORM; | ||
|
||
trait CountryTextTrait | ||
{ | ||
/** | ||
* @var string | ||
* | ||
* @ORM\Column(name="country_text", type="string", length=255, nullable=true) | ||
*/ | ||
protected $countryText; | ||
|
||
/** | ||
* @return string | ||
*/ | ||
public function getCountryText() | ||
{ | ||
return $this->countryText; | ||
} | ||
|
||
/** | ||
* @param string $countryText | ||
* @return $this | ||
*/ | ||
public function setCountryText($countryText) | ||
{ | ||
$this->countryText = $countryText; | ||
|
||
return $this; | ||
} | ||
|
||
/** | ||
* Get name of country | ||
* | ||
* @return string | ||
*/ | ||
public function getCountryName() | ||
{ | ||
return $this->getCountry() ? parent::getCountryName() : $this->getCountryText(); | ||
} | ||
|
||
/** | ||
* Get country ISO3 code | ||
* | ||
* @return string | ||
*/ | ||
public function getCountryIso3() | ||
{ | ||
return $this->getCountry() ? parent::getCountryIso3() : $this->getCountryText(); | ||
} | ||
|
||
/** | ||
* Get country ISO2 code | ||
* | ||
* @return string | ||
*/ | ||
public function getCountryIso2() | ||
{ | ||
return $this->getCountry() ? parent::getCountryIso2() : $this->getCountryText(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
src/Oro/Bundle/MagentoBundle/Migrations/Schema/v1_46_1/AddCountryTextToAddresses.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<?php | ||
|
||
namespace Oro\Bundle\MagentoBundle\Migrations\Schema\v1_46_1; | ||
|
||
use Doctrine\DBAL\Schema\Schema; | ||
use Oro\Bundle\MigrationBundle\Migration\Migration; | ||
use Oro\Bundle\MigrationBundle\Migration\QueryBag; | ||
|
||
class AddCountryTextToAddresses implements Migration | ||
{ | ||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function up(Schema $schema, QueryBag $queries) | ||
{ | ||
$this->addCountryTextField($schema, 'orocrm_magento_customer_addr'); | ||
$this->addCountryTextField($schema, 'orocrm_magento_order_address'); | ||
$this->addCountryTextField($schema, 'orocrm_magento_cart_address'); | ||
} | ||
|
||
/** | ||
* @param Schema $schema | ||
* @param string $tableName | ||
*/ | ||
private function addCountryTextField(Schema $schema, $tableName) | ||
{ | ||
$table = $schema->getTable($tableName); | ||
$table->addColumn('country_text', 'string', ['notnull' => false, 'length' => 255]); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
102 changes: 102 additions & 0 deletions
102
src/Oro/Bundle/MagentoBundle/Tests/Functional/ImportExport/Strategy/OrderStrategyTest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
<?php | ||
|
||
namespace Oro\Bundle\MagentoBundle\Tests\Functional\ImportExport\Strategy; | ||
|
||
use Akeneo\Bundle\BatchBundle\Entity\JobExecution; | ||
use Akeneo\Bundle\BatchBundle\Entity\JobInstance; | ||
use Akeneo\Bundle\BatchBundle\Entity\StepExecution; | ||
use Oro\Bundle\AddressBundle\Entity\Country; | ||
use Oro\Bundle\ImportExportBundle\Context\StepExecutionProxyContext; | ||
use Oro\Bundle\MagentoBundle\Entity\Order; | ||
use Oro\Bundle\MagentoBundle\Entity\OrderAddress; | ||
use Oro\Bundle\MagentoBundle\ImportExport\Strategy\OrderStrategy; | ||
use Oro\Bundle\MagentoBundle\Tests\Functional\Fixture\LoadMagentoChannel; | ||
use Oro\Bundle\TestFrameworkBundle\Test\WebTestCase; | ||
|
||
/** | ||
* @dbIsolation | ||
*/ | ||
class OrderStrategyTest extends WebTestCase | ||
{ | ||
/** | ||
* @var OrderStrategy | ||
*/ | ||
private $strategy; | ||
|
||
/** | ||
* @var StepExecutionProxyContext | ||
*/ | ||
protected $context; | ||
|
||
/** | ||
* @var StepExecution | ||
*/ | ||
protected $stepExecution; | ||
|
||
protected function setUp() | ||
{ | ||
$this->initClient(); | ||
|
||
$this->loadFixtures([ | ||
LoadMagentoChannel::class | ||
]); | ||
|
||
$this->strategy = $this->getContainer()->get('oro_magento.import.strategy.order.add_or_update'); | ||
$this->strategy->setEntityName(Order::class); | ||
|
||
$jobInstance = new JobInstance(); | ||
$jobInstance->setRawConfiguration(['channel' => 3]); | ||
$jobExecution = new JobExecution(); | ||
$jobExecution->setJobInstance($jobInstance); | ||
$this->stepExecution = new StepExecution('step', $jobExecution); | ||
$this->context = new StepExecutionProxyContext($this->stepExecution); | ||
$this->strategy->setImportExportContext($this->context); | ||
$this->strategy->setStepExecution($this->stepExecution); | ||
} | ||
|
||
public function testProcessAddressCountryTextSetTuNullWhenCountryIsSet() | ||
{ | ||
$em = $this->getContainer()->get('doctrine')->getManagerForClass(Order::class); | ||
$order = $em->getRepository(Order::class)->findOneBy([]); | ||
|
||
$street = 'Test_Street_001'; | ||
$country = new Country('US'); | ||
$address = new OrderAddress(); | ||
$address->setCountry($country); | ||
$address->setCountryText('Test'); | ||
$address->setStreet($street); | ||
|
||
$order->resetAddresses([$address]); | ||
|
||
/** @var Order $processedOrder */ | ||
$processedOrder = $this->strategy->process($order); | ||
/** @var OrderAddress $processedAddress */ | ||
$processedAddress = $processedOrder->getAddresses()->first(); | ||
$this->assertInstanceOf(OrderAddress::class, $processedAddress); | ||
$this->assertSame($street, $processedAddress->getStreet()); | ||
$this->assertInstanceOf(Country::class, $processedAddress->getCountry()); | ||
$this->assertNull($processedAddress->getCountryText()); | ||
} | ||
|
||
public function testProcessAddressCountryTextSetTuNullWhenCountryIsEmpty() | ||
{ | ||
$em = $this->getContainer()->get('doctrine')->getManagerForClass(Order::class); | ||
$order = $em->getRepository(Order::class)->findOneBy([]); | ||
|
||
$street = 'Test_Street_002'; | ||
$address = new OrderAddress(); | ||
$address->setCountryText('Test'); | ||
$address->setStreet($street); | ||
|
||
$order->resetAddresses([$address]); | ||
|
||
/** @var Order $processedOrder */ | ||
$processedOrder = $this->strategy->process($order); | ||
/** @var OrderAddress $processedAddress */ | ||
$processedAddress = $processedOrder->getAddresses()->first(); | ||
$this->assertInstanceOf(OrderAddress::class, $processedAddress); | ||
$this->assertSame($street, $processedAddress->getStreet()); | ||
$this->assertNull($processedAddress->getCountry()); | ||
$this->assertSame('Test', $processedAddress->getCountryText()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
src/Oro/Bundle/MagentoBundle/Tests/Unit/Entity/CartAddressTest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<?php | ||
|
||
namespace Oro\Bundle\MagentoBundle\Tests\Unit\Entity; | ||
|
||
use Oro\Bundle\AddressBundle\Entity\Country; | ||
use Oro\Bundle\MagentoBundle\Entity\CartAddress; | ||
|
||
class CartAddressTest extends AbstractEntityTestCase | ||
{ | ||
/** | ||
* {@inheritDoc} | ||
*/ | ||
public function getEntityFQCN() | ||
{ | ||
return CartAddress::class; | ||
} | ||
|
||
/** | ||
* {@inheritDoc} | ||
*/ | ||
public function getSetDataProvider() | ||
{ | ||
$country = new Country('US'); | ||
|
||
return [ | ||
'country' => ['country', $country, $country], | ||
'country_text' => ['countryText', 'USA', 'USA'] | ||
]; | ||
} | ||
} |
Oops, something went wrong.