Skip to content

Commit ae5f83b

Browse files
committed
Merge remote-tracking branch 'anzin/fix-deprecation-unit' into ph-delivery
2 parents 282b23b + 00641d0 commit ae5f83b

File tree

11 files changed

+62
-63
lines changed

11 files changed

+62
-63
lines changed

app/code/Magento/Backend/Test/Unit/Block/Widget/Grid/Column/Renderer/CurrencyTest.php

Lines changed: 19 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ protected function setUp(): void
7272

7373
$this->_curLocatorMock = $this->createMock(DefaultLocator::class);
7474
$this->_columnMock = $this->getMockBuilder(Column::class)
75-
->addMethods(['getIndex'])
75+
->addMethods(['getIndex', 'getCurrency', 'getRateField'])
7676
->disableOriginalConstructor()
7777
->getMock();
7878
$this->_columnMock->expects($this->any())->method('getIndex')->willReturn('columnIndex');
@@ -115,45 +115,25 @@ protected function tearDown(): void
115115
*/
116116
public function testRenderWithDefaultCurrency()
117117
{
118-
$this->_currencyMock->expects(
119-
$this->once()
120-
)->method(
121-
'getRate'
122-
)->with(
123-
'defaultCurrency'
124-
)->willReturn(
125-
1.5
126-
);
127-
128-
$this->_curLocatorMock->expects(
129-
$this->any()
130-
)->method(
131-
'getDefaultCurrency'
132-
)->with(
133-
$this->_requestMock
134-
)->willReturn(
135-
'defaultCurrency'
136-
);
137-
118+
$this->_currencyMock->expects($this->once())
119+
->method('getRate')
120+
->with('defaultCurrency')
121+
->willReturn(1.5);
122+
$this->_curLocatorMock->expects($this->any())
123+
->method('getDefaultCurrency')
124+
->with($this->_requestMock)
125+
->willReturn('defaultCurrency');
138126
$currLocaleMock = $this->createMock(\Zend_Currency::class);
139-
$currLocaleMock->expects(
140-
$this->once()
141-
)->method(
142-
'toCurrency'
143-
)->with(
144-
15.0000
145-
)->willReturn(
146-
'15USD'
147-
);
148-
$this->_localeMock->expects(
149-
$this->once()
150-
)->method(
151-
'getCurrency'
152-
)->with(
153-
'defaultCurrency'
154-
)->willReturn(
155-
$currLocaleMock
156-
);
127+
$currLocaleMock->expects($this->once())
128+
->method('toCurrency')
129+
->with(15.0000)
130+
->willReturn('15USD');
131+
$this->_localeMock->expects($this->once())
132+
->method('getCurrency')
133+
->with('defaultCurrency')
134+
->willReturn($currLocaleMock);
135+
$this->_columnMock->method('getCurrency')->willReturn('USD');
136+
$this->_columnMock->method('getRateField')->willReturn('test_rate_field');
157137

158138
$this->assertEquals('15USD', $this->_blockCurrency->render($this->_row));
159139
}

app/code/Magento/Bundle/Test/Unit/Model/Product/TypeTest.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2786,7 +2786,9 @@ public function notAvailableOptionProvider(): array
27862786
private function expectProductEntityMetadata(): void
27872787
{
27882788
$entityMetadataMock = $this->getMockBuilder(EntityMetadataInterface::class)
2789+
->onlyMethods(['getLinkField'])
27892790
->getMockForAbstractClass();
2791+
$entityMetadataMock->method('getLinkField')->willReturn('test_link_field');
27902792
$this->metadataPool->expects($this->any())->method('getMetadata')
27912793
->with(ProductInterface::class)
27922794
->willReturn($entityMetadataMock);

app/code/Magento/Catalog/Test/Unit/Block/Widget/LinkTest.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
use Magento\Catalog\Model\ResourceModel\AbstractResource;
1313
use Magento\CatalogUrlRewrite\Model\ProductUrlRewriteGenerator;
1414
use Magento\Framework\App\Config\ReinitableConfigInterface;
15+
use Magento\Framework\App\Config\ScopeConfigInterface;
1516
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
1617
use Magento\Framework\Url;
1718
use Magento\Framework\Url\ModifierInterface;
@@ -178,6 +179,7 @@ public function testStoreCodeShouldBeIncludedInURLOnlyIfItIsConfiguredSo(
178179
->willReturnMap(
179180
[
180181
[Store::XML_PATH_USE_REWRITES, ReinitableConfigInterface::SCOPE_TYPE_DEFAULT, null, true],
182+
[Store::XML_PATH_UNSECURE_BASE_LINK_URL, ScopeConfigInterface::SCOPE_TYPE_DEFAULT, null, ''],
181183
[
182184
Store::XML_PATH_STORE_IN_URL,
183185
ReinitableConfigInterface::SCOPE_TYPE_DEFAULT,

app/code/Magento/Catalog/Test/Unit/Model/Category/Attribute/Backend/ImageTest.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -325,6 +325,7 @@ public function testBeforeSaveTemporaryAttribute()
325325
*/
326326
public function testBeforeSaveAttributeStringValue()
327327
{
328+
$this->attribute->method('getName')->willReturn('test_attribute_name');
328329
$model = $this->objectManager->getObject(Image::class);
329330
$model->setAttribute($this->attribute);
330331

@@ -392,6 +393,7 @@ public function attributeValueDataProvider()
392393
*/
393394
public function testBeforeSaveWithAdditionalData($value)
394395
{
396+
$this->attribute->method('getName')->willReturn('test_attribute_name');
395397
$model = $this->setUpModelForTests();
396398

397399
$this->imageUploader->expects($this->never())
@@ -416,6 +418,7 @@ public function testBeforeSaveWithAdditionalData($value)
416418
*/
417419
public function testBeforeSaveWithoutAdditionalData($value)
418420
{
421+
$this->attribute->method('getName')->willReturn('test_attribute_name');
419422
$model = $this->setUpModelForTests();
420423

421424
$this->imageUploader->expects($this->never())

app/code/Magento/Config/Test/Unit/Block/System/Config/Form/Field/Select/AllowspecificTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ function (string $tag, array $attributes, string $content): string {
5959
'secureRenderer' => $secureRendererMock
6060
]
6161
);
62-
$this->_object->setData('html_id', 'spec_element');
62+
$this->_object->setId('spec_element');
6363
$this->_formMock = $this->getMockBuilder(Form::class)
6464
->addMethods(['getHtmlIdPrefix', 'getHtmlIdSuffix'])
6565
->onlyMethods(['getElement'])

app/code/Magento/Customer/Test/Unit/Model/ResourceModel/GroupTest.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,8 @@ public function testSaveWithReservedId()
131131
->willReturn([]);
132132
$this->groupModel->expects($this->once())->method('setId')
133133
->with($expectedId);
134+
$this->groupModel->expects($this->once())->method('getCode')
135+
->willReturn('customer_group_code');
134136

135137
$dbAdapter = $this->getMockBuilder(AdapterInterface::class)
136138
->disableOriginalConstructor()

app/code/Magento/Usps/Model/Carrier.php

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -28,45 +28,45 @@
2828
class Carrier extends AbstractCarrierOnline implements \Magento\Shipping\Model\Carrier\CarrierInterface
2929
{
3030
/** @deprecated Redundant dependency */
31-
const CONTAINER_VARIABLE = 'VARIABLE';
31+
public const CONTAINER_VARIABLE = 'VARIABLE';
3232

3333
/** @deprecated Redundant dependency */
34-
const CONTAINER_FLAT_RATE_BOX = 'FLAT RATE BOX';
34+
public const CONTAINER_FLAT_RATE_BOX = 'FLAT RATE BOX';
3535

3636
/** @deprecated Redundant dependency */
37-
const CONTAINER_FLAT_RATE_ENVELOPE = 'FLAT RATE ENVELOPE';
37+
public const CONTAINER_FLAT_RATE_ENVELOPE = 'FLAT RATE ENVELOPE';
3838

3939
/** @deprecated Redundant dependency */
40-
const CONTAINER_RECTANGULAR = 'RECTANGULAR';
40+
public const CONTAINER_RECTANGULAR = 'RECTANGULAR';
4141

4242
/** @deprecated Redundant dependency */
43-
const CONTAINER_NONRECTANGULAR = 'NONRECTANGULAR';
43+
public const CONTAINER_NONRECTANGULAR = 'NONRECTANGULAR';
4444

4545
/**
4646
* USPS size
4747
*/
48-
const SIZE_REGULAR = 'REGULAR';
48+
public const SIZE_REGULAR = 'REGULAR';
4949

50-
const SIZE_LARGE = 'LARGE';
50+
public const SIZE_LARGE = 'LARGE';
5151

5252
/**
5353
* Default api revision
5454
*
5555
* @var int
5656
*/
57-
const DEFAULT_REVISION = 2;
57+
public const DEFAULT_REVISION = 2;
5858

5959
/**
6060
* Code of the carrier
6161
*
6262
* @var string
6363
*/
64-
const CODE = 'usps';
64+
public const CODE = 'usps';
6565

6666
/**
6767
* Ounces in one pound for conversion
6868
*/
69-
const OUNCES_POUND = 16;
69+
public const OUNCES_POUND = 16;
7070

7171
/**
7272
* Code of the carrier
@@ -492,7 +492,10 @@ protected function _getXmlQuotes()
492492
}
493493
$package->addChild('ZipOrigination', $r->getOrigPostal());
494494
//only 5 chars available
495-
$package->addChild('ZipDestination', substr($r->getDestPostal(), 0, 5));
495+
$package->addChild(
496+
'ZipDestination',
497+
is_string($r->getDestPostal()) ? substr($r->getDestPostal(), 0, 5) : ''
498+
);
496499
$package->addChild('Pounds', $r->getWeightPounds());
497500
$package->addChild('Ounces', $r->getWeightOunces());
498501
// Because some methods don't accept VARIABLE and (NON)RECTANGULAR containers
@@ -1195,11 +1198,8 @@ public function getResponse()
11951198
}
11961199
}
11971200
}
1198-
if (empty($statuses)) {
1199-
$statuses = __('Empty response');
1200-
}
12011201

1202-
return $statuses;
1202+
return $statuses ?: __('Empty response');
12031203
}
12041204

12051205
/**

app/code/Magento/Widget/Test/Unit/Block/Adminhtml/Widget/Catalog/Category/ChooserTest.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,12 +83,12 @@ protected function setUp(): void
8383

8484
$this->childNode = $this->getMockBuilder(Node::class)
8585
->addMethods(['getLevel'])
86-
->onlyMethods(['hasChildren'])
86+
->onlyMethods(['hasChildren', 'getIdField'])
8787
->disableOriginalConstructor()
8888
->getMock();
8989
$this->rootNode = $this->getMockBuilder(Node::class)
9090
->addMethods(['getLevel'])
91-
->onlyMethods(['hasChildren', 'getChildren'])
91+
->onlyMethods(['hasChildren', 'getChildren', 'getIdField'])
9292
->disableOriginalConstructor()
9393
->getMock();
9494
$this->categoryTree = $this->createMock(Tree::class);
@@ -115,6 +115,8 @@ public function testGetTreeHasLevelField()
115115
]
116116
);
117117

118+
$this->rootNode->method('getIdField')->willReturn('test_id_field');
119+
$this->childNode->method('getIdField')->willReturn('test_id_field');
118120
$this->childNode->expects($this->atLeastOnce())->method('getLevel')->willReturn($level);
119121

120122
$this->rootNode->expects($this->atLeastOnce())->method('getLevel')->willReturn($rootLevel);

app/code/Magento/Wishlist/Test/Unit/Model/WishlistTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,8 @@ public function testLoadByCustomerId()
233233
$this->eventDispatcher->expects($this->any())
234234
->method('dispatch');
235235
$this->resource->expects($this->any())
236-
->method('getCustomerIdFieldName');
236+
->method('getCustomerIdFieldName')
237+
->willReturn('test_customer_id');
237238
$this->resource->expects($this->once())
238239
->method('load')
239240
->with($this->logicalOr($this->wishlist, $customerId, $customerIdFieldName));

lib/internal/Magento/Framework/App/Response/Http.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,13 @@
2323
class Http extends \Magento\Framework\HTTP\PhpEnvironment\Response
2424
{
2525
/** Cookie to store page vary string */
26-
const COOKIE_VARY_STRING = 'X-Magento-Vary';
26+
public const COOKIE_VARY_STRING = 'X-Magento-Vary';
2727

2828
/** Format for expiration timestamp headers */
29-
const EXPIRATION_TIMESTAMP_FORMAT = 'D, d M Y H:i:s T';
29+
public const EXPIRATION_TIMESTAMP_FORMAT = 'D, d M Y H:i:s T';
3030

3131
/** X-FRAME-OPTIONS Header name */
32-
const HEADER_X_FRAME_OPT = 'X-Frame-Options';
32+
public const HEADER_X_FRAME_OPT = 'X-Frame-Options';
3333

3434
/**
3535
* @var \Magento\Framework\App\Request\Http
@@ -131,7 +131,7 @@ public function sendVary()
131131
*/
132132
public function setPublicHeaders($ttl)
133133
{
134-
if ($ttl < 0 || !preg_match('/^[0-9]+$/', $ttl)) {
134+
if ($ttl === null || $ttl < 0 || !preg_match('/^[0-9]+$/', $ttl)) {
135135
throw new \InvalidArgumentException('Time to live is a mandatory parameter for set public headers');
136136
}
137137
$this->setHeader('pragma', 'cache', true);

0 commit comments

Comments
 (0)