|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace OroCRM\Bundle\MagentoBundle\Tests\Functional\ImportExport\Strategy; |
|
4
|
|
|
|
|
5
|
|
|
use Akeneo\Bundle\BatchBundle\Entity\JobExecution; |
|
6
|
|
|
use Akeneo\Bundle\BatchBundle\Entity\JobInstance; |
|
7
|
|
|
use Akeneo\Bundle\BatchBundle\Entity\StepExecution; |
|
8
|
|
|
use Oro\Bundle\ImportExportBundle\Context\StepExecutionProxyContext; |
|
9
|
|
|
use Oro\Bundle\TestFrameworkBundle\Test\WebTestCase; |
|
10
|
|
|
use OroCRM\Bundle\MagentoBundle\Entity\Customer; |
|
11
|
|
|
use OroCRM\Bundle\MagentoBundle\ImportExport\Strategy\CustomerStrategy; |
|
12
|
|
|
use OroCRM\Bundle\MagentoBundle\Tests\Functional\Fixture\LoadMagentoChannel; |
|
13
|
|
|
|
|
14
|
|
|
/** |
|
15
|
|
|
* @dbIsolationPerTest |
|
16
|
|
|
*/ |
|
17
|
|
|
class CustomerStrategyTest extends WebTestCase |
|
18
|
|
|
{ |
|
19
|
|
|
/** |
|
20
|
|
|
* @var CustomerStrategy |
|
21
|
|
|
*/ |
|
22
|
|
|
private $strategy; |
|
23
|
|
|
|
|
24
|
|
|
/** |
|
25
|
|
|
* @var StepExecutionProxyContext |
|
26
|
|
|
*/ |
|
27
|
|
|
protected $context; |
|
28
|
|
|
|
|
29
|
|
|
/** |
|
30
|
|
|
* @var StepExecution |
|
31
|
|
|
*/ |
|
32
|
|
|
protected $stepExecution; |
|
33
|
|
|
|
|
34
|
|
|
protected function setUp() |
|
35
|
|
|
{ |
|
36
|
|
|
$this->initClient(); |
|
37
|
|
|
|
|
38
|
|
|
$this->loadFixtures([ |
|
39
|
|
|
LoadMagentoChannel::class |
|
40
|
|
|
]); |
|
41
|
|
|
|
|
42
|
|
|
$this->strategy = $this->getContainer()->get('orocrm_magento.import.strategy.customer.add_or_update'); |
|
43
|
|
|
$this->strategy->setEntityName(Customer::class); |
|
44
|
|
|
|
|
45
|
|
|
$jobInstance = new JobInstance(); |
|
46
|
|
|
$jobInstance->setRawConfiguration(['channel' => $this->getReference('integration')]); |
|
47
|
|
|
$jobExecution = new JobExecution(); |
|
48
|
|
|
$jobExecution->setJobInstance($jobInstance); |
|
49
|
|
|
$this->stepExecution = new StepExecution('step', $jobExecution); |
|
50
|
|
|
$this->context = new StepExecutionProxyContext($this->stepExecution); |
|
51
|
|
|
$this->strategy->setImportExportContext($this->context); |
|
52
|
|
|
$this->strategy->setStepExecution($this->stepExecution); |
|
53
|
|
|
} |
|
54
|
|
|
|
|
55
|
|
|
public function testProcessWhenNewCustomerWithDuplicateEmailIsProcessed() |
|
56
|
|
|
{ |
|
57
|
|
|
/** @var Customer $originalCustomer */ |
|
58
|
|
|
$originalCustomer = $this->getReference('customer'); |
|
59
|
|
|
|
|
60
|
|
|
$duplicateEmailCustomer = new Customer(); |
|
61
|
|
|
$uniqueOriginId = 123456789; |
|
62
|
|
|
$duplicateEmailCustomer->setOriginId($uniqueOriginId); |
|
63
|
|
|
$duplicateEmailCustomer->setChannel($originalCustomer->getChannel()); |
|
64
|
|
|
$duplicateEmailCustomer->setEmail($originalCustomer->getEmail()); |
|
65
|
|
|
$duplicateEmailCustomer->setWebsite($originalCustomer->getWebsite()); |
|
66
|
|
|
|
|
67
|
|
|
/** @var Customer $duplicateEmailCustomer */ |
|
68
|
|
|
$resultCustomer = $this->strategy->process($duplicateEmailCustomer); |
|
69
|
|
|
$this->assertSame($duplicateEmailCustomer, $resultCustomer); |
|
70
|
|
|
} |
|
71
|
|
|
} |
|
72
|
|
|
|