Skip to content

Commit b90fffb

Browse files
authored
Merge pull request #5638 from magento-tsg/2.4-develop-php74-pr40
[TSG][PHP7.4] Integration tests Fixes for 2.4 (pr40) (2.4-develop-php74)
2 parents f9ded1d + 45738ad commit b90fffb

File tree

5 files changed

+202
-183
lines changed

5 files changed

+202
-183
lines changed

app/code/Magento/Captcha/Model/DefaultModel.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -496,12 +496,17 @@ public function getWord()
496496
/**
497497
* Get captcha words
498498
*
499-
* @return string|null
499+
* @return string
500500
*/
501501
private function getWords()
502502
{
503503
$sessionData = $this->session->getData($this->getFormIdKey(self::SESSION_WORD));
504-
return time() < $sessionData['expires'] ? $sessionData['words'] : null;
504+
$words = '';
505+
if (isset($sessionData['expires'], $sessionData['words']) && time() < $sessionData['expires']) {
506+
$words = $sessionData['words'];
507+
}
508+
509+
return $words;
505510
}
506511

507512
/**

app/code/Magento/Catalog/Controller/Adminhtml/Product/Attribute/Save.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,10 @@ public function execute()
194194
$attributeCode = $model && $model->getId()
195195
? $model->getAttributeCode()
196196
: $this->getRequest()->getParam('attribute_code');
197-
$attributeCode = $attributeCode ?: $this->generateCode($this->getRequest()->getParam('frontend_label')[0]);
197+
if (!$attributeCode) {
198+
$frontendLabel = $this->getRequest()->getParam('frontend_label')[0] ?? '';
199+
$attributeCode = $this->generateCode($frontendLabel);
200+
}
198201
$data['attribute_code'] = $attributeCode;
199202

200203
//validate frontend_input

app/code/Magento/Wishlist/Model/LocaleQuantityProcessor.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,11 @@ public function __construct(
4343
public function process($qty)
4444
{
4545
$this->localFilter->setOptions(['locale' => $this->localeResolver->getLocale()]);
46-
$qty = $this->localFilter->filter($qty);
46+
$qty = $this->localFilter->filter((string)$qty);
4747
if ($qty < 0) {
4848
$qty = null;
4949
}
50+
5051
return $qty;
5152
}
5253
}

dev/tests/api-functional/testsuite/Magento/Downloadable/Api/LinkRepositoryTest.php

Lines changed: 98 additions & 98 deletions
Original file line numberDiff line numberDiff line change
@@ -671,63 +671,6 @@ public function getInvalidNumberOfDownloads()
671671
];
672672
}
673673

674-
/**
675-
* @magentoApiDataFixture Magento/Catalog/_files/product_simple.php
676-
*/
677-
public function testCreateThrowsExceptionIfTargetProductTypeIsNotDownloadable()
678-
{
679-
$this->expectException(\Exception::class);
680-
$this->expectExceptionMessage(
681-
'The product needs to be the downloadable type. Verify the product and try again.'
682-
);
683-
684-
$this->createServiceInfo['rest']['resourcePath'] = '/V1/products/simple/downloadable-links';
685-
$requestData = [
686-
'isGlobalScopeContent' => false,
687-
'sku' => 'simple',
688-
'link' => [
689-
'title' => 'Link Title',
690-
'sort_order' => 50,
691-
'price' => 200,
692-
'is_shareable' => 0,
693-
'number_of_downloads' => 10,
694-
'sample_type' => 'url',
695-
'sample_url' => 'http://example.com/',
696-
'link_type' => 'url',
697-
'link_url' => 'http://example.com/',
698-
],
699-
];
700-
$this->_webApiCall($this->createServiceInfo, $requestData);
701-
}
702-
703-
/**
704-
*/
705-
public function testCreateThrowsExceptionIfTargetProductDoesNotExist()
706-
{
707-
$this->expectException(\Exception::class);
708-
$this->expectExceptionMessage(
709-
'The product that was requested doesn\'t exist. Verify the product and try again.'
710-
);
711-
712-
$this->createServiceInfo['rest']['resourcePath'] = '/V1/products/wrong-sku/downloadable-links';
713-
$requestData = [
714-
'isGlobalScopeContent' => false,
715-
'sku' => 'wrong-sku',
716-
'link' => [
717-
'title' => 'Link Title',
718-
'sort_order' => 15,
719-
'price' => 200,
720-
'is_shareable' => 1,
721-
'number_of_downloads' => 100,
722-
'sample_type' => 'url',
723-
'sample_url' => 'http://example.com/',
724-
'link_type' => 'url',
725-
'link_url' => 'http://example.com/',
726-
],
727-
];
728-
$this->_webApiCall($this->createServiceInfo, $requestData);
729-
}
730-
731674
/**
732675
* @magentoApiDataFixture Magento/Downloadable/_files/product_downloadable.php
733676
*/
@@ -964,6 +907,61 @@ public function testDelete()
964907
$this->assertNull($link);
965908
}
966909

910+
/**
911+
* @magentoApiDataFixture Magento/Downloadable/_files/product_downloadable_with_files.php
912+
* @dataProvider getListForAbsentProductProvider
913+
*/
914+
public function testGetList($urlTail, $method, $expectations)
915+
{
916+
$sku = 'downloadable-product';
917+
918+
$serviceInfo = [
919+
'rest' => [
920+
'resourcePath' => '/V1/products/' . $sku . $urlTail,
921+
'httpMethod' => \Magento\Framework\Webapi\Rest\Request::HTTP_METHOD_GET,
922+
],
923+
'soap' => [
924+
'service' => 'downloadableLinkRepositoryV1',
925+
'serviceVersion' => 'V1',
926+
'operation' => 'downloadableLinkRepositoryV1' . $method,
927+
],
928+
];
929+
930+
$requestData = ['sku' => $sku];
931+
932+
$list = $this->_webApiCall($serviceInfo, $requestData);
933+
934+
$this->assertCount(1, $list);
935+
936+
$link = reset($list);
937+
foreach ($expectations['fields'] as $index => $value) {
938+
$this->assertEquals($value, $link[$index]);
939+
}
940+
$this->assertStringContainsString('jellyfish_1_3.jpg', $link['sample_file']);
941+
}
942+
943+
public function getListForAbsentProductProvider()
944+
{
945+
$linkExpectation = [
946+
'fields' => [
947+
'is_shareable' => 2,
948+
'price' => 15,
949+
'number_of_downloads' => 15,
950+
'sample_type' => 'file',
951+
'link_file' => '/j/e/jellyfish_2_4.jpg',
952+
'link_type' => 'file'
953+
]
954+
];
955+
956+
return [
957+
'links' => [
958+
'/downloadable-links',
959+
'GetList',
960+
$linkExpectation,
961+
],
962+
];
963+
}
964+
967965
/**
968966
*/
969967
public function testDeleteThrowsExceptionIfThereIsNoDownloadableLinkWithGivenId()
@@ -1040,57 +1038,59 @@ public function testGetListForSimpleProduct($urlTail, $method)
10401038
}
10411039

10421040
/**
1043-
* @magentoApiDataFixture Magento/Downloadable/_files/product_downloadable_with_files.php
1044-
* @dataProvider getListForAbsentProductProvider
1041+
* @magentoApiDataFixture Magento/Catalog/_files/product_simple.php
10451042
*/
1046-
public function testGetList($urlTail, $method, $expectations)
1043+
public function testCreateThrowsExceptionIfTargetProductTypeIsNotDownloadable()
10471044
{
1048-
$sku = 'downloadable-product';
1045+
$this->expectException(\Exception::class);
1046+
$this->expectExceptionMessage(
1047+
'The product needs to be the downloadable type. Verify the product and try again.'
1048+
);
10491049

1050-
$serviceInfo = [
1051-
'rest' => [
1052-
'resourcePath' => '/V1/products/' . $sku . $urlTail,
1053-
'httpMethod' => \Magento\Framework\Webapi\Rest\Request::HTTP_METHOD_GET,
1054-
],
1055-
'soap' => [
1056-
'service' => 'downloadableLinkRepositoryV1',
1057-
'serviceVersion' => 'V1',
1058-
'operation' => 'downloadableLinkRepositoryV1' . $method,
1050+
$this->createServiceInfo['rest']['resourcePath'] = '/V1/products/simple/downloadable-links';
1051+
$requestData = [
1052+
'isGlobalScopeContent' => false,
1053+
'sku' => 'simple',
1054+
'link' => [
1055+
'title' => 'Link Title',
1056+
'sort_order' => 50,
1057+
'price' => 200,
1058+
'is_shareable' => 0,
1059+
'number_of_downloads' => 10,
1060+
'sample_type' => 'url',
1061+
'sample_url' => 'http://example.com/',
1062+
'link_type' => 'url',
1063+
'link_url' => 'http://example.com/',
10591064
],
10601065
];
1061-
1062-
$requestData = ['sku' => $sku];
1063-
1064-
$list = $this->_webApiCall($serviceInfo, $requestData);
1065-
1066-
$this->assertCount(1, $list);
1067-
1068-
$link = reset($list);
1069-
foreach ($expectations['fields'] as $index => $value) {
1070-
$this->assertEquals($value, $link[$index]);
1071-
}
1072-
$this->assertStringContainsString('jellyfish_1_3.jpg', $link['sample_file']);
1066+
$this->_webApiCall($this->createServiceInfo, $requestData);
10731067
}
10741068

1075-
public function getListForAbsentProductProvider()
1069+
/**
1070+
*/
1071+
public function testCreateThrowsExceptionIfTargetProductDoesNotExist()
10761072
{
1077-
$linkExpectation = [
1078-
'fields' => [
1079-
'is_shareable' => 2,
1080-
'price' => 15,
1081-
'number_of_downloads' => 15,
1082-
'sample_type' => 'file',
1083-
'link_file' => '/j/e/jellyfish_2_4.jpg',
1084-
'link_type' => 'file'
1085-
]
1086-
];
1073+
$this->expectException(\Exception::class);
1074+
$this->expectExceptionMessage(
1075+
'The product that was requested doesn\'t exist. Verify the product and try again.'
1076+
);
10871077

1088-
return [
1089-
'links' => [
1090-
'/downloadable-links',
1091-
'GetList',
1092-
$linkExpectation,
1078+
$this->createServiceInfo['rest']['resourcePath'] = '/V1/products/wrong-sku/downloadable-links';
1079+
$requestData = [
1080+
'isGlobalScopeContent' => false,
1081+
'sku' => 'wrong-sku',
1082+
'link' => [
1083+
'title' => 'Link Title',
1084+
'sort_order' => 15,
1085+
'price' => 200,
1086+
'is_shareable' => 1,
1087+
'number_of_downloads' => 100,
1088+
'sample_type' => 'url',
1089+
'sample_url' => 'http://example.com/',
1090+
'link_type' => 'url',
1091+
'link_url' => 'http://example.com/',
10931092
],
10941093
];
1094+
$this->_webApiCall($this->createServiceInfo, $requestData);
10951095
}
10961096
}

0 commit comments

Comments
 (0)