Skip to content

Commit b5b67e1

Browse files
author
Deepak Tiwari
committed
Resolve Conflicts
2 parents a3bfd01 + b2b07d3 commit b5b67e1

File tree

5 files changed

+82
-48
lines changed

5 files changed

+82
-48
lines changed

app/code/Magento/Downloadable/Test/Fixture/DownloadableProduct.php

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
use Magento\TestFramework\Fixture\Api\DataMerger;
2020
use Magento\TestFramework\Fixture\Api\ServiceFactory;
2121
use Magento\TestFramework\Fixture\Data\ProcessorInterface;
22+
use Magento\Downloadable\Api\DomainManagerInterface;
2223

2324
class DownloadableProduct extends Product
2425
{
@@ -43,6 +44,8 @@ class DownloadableProduct extends Product
4344
],
4445
];
4546

47+
private const DOMAINS = ['example.com','www.example.com'];
48+
4649
/**
4750
* DownloadableProduct constructor
4851
*
@@ -61,7 +64,8 @@ public function __construct(
6164
private readonly ProductRepositoryInterface $productRepository,
6265
private readonly DirectoryList $directoryList,
6366
private readonly Link $link,
64-
private readonly File $file
67+
private readonly File $file,
68+
private readonly DomainManagerInterface $domainManager
6569
) {
6670
parent::__construct($serviceFactory, $dataProcessor, $dataMerger, $productRepository);
6771
}
@@ -74,9 +78,17 @@ public function __construct(
7478
*/
7579
public function apply(array $data = []): ?DataObject
7680
{
81+
$this->domainManager->addDomains(self::DOMAINS);
82+
7783
return parent::apply($this->prepareData($data));
7884
}
7985

86+
public function revert(DataObject $data): void
87+
{
88+
$this->domainManager->removeDomains(self::DOMAINS);
89+
parent::revert($data);
90+
}
91+
8092
/**
8193
* Prepare product data
8294
*
@@ -112,13 +124,22 @@ private function prepareLinksData(array $data): array
112124
{
113125
$links = [];
114126
foreach ($data['extension_attributes']['downloadable_product_links'] as $link) {
127+
128+
if ($link['link_type'] == 'url') {
129+
$link['link_url'] = 'http://example.com/downloadable.txt';
130+
$link['link_file'] = '';
131+
} else {
132+
$link['link_file'] = $this->generateDownloadableLink($link['link_file'] ?? 'test-' . uniqid() . '.txt');
133+
$link['link_url'] = '';
134+
}
135+
115136
$links[] = [
116137
'id' => null,
117138
'title' => $link['title'] ?? 'Test Link%uniqid%',
118139
'price' => $link['price'] ?? 0,
119140
'link_type' => $link['link_type'] ?? 'file',
120-
'link_url' => null,
121-
'link_file' => $this->generateDownloadableLink($link['link_file'] ?? 'test-' . uniqid() . '.txt'),
141+
'link_url' => $link['link_url'],
142+
'link_file' => $link['link_file'],
122143
'is_shareable' => $link['is_shareable'] ?? 0,
123144
'number_of_downloads' => $link['number_of_downloads'] ?? 5,
124145
'sort_order' => $link['sort_order'] ?? 10,

app/code/Magento/Multishipping/Model/Checkout/Type/Multishipping.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?php
22
/**
3-
* Copyright © Magento, Inc. All rights reserved.
4-
* See COPYING.txt for license details.
3+
* Copyright 2011 Adobe
4+
* All Rights Reserved.
55
*/
66

77
namespace Magento\Multishipping\Model\Checkout\Type;
@@ -703,7 +703,7 @@ protected function _prepareOrder(\Magento\Quote\Model\Quote\Address $address)
703703
$store = $order->getStore();
704704
$amountPrice = $store->getBaseCurrency()
705705
->convert($shippingPrice, $store->getCurrentCurrencyCode());
706-
$order->setBaseShippingAmount($shippingPrice);
706+
$order->setBaseShippingAmount((float)$shippingPrice);
707707
$order->setShippingAmount($amountPrice);
708708

709709
$order->setQuote($quote);

dev/tests/api-functional/testsuite/Magento/GraphQl/GiftMessage/CartItemWithGiftMessageTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,12 +102,12 @@ public function testCartQueryWithVirtualItem(): void
102102
[
103103
'title' => 'Example 1',
104104
'price' => 0.00,
105-
'link_type' => 'file'
105+
'link_type' => 'url'
106106
],
107107
[
108108
'title' => 'Example 2',
109109
'price' => 0.00,
110-
'link_type' => 'file'
110+
'link_type' => 'url'
111111
]
112112
]
113113
], as: 'product'),

dev/tests/api-functional/testsuite/Magento/GraphQl/GraphQlCache/CacheIdFactorProviders/Customer/CustomerGroupProviderTest.php

Lines changed: 49 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22
/**
3-
* Copyright 2024 Adobe
3+
* Copyright 2021 Adobe
44
* All Rights Reserved.
55
*/
66
declare(strict_types=1);
@@ -10,11 +10,13 @@
1010
use Magento\Catalog\Test\Fixture\Product as ProductFixture;
1111
use Magento\Customer\Api\CustomerRepositoryInterface;
1212
use Magento\Customer\Model\Group;
13-
use Magento\Customer\Test\Fixture\Customer;
13+
use Magento\Customer\Test\Fixture\Customer as CustomerFixture;
1414
use Magento\Framework\Exception\AuthenticationException;
15+
use Magento\Framework\Exception\EmailNotConfirmedException;
1516
use Magento\GraphQlCache\Model\CacheId\CacheIdCalculator;
1617
use Magento\Integration\Api\CustomerTokenServiceInterface;
1718
use Magento\TestFramework\Fixture\DataFixture;
19+
use Magento\TestFramework\Fixture\DataFixtureStorage;
1820
use Magento\TestFramework\Fixture\DataFixtureStorageManager;
1921
use Magento\TestFramework\Helper\Bootstrap;
2022
use Magento\TestFramework\TestCase\GraphQlAbstract;
@@ -39,60 +41,70 @@ class CustomerGroupProviderTest extends GraphQlAbstract
3941
*/
4042
private $customerRepository;
4143

44+
/**
45+
* @var DataFixtureStorage
46+
*/
47+
private $fixtures;
48+
4249
protected function setUp(): void
4350
{
44-
$objectManager = Bootstrap::getObjectManager();
45-
$this->customerTokenService = $objectManager->get(CustomerTokenServiceInterface::class);
46-
$this->customerGroup = $objectManager->get(Group::class);
47-
$this->customerRepository = $objectManager->get(CustomerRepositoryInterface::class);
51+
$this->customerTokenService = Bootstrap::getObjectManager()->get(CustomerTokenServiceInterface::class);
52+
$this->customerGroup = Bootstrap::getObjectManager()->get(Group::class);
53+
$this->customerRepository = Bootstrap::getObjectManager()->get(CustomerRepositoryInterface::class);
54+
$this->fixtures = Bootstrap::getObjectManager()->get(DataFixtureStorageManager::class)->getStorage();
4855
}
4956

5057
/**
5158
* Tests that cache id header changes based on customer group and remains consistent for same customer group
5259
*/
5360
#[
54-
DataFixture(Customer::class, as: 'customer'),
5561
DataFixture(ProductFixture::class, as: 'product'),
62+
DataFixture(CustomerFixture::class, as: 'customer'),
5663
]
57-
public function testCacheIdHeaderWithCustomerGroup()
64+
public function testCacheIdHeaderWithCustomerGroup(): void
5865
{
59-
$customer = DataFixtureStorageManager::getStorage()->get('customer');
60-
$product = DataFixtureStorageManager::getStorage()->get('product');
61-
$sku = $product->getSku();
66+
$customerEmail = $this->fixtures->get('customer')->getEmail();
6267
$query = <<<QUERY
63-
{
64-
products(filter: {sku: {eq: "{$sku}"}})
65-
{
66-
items {
67-
id
68-
name
69-
sku
70-
description {
71-
html
68+
{
69+
products(filter: {sku: {eq: "{$this->fixtures->get('product')->getSku()}"}})
70+
{
71+
items {
72+
id
73+
name
74+
sku
75+
description {
76+
html
77+
}
7278
}
7379
}
7480
}
75-
}
76-
QUERY;
77-
$response = $this->graphQlQueryWithResponseHeaders($query, [], '', $this->getHeaderMap($customer->getEmail()));
81+
QUERY;
82+
$response = $this->graphQlQueryWithResponseHeaders(
83+
$query,
84+
[],
85+
'',
86+
$this->getHeaderMap($customerEmail)
87+
);
7888
$this->assertArrayHasKey(CacheIdCalculator::CACHE_ID_HEADER, $response['headers']);
7989
$cacheId = $response['headers'][CacheIdCalculator::CACHE_ID_HEADER];
8090
$this->assertTrue((boolean)preg_match('/^[0-9a-f]{64}$/i', $cacheId));
81-
$groupCode = 'Retailer';
82-
$customer = $this->customerRepository->get($customer->getEmail());
83-
$customerGroupId = $this->customerGroup->load($groupCode, 'customer_group_code')->getId();
91+
$customer = $this->customerRepository->get($customerEmail);
92+
$customerGroupId = $this->customerGroup->load('Retailer', 'customer_group_code')->getId();
8493
// change the customer group of this customer from the default group
8594
$customer->setGroupId($customerGroupId);
8695
$this->customerRepository->save($customer);
8796
$responseAfterCustomerGroupChange = $this->graphQlQueryWithResponseHeaders(
8897
$query,
8998
[],
9099
'',
91-
$this->getHeaderMap($customer->getEmail())
100+
$this->getHeaderMap($customerEmail)
101+
);
102+
$this->assertArrayHasKey(
103+
CacheIdCalculator::CACHE_ID_HEADER,
104+
$responseAfterCustomerGroupChange['headers']
92105
);
93-
$this->assertArrayHasKey(CacheIdCalculator::CACHE_ID_HEADER, $responseAfterCustomerGroupChange['headers']);
94106
$cacheIdCustomerGroupChange = $responseAfterCustomerGroupChange['headers'][CacheIdCalculator::CACHE_ID_HEADER];
95-
// Verify that the the cache id generated is a 64 character long
107+
// Verify that the cache id generated is a 64 character long
96108
$this->assertTrue((boolean)preg_match('/^[0-9a-f]{64}$/i', $cacheId));
97109
// check that the cache ids generated before and after customer group changes are not equal
98110
$this->assertNotEquals($cacheId, $cacheIdCustomerGroupChange);
@@ -103,26 +115,27 @@ public function testCacheIdHeaderWithCustomerGroup()
103115
$query,
104116
[],
105117
'',
106-
$this->getHeaderMap($customer->getEmail())
118+
$this->getHeaderMap($customerEmail)
107119
);
108-
$cacheIdDefaultCustomerGroup = $responseDefaultCustomerGroup['headers'][CacheIdCalculator::CACHE_ID_HEADER];
109120
//Verify that the cache id is same as original $cacheId
110-
$this->assertEquals($cacheIdDefaultCustomerGroup, $cacheId);
121+
$this->assertEquals(
122+
$responseDefaultCustomerGroup['headers'][CacheIdCalculator::CACHE_ID_HEADER],
123+
$cacheId
124+
);
111125
}
112126

113127
/**
114128
* Authentication header map
115129
*
116130
* @param string $username
117-
* @param string $password
118-
*
119131
* @return array
120132
*
121133
* @throws AuthenticationException
134+
* @throws EmailNotConfirmedException
122135
*/
123-
private function getHeaderMap(string $username = 'customer@example.com', string $password = 'password'): array
136+
private function getHeaderMap(string $username): array
124137
{
125-
$customerToken = $this->customerTokenService->createCustomerAccessToken($username, $password);
138+
$customerToken = $this->customerTokenService->createCustomerAccessToken($username, 'password');
126139

127140
return ['Authorization' => 'Bearer ' . $customerToken];
128141
}

dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/DownloadableProductCartItemPriceTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,12 +56,12 @@ protected function setUp(): void
5656
[
5757
'title' => 'Example 1',
5858
'price' => 0.00,
59-
'link_type' => 'file'
59+
'link_type' => 'url'
6060
],
6161
[
6262
'title' => 'Example 2',
6363
'price' => 0.00,
64-
'link_type' => 'file'
64+
'link_type' => 'url'
6565
],
6666
]
6767
], as: 'product'),
@@ -158,12 +158,12 @@ public function testGetCartItemPricesForDownloadableProductWithoutSeparateLinks(
158158
[
159159
'title' => 'Example 1',
160160
'price' => 10,
161-
'link_type' => 'file'
161+
'link_type' => 'url'
162162
],
163163
[
164164
'title' => 'Example 2',
165165
'price' => 10,
166-
'link_type' => 'file'
166+
'link_type' => 'url'
167167
],
168168
]
169169
], as: 'product'),

0 commit comments

Comments
 (0)