Skip to content

Commit 918b682

Browse files
committed
Merge branch 'v1-develop' into v1
2 parents 30f3b12 + 4244bae commit 918b682

File tree

13 files changed

+3711
-2057
lines changed

13 files changed

+3711
-2057
lines changed

.gitignore

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1-
.php_cs.cache
2-
auth.json
1+
/.php-cs-fixer.cache
2+
/auth.json
3+
/Test/.phpunit.result.cache
34
/vendor/

.php_cs renamed to .php-cs-fixer.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@
55
->exclude('vendor')
66
;
77

8-
return PhpCsFixer\Config::create()
8+
$config = new PhpCsFixer\Config();
9+
return $config
910
->setRules([
1011
'@Symfony' => true,
1112
'@PSR12' => true,
12-
'array_syntax' => ['syntax' => 'short'],
1313
'binary_operator_spaces' => ['default' => null, 'operators' => ['=>' => 'align']],
1414
'concat_space' => ['spacing' => 'one'],
1515
'declare_strict_types' => true,
@@ -27,8 +27,8 @@
2727
'phpdoc_summary' => false,
2828
'self_accessor' => true,
2929
'single_line_throw' => false,
30-
'visibility_required' => ['property', 'method'], // removed 'const' since we still support PHP 7.0 for now
31-
'yoda_style' => null,
30+
'visibility_required' => ['elements' => ['property', 'method']], // removed 'const' since we still support PHP 7.0 for now
31+
'yoda_style' => false,
3232
])
3333
->setFinder($finder)
3434
;

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
}

Makefile

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@ check: checkstyle checkquality test
1111
.PHONY: checkstyle
1212
checkstyle:
1313
vendor/bin/php-cs-fixer fix --dry-run --diff --stop-on-violation --allow-risky=yes
14-
vendor/bin/phpcs --standard=Magento2 --ignore=./vendor/ .
15-
vendor/bin/phpcs --standard=PHPCompatibility --runtime-set testVersion 7.0- --ignore=./vendor/,./Test/ .
16-
vendor/bin/phpcs --standard=PHPCompatibility --runtime-set testVersion 7.1- ./Test/
14+
vendor/bin/phpcs -s --standard=Magento2 --ignore=./vendor/ .
15+
vendor/bin/phpcs -s --standard=PHPCompatibility --runtime-set testVersion 7.0- --ignore=./vendor/,./Test/ .
16+
vendor/bin/phpcs -s --standard=PHPCompatibility --runtime-set testVersion 7.1- ./Test/
1717
composer normalize --dry-run
1818

1919
.PHONY: checkquality
@@ -39,4 +39,4 @@ checkquality:
3939

4040
.PHONY: test
4141
test:
42-
vendor/bin/phpunit Test/
42+
vendor/bin/phpunit -c Test/phpunit.xml Test/

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')

Test/bootstrap.php

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<?php
2+
3+
// took some inspiration from: https://magento.stackexchange.com/a/116987/2911
4+
5+
declare(strict_types=1);
6+
7+
use Magento\Framework\Code\Generator\Io;
8+
use Magento\Framework\Filesystem\Driver\File;
9+
use Magento\Framework\TestFramework\Unit\Autoloader\ExtensionAttributesGenerator;
10+
use Magento\Framework\TestFramework\Unit\Autoloader\ExtensionAttributesInterfaceGenerator;
11+
use Magento\Framework\TestFramework\Unit\Autoloader\FactoryGenerator;
12+
use Magento\Framework\TestFramework\Unit\Autoloader\GeneratedClassesAutoloader;
13+
14+
$generatorIo = new Io(
15+
new File(),
16+
org\bovigo\vfs\vfsStream::setup('my_generated_classes')->url()
17+
);
18+
$generatedCodeAutoloader = new GeneratedClassesAutoloader(
19+
[
20+
new ExtensionAttributesGenerator(),
21+
new ExtensionAttributesInterfaceGenerator(),
22+
new FactoryGenerator(),
23+
],
24+
$generatorIo
25+
);
26+
spl_autoload_register([$generatedCodeAutoloader, 'load']);

Test/phpunit.xml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/9.5/phpunit.xsd"
4+
colors="true"
5+
columns="max"
6+
bootstrap="./bootstrap.php"
7+
>
8+
</phpunit>

composer.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,15 @@
2121
"symfony/console": "^2.5 || ^3.0 || ^4.0 || ^5.0"
2222
},
2323
"require-dev": {
24-
"bitexpert/phpstan-magento": "^0.7.0",
24+
"bitexpert/phpstan-magento": "^0.9.0",
2525
"ergebnis/composer-normalize": "^2.2",
26-
"friendsofphp/php-cs-fixer": "^2.18",
26+
"friendsofphp/php-cs-fixer": "^3.0",
2727
"magento/magento-coding-standard": "^6.0",
28+
"mikey179/vfsstream": "^1.6",
2829
"phpcompatibility/php-compatibility": "^9.2",
2930
"phpstan/extension-installer": "^1.0",
3031
"phpstan/phpstan": "^0.12.26",
32+
"phpstan/phpstan-deprecation-rules": "^0.12.6",
3133
"phpunit/phpunit": "^9.0"
3234
},
3335
"config": {

0 commit comments

Comments
 (0)