|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Tests\ShopwarePlugins\Connect\Subscribers; |
|
4
|
|
|
|
|
5
|
|
|
use ShopwarePlugins\Connect\Components\Config; |
|
6
|
|
|
use ShopwarePlugins\Connect\Components\ProductStream\ProductStreamsAssignments; |
|
7
|
|
|
use ShopwarePlugins\Connect\Subscribers\Article; |
|
8
|
|
|
use Shopware\Connect\Gateway; |
|
9
|
|
|
use Shopware\Components\Model\ModelManager; |
|
10
|
|
|
use ShopwarePlugins\Connect\Components\ConnectExport; |
|
11
|
|
|
use ShopwarePlugins\Connect\Components\ProductStream\ProductStreamService; |
|
12
|
|
|
use Tests\ShopwarePlugins\Connect\ConnectTestHelper; |
|
13
|
|
|
use Shopware\Models\Article\Article as ArticleModel; |
|
14
|
|
|
use Doctrine\ORM\EntityRepository; |
|
15
|
|
|
use ShopwarePlugins\Connect\Components\Helper; |
|
16
|
|
|
use Shopware\CustomModels\Connect\Attribute as ConnectAttribute; |
|
17
|
|
|
|
|
18
|
|
|
class ArticleTest extends ConnectTestHelper |
|
19
|
|
|
{ |
|
20
|
|
|
/** |
|
21
|
|
|
* @var Article |
|
22
|
|
|
*/ |
|
23
|
|
|
private $subscriber; |
|
24
|
|
|
|
|
25
|
|
|
/** |
|
26
|
|
|
* @var ModelManager |
|
27
|
|
|
*/ |
|
28
|
|
|
private $modelManager; |
|
29
|
|
|
|
|
30
|
|
|
/** |
|
31
|
|
|
* @var Helper |
|
32
|
|
|
*/ |
|
33
|
|
|
private $helper; |
|
34
|
|
|
|
|
35
|
|
|
/** |
|
36
|
|
|
* @var ConnectExport |
|
37
|
|
|
*/ |
|
38
|
|
|
private $connectExport; |
|
39
|
|
|
|
|
40
|
|
|
/** |
|
41
|
|
|
* @var Config |
|
42
|
|
|
*/ |
|
43
|
|
|
private $config; |
|
44
|
|
|
|
|
45
|
|
|
public function setUp() |
|
46
|
|
|
{ |
|
47
|
|
|
$this->modelManager = $this->createMock(ModelManager::class); |
|
48
|
|
|
$this->helper = $this->createMock(Helper::class); |
|
49
|
|
|
$this->connectExport = $this->createMock(ConnectExport::class); |
|
50
|
|
|
$this->config = $this->createMock(Config::class); |
|
51
|
|
|
|
|
52
|
|
|
$this->subscriber = new Article( |
|
53
|
|
|
$this->createMock(Gateway::class), |
|
54
|
|
|
$this->modelManager, |
|
55
|
|
|
$this->connectExport, |
|
56
|
|
|
$this->createMock(ProductStreamService::class), |
|
57
|
|
|
$this->helper, |
|
58
|
|
|
$this->config |
|
59
|
|
|
); |
|
60
|
|
|
} |
|
61
|
|
|
|
|
62
|
|
|
public function testRegenerateChanges() |
|
63
|
|
|
{ |
|
64
|
|
|
$articleId = 5; |
|
65
|
|
|
$article = new ArticleModel(); |
|
66
|
|
|
$connectAttribute = new ConnectAttribute(); |
|
67
|
|
|
|
|
68
|
|
|
$repositoryMock = $this->createMock(EntityRepository::class); |
|
69
|
|
|
|
|
70
|
|
|
$this->modelManager->method('getRepository') |
|
71
|
|
|
->with(ArticleModel::class) |
|
72
|
|
|
->willReturn($repositoryMock); |
|
73
|
|
|
|
|
74
|
|
|
$repositoryMock->method('find') |
|
75
|
|
|
->with($articleId) |
|
76
|
|
|
->willReturn($article); |
|
77
|
|
|
|
|
78
|
|
|
$this->helper->method('getConnectAttributeByModel') |
|
|
|
|
|
|
79
|
|
|
->with($article) |
|
80
|
|
|
->willReturn($connectAttribute); |
|
81
|
|
|
|
|
82
|
|
|
$this->helper->method('isProductExported') |
|
|
|
|
|
|
83
|
|
|
->with($connectAttribute) |
|
84
|
|
|
->willReturn(true); |
|
85
|
|
|
|
|
86
|
|
|
$this->connectExport->method('setDeleteStatusForVariants') |
|
|
|
|
|
|
87
|
|
|
->with($article); |
|
88
|
|
|
|
|
89
|
|
|
$this->config->method('getConfig') |
|
|
|
|
|
|
90
|
|
|
->with('autoUpdateProducts', Config::UPDATE_AUTO) |
|
91
|
|
|
->willReturn(Config::UPDATE_AUTO); |
|
92
|
|
|
|
|
93
|
|
|
$sourceIds = ['5', '5-101', '5-102', '5-103']; |
|
94
|
|
|
$this->helper->method('getSourceIdsFromArticleId') |
|
|
|
|
|
|
95
|
|
|
->with($articleId) |
|
96
|
|
|
->willReturn($sourceIds); |
|
97
|
|
|
|
|
98
|
|
|
$this->connectExport->expects($this->once()) |
|
|
|
|
|
|
99
|
|
|
->method('export') |
|
100
|
|
|
->with($sourceIds, new ProductStreamsAssignments()); |
|
101
|
|
|
|
|
102
|
|
|
$this->subscriber->regenerateChangesForArticle($articleId); |
|
103
|
|
|
$this->assertTrue(true); |
|
104
|
|
|
} |
|
105
|
|
|
} |
|
106
|
|
|
|
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.