Skip to content

Commit 93b89c6

Browse files
cia-2.4.8-beta2-develop-2.4-develop-sync-11222024: resolve conflict
1 parent 5c80efa commit 93b89c6

File tree

1 file changed

+9
-52
lines changed

1 file changed

+9
-52
lines changed

app/code/Magento/Catalog/Test/Unit/Model/Product/Price/Validation/TierPriceValidatorTest.php

Lines changed: 9 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
<?php
22
/**
33
* Copyright 2024 Adobe
4-
* All rights reserved.
5-
* See COPYING.txt for license details.
4+
* All Rights Reserved.
65
*/
76
declare(strict_types=1);
87

@@ -15,22 +14,15 @@
1514
use Magento\Catalog\Model\Product\Price\Validation\TierPriceValidator;
1615
use Magento\Catalog\Model\Product\Type;
1716
use Magento\Catalog\Model\ProductIdLocatorInterface;
18-
use Magento\Customer\Api\Data\GroupInterface;
19-
use Magento\Customer\Api\Data\GroupSearchResultsInterface;
20-
use Magento\Customer\Api\GroupRepositoryInterface;
21-
use Magento\Framework\Api\AbstractSimpleObject;
22-
use Magento\Framework\Api\FilterBuilder;
23-
use Magento\Framework\Api\Search\SearchCriteriaInterface;
24-
use Magento\Framework\Api\SearchCriteriaBuilder;
17+
use Magento\Framework\App\ResourceConnection;
18+
use Magento\Framework\DB\Adapter\AdapterInterface;
19+
use Magento\Framework\DB\Select;
2520
use Magento\Framework\Exception\NoSuchEntityException;
2621
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
2722
use Magento\Store\Api\Data\WebsiteInterface;
2823
use Magento\Store\Api\WebsiteRepositoryInterface;
2924
use PHPUnit\Framework\MockObject\MockObject;
3025
use PHPUnit\Framework\TestCase;
31-
use Magento\Framework\App\ResourceConnection;
32-
use Magento\Framework\DB\Adapter\AdapterInterface;
33-
use Magento\Framework\DB\Select;
3426

3527
/**
3628
* Test for \Magento\Catalog\Model\Product\Price\Validation\TierPriceValidator.
@@ -92,15 +84,6 @@ protected function setUp(): void
9284
$this->productIdLocator = $this->getMockBuilder(ProductIdLocatorInterface::class)
9385
->disableOriginalConstructor()
9486
->getMockForAbstractClass();
95-
$this->searchCriteriaBuilder = $this->getMockBuilder(SearchCriteriaBuilder::class)
96-
->disableOriginalConstructor()
97-
->getMock();
98-
$this->filterBuilder = $this->getMockBuilder(FilterBuilder::class)
99-
->disableOriginalConstructor()
100-
->getMock();
101-
$this->customerGroupRepository = $this->getMockBuilder(GroupRepositoryInterface::class)
102-
->disableOriginalConstructor()
103-
->getMockForAbstractClass();
10487
$this->websiteRepository = $this->getMockBuilder(WebsiteRepositoryInterface::class)
10588
->disableOriginalConstructor()
10689
->getMockForAbstractClass();
@@ -130,9 +113,6 @@ protected function setUp(): void
130113
TierPriceValidator::class,
131114
[
132115
'productIdLocator' => $this->productIdLocator,
133-
'searchCriteriaBuilder' => $this->searchCriteriaBuilder,
134-
'filterBuilder' => $this->filterBuilder,
135-
'customerGroupRepository' => $this->customerGroupRepository,
136116
'websiteRepository' => $this->websiteRepository,
137117
'validationResult' => $this->validationResult,
138118
'invalidSkuProcessor' => $this->invalidSkuProcessor,
@@ -145,10 +125,9 @@ protected function setUp(): void
145125
/**
146126
* Prepare CustomerGroupRepository mock.
147127
*
148-
* @param array $returned
149128
* @return void
150129
*/
151-
private function prepareCustomerGroupRepositoryMock(array $returned)
130+
private function prepareCustomerGroupRepositoryMock()
152131
{
153132
$select = $this->createMock(Select::class);
154133
$select->expects($this->once())
@@ -257,11 +236,6 @@ public function testValidateSkus()
257236
*/
258237
public function testRetrieveValidationResult(array $returned)
259238
{
260-
if (!empty($returned['customerGroupSearchResults_getItems'])) {
261-
$groupSearchResult = $returned['customerGroupSearchResults_getItems'][0];
262-
$returned['customerGroupSearchResults_getItems'][0] = $groupSearchResult($this);
263-
}
264-
265239
$sku = 'ASDF234234';
266240
$prices = [$this->tierPrice];
267241
$existingPrices = [$this->tierPrice];
@@ -270,26 +244,14 @@ public function testRetrieveValidationResult(array $returned)
270244
->disableOriginalConstructor()
271245
->getMockForAbstractClass();
272246
$this->websiteRepository->expects($this->atLeastOnce())->method('getById')->willReturn($website);
273-
$this->prepareCustomerGroupRepositoryMock($returned);
247+
$this->prepareCustomerGroupRepositoryMock();
274248

275249
$this->assertEquals(
276250
$this->validationResult,
277251
$this->tierPriceValidator->retrieveValidationResult($prices, $existingPrices)
278252
);
279253
}
280254

281-
protected function getMockForCustomerGroup($customerGroupName)
282-
{
283-
$customerGroup = $this->getMockBuilder(GroupInterface::class)
284-
->onlyMethods(['getCode', 'getId'])
285-
->disableOriginalConstructor()
286-
->getMockForAbstractClass();
287-
$customerGroup->expects($this->atLeastOnce())->method('getCode')->willReturn($customerGroupName);
288-
$customerGroupId = 23;
289-
$customerGroup->expects($this->atLeastOnce())->method('getId')->willReturn($customerGroupId);
290-
return $customerGroup;
291-
}
292-
293255
/**
294256
* Data provider for retrieveValidationResult() test.
295257
*
@@ -298,21 +260,17 @@ protected function getMockForCustomerGroup($customerGroupName)
298260
public static function retrieveValidationResultDataProvider()
299261
{
300262
$customerGroupName = 'test_Group';
301-
$customerGroup = static fn (self $testCase) => $testCase->getMockForCustomerGroup($customerGroupName);
302-
303263
return [
304264
[
305265
[
306266
'tierPrice_getCustomerGroup' => $customerGroupName,
307-
'tierPrice_getPriceType' => TierPriceInterface::PRICE_TYPE_DISCOUNT,
308-
'customerGroupSearchResults_getItems' => [$customerGroup]
267+
'tierPrice_getPriceType' => TierPriceInterface::PRICE_TYPE_DISCOUNT
309268
]
310269
],
311270
[
312271
[
313272
'tierPrice_getCustomerGroup' => $customerGroupName,
314-
'tierPrice_getPriceType' => TierPriceInterface::PRICE_TYPE_FIXED,
315-
'customerGroupSearchResults_getItems' => []
273+
'tierPrice_getPriceType' => TierPriceInterface::PRICE_TYPE_FIXED
316274
]
317275
]
318276
];
@@ -331,13 +289,12 @@ public function testRetrieveValidationResultWithException()
331289
$existingPrices = [$this->tierPrice];
332290
$returned = [
333291
'tierPrice_getPriceType' => TierPriceInterface::PRICE_TYPE_DISCOUNT,
334-
'customerGroupSearchResults_getItems' => [],
335292
'tierPrice_getCustomerGroup' => $customerGroupName,
336293
];
337294
$this->prepareRetrieveValidationResultMethod($sku, $returned);
338295
$exception = new NoSuchEntityException();
339296
$this->websiteRepository->expects($this->atLeastOnce())->method('getById')->willThrowException($exception);
340-
$this->prepareCustomerGroupRepositoryMock($returned);
297+
$this->prepareCustomerGroupRepositoryMock();
341298

342299
$this->assertEquals(
343300
$this->validationResult,

0 commit comments

Comments
 (0)