Skip to content

Commit 2159e47

Browse files
committed
Preparation for getting rid of deprecated method calls. The bootstrap test file addition is needed to auto-generate Factories which we will need after getting rid of the deprecated 'setMethods' call in the phpunit tests (see next commit).
1 parent 05dc713 commit 2159e47

File tree

6 files changed

+143
-4
lines changed

6 files changed

+143
-4
lines changed

.gitignore

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

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -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/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: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,11 @@
2525
"ergebnis/composer-normalize": "^2.2",
2626
"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": {

composer.lock

Lines changed: 103 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)