Skip to content

Commit aa47d04

Browse files
committed
No longer using deprecated functionality.
1 parent 2159e47 commit aa47d04

File tree

6 files changed

+29
-26
lines changed

6 files changed

+29
-26
lines changed

Controller/Adminhtml/Catalog/Category/UrlKey/Refresh.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public function execute()
3535
$scheduled = $this->scheduleJob->schedule(CheckCategoryUrlKeyCron::JOB_NAME);
3636

3737
if ($scheduled) {
38-
$this->getMessageManager()->addSuccess(
38+
$this->getMessageManager()->addSuccessMessage(
3939
(string) __(
4040
'The refresh job was scheduled, please check back in a few moments to see the updated results'
4141
)
@@ -45,10 +45,10 @@ public function execute()
4545
$storageIdentifier = UrlKeyChecker::STORAGE_IDENTIFIER;
4646
$this->metaStorage->setPending($storageIdentifier, MetaStorage::INITIATOR_CRON);
4747
} catch (AlreadyRefreshingException $ex) {
48-
$this->getMessageManager()->addError($ex->getMessage());
48+
$this->getMessageManager()->addErrorMessage($ex->getMessage());
4949
}
5050
} else {
51-
$this->getMessageManager()->addError(
51+
$this->getMessageManager()->addErrorMessage(
5252
(string) __('Couldn\'t schedule refreshing due to some unknown error')
5353
);
5454
}

Controller/Adminhtml/Catalog/Category/UrlPath/Refresh.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public function execute()
3535
$scheduled = $this->scheduleJob->schedule(CheckCategoryUrlPathCron::JOB_NAME);
3636

3737
if ($scheduled) {
38-
$this->getMessageManager()->addSuccess(
38+
$this->getMessageManager()->addSuccessMessage(
3939
(string) __(
4040
'The refresh job was scheduled, please check back in a few moments to see the updated results'
4141
)
@@ -45,10 +45,10 @@ public function execute()
4545
$storageIdentifier = UrlPathChecker::STORAGE_IDENTIFIER;
4646
$this->metaStorage->setPending($storageIdentifier, MetaStorage::INITIATOR_CRON);
4747
} catch (AlreadyRefreshingException $ex) {
48-
$this->getMessageManager()->addError($ex->getMessage());
48+
$this->getMessageManager()->addErrorMessage($ex->getMessage());
4949
}
5050
} else {
51-
$this->getMessageManager()->addError(
51+
$this->getMessageManager()->addErrorMessage(
5252
(string) __('Couldn\'t schedule refreshing due to some unknown error')
5353
);
5454
}

Controller/Adminhtml/Catalog/Product/UrlKey/Refresh.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public function execute()
3535
$scheduled = $this->scheduleJob->schedule(CheckProductUrlKeyCron::JOB_NAME);
3636

3737
if ($scheduled) {
38-
$this->getMessageManager()->addSuccess(
38+
$this->getMessageManager()->addSuccessMessage(
3939
(string) __(
4040
'The refresh job was scheduled, please check back in a few moments to see the updated results'
4141
)
@@ -45,10 +45,10 @@ public function execute()
4545
$storageIdentifier = UrlKeyChecker::STORAGE_IDENTIFIER;
4646
$this->metaStorage->setPending($storageIdentifier, MetaStorage::INITIATOR_CRON);
4747
} catch (AlreadyRefreshingException $ex) {
48-
$this->getMessageManager()->addError($ex->getMessage());
48+
$this->getMessageManager()->addErrorMessage($ex->getMessage());
4949
}
5050
} else {
51-
$this->getMessageManager()->addError(
51+
$this->getMessageManager()->addErrorMessage(
5252
(string) __('Couldn\'t schedule refreshing due to some unknown error')
5353
);
5454
}

Controller/Adminhtml/Catalog/Product/UrlPath/Refresh.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public function execute()
3535
$scheduled = $this->scheduleJob->schedule(CheckProductUrlPathCron::JOB_NAME);
3636

3737
if ($scheduled) {
38-
$this->getMessageManager()->addSuccess(
38+
$this->getMessageManager()->addSuccessMessage(
3939
(string) __(
4040
'The refresh job was scheduled, please check back in a few moments to see the updated results'
4141
)
@@ -45,10 +45,10 @@ public function execute()
4545
$storageIdentifier = UrlPathChecker::STORAGE_IDENTIFIER;
4646
$this->metaStorage->setPending($storageIdentifier, MetaStorage::INITIATOR_CRON);
4747
} catch (AlreadyRefreshingException $ex) {
48-
$this->getMessageManager()->addError($ex->getMessage());
48+
$this->getMessageManager()->addErrorMessage($ex->getMessage());
4949
}
5050
} else {
51-
$this->getMessageManager()->addError(
51+
$this->getMessageManager()->addErrorMessage(
5252
(string) __('Couldn\'t schedule refreshing due to some unknown error')
5353
);
5454
}

Test/Checker/Catalog/Product/UrlKey/DuplicateUrlKeyTest.php

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -12,20 +12,11 @@
1212
use Magento\Catalog\Model\ResourceModel\Product\Collection as ProductCollection;
1313
use Magento\Catalog\Model\ResourceModel\Product\CollectionFactory as ProductCollectionFactory;
1414
use Magento\Framework\DataObject;
15-
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager as ObjectManagerHelper;
1615
use PHPUnit\Framework\MockObject\MockObject;
1716
use PHPUnit\Framework\TestCase;
1817

1918
class DuplicateUrlKeyTest extends TestCase
2019
{
21-
/** @var ObjectManagerHelper */
22-
private $objectManagerHelper;
23-
24-
protected function setUp(): void
25-
{
26-
$this->objectManagerHelper = new ObjectManagerHelper($this);
27-
}
28-
2920
/**
3021
* @dataProvider duplicatedProductUrlKeyValuesDataProvider
3122
*
@@ -57,8 +48,12 @@ function ($productData) use ($storeId) {
5748
$collectionsPerStoreId = array_map(
5849
function ($productsData) {
5950
/** @var MockObject $productCollectionMock */
60-
$productCollectionMock = $this->objectManagerHelper
61-
->getCollectionMock(ProductCollection::class, $productsData);
51+
$productCollectionMock = $this->getMockBuilder(ProductCollection::class)
52+
->disableOriginalConstructor()
53+
->getMock();
54+
$productCollectionMock->expects($this->any())
55+
->method('getIterator')
56+
->will($this->returnValue(new \ArrayIterator($productsData)));
6257

6358
$productCollectionMock->expects($this->once())
6459
->method('setStoreId')
@@ -97,7 +92,7 @@ function ($productsData) {
9792
$productCollectionFactoryMock = $this
9893
->getMockBuilder(ProductCollectionFactory::class)
9994
->disableOriginalConstructor()
100-
->setMethods(['create'])
95+
->onlyMethods(['create'])
10196
->getMock();
10297

10398
$productCollectionFactoryMock->expects($this->exactly(count($storeIds)))
@@ -118,7 +113,7 @@ function ($productsData) {
118113
$attributeScopeOverriddenValueFactoryMock = $this
119114
->getMockBuilder(AttributeScopeOverriddenValueFactory::class)
120115
->disableOriginalConstructor()
121-
->setMethods(['create'])
116+
->onlyMethods(['create'])
122117
->getMock();
123118
$attributeScopeOverriddenValueFactoryMock->expects($this->exactly(count($dbData)))
124119
->method('create')

phpstan.neon

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,12 @@ parameters:
99
- %currentWorkingDirectory%/vendor/*
1010
ignoreErrors:
1111
- '/ has no return typehint specified./'
12-
- '/Use service contracts to persist entities in favour of Magento\\Cron\\Model\\Schedule\:\:save\(\) method/'
12+
13+
- message: '/Use service contracts to persist entities in favour of Magento\\Cron\\Model\\Schedule\:\:save\(\) method/'
14+
path: Cron/ScheduleJob.php
15+
16+
- message: '/Call to deprecated method save\(\) of class Magento\\Framework\\Model\\AbstractModel/'
17+
path: Cron/ScheduleJob.php
18+
19+
- message: '/Parameter \#1 \$autoload_function of function spl_autoload_register expects callable\(string\)\: void, array\(Magento\\Framework\\TestFramework\\Unit\\Autoloader\\GeneratedClassesAutoloader/'
20+
path: Test/bootstrap.php

0 commit comments

Comments
 (0)