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\MerchantCategory\Communication; |
||
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\MerchantTransfer; |
||
15 | use Spryker\Zed\MerchantCategory\Business\MerchantCategoryFacade; |
||
16 | use Spryker\Zed\MerchantCategory\Communication\Plugin\Merchant\MerchantCategoryMerchantExpanderPlugin; |
||
17 | |||
18 | /** |
||
19 | * Auto-generated group annotations |
||
20 | * |
||
21 | * @group SprykerTest |
||
22 | * @group Zed |
||
23 | * @group MerchantCategory |
||
24 | * @group Communication |
||
25 | * @group MerchantCategoryMerchantExpanderPluginTest |
||
26 | * Add your own group annotations below this line |
||
27 | */ |
||
28 | class MerchantCategoryMerchantExpanderPluginTest extends Unit |
||
29 | { |
||
30 | /** |
||
31 | * @return void |
||
32 | */ |
||
33 | public function testExpandExpandsMerchantDataWithCategories(): void |
||
34 | { |
||
35 | // Arrange |
||
36 | $merchantCategoryMerchantExpanderPluginMock = $this->createMerchantCategoryMerchantExpanderPluginMock( |
||
37 | (new MerchantCategoryResponseTransfer()) |
||
38 | ->addMerchantCategory( |
||
39 | (new MerchantCategoryTransfer()) |
||
40 | ->setCategory(new CategoryTransfer()), |
||
41 | ) |
||
42 | ->setIsSuccessful(true), |
||
43 | ); |
||
44 | |||
45 | // Act |
||
46 | $merchantTransfer = $merchantCategoryMerchantExpanderPluginMock->expand( |
||
47 | (new MerchantTransfer())->setIdMerchant(1), |
||
48 | ); |
||
49 | |||
50 | // Assert |
||
51 | $this->assertNotEmpty($merchantTransfer->getCategories()); |
||
52 | } |
||
53 | |||
54 | /** |
||
55 | * @return void |
||
56 | */ |
||
57 | public function testExpandNotExpandMerchantDataWithCategoriesForNotSuccessfulResponse() |
||
58 | { |
||
59 | // Arrange |
||
60 | $merchantCategoryMerchantExpanderPluginMock = $this->createMerchantCategoryMerchantExpanderPluginMock( |
||
61 | (new MerchantCategoryResponseTransfer()) |
||
62 | ->addMerchantCategory( |
||
63 | (new MerchantCategoryTransfer()) |
||
64 | ->setCategory(new CategoryTransfer()), |
||
65 | ) |
||
66 | ->setIsSuccessful(false), |
||
67 | ); |
||
68 | |||
69 | // Act |
||
70 | $merchantTransfer = $merchantCategoryMerchantExpanderPluginMock->expand( |
||
71 | (new MerchantTransfer())->setIdMerchant(1), |
||
72 | ); |
||
73 | |||
74 | // Assert |
||
75 | $this->assertEmpty($merchantTransfer->getCategories()); |
||
76 | } |
||
77 | |||
78 | /** |
||
79 | * @param \Generated\Shared\Transfer\MerchantCategoryResponseTransfer $merchantCategoryResponseTransfer |
||
80 | * |
||
81 | * @return \Spryker\Zed\MerchantCategory\Communication\Plugin\Merchant\MerchantCategoryMerchantExpanderPlugin |
||
82 | */ |
||
83 | protected function createMerchantCategoryMerchantExpanderPluginMock( |
||
84 | MerchantCategoryResponseTransfer $merchantCategoryResponseTransfer |
||
85 | ): MerchantCategoryMerchantExpanderPlugin { |
||
86 | $merchantCategoryFacadeMock = $this->createMock(MerchantCategoryFacade::class); |
||
87 | $merchantCategoryFacadeMock->method('get') |
||
88 | ->willReturn($merchantCategoryResponseTransfer); |
||
89 | |||
90 | $merchantCategoryMerchantExpanderPlugin = new MerchantCategoryMerchantExpanderPlugin(); |
||
0 ignored issues
–
show
Deprecated Code
introduced
by
Loading history...
|
|||
91 | $merchantCategoryMerchantExpanderPlugin->setFacade($merchantCategoryFacadeMock); |
||
92 | |||
93 | return $merchantCategoryMerchantExpanderPlugin; |
||
94 | } |
||
95 | } |
||
96 |