Skip to content

Commit bbb7339

Browse files
committed
AC-1685: Fix Integration Tests to be compatible with PHP 8.1
- code style fixes - fix after code review
1 parent 9ab9cd3 commit bbb7339

File tree

5 files changed

+31
-32
lines changed

5 files changed

+31
-32
lines changed

app/code/Magento/ReleaseNotification/Model/Condition/CanViewNotification.php

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -82,11 +82,9 @@ public function isVisible(array $arguments)
8282
$value = $this->cacheStorage->load($cacheKey);
8383

8484
if ($value === false) {
85-
$value = version_compare(
86-
$this->viewerLogger->get($userId)->getLastViewVersion() ?? '',
87-
$this->productMetadata->getVersion(),
88-
'<'
89-
);
85+
$lastViewVersion = $this->viewerLogger->get($userId)->getLastViewVersion();
86+
$value = ($lastViewVersion) ?
87+
version_compare($lastViewVersion, $this->productMetadata->getVersion(), '<') : true;
9088
$this->cacheStorage->save(false, $cacheKey);
9189
}
9290
return (bool)$value;

app/code/Magento/ReleaseNotification/Test/Unit/Model/Condition/CanViewNotificationTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ public function testIsVisible($expected, $version, $lastViewVersion)
9898
$this->sessionMock->expects($this->once())
9999
->method('getId')
100100
->willReturn(1);
101-
$this->productMetadataMock->expects($this->once())
101+
$this->productMetadataMock->expects($this->any())
102102
->method('getVersion')
103103
->willReturn($version);
104104
$this->logMock->expects($this->once())

app/code/Magento/Widget/Model/ResourceModel/Widget/Instance.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ protected function _afterSave(AbstractModel $object)
8989
if (in_array($pageGroup['page_id'], $pageIds)) {
9090
$connection->update($pageTable, $data, ['page_id = ?' => (int)$pageId]);
9191
} else {
92+
// phpcs:ignore Magento2.Performance.ForeachArrayMerge
9293
$connection->insert($pageTable, array_merge(['instance_id' => $object->getId()], $data));
9394
$pageId = $connection->lastInsertId($pageTable);
9495
}
@@ -147,6 +148,7 @@ protected function _saveLayoutUpdates($widgetInstance, $pageGroupData)
147148

148149
/**
149150
* Prepare store ids.
151+
*
150152
* If one of store id is default (0) return all store ids
151153
*
152154
* @param array $storeIds
@@ -162,6 +164,7 @@ protected function _prepareStoreIds($storeIds)
162164

163165
/**
164166
* Perform actions before object delete.
167+
*
165168
* Collect page ids and layout update ids and set to object for further delete
166169
*
167170
* @param \Magento\Framework\Model\AbstractModel $object
@@ -188,6 +191,7 @@ protected function _beforeDelete(AbstractModel $object)
188191

189192
/**
190193
* Perform actions after object delete.
194+
*
191195
* Delete layout updates by layout update ids collected in _beforeSave
192196
*
193197
* @param \Magento\Widget\Model\Widget\Instance $object

lib/internal/Magento/Framework/Code/Reader/ArgumentsReader.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ class ArgumentsReader
1414
{
1515
use GetParameterClassTrait;
1616

17-
const NO_DEFAULT_VALUE = 'NO-DEFAULT';
17+
public const NO_DEFAULT_VALUE = 'NO-DEFAULT';
1818

1919
/**
2020
* @var NamespaceResolver

lib/internal/Magento/Framework/View/Page/Config.php

Lines changed: 22 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
use Magento\Framework\View;
1212
use Magento\Framework\Escaper;
1313
use Magento\Framework\App\ObjectManager;
14+
use Magento\Store\Model\ScopeInterface;
1415

1516
/**
1617
* An API for page configuration
@@ -33,29 +34,29 @@ class Config
3334
/**#@+
3435
* Constants of available types
3536
*/
36-
const ELEMENT_TYPE_BODY = 'body';
37-
const ELEMENT_TYPE_HTML = 'html';
38-
const ELEMENT_TYPE_HEAD = 'head';
37+
public const ELEMENT_TYPE_BODY = 'body';
38+
public const ELEMENT_TYPE_HTML = 'html';
39+
public const ELEMENT_TYPE_HEAD = 'head';
3940
/**#@-*/
4041

41-
const META_DESCRIPTION = 'description';
42-
const META_CONTENT_TYPE = 'content_type';
43-
const META_MEDIA_TYPE = 'media_type';
44-
const META_CHARSET = 'charset';
45-
const META_TITLE = 'title';
46-
const META_KEYWORDS = 'keywords';
47-
const META_ROBOTS = 'robots';
48-
const META_X_UI_COMPATIBLE = 'x_ua_compatible';
42+
public const META_DESCRIPTION = 'description';
43+
public const META_CONTENT_TYPE = 'content_type';
44+
public const META_MEDIA_TYPE = 'media_type';
45+
public const META_CHARSET = 'charset';
46+
public const META_TITLE = 'title';
47+
public const META_KEYWORDS = 'keywords';
48+
public const META_ROBOTS = 'robots';
49+
public const META_X_UI_COMPATIBLE = 'x_ua_compatible';
4950

5051
/**
5152
* Constant body attribute class
5253
*/
53-
const BODY_ATTRIBUTE_CLASS = 'class';
54+
public const BODY_ATTRIBUTE_CLASS = 'class';
5455

5556
/**
5657
* Constant html language attribute
5758
*/
58-
const HTML_ATTRIBUTE_LANG = 'lang';
59+
public const HTML_ATTRIBUTE_LANG = 'lang';
5960

6061
/**
6162
* @var Escaper
@@ -321,7 +322,7 @@ public function getMediaType()
321322
if (empty($this->metadata[self::META_MEDIA_TYPE])) {
322323
$this->metadata[self::META_MEDIA_TYPE] = $this->scopeConfig->getValue(
323324
'design/head/default_media_type',
324-
\Magento\Store\Model\ScopeInterface::SCOPE_STORE
325+
ScopeInterface::SCOPE_STORE
325326
);
326327
}
327328
return $this->metadata[self::META_MEDIA_TYPE];
@@ -349,7 +350,7 @@ public function getCharset()
349350
if (empty($this->metadata[self::META_CHARSET])) {
350351
$this->metadata[self::META_CHARSET] = $this->scopeConfig->getValue(
351352
'design/head/default_charset',
352-
\Magento\Store\Model\ScopeInterface::SCOPE_STORE
353+
ScopeInterface::SCOPE_STORE
353354
);
354355
}
355356
return $this->metadata[self::META_CHARSET];
@@ -377,7 +378,7 @@ public function getDescription()
377378
if (empty($this->metadata[self::META_DESCRIPTION])) {
378379
$this->metadata[self::META_DESCRIPTION] = $this->scopeConfig->getValue(
379380
'design/head/default_description',
380-
\Magento\Store\Model\ScopeInterface::SCOPE_STORE
381+
ScopeInterface::SCOPE_STORE
381382
);
382383
}
383384
return $this->metadata[self::META_DESCRIPTION];
@@ -432,7 +433,7 @@ public function getKeywords()
432433
if (empty($this->metadata[self::META_KEYWORDS])) {
433434
$this->metadata[self::META_KEYWORDS] = $this->scopeConfig->getValue(
434435
'design/head/default_keywords',
435-
\Magento\Store\Model\ScopeInterface::SCOPE_STORE
436+
ScopeInterface::SCOPE_STORE
436437
);
437438
}
438439
return $this->metadata[self::META_KEYWORDS];
@@ -464,7 +465,7 @@ public function getRobots()
464465
if (empty($this->metadata[self::META_ROBOTS])) {
465466
$this->metadata[self::META_ROBOTS] = $this->scopeConfig->getValue(
466467
'design/search_engine_robots/default_robots',
467-
\Magento\Store\Model\ScopeInterface::SCOPE_STORE
468+
ScopeInterface::SCOPE_STORE
468469
);
469470
}
470471
return $this->metadata[self::META_ROBOTS];
@@ -651,12 +652,8 @@ public function getDefaultFavicon()
651652
*/
652653
public function getIncludes()
653654
{
654-
if (empty($this->includes) && $this->isIncludesAvailable) {
655-
$this->includes = $this->scopeConfig->getValue(
656-
'design/head/includes',
657-
\Magento\Store\Model\ScopeInterface::SCOPE_STORE
658-
);
659-
}
660-
return $this->includes ?? '';
655+
$this->includes = ($this->isIncludesAvailable && $this->includes === null) ?
656+
$this->scopeConfig->getValue('design/head/includes', ScopeInterface::SCOPE_STORE) : '';
657+
return $this->includes;
661658
}
662659
}

0 commit comments

Comments
 (0)