Skip to content

Commit 6cc5614

Browse files
committed
AC-14095: CNS WebApi Broken and Failed tests
1 parent 37f7aa3 commit 6cc5614

File tree

3 files changed

+24
-31
lines changed

3 files changed

+24
-31
lines changed

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

Lines changed: 18 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@ class DownloadableProduct extends Product
4444
],
4545
];
4646

47+
private const DOMAINS = ['example.com','www.example.com'];
48+
4749
/**
4850
* DownloadableProduct constructor
4951
*
@@ -76,27 +78,15 @@ public function __construct(
7678
*/
7779
public function apply(array $data = []): ?DataObject
7880
{
79-
$this->domainManager->addDomains(
80-
[
81-
'example.com',
82-
'www.example.com'
83-
]
84-
);
81+
$this->domainManager->addDomains(self::DOMAINS);
8582

8683
return parent::apply($this->prepareData($data));
8784
}
8885

8986
public function revert(DataObject $data): void
9087
{
91-
$this->domainManager->removeDomains(
92-
[
93-
'example.com',
94-
'www.example.com',
95-
]
96-
);
97-
88+
$this->domainManager->removeDomains(self::DOMAINS);
9889
parent::revert($data);
99-
10090
}
10191

10292
/**
@@ -134,21 +124,24 @@ private function prepareLinksData(array $data): array
134124
{
135125
$links = [];
136126
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+
137136
$links[] = [
138137
'id' => null,
139138
'title' => $link['title'] ?? 'Test Link%uniqid%',
140139
'price' => $link['price'] ?? 0,
141-
142-
'link_type' => \Magento\Downloadable\Helper\Download::LINK_TYPE_URL,
143-
'link_url' => 'http://example.com/downloadable.txt',
144-
'is_shareable' => \Magento\Downloadable\Model\Link::LINK_SHAREABLE_CONFIG,
145-
'number_of_downloads' => 10,
146-
147-
//'link_type' => $link['link_type'] ?? 'file',
148-
//'link_url' => null,
149-
//'link_file' => $this->generateDownloadableLink($link['link_file'] ?? 'test-' . uniqid() . '.txt'),
150-
//'is_shareable' => $link['is_shareable'] ?? 0,
151-
//'number_of_downloads' => $link['number_of_downloads'] ?? 5,
140+
'link_type' => $link['link_type'] ?? 'file',
141+
'link_url' => $link['link_url'],
142+
'link_file' => $link['link_file'],
143+
'is_shareable' => $link['is_shareable'] ?? 0,
144+
'number_of_downloads' => $link['number_of_downloads'] ?? 5,
152145
'sort_order' => $link['sort_order'] ?? 10,
153146
];
154147
}

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/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)