Skip to content

Commit 65878df

Browse files
committed
Merge remote-tracking branch 'SilinMykola/php81-compatibility/deprecations-unit' into ph-delivery
2 parents 1565e5c + f80d876 commit 65878df

File tree

19 files changed

+129
-97
lines changed

19 files changed

+129
-97
lines changed

app/code/Magento/Catalog/Test/Unit/Controller/Adminhtml/Product/Attribute/SaveTest.php

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,10 @@ class SaveTest extends AttributeTest
121121
protected function setUp(): void
122122
{
123123
parent::setUp();
124-
$this->filterManagerMock = $this->createMock(FilterManager::class);
124+
$this->filterManagerMock = $this->getMockBuilder(FilterManager::class)
125+
->addMethods(['stripTags'])
126+
->disableOriginalConstructor()
127+
->getMock();
125128
$this->productHelperMock = $this->createMock(ProductHelper::class);
126129
$this->attributeSetMock = $this->createMock(AttributeSetInterface::class);
127130
$this->builderMock = $this->createMock(Build::class);
@@ -132,34 +135,38 @@ protected function setUp(): void
132135
$this->sessionMock = $this->createMock(Session::class);
133136
$this->layoutFactoryMock = $this->createMock(LayoutFactory::class);
134137
$this->buildFactoryMock = $this->getMockBuilder(BuildFactory::class)
135-
->setMethods(['create'])
138+
->onlyMethods(['create'])
136139
->disableOriginalConstructor()
137140
->getMock();
138141
$this->attributeFactoryMock = $this->getMockBuilder(AttributeFactory::class)
139-
->setMethods(['create'])
142+
->onlyMethods(['create'])
140143
->disableOriginalConstructor()
141144
->getMock();
142145
$this->validatorFactoryMock = $this->getMockBuilder(ValidatorFactory::class)
143-
->setMethods(['create'])
146+
->onlyMethods(['create'])
144147
->disableOriginalConstructor()
145148
->getMock();
146149
$this->groupCollectionFactoryMock = $this->getMockBuilder(CollectionFactory::class)
147-
->setMethods(['create'])
150+
->onlyMethods(['create'])
148151
->disableOriginalConstructor()
149152
->getMock();
150153
$this->redirectMock = $this->getMockBuilder(ResultRedirect::class)
151-
->setMethods(['setData', 'setPath'])
154+
->onlyMethods(['setPath'])
155+
->addMethods(['setData'])
152156
->disableOriginalConstructor()
153157
->getMock();
154158
$this->productAttributeMock = $this->getMockBuilder(ProductAttributeInterface::class)
155-
->setMethods(
159+
->onlyMethods(
160+
[
161+
'getBackendType',
162+
'getFrontendClass'
163+
]
164+
)->addMethods(
156165
[
157166
'getId',
158167
'get',
159168
'getBackendTypeByInput',
160169
'getDefaultValueByInput',
161-
'getBackendType',
162-
'getFrontendClass',
163170
'addData',
164171
'save'
165172
]
@@ -292,7 +299,9 @@ public function testExecute()
292299
'new_attribute_set_name' => 'Test attribute set name',
293300
'frontend_input' => 'test_frontend_input',
294301
];
295-
302+
$this->filterManagerMock
303+
->method('stripTags')
304+
->willReturn('Test attribute set name');
296305
$this->requestMock->expects($this->any())
297306
->method('getParam')
298307
->willReturnMap([

app/code/Magento/Catalog/Test/Unit/Model/Category/FileInfoTest.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,9 @@ function ($arg) use ($baseDirectory, $pubDirectory) {
116116
$this->pubDirectory->method('getAbsolutePath')
117117
->willReturn('/a/b/c/pub/');
118118

119+
$this->store->method('getBaseUrl')
120+
->willReturn('https://example.com/');
121+
119122
$this->model = new FileInfo(
120123
$this->filesystem,
121124
$this->mime,

app/code/Magento/CatalogImportExport/Test/Unit/Model/Import/Product/ValidatorTest.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
use Magento\CatalogImportExport\Model\Import\Product\Validator;
1313
use Magento\CatalogImportExport\Model\Import\Product\Validator\Media;
1414
use Magento\CatalogImportExport\Model\Import\Product\Validator\Website;
15+
use Magento\Framework\Stdlib\StringUtils;
1516
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager as ObjectManagerHelper;
1617
use Magento\ImportExport\Model\Import;
1718
use PHPUnit\Framework\MockObject\MockObject;
@@ -64,7 +65,10 @@ protected function setUp(): void
6465
$this->objectManagerHelper = new ObjectManagerHelper($this);
6566
$this->validator = $this->objectManagerHelper->getObject(
6667
Validator::class,
67-
['validators' => $this->validators]
68+
[
69+
'string' => new StringUtils(),
70+
'validators' => $this->validators
71+
]
6872
);
6973
$this->validator->init($this->context);
7074
}

app/code/Magento/Customer/Model/Metadata/Form/Text.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
<?php
22
/**
3-
* Form Element Text Data Model
4-
*
53
* Copyright © Magento, Inc. All rights reserved.
64
* See COPYING.txt for license details.
75
*/
@@ -126,7 +124,7 @@ private function validateLength($value, AttributeMetadataInterface $attribute, a
126124
// validate length
127125
$label = __($attribute->getStoreLabel());
128126

129-
$length = $this->_string->strlen(trim($value));
127+
$length = $value ? $this->_string->strlen(trim($value)) : 0;
130128

131129
$validateRules = $attribute->getValidationRules();
132130

app/code/Magento/Customer/Test/Unit/Block/Adminhtml/Edit/Tab/View/PersonalInfoTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,7 @@ public function getStoreLastLoginDateDataProvider()
246246
{
247247
return [
248248
['2015-03-04 12:00:00', '2015-03-04 12:00:00'],
249-
['Never', null]
249+
['Never', '']
250250
];
251251
}
252252

app/code/Magento/Customer/Test/Unit/Model/Metadata/Form/FileTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
*/
2828
class FileTest extends AbstractFormTestCase
2929
{
30-
const ENTITY_TYPE = 0;
30+
public const ENTITY_TYPE = 0;
3131

3232
/**
3333
* @var MockObject|EncoderInterface
@@ -130,7 +130,7 @@ public function testExtractValueNoRequestScope($expected, $attributeCode = '', $
130130
'entityTypeCode' => self::ENTITY_TYPE,
131131
]
132132
);
133-
133+
$model->setRequestScope('');
134134
$this->assertEquals($expected, $model->extractValue($this->requestMock));
135135
if (!empty($attributeCode)) {
136136
unset($_FILES[$attributeCode]);

app/code/Magento/Customer/Test/Unit/Model/Metadata/Form/MultiselectTest.php

Lines changed: 11 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1-
<?php declare(strict_types=1);
1+
<?php
22
/**
3-
* test Magento\Customer\Model\Metadata\Form\Multiselect
4-
*
53
* Copyright © Magento, Inc. All rights reserved.
64
* See COPYING.txt for license details.
75
*/
6+
7+
declare(strict_types=1);
8+
89
namespace Magento\Customer\Test\Unit\Model\Metadata\Form;
910

1011
use Magento\Customer\Api\Data\OptionInterface;
@@ -143,7 +144,7 @@ public function outputValueTextDataProvider()
143144
{
144145
return [
145146
'empty' => ['', ''],
146-
'null' => [null, ''],
147+
'null' => [false, ''],
147148
'number' => [14, 'fourteen'],
148149
'string' => ['some key', 'some string'],
149150
'array' => [[14, 'some key'], 'fourteen, some string'],
@@ -174,7 +175,7 @@ public function outputValueJsonDataProvider()
174175
{
175176
return [
176177
'empty' => ['', ['']],
177-
'null' => [null, ['']],
178+
'null' => [false, ['']],
178179
'number' => [14, ['14']],
179180
'string' => ['some key', ['some key']],
180181
'array' => [[14, 'some key'], ['14', 'some key']],
@@ -195,27 +196,21 @@ protected function runOutputValueTest($value, $expected, $format)
195196
->disableOriginalConstructor()
196197
->setMethods(['getLabel', 'getValue'])
197198
->getMockForAbstractClass();
198-
$option1->expects($this->any())
199-
->method('getLabel')
199+
$option1->method('getLabel')
200200
->willReturn('fourteen');
201-
$option1->expects($this->any())
202-
->method('getValue')
201+
$option1->method('getValue')
203202
->willReturn('14');
204203

205204
$option2 = $this->getMockBuilder(OptionInterface::class)
206205
->disableOriginalConstructor()
207206
->setMethods(['getLabel', 'getValue'])
208207
->getMockForAbstractClass();
209-
$option2->expects($this->any())
210-
->method('getLabel')
208+
$option2->method('getLabel')
211209
->willReturn('some string');
212-
$option2->expects($this->any())
213-
->method('getValue')
210+
$option2->method('getValue')
214211
->willReturn('some key');
215212

216-
$this->attributeMetadataMock->expects(
217-
$this->any()
218-
)->method(
213+
$this->attributeMetadataMock->method(
219214
'getOptions'
220215
)->willReturn(
221216
[

app/code/Magento/MediaStorage/Test/Unit/App/MediaTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,9 @@
3737
*/
3838
class MediaTest extends TestCase
3939
{
40-
const MEDIA_DIRECTORY = 'mediaDirectory';
41-
const RELATIVE_FILE_PATH = 'test/file.png';
42-
const CACHE_FILE_PATH = 'var';
40+
public const MEDIA_DIRECTORY = 'mediaDirectory';
41+
public const RELATIVE_FILE_PATH = 'test/file.png';
42+
public const CACHE_FILE_PATH = 'var';
4343

4444
/**
4545
* @var Media
@@ -264,7 +264,7 @@ protected function createMediaModel(bool $isAllowed = true): Media
264264
$this->syncFactoryMock,
265265
$this->responseMock,
266266
$isAllowedCallback,
267-
false,
267+
self::MEDIA_DIRECTORY,
268268
self::CACHE_FILE_PATH,
269269
self::RELATIVE_FILE_PATH,
270270
$this->filesystemMock,

app/code/Magento/Paypal/Test/Unit/Model/Api/NvpTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ public function callDataProvider()
197197
10417
198198
],
199199
[
200-
"\r\n" . 'ACK[7]=Failure&L_ERRORCODE0[5]=10417&L_SHORTMESSAGE0[8]=Message.',
200+
"\r\n" . 'ACK[7]=Failure&L_ERRORCODE0[5]=10417&L_SHORTMESSAGE0[8]=Message.&L_LONGMESSAGE0[15]=',
201201
[10417, 10422],
202202
ProcessableException::class,
203203
'PayPal gateway has rejected request. #10417: Message.',

app/code/Magento/Rule/Test/Unit/Model/Condition/Product/AbstractProductTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,7 @@ public function testValidateSetEntityAttributeValuesWithResource()
208208
->disableOriginalConstructor()
209209
->getMockForAbstractClass();
210210
$product->setAtribute('attribute');
211+
$product->setData('someAttribute', '');
211212
$product->setId(12);
212213

213214
$this->_configProperty->setValue(

0 commit comments

Comments
 (0)