1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* Copyright © 2016-present Spryker Systems GmbH. All rights reserved. |
5
|
|
|
* Use of this software requires acceptance of the Spryker Marketplace License Agreement. See LICENSE file. |
6
|
|
|
*/ |
7
|
|
|
|
8
|
|
|
namespace SprykerTest\Zed\MerchantCategorySearch\Communication\Plugin\MerchantSearch; |
9
|
|
|
|
10
|
|
|
use Codeception\Test\Unit; |
11
|
|
|
use Generated\Shared\Transfer\CategoryTransfer; |
12
|
|
|
use Generated\Shared\Transfer\MerchantCategoryResponseTransfer; |
13
|
|
|
use Generated\Shared\Transfer\MerchantCategoryTransfer; |
14
|
|
|
use Generated\Shared\Transfer\MerchantSearchCollectionTransfer; |
15
|
|
|
use Generated\Shared\Transfer\MerchantSearchTransfer; |
16
|
|
|
use Spryker\Zed\MerchantCategorySearch\Communication\MerchantCategorySearchCommunicationFactory; |
17
|
|
|
use Spryker\Zed\MerchantCategorySearch\Communication\Plugin\MerchantSearch\MerchantCategoryMerchantSearchDataExpanderPlugin; |
18
|
|
|
use Spryker\Zed\MerchantCategorySearch\Dependency\Facade\MerchantCategorySearchToMerchantCategoryFacadeInterface; |
19
|
|
|
|
20
|
|
|
/** |
21
|
|
|
* Auto-generated group annotations |
22
|
|
|
* |
23
|
|
|
* @group SprykerTest |
24
|
|
|
* @group Zed |
25
|
|
|
* @group MerchantCategorySearch |
26
|
|
|
* @group Communication |
27
|
|
|
* @group Plugin |
28
|
|
|
* @group MerchantSearch |
29
|
|
|
* @group MerchantCategoryMerchantSearchDataExpanderPluginTest |
30
|
|
|
* Add your own group annotations below this line |
31
|
|
|
*/ |
32
|
|
|
class MerchantCategoryMerchantSearchDataExpanderPluginTest extends Unit |
33
|
|
|
{ |
34
|
|
|
/** |
35
|
|
|
* @uses \Spryker\Zed\MerchantCategorySearch\Communication\Expander\MerchantCategorySearchExpander::CATEGORY_KEYS |
36
|
|
|
* |
37
|
|
|
* @var string |
38
|
|
|
*/ |
39
|
|
|
protected const CATEGORY_KEYS = 'category-keys'; |
40
|
|
|
|
41
|
|
|
/** |
42
|
|
|
* @var \SprykerTest\Zed\MerchantCategorySearch\MerchantCategorySearchCommunicationTester |
43
|
|
|
*/ |
44
|
|
|
protected $tester; |
45
|
|
|
|
46
|
|
|
/** |
47
|
|
|
* @return void |
48
|
|
|
*/ |
49
|
|
|
public function testExpandSuccess(): void |
50
|
|
|
{ |
51
|
|
|
// Arrange |
52
|
|
|
$expectedCategoryKey = 'example'; |
53
|
|
|
|
54
|
|
|
$facadeMock = $this->getMerchantCategoryFacadeMock(); |
55
|
|
|
$facadeMock->method('get') |
|
|
|
|
56
|
|
|
->willReturn( |
57
|
|
|
(new MerchantCategoryResponseTransfer()) |
58
|
|
|
->addMerchantCategory( |
59
|
|
|
(new MerchantCategoryTransfer()) |
60
|
|
|
->setFkMerchant(1) |
61
|
|
|
->setCategory( |
62
|
|
|
(new CategoryTransfer()) |
63
|
|
|
->setCategoryKey($expectedCategoryKey), |
64
|
|
|
), |
65
|
|
|
), |
66
|
|
|
); |
67
|
|
|
|
68
|
|
|
$factoryMock = $this->getFactoryMock(); |
69
|
|
|
$factoryMock->method('getMerchantCategoryFacade') |
70
|
|
|
->willReturn($facadeMock); |
71
|
|
|
|
72
|
|
|
$plugin = new MerchantCategoryMerchantSearchDataExpanderPlugin(); |
73
|
|
|
$plugin->setFactory($factoryMock); |
74
|
|
|
|
75
|
|
|
$merchantSearchCollectionTransfer = (new MerchantSearchCollectionTransfer()) |
76
|
|
|
->addMerchant( |
77
|
|
|
(new MerchantSearchTransfer()) |
78
|
|
|
->setIdMerchant(1), |
79
|
|
|
); |
80
|
|
|
|
81
|
|
|
// Act |
82
|
|
|
$expandedMerchantSearchCollectionTransfer = $plugin->expand($merchantSearchCollectionTransfer); |
83
|
|
|
|
84
|
|
|
// Assert |
85
|
|
|
$this->assertNotEmpty($expandedMerchantSearchCollectionTransfer->getMerchants()); |
86
|
|
|
$this->assertSame( |
87
|
|
|
[ |
88
|
|
|
static::CATEGORY_KEYS => [$expectedCategoryKey], |
89
|
|
|
], |
90
|
|
|
$expandedMerchantSearchCollectionTransfer->getMerchants()[0]->getData(), |
91
|
|
|
); |
92
|
|
|
} |
93
|
|
|
|
94
|
|
|
/** |
95
|
|
|
* @return \PHPUnit\Framework\MockObject\MockObject|\Spryker\Zed\MerchantCategorySearch\Communication\MerchantCategorySearchCommunicationFactory |
96
|
|
|
*/ |
97
|
|
|
protected function getFactoryMock(): MerchantCategorySearchCommunicationFactory |
98
|
|
|
{ |
99
|
|
|
return $this->getMockBuilder(MerchantCategorySearchCommunicationFactory::class) |
100
|
|
|
->onlyMethods(['getMerchantCategoryFacade']) |
101
|
|
|
->getMock(); |
102
|
|
|
} |
103
|
|
|
|
104
|
|
|
/** |
105
|
|
|
* @return \PHPUnit\Framework\MockObject\MockObject|\Spryker\Zed\MerchantCategorySearch\Dependency\Facade\MerchantCategorySearchToMerchantCategoryFacadeInterface |
106
|
|
|
*/ |
107
|
|
|
protected function getMerchantCategoryFacadeMock(): MerchantCategorySearchToMerchantCategoryFacadeInterface |
108
|
|
|
{ |
109
|
|
|
return $this->getMockBuilder(MerchantCategorySearchToMerchantCategoryFacadeInterface::class) |
110
|
|
|
->onlyMethods(['get']) |
111
|
|
|
->getMock(); |
112
|
|
|
} |
113
|
|
|
} |
114
|
|
|
|
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.