diff --git a/.github/dependabot.yaml b/.github/dependabot.yaml
new file mode 100644
index 000000000..661f797ca
--- /dev/null
+++ b/.github/dependabot.yaml
@@ -0,0 +1,23 @@
+# https://docs.github.com/en/github/administering-a-repository/configuration-options-for-dependency-updates
+
+version: 2
+
+updates:
+ - commit-message:
+ include: "scope"
+ prefix: "composer"
+ directory: "/"
+ open-pull-requests-limit: 10
+ package-ecosystem: "composer"
+ schedule:
+ interval: "weekly"
+ versioning-strategy: "widen"
+
+ - commit-message:
+ include: "scope"
+ prefix: "github-actions"
+ directory: "/"
+ open-pull-requests-limit: 10
+ package-ecosystem: "github-actions"
+ schedule:
+ interval: "weekly"
diff --git a/.github/workflows/diagnostics.yml b/.github/workflows/diagnostics.yml
index 7f7bca80e..afc3477c8 100644
--- a/.github/workflows/diagnostics.yml
+++ b/.github/workflows/diagnostics.yml
@@ -13,8 +13,8 @@ jobs:
strategy:
fail-fast: false
matrix:
- php: [ '8.2', '8.3' ]
- contao: [ '~5.3.0' ]
+ php: [ '8.4', '8.5' ]
+ contao: [ '~5.7.0' ]
phpcq_install: [ 'update' ]
output: [ '-o github-action -o default' ]
diff --git a/.gitignore b/.gitignore
index e27324c56..42f0380e6 100644
--- a/.gitignore
+++ b/.gitignore
@@ -18,5 +18,6 @@ composer.lock
# build
/.cache
/.phpunit.result.cache
+/.phpunit.cache
/.pdepend/*
/.phpcq/*
diff --git a/.phpcq.lock b/.phpcq.lock
index aaa029ad5..913b4862c 100644
--- a/.phpcq.lock
+++ b/.phpcq.lock
@@ -1 +1 @@
-{"plugins":{"phpunit":{"api-version":"1.0.0","version":"1.1.0.0","type":"php-file","url":"https://phpcq.github.io/repository/plugin/phpunit/phpunit-1.1.0.0.php","signature":null,"requirements":{"php":{"php":"^7.3 || ^8.0"},"tool":{"phpunit":"^6.0 || ^7.0 || ^8.0 || ^9.0 || ^10.0 || ^11.0 || ^12.0"}},"checksum":{"type":"sha-512","value":"c73f15658e3ba62665f09492ec91c3a6a715760bfaa88473a987538439fff442540148e086e46a6aa18ce55a3ea2fbf76caaa581384cb84a38859fcc609ae7e4"},"tools":{"phpunit":{"version":"10.5.63","url":"https://phar.phpunit.de/phpunit-10.5.63.phar","requirements":{"php":{"php":">=8.1","ext-dom":"*","ext-json":"*","ext-libxml":"*","ext-mbstring":"*","ext-xml":"*","ext-xmlwriter":"*"}},"checksum":{"type":"sha-256","value":"3160398ef3e1ac041866fab0e88bdbc46349c7420824b750d2ede9a58ead1ba8"},"signature":"https://phar.phpunit.de/phpunit-10.5.63.phar.asc"}},"composerLock":null},"psalm":{"api-version":"1.0.0","version":"1.3.0.0","type":"php-file","url":"https://phpcq.github.io/repository/plugin/psalm/psalm-1.3.0.0.php","signature":null,"requirements":{"php":{"php":"^7.4 || ^8.0","ext-dom":"*"},"tool":{"psalm":"^3.0 || ^4.0 || ^5.0 || ^6.0"}},"checksum":{"type":"sha-512","value":"4a550c9226d7bca582d7c10bd87cce01190c96398936b1613421640c83df62ed1c6e0d44c1b39635414ea8cf4a892a6458d27590793238add24e7cb5547e6ffd"},"tools":{"psalm":{"version":"6.16.1","url":"https://github.com/vimeo/psalm/releases/download/6.16.1/psalm.phar","requirements":{"php":{"php":"~8.2.27 || ~8.3.16 || ~8.4.3 || ~8.5.0","ext-SimpleXML":"*","ext-ctype":"*","ext-dom":"*","ext-json":"*","ext-libxml":"*","ext-mbstring":"*","ext-tokenizer":"*"}},"checksum":null,"signature":"https://github.com/vimeo/psalm/releases/download/6.16.1/psalm.phar.asc"}},"composerLock":null},"composer-require-checker":{"api-version":"1.0.0","version":"1.1.1.0","type":"php-file","url":"https://phpcq.github.io/repository/plugin/composer-require-checker/composer-require-checker-1.1.1.0.php","signature":null,"requirements":{"php":{"php":"^7.4 || ^8.0"},"tool":{"composer-require-checker":"^3.8 || ^4.0"}},"checksum":{"type":"sha-512","value":"d5415bddfe024c5749d894034583882aee4e5c3e1087815d9fdd81cb5e71630f631a0e35de0ff84b97fbbf738c16ece5f83bd8c00695913eb846aa6f04577dc2"},"tools":{"composer-require-checker":{"version":"4.20.0","url":"https://github.com/maglnet/ComposerRequireChecker/releases/download/4.20.0/composer-require-checker.phar","requirements":{"php":{"php":"~8.3.0 || ~8.4.0 || ~8.5.0","ext-phar":"*"}},"checksum":null,"signature":"https://github.com/maglnet/ComposerRequireChecker/releases/download/4.20.0/composer-require-checker.phar.asc"}},"composerLock":null},"phpmd":{"api-version":"1.0.0","version":"1.0.2.0","type":"php-file","url":"https://phpcq.github.io/repository/plugin/phpmd/phpmd-1.0.2.0.php","signature":null,"requirements":{"php":{"php":"^7.3 || ^8.0","ext-dom":"*"},"tool":{"phpmd":"^2.6.1"}},"checksum":{"type":"sha-512","value":"f22280a6dec8dbdd2ec1d83b294f23237fe32c34f4a298e52038e0a7a0074d541635b2b488b1a6098a42d8418a6cd8eb804406ea82b91e362be2b5d11a0915b0"},"tools":{"phpmd":{"version":"2.15.0","url":"https://github.com/phpmd/phpmd/releases/download/2.15.0/phpmd.phar","requirements":{"php":{"php":">=5.3.9","ext-xml":"*"}},"checksum":null,"signature":"https://github.com/phpmd/phpmd/releases/download/2.15.0/phpmd.phar.asc"}},"composerLock":null},"phpcpd":{"api-version":"1.0.0","version":"1.1.1.0","type":"php-file","url":"https://phpcq.github.io/repository/plugin/phpcpd/phpcpd-1.1.1.0.php","signature":null,"requirements":{"php":{"php":"^7.3 || ^8.0","ext-dom":"*"},"tool":{"phpcpd":"^6.0"}},"checksum":{"type":"sha-512","value":"1189ce0bf3fade4cb4241f1d96f915ef8fc7651f4450dc79fdf464ee3d6be3009316f0d423ce2d4af9d76ad50807b7fdf4d77bfa6d9ee2c91d6eda32ea214433"},"tools":{"phpcpd":{"version":"6.0.3","url":"https://phar.phpunit.de/phpcpd-6.0.3.phar","requirements":{"php":{"php":">=7.3","ext-dom":"*"}},"checksum":{"type":"sha-256","value":"2cbaea7cfda1bb4299d863eb075e977c3f49055dd16d88529fae5150d48a84cb"},"signature":"https://phar.phpunit.de/phpcpd-6.0.3.phar.asc"}},"composerLock":null},"phploc":{"api-version":"1.0.0","version":"1.0.0.0","type":"php-file","url":"https://phpcq.github.io/repository/plugin/phploc/phploc-1.0.0.0.php","signature":null,"requirements":{"php":{"php":"^7.3 || ^8.0","ext-dom":"*","ext-json":"*"},"tool":{"phploc":"^3.0 || ^4.0 || ^5.0 || ^6.0 || ^7.0"}},"checksum":{"type":"sha-512","value":"f67b02d494796adf553cb3dd13ec06c1cb8e53c799954061749424251379541637538199afb3afa3c7a01cabd1cb6f1c53eb621f015dff9644c6c7cbf10c56d1"},"tools":{"phploc":{"version":"7.0.2","url":"https://phar.phpunit.de/phploc-7.0.2.phar","requirements":{"php":{"php":">=7.3","ext-dom":"*","ext-json":"*"}},"checksum":{"type":"sha-256","value":"3d59778ec86faf25fd00e3a329b2f9ad4a3c751ca91601ea7dab70f887b0bf46"},"signature":"https://phar.phpunit.de/phploc-7.0.2.phar.asc"}},"composerLock":null},"phpcs":{"api-version":"1.0.0","version":"1.2.1.0","type":"php-file","url":"https://phpcq.github.io/repository/plugin/phpcs/phpcs-1.2.1.0.php","signature":null,"requirements":{"php":{"php":"^7.3 || ^8.0","ext-dom":"*"},"tool":{"phpcs":"^4.0 || ^3.0 || ^2.0","phpcbf":"^4.0 || ^3.0 || ^2.0"}},"checksum":{"type":"sha-512","value":"03f1c6c2d94b79d0e8cbd42996382e0d100c7e07f84c3138fa3a8b394e814ec18ce05cbbd257e527913219b2264f062522e4cf3e3bd402b907b9437d96982b44"},"tools":{"phpcs":{"version":"4.0.1","url":"https://github.com/PHPCSStandards/PHP_CodeSniffer/releases/download/4.0.1/phpcs.phar","requirements":{"php":{"php":">=7.2.0","ext-simplexml":"*","ext-tokenizer":"*","ext-xmlwriter":"*"}},"checksum":null,"signature":"https://github.com/PHPCSStandards/PHP_CodeSniffer/releases/download/4.0.1/phpcs.phar.asc"},"phpcbf":{"version":"4.0.1","url":"https://github.com/PHPCSStandards/PHP_CodeSniffer/releases/download/4.0.1/phpcbf.phar","requirements":{"php":{"php":">=7.2.0","ext-simplexml":"*","ext-tokenizer":"*","ext-xmlwriter":"*"}},"checksum":null,"signature":"https://github.com/PHPCSStandards/PHP_CodeSniffer/releases/download/4.0.1/phpcbf.phar.asc"}},"composerLock":null},"composer-normalize":{"api-version":"1.0.0","version":"1.1.1.0","type":"php-file","url":"https://phpcq.github.io/repository/plugin/composer-normalize/composer-normalize-1.1.1.0.php","signature":null,"requirements":{"php":{"php":"^7.3 || ^8.0","ext-json":"*"},"tool":{"composer-normalize":"^2.1"}},"checksum":{"type":"sha-512","value":"d9abda440b85d501c58abf9c81bf76f417594b397129215ffa8b777e9bb5e5eda37d7661d661db3c8d11c24f20345bc6fbe56f013b3b9435d459d2b94f086e0f"},"tools":{"composer-normalize":{"version":"2.50.0","url":"https://github.com/ergebnis/composer-normalize/releases/download/2.50.0/composer-normalize.phar","requirements":{"php":{"php":"~7.4.0 || ~8.0.0 || ~8.1.0 || ~8.2.0 || ~8.3.0 || ~8.4.0 || ~8.5.0","ext-json":"*"}},"checksum":null,"signature":"https://github.com/ergebnis/composer-normalize/releases/download/2.50.0/composer-normalize.phar.asc"}},"composerLock":null}},"tools":[]}
+{"plugins":{"phpunit":{"api-version":"1.0.0","version":"1.1.0.0","type":"php-file","url":"https://phpcq.github.io/repository/plugin/phpunit/phpunit-1.1.0.0.php","signature":null,"requirements":{"php":{"php":"^7.3 || ^8.0"},"tool":{"phpunit":"^6.0 || ^7.0 || ^8.0 || ^9.0 || ^10.0 || ^11.0 || ^12.0"}},"checksum":{"type":"sha-512","value":"c73f15658e3ba62665f09492ec91c3a6a715760bfaa88473a987538439fff442540148e086e46a6aa18ce55a3ea2fbf76caaa581384cb84a38859fcc609ae7e4"},"tools":{"phpunit":{"version":"12.5.29","url":"https://phar.phpunit.de/phpunit-12.5.29.phar","requirements":{"php":{"php":">=8.3","ext-dom":"*","ext-json":"*","ext-libxml":"*","ext-mbstring":"*","ext-xml":"*","ext-xmlwriter":"*"}},"checksum":{"type":"sha-256","value":"8633f5fa455c054ade4d4bceb01db85c17e2b278d1252ea267cc5c4d3600d0fb"},"signature":"https://phar.phpunit.de/phpunit-12.5.29.phar.asc"}},"composerLock":null},"psalm":{"api-version":"1.0.0","version":"1.3.0.0","type":"php-file","url":"https://phpcq.github.io/repository/plugin/psalm/psalm-1.3.0.0.php","signature":null,"requirements":{"php":{"php":"^7.4 || ^8.0","ext-dom":"*"},"tool":{"psalm":"^3.0 || ^4.0 || ^5.0 || ^6.0"}},"checksum":{"type":"sha-512","value":"4a550c9226d7bca582d7c10bd87cce01190c96398936b1613421640c83df62ed1c6e0d44c1b39635414ea8cf4a892a6458d27590793238add24e7cb5547e6ffd"},"tools":{"psalm":{"version":"6.16.1","url":"https://github.com/vimeo/psalm/releases/download/6.16.1/psalm.phar","requirements":{"php":{"php":"~8.2.27 || ~8.3.16 || ~8.4.3 || ~8.5.0","ext-SimpleXML":"*","ext-ctype":"*","ext-dom":"*","ext-json":"*","ext-libxml":"*","ext-mbstring":"*","ext-tokenizer":"*"}},"checksum":null,"signature":"https://github.com/vimeo/psalm/releases/download/6.16.1/psalm.phar.asc"}},"composerLock":null},"composer-require-checker":{"api-version":"1.0.0","version":"1.1.1.0","type":"php-file","url":"https://phpcq.github.io/repository/plugin/composer-require-checker/composer-require-checker-1.1.1.0.php","signature":null,"requirements":{"php":{"php":"^7.4 || ^8.0"},"tool":{"composer-require-checker":"^3.8 || ^4.0"}},"checksum":{"type":"sha-512","value":"d5415bddfe024c5749d894034583882aee4e5c3e1087815d9fdd81cb5e71630f631a0e35de0ff84b97fbbf738c16ece5f83bd8c00695913eb846aa6f04577dc2"},"tools":{"composer-require-checker":{"version":"4.24.0","url":"https://github.com/maglnet/ComposerRequireChecker/releases/download/4.24.0/composer-require-checker.phar","requirements":{"php":{"php":"~8.4.0 || ~8.5.0","ext-phar":"*"}},"checksum":null,"signature":"https://github.com/maglnet/ComposerRequireChecker/releases/download/4.24.0/composer-require-checker.phar.asc"}},"composerLock":null},"phpmd":{"api-version":"1.0.0","version":"1.0.2.0","type":"php-file","url":"https://phpcq.github.io/repository/plugin/phpmd/phpmd-1.0.2.0.php","signature":null,"requirements":{"php":{"php":"^7.3 || ^8.0","ext-dom":"*"},"tool":{"phpmd":"^2.6.1"}},"checksum":{"type":"sha-512","value":"f22280a6dec8dbdd2ec1d83b294f23237fe32c34f4a298e52038e0a7a0074d541635b2b488b1a6098a42d8418a6cd8eb804406ea82b91e362be2b5d11a0915b0"},"tools":{"phpmd":{"version":"2.15.0","url":"https://github.com/phpmd/phpmd/releases/download/2.15.0/phpmd.phar","requirements":{"php":{"php":">=5.3.9","ext-xml":"*"}},"checksum":null,"signature":"https://github.com/phpmd/phpmd/releases/download/2.15.0/phpmd.phar.asc"}},"composerLock":null},"phpcpd":{"api-version":"1.0.0","version":"1.1.1.0","type":"php-file","url":"https://phpcq.github.io/repository/plugin/phpcpd/phpcpd-1.1.1.0.php","signature":null,"requirements":{"php":{"php":"^7.3 || ^8.0","ext-dom":"*"},"tool":{"phpcpd":"^6.0"}},"checksum":{"type":"sha-512","value":"1189ce0bf3fade4cb4241f1d96f915ef8fc7651f4450dc79fdf464ee3d6be3009316f0d423ce2d4af9d76ad50807b7fdf4d77bfa6d9ee2c91d6eda32ea214433"},"tools":{"phpcpd":{"version":"6.0.3","url":"https://phar.phpunit.de/phpcpd-6.0.3.phar","requirements":{"php":{"php":">=7.3","ext-dom":"*"}},"checksum":{"type":"sha-256","value":"2cbaea7cfda1bb4299d863eb075e977c3f49055dd16d88529fae5150d48a84cb"},"signature":"https://phar.phpunit.de/phpcpd-6.0.3.phar.asc"}},"composerLock":null},"phploc":{"api-version":"1.0.0","version":"1.0.0.0","type":"php-file","url":"https://phpcq.github.io/repository/plugin/phploc/phploc-1.0.0.0.php","signature":null,"requirements":{"php":{"php":"^7.3 || ^8.0","ext-dom":"*","ext-json":"*"},"tool":{"phploc":"^3.0 || ^4.0 || ^5.0 || ^6.0 || ^7.0"}},"checksum":{"type":"sha-512","value":"f67b02d494796adf553cb3dd13ec06c1cb8e53c799954061749424251379541637538199afb3afa3c7a01cabd1cb6f1c53eb621f015dff9644c6c7cbf10c56d1"},"tools":{"phploc":{"version":"7.0.2","url":"https://phar.phpunit.de/phploc-7.0.2.phar","requirements":{"php":{"php":">=7.3","ext-dom":"*","ext-json":"*"}},"checksum":{"type":"sha-256","value":"3d59778ec86faf25fd00e3a329b2f9ad4a3c751ca91601ea7dab70f887b0bf46"},"signature":"https://phar.phpunit.de/phploc-7.0.2.phar.asc"}},"composerLock":null},"phpcs":{"api-version":"1.0.0","version":"1.2.1.0","type":"php-file","url":"https://phpcq.github.io/repository/plugin/phpcs/phpcs-1.2.1.0.php","signature":null,"requirements":{"php":{"php":"^7.3 || ^8.0","ext-dom":"*"},"tool":{"phpcs":"^4.0 || ^3.0 || ^2.0","phpcbf":"^4.0 || ^3.0 || ^2.0"}},"checksum":{"type":"sha-512","value":"03f1c6c2d94b79d0e8cbd42996382e0d100c7e07f84c3138fa3a8b394e814ec18ce05cbbd257e527913219b2264f062522e4cf3e3bd402b907b9437d96982b44"},"tools":{"phpcs":{"version":"4.0.1","url":"https://github.com/PHPCSStandards/PHP_CodeSniffer/releases/download/4.0.1/phpcs.phar","requirements":{"php":{"php":">=7.2.0","ext-simplexml":"*","ext-tokenizer":"*","ext-xmlwriter":"*"}},"checksum":null,"signature":"https://github.com/PHPCSStandards/PHP_CodeSniffer/releases/download/4.0.1/phpcs.phar.asc"},"phpcbf":{"version":"4.0.1","url":"https://github.com/PHPCSStandards/PHP_CodeSniffer/releases/download/4.0.1/phpcbf.phar","requirements":{"php":{"php":">=7.2.0","ext-simplexml":"*","ext-tokenizer":"*","ext-xmlwriter":"*"}},"checksum":null,"signature":"https://github.com/PHPCSStandards/PHP_CodeSniffer/releases/download/4.0.1/phpcbf.phar.asc"}},"composerLock":null},"composer-normalize":{"api-version":"1.0.0","version":"1.1.1.0","type":"php-file","url":"https://phpcq.github.io/repository/plugin/composer-normalize/composer-normalize-1.1.1.0.php","signature":null,"requirements":{"php":{"php":"^7.3 || ^8.0","ext-json":"*"},"tool":{"composer-normalize":"^2.1"}},"checksum":{"type":"sha-512","value":"d9abda440b85d501c58abf9c81bf76f417594b397129215ffa8b777e9bb5e5eda37d7661d661db3c8d11c24f20345bc6fbe56f013b3b9435d459d2b94f086e0f"},"tools":{"composer-normalize":{"version":"2.52.0","url":"https://github.com/ergebnis/composer-normalize/releases/download/2.52.0/composer-normalize.phar","requirements":{"php":{"php":"~7.4.0 || ~8.0.0 || ~8.1.0 || ~8.2.0 || ~8.3.0 || ~8.4.0 || ~8.5.0","ext-json":"*"}},"checksum":null,"signature":"https://github.com/ergebnis/composer-normalize/releases/download/2.52.0/composer-normalize.phar.asc"}},"composerLock":null}},"tools":[]}
\ No newline at end of file
diff --git a/.phpcq.yaml.dist b/.phpcq.yaml.dist
index 24a7df467..86be3e32c 100644
--- a/.phpcq.yaml.dist
+++ b/.phpcq.yaml.dist
@@ -14,19 +14,29 @@ phpcq:
signed: false
requirements:
phpunit:
- version: ^10.0
+ version: ^12
psalm:
- version: ^1.0
+ version: ^1.1
signed: false
composer-require-checker:
version: ^1.0
signed: false
+ requirements:
+ composer-require-checker:
+ signed: false
+ version: ^4.0
phpmd:
version: ^1.0
signed: false
+ requirements:
+ phpmd:
+ signed: false
phpcpd:
version: ^1.1
signed: false
+ requirements:
+ phpcpd:
+ version: ^6.0
phploc:
version: ^1.0
signed: false
@@ -55,6 +65,7 @@ phpcq:
# Composer normalize
- C00543248C87FB13
# phpmd
+ - 0F9684B8B16B7AB0
- A4E55EA12C7C085C
- 9093F8B32E4815AA
diff --git a/composer.json b/composer.json
index 7f471242b..7d22f3531 100644
--- a/composer.json
+++ b/composer.json
@@ -29,48 +29,47 @@
"source": "https://github.com/MetaModels/core"
},
"require": {
- "php": "^8.2",
+ "php": "^8.4",
"ext-dom": "*",
- "contao-community-alliance/dc-general": "^2.4.13",
- "contao-community-alliance/events-contao-bindings": "^5.0",
- "contao-community-alliance/meta-palettes": "^2.0.10",
- "contao-community-alliance/translator": "^2.5",
- "contao-community-alliance/url-builder": "^2.0",
- "contao/core-bundle": "^5.3 <5.7",
- "discordier/justtextwidgets": "^2.0",
+ "contao-community-alliance/dc-general": "^2.5@dev",
+ "contao-community-alliance/events-contao-bindings": "^5.7",
+ "contao-community-alliance/meta-palettes": "^2.1",
+ "contao-community-alliance/translator": "^2.6",
+ "contao-community-alliance/url-builder": "^2.1",
+ "contao/core-bundle": "^5.7",
+ "discordier/justtextwidgets": "^2.1",
"doctrine/cache": "^2.1",
"doctrine/dbal": "^3.6",
"doctrine/doctrine-bundle": "^2.8",
"doctrine/orm": "^2.17",
"knplabs/knp-menu": "^3.1",
- "menatwork/contao-multicolumnwizard-bundle": "^3.6.10",
+ "menatwork/contao-multicolumnwizard-bundle": "^3.6.15",
"psr/container": "^2.0",
"psr/log": "^2.0 || ^3.0",
- "symfony/asset": "^6.4",
- "symfony/cache": "^6.4",
+ "symfony/asset": "^7.4",
+ "symfony/cache": "^7.4",
"symfony/cache-contracts": "^3.0",
- "symfony/config": "^6.4",
- "symfony/console": "^6.4",
- "symfony/dependency-injection": "^6.4",
+ "symfony/config": "^7.4",
+ "symfony/console": "^7.4",
+ "symfony/dependency-injection": "^7.4",
"symfony/deprecation-contracts": "^3.3.0",
- "symfony/event-dispatcher": "^6.4",
+ "symfony/event-dispatcher": "^7.4",
"symfony/event-dispatcher-contracts": "^3.0",
- "symfony/filesystem": "^6.4",
- "symfony/finder": "^6.4",
- "symfony/framework-bundle": "^6.4",
- "symfony/http-foundation": "^6.4",
- "symfony/http-kernel": "^6.4",
- "symfony/routing": "^6.4",
- "symfony/security-core": "^6.4",
+ "symfony/filesystem": "^7.4",
+ "symfony/finder": "^7.4",
+ "symfony/framework-bundle": "^7.4",
+ "symfony/http-foundation": "^7.4",
+ "symfony/http-kernel": "^7.4",
+ "symfony/routing": "^7.4",
+ "symfony/security-core": "^7.4",
"symfony/service-contracts": "^3.0",
- "symfony/translation": "^6.4",
+ "symfony/translation": "^7.4",
"symfony/translation-contracts": "^3.0",
"terminal42/service-annotation-bundle": "^1.1",
"twig/intl-extra": "^3.21",
"twig/twig": "^3.10.0"
},
"require-dev": {
- "contao/manager-bundle": "^5.3.0 <5.7.0",
"contao/manager-plugin": "^2.8",
"doctrine/doctrine-bundle": "^2.8.3",
"inspiredminds/contao-file-usage": "^3.0.1",
@@ -96,8 +95,7 @@
},
"extra": {
"branch-alias": {
- "dev-hotfix/2.4.18": "2.4.x-dev",
- "dev-master": "2.4.x-dev"
+ "dev-release/2.5": "2.5.x-dev"
},
"contao": {
"runonce": [
diff --git a/psalm.xml b/psalm.xml
index 683d39edc..f70c14641 100644
--- a/psalm.xml
+++ b/psalm.xml
@@ -307,5 +307,10 @@
+
+
+
+
+
diff --git a/src/Attribute/Base.php b/src/Attribute/Base.php
index 8a197af4a..1323b29cd 100644
--- a/src/Attribute/Base.php
+++ b/src/Attribute/Base.php
@@ -26,12 +26,14 @@
namespace MetaModels\Attribute;
+use Contao\System;
use MetaModels\Helper\LocaleUtil;
use MetaModels\IMetaModel;
use MetaModels\ITranslatedMetaModel;
use MetaModels\Render\Setting\ISimple as ISimpleRenderSetting;
use MetaModels\Render\Setting\Simple;
use MetaModels\Render\Template;
+use MetaModels\Render\TemplateFactory;
/**
* This is the main MetaModels-attribute base class.
@@ -635,7 +637,9 @@ public function parseValue($arrRowData, $strOutputFormat = 'text', $objSettings
$arrResult = ['raw' => ($arrRowData[$this->getColName()] ?? null)];
if ($objSettings && ($strTemplate = (string) $objSettings->get('template'))) {
- $objTemplate = new Template($strTemplate);
+ $templateFactory = System::getContainer()->get('metamodels.template_factory');
+ assert($templateFactory instanceof TemplateFactory);
+ $objTemplate = $templateFactory->createTemplate($strTemplate);
$this->prepareTemplate($objTemplate, $arrRowData, $objSettings);
@@ -653,7 +657,7 @@ public function parseValue($arrRowData, $strOutputFormat = 'text', $objSettings
// FIXME: this throws when no parent has been set - need to catch!
$objSettingsFallback = $this->getDefaultRenderSettings()->setParent($objSettings->getParent());
- $objTemplate = new Template($objSettingsFallback->get('template') ?? '');
+ $objTemplate = $templateFactory->createTemplate((string) $objSettingsFallback->get('template'));
$this->prepareTemplate($objTemplate, $arrRowData, $objSettingsFallback);
$arrResult['text'] = $objTemplate->parse('text', true);
diff --git a/src/Attribute/BaseSimple.php b/src/Attribute/BaseSimple.php
index 10c5c1947..13a907f2f 100644
--- a/src/Attribute/BaseSimple.php
+++ b/src/Attribute/BaseSimple.php
@@ -78,8 +78,8 @@ class BaseSimple extends Base implements ISimple
public function __construct(
IMetaModel $objMetaModel,
$arrData = [],
- Connection $connection = null,
- TableManipulator $tableManipulator = null
+ ?Connection $connection = null,
+ ?TableManipulator $tableManipulator = null
) {
parent::__construct($objMetaModel, $arrData);
diff --git a/src/Attribute/TranslatedReference.php b/src/Attribute/TranslatedReference.php
index cc0744fe5..785602131 100644
--- a/src/Attribute/TranslatedReference.php
+++ b/src/Attribute/TranslatedReference.php
@@ -58,7 +58,7 @@ abstract class TranslatedReference extends BaseComplex implements ITranslated
* classes for information what values are understood.
* @param Connection|null $connection Database connection.
*/
- public function __construct(IMetaModel $objMetaModel, $arrData = [], Connection $connection = null)
+ public function __construct(IMetaModel $objMetaModel, $arrData = [], ?Connection $connection = null)
{
parent::__construct($objMetaModel, $arrData);
diff --git a/src/CoreBundle/BackendHelp/CustomSqlHelpTextProvider.php b/src/CoreBundle/BackendHelp/CustomSqlHelpTextProvider.php
index e243d3503..cce2dd437 100644
--- a/src/CoreBundle/BackendHelp/CustomSqlHelpTextProvider.php
+++ b/src/CoreBundle/BackendHelp/CustomSqlHelpTextProvider.php
@@ -7,8 +7,6 @@
use ContaoCommunityAlliance\DcGeneral\BackendHelp\BackendHelpProviderInterface;
use ContaoCommunityAlliance\DcGeneral\BackendHelp\HelpText;
-use function array_key_exists;
-
final readonly class CustomSqlHelpTextProvider implements BackendHelpProviderInterface
{
public function __construct(
diff --git a/src/CoreBundle/BackendHelp/PanelLayoutHelpTextProvider.php b/src/CoreBundle/BackendHelp/PanelLayoutHelpTextProvider.php
index ef8c61027..fe2dce84b 100644
--- a/src/CoreBundle/BackendHelp/PanelLayoutHelpTextProvider.php
+++ b/src/CoreBundle/BackendHelp/PanelLayoutHelpTextProvider.php
@@ -7,8 +7,6 @@
use ContaoCommunityAlliance\DcGeneral\BackendHelp\BackendHelpProviderInterface;
use ContaoCommunityAlliance\DcGeneral\BackendHelp\HelpText;
-use function array_key_exists;
-
final readonly class PanelLayoutHelpTextProvider implements BackendHelpProviderInterface
{
public function __construct(
diff --git a/src/CoreBundle/BackendHelp/TlClassHelpTextProvider.php b/src/CoreBundle/BackendHelp/TlClassHelpTextProvider.php
index 713fa7298..1479d9eae 100644
--- a/src/CoreBundle/BackendHelp/TlClassHelpTextProvider.php
+++ b/src/CoreBundle/BackendHelp/TlClassHelpTextProvider.php
@@ -7,8 +7,6 @@
use ContaoCommunityAlliance\DcGeneral\BackendHelp\BackendHelpProviderInterface;
use ContaoCommunityAlliance\DcGeneral\BackendHelp\HelpText;
-use function array_key_exists;
-
final readonly class TlClassHelpTextProvider implements BackendHelpProviderInterface
{
public function __construct(
diff --git a/src/CoreBundle/BackendHelp/TypeHelpTextProvider.php b/src/CoreBundle/BackendHelp/TypeHelpTextProvider.php
index 1cab39c3c..0bc406c28 100644
--- a/src/CoreBundle/BackendHelp/TypeHelpTextProvider.php
+++ b/src/CoreBundle/BackendHelp/TypeHelpTextProvider.php
@@ -7,8 +7,6 @@
use ContaoCommunityAlliance\DcGeneral\BackendHelp\BackendHelpProviderInterface;
use ContaoCommunityAlliance\DcGeneral\BackendHelp\HelpText;
-use function array_key_exists;
-
final readonly class TypeHelpTextProvider implements BackendHelpProviderInterface
{
public function __construct(
diff --git a/src/CoreBundle/Contao/Hooks/AbstractContentElementAndModuleCallback.php b/src/CoreBundle/Contao/Hooks/AbstractContentElementAndModuleCallback.php
index 1e4354449..a67525940 100644
--- a/src/CoreBundle/Contao/Hooks/AbstractContentElementAndModuleCallback.php
+++ b/src/CoreBundle/Contao/Hooks/AbstractContentElementAndModuleCallback.php
@@ -370,7 +370,7 @@ protected function buildFilterParamsFor(DC_Table $dataContainer, $elementName)
*
* @return string|null
*/
- public function saveCallback(string $value = null)
+ public function saveCallback(?string $value = null)
{
return ('--null--' === $value || null === $value) ? null : base64_decode($value);
}
@@ -382,7 +382,7 @@ public function saveCallback(string $value = null)
*
* @return string|null
*/
- public function loadCallback(string $value = null)
+ public function loadCallback(?string $value = null)
{
return null === $value ? '--null--' : trim(base64_encode($value), '=');
}
diff --git a/src/CoreBundle/Controller/Backend/AbstractAddAllController.php b/src/CoreBundle/Controller/Backend/AbstractAddAllController.php
index 1c89b607f..50ce7b230 100644
--- a/src/CoreBundle/Controller/Backend/AbstractAddAllController.php
+++ b/src/CoreBundle/Controller/Backend/AbstractAddAllController.php
@@ -22,7 +22,7 @@
namespace MetaModels\CoreBundle\Controller\Backend;
-use Contao\CoreBundle\Controller\AbstractBackendController;
+use Contao\CoreBundle\Controller\Backend\AbstractBackendController;
use Contao\CoreBundle\Csrf\ContaoCsrfTokenManager;
use Contao\CoreBundle\Framework\Adapter;
use Contao\System;
diff --git a/src/CoreBundle/Controller/Backend/ConfigurationController.php b/src/CoreBundle/Controller/Backend/ConfigurationController.php
index fd73768dc..c08fb891f 100644
--- a/src/CoreBundle/Controller/Backend/ConfigurationController.php
+++ b/src/CoreBundle/Controller/Backend/ConfigurationController.php
@@ -20,7 +20,7 @@
namespace MetaModels\CoreBundle\Controller\Backend;
-use Contao\CoreBundle\Controller\AbstractBackendController;
+use Contao\CoreBundle\Controller\Backend\AbstractBackendController;
use Contao\CoreBundle\Framework\ContaoFramework;
use ContaoCommunityAlliance\DcGeneral\Factory\DcGeneralFactoryService;
use ContaoCommunityAlliance\Translator\TranslatorInterface;
@@ -56,7 +56,7 @@ public function __invoke(
TranslatorInterface $translator,
ContaoFramework $framework,
): Response {
- $containerName = (string) $request->query->get('table', '');
+ $containerName = $request->query->get('table', '');
if ('' === $containerName) {
$containerName = (string) ($request->attributes->get('_route_params', [])['tableName'] ?? 'tl_metamodel');
}
diff --git a/src/CoreBundle/Controller/Backend/DcGeneralControllerTrait.php b/src/CoreBundle/Controller/Backend/DcGeneralControllerTrait.php
index 0c4ded97e..255fdcf06 100644
--- a/src/CoreBundle/Controller/Backend/DcGeneralControllerTrait.php
+++ b/src/CoreBundle/Controller/Backend/DcGeneralControllerTrait.php
@@ -52,7 +52,7 @@ public function bootDcGeneralAndProcess(
TranslatorInterface $translator,
ContaoFramework $framework,
): string {
- $act = (string) $request->query->get('act', 'showAll');
+ $act = $request->query->get('act', 'showAll');
// Work around legacy Contao code.
/** @psalm-suppress InternalMethod - Class ContaoFramework is internal, not the getAdapter() method. */
diff --git a/src/CoreBundle/Controller/Backend/MetaModelController.php b/src/CoreBundle/Controller/Backend/MetaModelController.php
index e86fa808e..2c1987d71 100644
--- a/src/CoreBundle/Controller/Backend/MetaModelController.php
+++ b/src/CoreBundle/Controller/Backend/MetaModelController.php
@@ -20,7 +20,7 @@
namespace MetaModels\CoreBundle\Controller\Backend;
-use Contao\CoreBundle\Controller\AbstractBackendController;
+use Contao\CoreBundle\Controller\Backend\AbstractBackendController;
use Contao\CoreBundle\Exception\AccessDeniedException;
use Contao\CoreBundle\Framework\ContaoFramework;
use Contao\CoreBundle\Menu\BackendMenuBuilder;
@@ -67,7 +67,7 @@ public function __invoke(
ContaoFramework $framework,
ViewCombination $viewCombination,
): Response {
- $containerName = (string) $request->query->get('table', '');
+ $containerName = $request->query->get('table', '');
if ('' === $containerName) {
$containerName = (string) ($request->attributes->get('_route_params', [])['tableName'] ?? '');
}
diff --git a/src/CoreBundle/Controller/Backend/SupportMetaModelsController.php b/src/CoreBundle/Controller/Backend/SupportMetaModelsController.php
index 1bd10c45d..2af470b31 100644
--- a/src/CoreBundle/Controller/Backend/SupportMetaModelsController.php
+++ b/src/CoreBundle/Controller/Backend/SupportMetaModelsController.php
@@ -22,7 +22,7 @@
namespace MetaModels\CoreBundle\Controller\Backend;
-use Contao\CoreBundle\Controller\AbstractBackendController;
+use Contao\CoreBundle\Controller\Backend\AbstractBackendController;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Contracts\Translation\TranslatorInterface;
use Twig\Environment as TwigEnvironment;
diff --git a/src/CoreBundle/Controller/ContentElement/ItemListController.php b/src/CoreBundle/Controller/ContentElement/ItemListController.php
index e1f25becd..0f40ee7e4 100644
--- a/src/CoreBundle/Controller/ContentElement/ItemListController.php
+++ b/src/CoreBundle/Controller/ContentElement/ItemListController.php
@@ -59,8 +59,8 @@ public function __invoke(
Request $request,
ContentModel $model,
string $section,
- array $classes = null,
- PageModel $pageModel = null
+ ?array $classes = null,
+ ?PageModel $pageModel = null
): Response {
if ($this->scopeMatcher->isBackendRequest($request)) {
return $this->getBackendWildcard($model);
diff --git a/src/CoreBundle/Controller/FrontendModule/ItemListController.php b/src/CoreBundle/Controller/FrontendModule/ItemListController.php
index 9754b2f25..51dedaba0 100644
--- a/src/CoreBundle/Controller/FrontendModule/ItemListController.php
+++ b/src/CoreBundle/Controller/FrontendModule/ItemListController.php
@@ -58,8 +58,8 @@ public function __invoke(
Request $request,
ModuleModel $model,
string $section,
- array $classes = null,
- PageModel $pageModel = null
+ ?array $classes = null,
+ ?PageModel $pageModel = null
): Response {
if ($this->scopeMatcher->isBackendRequest($request)) {
return $this->getBackendWildcard($model);
diff --git a/src/CoreBundle/Controller/ListControllerTrait.php b/src/CoreBundle/Controller/ListControllerTrait.php
index db9652f77..9c7af525d 100644
--- a/src/CoreBundle/Controller/ListControllerTrait.php
+++ b/src/CoreBundle/Controller/ListControllerTrait.php
@@ -125,9 +125,9 @@ public function __construct(
IRenderSettingFactory $renderSettingFactory,
EventDispatcherInterface $eventDispatcher,
FilterUrlBuilder $filterUrlBuilder,
- TranslatorInterface $translator = null,
- RouterInterface $router = null,
- ScopeMatcher $scopeMatcher = null
+ ?TranslatorInterface $translator = null,
+ ?RouterInterface $router = null,
+ ?ScopeMatcher $scopeMatcher = null
) {
$this->factory = $factory;
$this->filterFactory = $filterFactory;
diff --git a/src/CoreBundle/DependencyInjection/CompilerPass/RegisterFileUsageIgnoreTablesPass.php b/src/CoreBundle/DependencyInjection/CompilerPass/RegisterFileUsageIgnoreTablesPass.php
new file mode 100644
index 000000000..efa2b380d
--- /dev/null
+++ b/src/CoreBundle/DependencyInjection/CompilerPass/RegisterFileUsageIgnoreTablesPass.php
@@ -0,0 +1,72 @@
+
+ * @copyright 2012-2026 The MetaModels team.
+ * @license https://github.com/MetaModels/core/blob/master/LICENSE LGPL-3.0-or-later
+ * @filesource
+ */
+
+declare(strict_types=1);
+
+namespace MetaModels\CoreBundle\DependencyInjection\CompilerPass;
+
+use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
+use Symfony\Component\DependencyInjection\ContainerBuilder;
+
+use function array_unique;
+use function array_values;
+use function is_array;
+
+/**
+ * Registers the MetaModels storage tables that hold file references with the
+ * "ignore tables" list of inspiredminds/contao-file-usage.
+ *
+ * These tables are already covered by the dedicated MetaModels file usage
+ * providers, so the generic database provider of the file usage extension must
+ * not scan them again - otherwise every reference would be reported twice.
+ */
+class RegisterFileUsageIgnoreTablesPass implements CompilerPassInterface
+{
+ /**
+ * The parameter holding the tables to be ignored by the file usage extension.
+ */
+ private const PARAMETER = 'contao_file_usage.ignore_tables';
+
+ /**
+ * MetaModels attribute storage tables that store file references as text
+ * (plain UUID or insert tag) and provide their own file usage provider.
+ */
+ private const IGNORE_TABLES = [
+ 'tl_metamodel_tablemulti',
+ 'tl_metamodel_translatedtablemulti',
+ ];
+
+ #[\Override]
+ public function process(ContainerBuilder $container): void
+ {
+ if (!$container->hasParameter(self::PARAMETER)) {
+ return;
+ }
+
+ $tables = $container->getParameter(self::PARAMETER);
+ if (!is_array($tables)) {
+ return;
+ }
+
+ $container->setParameter(
+ self::PARAMETER,
+ array_values(array_unique([...$tables, ...self::IGNORE_TABLES]))
+ );
+ }
+}
diff --git a/src/CoreBundle/DependencyInjection/Configuration.php b/src/CoreBundle/DependencyInjection/Configuration.php
index aa518ef4f..922cdd852 100644
--- a/src/CoreBundle/DependencyInjection/Configuration.php
+++ b/src/CoreBundle/DependencyInjection/Configuration.php
@@ -63,9 +63,10 @@ public function __construct($debug, $rootDir)
* @return TreeBuilder
*
* @psalm-suppress UndefinedMethod
+ * @psalm-suppress ImplementedReturnTypeMismatch
*/
#[\Override]
- public function getConfigTreeBuilder()
+ public function getConfigTreeBuilder(): TreeBuilder
{
$treeBuilder = new TreeBuilder('metamodels');
$treeBuilder
diff --git a/src/CoreBundle/EventListener/DcGeneral/DefinitionBuilder/PaletteBuilder.php b/src/CoreBundle/EventListener/DcGeneral/DefinitionBuilder/PaletteBuilder.php
index 1dc6317c0..a2c4d4cf3 100644
--- a/src/CoreBundle/EventListener/DcGeneral/DefinitionBuilder/PaletteBuilder.php
+++ b/src/CoreBundle/EventListener/DcGeneral/DefinitionBuilder/PaletteBuilder.php
@@ -173,8 +173,8 @@ private function createProperty(
PropertyInterface $property,
string $propertyName,
bool $variantHandling,
- ConditionInterface $condition = null,
- ConditionInterface $legendCondition = null
+ ?ConditionInterface $condition = null,
+ ?ConditionInterface $legendCondition = null
): Property {
$paletteProperty = new Property($propertyName);
diff --git a/src/CoreBundle/EventListener/DcGeneral/DefinitionBuilder/PanelBuilder.php b/src/CoreBundle/EventListener/DcGeneral/DefinitionBuilder/PanelBuilder.php
index 00f8d1068..a6a171d86 100644
--- a/src/CoreBundle/EventListener/DcGeneral/DefinitionBuilder/PanelBuilder.php
+++ b/src/CoreBundle/EventListener/DcGeneral/DefinitionBuilder/PanelBuilder.php
@@ -102,7 +102,6 @@ protected function build(IMetaModelDataDefinition $container)
// Create a new panel container.
$panel = $view->getPanelLayout();
$panelRows = $panel->getRows();
-
foreach ($arrRows as $rowNo => $rowElements) {
// Get the row, if we have one or create a new one.
if ($panelRows->getRowCount() < ((int) $rowNo + 1)) {
@@ -113,7 +112,6 @@ protected function build(IMetaModelDataDefinition $container)
// Get the fields.
$fields = StringUtil::trimsplit(',', $rowElements);
- $fields = \array_reverse($fields);
$this->parsePanelRow($fields, $panelRow);
@@ -156,7 +154,7 @@ private function ensureSubmitElement(PanelRowCollectionInterface $panelRows): vo
// If not add a submit.
if (!$hasSubmit && $panelRows->getRowCount()) {
$row = $panelRows->getRow($panelRows->getRowCount() - 1);
- $row->addElement(new DefaultSubmitElementInformation(), 0);
+ $row->addElement(new DefaultSubmitElementInformation(), -1);
}
}
diff --git a/src/CoreBundle/EventListener/DcGeneral/Table/Attribute/BaseListener.php b/src/CoreBundle/EventListener/DcGeneral/Table/Attribute/BaseListener.php
index 85a43ee20..081587296 100644
--- a/src/CoreBundle/EventListener/DcGeneral/Table/Attribute/BaseListener.php
+++ b/src/CoreBundle/EventListener/DcGeneral/Table/Attribute/BaseListener.php
@@ -107,7 +107,7 @@ protected function getMetaModelByModelPid(ModelInterface $model)
*
* @throws \InvalidArgumentException When the MetaModel could not be retrieved.
*/
- protected function createAttributeInstance(ModelInterface $model = null)
+ protected function createAttributeInstance(?ModelInterface $model = null)
{
if (null === $model) {
return null;
diff --git a/src/CoreBundle/EventListener/GetSearchablePagesListener.php b/src/CoreBundle/EventListener/GetSearchablePagesListener.php
index a69f6d226..77a3b9223 100644
--- a/src/CoreBundle/EventListener/GetSearchablePagesListener.php
+++ b/src/CoreBundle/EventListener/GetSearchablePagesListener.php
@@ -352,7 +352,7 @@ private function buildUrlsForItems(
*
* @return UrlBuilder
*/
- private function getBaseUrl(array $pageDetails, string $path = null): UrlBuilder
+ private function getBaseUrl(array $pageDetails, ?string $path = null): UrlBuilder
{
$url = new UrlBuilder();
// Set the domain (see contao/core#6421)
diff --git a/src/CoreBundle/EventListener/InsertTagsListener.php b/src/CoreBundle/EventListener/InsertTagsListener.php
index 70e7c56ae..f7984c8af 100644
--- a/src/CoreBundle/EventListener/InsertTagsListener.php
+++ b/src/CoreBundle/EventListener/InsertTagsListener.php
@@ -116,7 +116,7 @@ public function __construct(
IFactory $factory,
IRenderSettingFactory $renderSettingFactory,
IFilterSettingFactory $filterSettingFactory,
- LoggerInterface $logger = null
+ ?LoggerInterface $logger = null
) {
$this->connection = $connection;
$this->factory = $factory;
diff --git a/src/CoreBundle/MetaModelsCoreBundle.php b/src/CoreBundle/MetaModelsCoreBundle.php
index 840f837ca..11a388452 100644
--- a/src/CoreBundle/MetaModelsCoreBundle.php
+++ b/src/CoreBundle/MetaModelsCoreBundle.php
@@ -26,6 +26,7 @@
use MetaModels\CoreBundle\DependencyInjection\CompilerPass\CollectSchemaGeneratorsPass;
use MetaModels\CoreBundle\DependencyInjection\CompilerPass\CollectSchemaManagersPass;
use MetaModels\CoreBundle\DependencyInjection\CompilerPass\PrepareTranslatorPass;
+use MetaModels\CoreBundle\DependencyInjection\CompilerPass\RegisterFileUsageIgnoreTablesPass;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\HttpKernel\Bundle\Bundle;
@@ -46,6 +47,7 @@ public function build(ContainerBuilder $container): void
$container->addCompilerPass(new CollectSchemaGeneratorsPass());
$container->addCompilerPass(new CollectSchemaManagersPass());
$container->addCompilerPass(new CollectDoctrineSchemaGeneratorsPass());
+ $container->addCompilerPass(new RegisterFileUsageIgnoreTablesPass());
$container->addCompilerPass(new PrepareTranslatorPass(), priority: -64);
}
}
diff --git a/src/CoreBundle/Resources/config/services.yml b/src/CoreBundle/Resources/config/services.yml
index 8e86ed4e3..c407a8a83 100644
--- a/src/CoreBundle/Resources/config/services.yml
+++ b/src/CoreBundle/Resources/config/services.yml
@@ -80,6 +80,13 @@ services:
- "%kernel.project_dir%"
- "@translator"
+ metamodels.template_factory:
+ class: MetaModels\Render\TemplateFactory
+ arguments:
+ - "@=service('contao.framework').getAdapter('Contao\\\\TemplateLoader')"
+ - "@cca.dc-general.scope-matcher"
+ public: true
+
metamodels.contao_input:
class: Contao\Input
factory: ['@MetaModels\CoreBundle\Contao\Compat\ContaoFactory', 'getAdapter']
diff --git a/src/CoreBundle/Resources/contao/config/config.php b/src/CoreBundle/Resources/contao/config/config.php
index a9d92b7c3..7530e9640 100644
--- a/src/CoreBundle/Resources/contao/config/config.php
+++ b/src/CoreBundle/Resources/contao/config/config.php
@@ -66,7 +66,7 @@
$GLOBALS['TL_PURGE']['folders']['metamodels']['affected'] = [
\str_replace(
$container->getParameter('kernel.cache_dir') . '/',
- '%s/',
+ '%kernel.cache_dir%/',
$cacheDir
)
];
diff --git a/src/CoreBundle/Resources/views/Backend/be_base.html.twig b/src/CoreBundle/Resources/views/Backend/be_base.html.twig
index c4c8a1b8c..a36b6d79c 100644
--- a/src/CoreBundle/Resources/views/Backend/be_base.html.twig
+++ b/src/CoreBundle/Resources/views/Backend/be_base.html.twig
@@ -1 +1,6 @@
{% extends "@Contao/be_main" %}
+
+{%- set bodyAttributes = attrs(attributes|default)
+ .set('data-turbo', 'false')
+ .mergeWith(bodyAttributes|default)
+-%}
diff --git a/src/CoreBundle/Resources/views/Backend/be_config.html.twig b/src/CoreBundle/Resources/views/Backend/be_config.html.twig
index 30876aae2..71dc0605b 100644
--- a/src/CoreBundle/Resources/views/Backend/be_config.html.twig
+++ b/src/CoreBundle/Resources/views/Backend/be_config.html.twig
@@ -1,9 +1,5 @@
{% extends "@MetaModelsCore/Backend/be_base.html.twig" %}
-{% block main_headline %}
- {{ headline }}
-{% endblock %}
-
{% block error %}
{%- if error is defined -%}
{{- error -}}
diff --git a/src/Exceptions/DifferentValuesException.php b/src/Exceptions/DifferentValuesException.php
index b796fd2e3..51db75e06 100644
--- a/src/Exceptions/DifferentValuesException.php
+++ b/src/Exceptions/DifferentValuesException.php
@@ -83,7 +83,7 @@ class DifferentValuesException extends \Exception
*
* @param \Exception $previous The previous exception used for the exception chaining.
*/
- public function __construct($expected, $actual, $strict, $message = '', $code = 0, \Exception $previous = null)
+ public function __construct($expected, $actual, $strict, $message = '', $code = 0, ?\Exception $previous = null)
{
parent::__construct(
$message,
diff --git a/src/Filter/FilterUrlBuilder.php b/src/Filter/FilterUrlBuilder.php
index 1ccde73ed..d375dd5ab 100644
--- a/src/Filter/FilterUrlBuilder.php
+++ b/src/Filter/FilterUrlBuilder.php
@@ -128,7 +128,7 @@ public function generate(FilterUrl $filterUrl): string
*
* @return FilterUrl
*/
- public function getCurrentFilterUrl(array $options = null): FilterUrl
+ public function getCurrentFilterUrl(?array $options = null): FilterUrl
{
$this->addFromCurrentRequest($filterUrl = new FilterUrl(), $options);
@@ -155,7 +155,7 @@ public function getCurrentFilterUrl(array $options = null): FilterUrl
*
* @return void
*/
- public function addFromCurrentRequest(FilterUrl $filterUrl, array $options = null): void
+ public function addFromCurrentRequest(FilterUrl $filterUrl, ?array $options = null): void
{
if (null === $options) {
$options = [
diff --git a/src/Filter/Setting/Simple.php b/src/Filter/Setting/Simple.php
index 1770cc4ca..6f7f76487 100644
--- a/src/Filter/Setting/Simple.php
+++ b/src/Filter/Setting/Simple.php
@@ -98,9 +98,9 @@ abstract class Simple implements ISimple
public function __construct(
$collection,
$data,
- EventDispatcherInterface $eventDispatcher = null,
- FilterUrlBuilder $filterUrlBuilder = null,
- TranslatorInterface $translator = null
+ ?EventDispatcherInterface $eventDispatcher = null,
+ ?FilterUrlBuilder $filterUrlBuilder = null,
+ ?TranslatorInterface $translator = null
) {
$this->collection = $collection;
$this->data = $data;
diff --git a/src/FrontendIntegration/FrontendFilter.php b/src/FrontendIntegration/FrontendFilter.php
index a0f296a0b..06150aafc 100644
--- a/src/FrontendIntegration/FrontendFilter.php
+++ b/src/FrontendIntegration/FrontendFilter.php
@@ -95,14 +95,14 @@ class FrontendFilter
/**
* FrontendFilter constructor.
*
- * @param Connection|null $connection Database connection.
- * @param FilterUrlBuilder|null $filterUrlBuilder The filter URL builder.
- * @param TranslatorInterface $translator The translator.
+ * @param Connection|null $connection Database connection.
+ * @param FilterUrlBuilder|null $filterUrlBuilder The filter URL builder.
+ * @param TranslatorInterface|null $translator The translator.
*/
public function __construct(
- Connection $connection = null,
- FilterUrlBuilder $filterUrlBuilder = null,
- TranslatorInterface $translator = null
+ ?Connection $connection = null,
+ ?FilterUrlBuilder $filterUrlBuilder = null,
+ ?TranslatorInterface $translator = null
) {
if (null === $connection) {
// @codingStandardsIgnoreStart
diff --git a/src/Helper/ToolboxFile.php b/src/Helper/ToolboxFile.php
index 4820633f1..09b1cefaa 100644
--- a/src/Helper/ToolboxFile.php
+++ b/src/Helper/ToolboxFile.php
@@ -249,11 +249,11 @@ class ToolboxFile
* @SuppressWarnings(PHPMD.NPathComplexity)
*/
public function __construct(
- ImageFactoryInterface|EventDispatcherInterface $imageFactory = null,
- string $rootDir = null,
- ContextInterface $filesContext = null,
- PictureFactoryInterface $pictureFactory = null,
- RequestStack $requestStack = null
+ ImageFactoryInterface|EventDispatcherInterface|null $imageFactory = null,
+ ?string $rootDir = null,
+ ?ContextInterface $filesContext = null,
+ ?PictureFactoryInterface $pictureFactory = null,
+ ?RequestStack $requestStack = null
) {
switch (true) {
case ($imageFactory instanceof ImageFactoryInterface) && (null !== $rootDir):
@@ -902,6 +902,7 @@ private function checkDownloads()
// Check key and return 403 if mismatch
// keep both null-coalescing values different to account for missing values.
if (($links[$file] ?? null) !== (Input::get('fileKey') ?? false)) {
+ /** @psalm-suppress DeprecatedClass */
(new PageError403())->getResponse();
}
}
diff --git a/src/Item.php b/src/Item.php
index d273b258b..ebf175df7 100644
--- a/src/Item.php
+++ b/src/Item.php
@@ -79,7 +79,7 @@ class Item implements IItem, IDirtyTracking
* @param array|null $arrData The initial data that shall be injected into the new instance.
* @param EventDispatcherInterface|null $dispatcher The event dispatcher.
*/
- public function __construct(IMetaModel $objMetaModel, $arrData, EventDispatcherInterface $dispatcher = null)
+ public function __construct(IMetaModel $objMetaModel, $arrData, ?EventDispatcherInterface $dispatcher = null)
{
$this->metaModel = $objMetaModel;
$this->dispatcher = $dispatcher;
diff --git a/src/ItemList.php b/src/ItemList.php
index 4952b2ad3..2ed42dc5e 100644
--- a/src/ItemList.php
+++ b/src/ItemList.php
@@ -54,6 +54,7 @@
use MetaModels\Render\Setting\ICollection as IRenderSettingCollection;
use MetaModels\Render\Setting\IRenderSettingFactory;
use MetaModels\Render\Template;
+use MetaModels\Render\TemplateFactory;
use RuntimeException;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
use Symfony\Component\HttpFoundation\RequestStack;
@@ -65,7 +66,6 @@
use function func_num_args;
use function in_array;
use function is_int;
-use function is_object;
use function sprintf;
use function strtoupper;
use function trigger_error;
@@ -221,11 +221,11 @@ class ItemList
* @SuppressWarnings(PHPMD.ExcessiveParameterList)
*/
public function __construct(
- IFactory $factory = null,
- IFilterSettingFactory $filterFactory = null,
- IRenderSettingFactory $renderSettingFactory = null,
- EventDispatcherInterface $eventDispatcher = null,
- FilterUrlBuilder $filterUrlBuilder = null,
+ ?IFactory $factory = null,
+ ?IFilterSettingFactory $filterFactory = null,
+ ?IRenderSettingFactory $renderSettingFactory = null,
+ ?EventDispatcherInterface $eventDispatcher = null,
+ ?FilterUrlBuilder $filterUrlBuilder = null,
string $pageParam = 'page',
string $paramType = 'get',
int $maxPaginationLinks = 0,
@@ -500,7 +500,7 @@ public function setSorting(string $sortBy, string $sortDirection = 'ASC'): self
*
* @return ItemList
*/
- public function overrideOutputFormat(string $outputFormat = null): self
+ public function overrideOutputFormat(?string $outputFormat = null): self
{
$outputFormat = (string) $outputFormat;
if ('' !== $outputFormat) {
@@ -682,7 +682,10 @@ protected function prepareView(): void
$this->objView = $metaModel->getView((int) $this->intView);
}
- $this->objTemplate = new Template((string) $this->objView->get('template'));
+ $templateFactory = System::getContainer()->get('metamodels.template_factory');
+ assert($templateFactory instanceof TemplateFactory);
+
+ $this->objTemplate = $templateFactory->createTemplate((string) $this->objView->get('template'));
/** @psalm-suppress UndefinedMagicPropertyAssignment */
$this->objTemplate->view = $this->objView;
}
@@ -1259,7 +1262,7 @@ public function setSortingLinkGenerator(SortingLinkGenerator $generator): self
*
* @psalm-suppress UndefinedMagicPropertyAssignment
*/
- public function render(bool $isNoNativeParsing, object $caller = null): string
+ public function render(bool $isNoNativeParsing, ?object $caller = null): string
{
if (func_num_args() > 1) {
trigger_error('Passing $objCaller as second argument is deprecated', E_USER_DEPRECATED);
diff --git a/src/MetaModel.php b/src/MetaModel.php
index 9113780b9..d46d0d2e4 100644
--- a/src/MetaModel.php
+++ b/src/MetaModel.php
@@ -125,8 +125,8 @@ class MetaModel implements IMetaModel
*/
public function __construct(
$arrData,
- EventDispatcherInterface $dispatcher = null,
- Connection $connection = null
+ ?EventDispatcherInterface $dispatcher = null,
+ ?Connection $connection = null
) {
foreach ($arrData as $strKey => $varValue) {
$this->arrData[$strKey] = $this->tryUnserialize($varValue);
@@ -166,6 +166,8 @@ public function __construct(
* {@inheritdoc}
*
* @deprecated Inject services via constructor or setter.
+ *
+ * @psalm-suppress DeprecatedProperty
*/
#[\Override]
public function getServiceContainer()
@@ -198,6 +200,8 @@ public function getServiceContainer()
* @return MetaModel
*
* @deprecated Inject services via constructor or setter.
+ *
+ * @psalm-suppress DeprecatedProperty
*/
public function setServiceContainer($serviceContainer, $deprecationNotice = true)
{
diff --git a/src/Render/Setting/Collection.php b/src/Render/Setting/Collection.php
index 9f8370533..d08b4b611 100644
--- a/src/Render/Setting/Collection.php
+++ b/src/Render/Setting/Collection.php
@@ -108,7 +108,7 @@ public function __construct(
array $arrInformation,
EventDispatcherInterface $dispatcher,
IFilterSettingFactory $filterFactory,
- FilterUrlBuilder $filterUrlBuilder = null
+ ?FilterUrlBuilder $filterUrlBuilder = null
) {
$this->metaModel = $metaModel;
$this->dispatcher = $dispatcher;
@@ -281,7 +281,7 @@ private function determineJumpToInformation(): array
*
* @return array
*/
- private function lookupJumpTo(bool $translated, string $desired = null, string $fallback = null): array
+ private function lookupJumpTo(bool $translated, ?string $desired = null, ?string $fallback = null): array
{
$jumpToPageId = '';
$filterSettingId = '';
@@ -322,7 +322,7 @@ private function lookupJumpTo(bool $translated, string $desired = null, string $
* {@inheritdoc}
*/
#[\Override]
- public function buildJumpToUrlFor(IItem $item /**, ?int $referenceType */)
+ public function buildJumpToUrlFor(IItem $item, ?int $referenceType = null)
{
$information = $this->determineJumpToInformation();
if (empty($information['pageDetails'])) {
diff --git a/src/Render/Template.php b/src/Render/Template.php
index 60680cd4b..22c6f83d6 100644
--- a/src/Render/Template.php
+++ b/src/Render/Template.php
@@ -148,8 +148,8 @@ public function __call($strMethod, $arrArgs)
*/
public function __construct(
$strTemplate = '',
- Adapter $templateLoader = null,
- RequestScopeDeterminator $scopeDeterminator = null
+ ?Adapter $templateLoader = null,
+ ?RequestScopeDeterminator $scopeDeterminator = null
) {
$this->strTemplate = $strTemplate;
@@ -638,7 +638,7 @@ public function endblock()
*
* @return void
*/
- public function insert($strName, array $arrData = null)
+ public function insert($strName, ?array $arrData = null)
{
if ($this->scopeDeterminator->currentScopeIsBackend()) {
$objTemplate = new BackendTemplate($strName);
diff --git a/src/Render/TemplateFactory.php b/src/Render/TemplateFactory.php
new file mode 100644
index 000000000..370a2849e
--- /dev/null
+++ b/src/Render/TemplateFactory.php
@@ -0,0 +1,30 @@
+templateLoader,
+ $this->requestScopeDeterminator,
+ );
+ }
+}
diff --git a/tests/Attribute/AttributeFactoryTest.php b/tests/Attribute/AttributeFactoryTest.php
index 652141420..f82a2eb51 100644
--- a/tests/Attribute/AttributeFactoryTest.php
+++ b/tests/Attribute/AttributeFactoryTest.php
@@ -140,7 +140,7 @@ protected function mockFactoryTester($factory, $attributeFactory, $shouldTransla
*/
public function testAttributeTypeMatchesFlags()
{
- $factory = new AttributeFactory($this->getMockForAbstractClass(EventDispatcherInterface::class));
+ $factory = new AttributeFactory($this->createMock(EventDispatcherInterface::class));
$factory->addTypeFactory($this->mockAttributeFactory('test_translated', true, false, false));
$factory->addTypeFactory($this->mockAttributeFactory('test_simple', false, true, false));
$factory->addTypeFactory($this->mockAttributeFactory('test_complex', false, false, true));
@@ -167,7 +167,7 @@ public function testAttributeTypeMatchesFlags()
*/
public function testGetTypeNames()
{
- $factory = new AttributeFactory($this->getMockForAbstractClass(EventDispatcherInterface::class));
+ $factory = new AttributeFactory($this->createMock(EventDispatcherInterface::class));
self::assertSame(
array(),
@@ -275,7 +275,7 @@ public function testGetTypeNames()
*/
public function testGetTypeIcon()
{
- $factory = new AttributeFactory($this->getMockForAbstractClass(EventDispatcherInterface::class));
+ $factory = new AttributeFactory($this->createMock(EventDispatcherInterface::class));
$typeFactory = $this->mockAttributeFactory('test', true, false, false, new \stdClass(), 'icon.png');
$factory->addTypeFactory($typeFactory);
@@ -307,7 +307,7 @@ protected function mockAttributeFactory(
$class = 'stdClass',
$typeIcon = 'icon.png'
) {
- $mockTypeFactory = $this->getMockForAbstractClass(IAttributeTypeFactory::class);
+ $mockTypeFactory = $this->createMock(IAttributeTypeFactory::class);
$mockTypeFactory
->expects(self::any())
diff --git a/tests/Attribute/BaseSimpleTest.php b/tests/Attribute/BaseSimpleTest.php
index c5a1668a0..8521c325c 100644
--- a/tests/Attribute/BaseSimpleTest.php
+++ b/tests/Attribute/BaseSimpleTest.php
@@ -28,12 +28,13 @@
use MetaModels\Helper\TableManipulator;
use MetaModels\IMetaModel;
use PHPUnit\Framework\TestCase;
+use PHPUnit\Framework\Attributes\CoversClass;
/**
* Class BaseSimpleTest
*
- * @covers \MetaModels\Attribute\BaseSimple
*/
+#[CoversClass(\MetaModels\Attribute\BaseSimple::class)]
class BaseSimpleTest extends TestCase
{
/**
diff --git a/tests/Attribute/BaseTest.php b/tests/Attribute/BaseTest.php
index 382036b2b..c7f60f32d 100644
--- a/tests/Attribute/BaseTest.php
+++ b/tests/Attribute/BaseTest.php
@@ -23,12 +23,13 @@
use MetaModels\Attribute\Base;
use MetaModels\IMetaModel;
use PHPUnit\Framework\TestCase;
+use PHPUnit\Framework\Attributes\CoversClass;
/**
* Test the base attribute.
*
- * @covers \MetaModels\Attribute\Base
*/
+#[CoversClass(\MetaModels\Attribute\Base::class)]
class BaseTest extends TestCase
{
/**
@@ -41,7 +42,7 @@ class BaseTest extends TestCase
*/
protected function mockMetaModel($language, $fallbackLanguage)
{
- $metaModel = $this->getMockForAbstractClass(IMetaModel::class);
+ $metaModel = $this->createMock(IMetaModel::class);
$metaModel
->expects(self::any())
@@ -106,13 +107,15 @@ protected function getAttribute($data = array(), $metaModel = null)
/** @var Base $attribute */
return $this
- ->getMockForAbstractClass(
- 'MetaModels\Attribute\Base',
+ ->getMockBuilder('MetaModels\Attribute\Base')
+ ->setConstructorArgs(
array(
$metaModel ?: $this->mockMetaModel('en', 'en'),
$serialized
)
- );
+ )
+ ->onlyMethods(['searchFor', 'setDataFor', 'getFilterOptions'])
+ ->getMock();
}
/**
diff --git a/tests/CoreBundle/DependencyInjection/CompilerPass/CollectDoctrineSchemaGeneratorsPassTest.php b/tests/CoreBundle/DependencyInjection/CompilerPass/CollectDoctrineSchemaGeneratorsPassTest.php
index 468229021..3296b327c 100644
--- a/tests/CoreBundle/DependencyInjection/CompilerPass/CollectDoctrineSchemaGeneratorsPassTest.php
+++ b/tests/CoreBundle/DependencyInjection/CompilerPass/CollectDoctrineSchemaGeneratorsPassTest.php
@@ -29,12 +29,13 @@
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Definition;
use Symfony\Component\DependencyInjection\Reference;
+use PHPUnit\Framework\Attributes\CoversClass;
/**
* This tests the schema generator collecting.
*
- * @covers \MetaModels\CoreBundle\DependencyInjection\CompilerPass\CollectDoctrineSchemaGeneratorsPass
*/
+#[CoversClass(\MetaModels\CoreBundle\DependencyInjection\CompilerPass\CollectDoctrineSchemaGeneratorsPass::class)]
class CollectDoctrineSchemaGeneratorsPassTest extends TestCase
{
/**
diff --git a/tests/CoreBundle/DependencyInjection/CompilerPass/CollectSchemaGeneratorsPassTest.php b/tests/CoreBundle/DependencyInjection/CompilerPass/CollectSchemaGeneratorsPassTest.php
index dce0a623b..37746a811 100644
--- a/tests/CoreBundle/DependencyInjection/CompilerPass/CollectSchemaGeneratorsPassTest.php
+++ b/tests/CoreBundle/DependencyInjection/CompilerPass/CollectSchemaGeneratorsPassTest.php
@@ -28,12 +28,13 @@
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Definition;
use Symfony\Component\DependencyInjection\Reference;
+use PHPUnit\Framework\Attributes\CoversClass;
/**
* This tests the schema generator collecting.
*
- * @covers \MetaModels\CoreBundle\DependencyInjection\CompilerPass\CollectSchemaGeneratorsPass
*/
+#[CoversClass(\MetaModels\CoreBundle\DependencyInjection\CompilerPass\CollectSchemaGeneratorsPass::class)]
class CollectSchemaGeneratorsPassTest extends TestCase
{
/**
diff --git a/tests/CoreBundle/DependencyInjection/CompilerPass/CollectSchemaManagersPassTest.php b/tests/CoreBundle/DependencyInjection/CompilerPass/CollectSchemaManagersPassTest.php
index 854007b2c..8ab9ffdcd 100644
--- a/tests/CoreBundle/DependencyInjection/CompilerPass/CollectSchemaManagersPassTest.php
+++ b/tests/CoreBundle/DependencyInjection/CompilerPass/CollectSchemaManagersPassTest.php
@@ -28,12 +28,13 @@
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Definition;
use Symfony\Component\DependencyInjection\Reference;
+use PHPUnit\Framework\Attributes\CoversClass;
/**
* This tests the schema generator collecting.
*
- * @covers \MetaModels\CoreBundle\DependencyInjection\CompilerPass\CollectSchemaManagersPass
*/
+#[CoversClass(\MetaModels\CoreBundle\DependencyInjection\CompilerPass\CollectSchemaManagersPass::class)]
class CollectSchemaManagersPassTest extends TestCase
{
/**
diff --git a/tests/CoreBundle/Formatter/SelectAttributeOptionLabelFormatterTest.php b/tests/CoreBundle/Formatter/SelectAttributeOptionLabelFormatterTest.php
index 84b419377..980397ab6 100644
--- a/tests/CoreBundle/Formatter/SelectAttributeOptionLabelFormatterTest.php
+++ b/tests/CoreBundle/Formatter/SelectAttributeOptionLabelFormatterTest.php
@@ -25,17 +25,18 @@
use MetaModels\Attribute\IAttribute;
use MetaModels\CoreBundle\Formatter\SelectAttributeOptionLabelFormatter;
use PHPUnit\Framework\TestCase;
+use PHPUnit\Framework\Attributes\CoversClass;
/**
* The test for MetaModels\CoreBundle\Formatter\SelectAttributeOptionLabelFormatter.
*
- * @covers \MetaModels\CoreBundle\Formatter\SelectAttributeOptionLabelFormatter
*/
+#[CoversClass(\MetaModels\CoreBundle\Formatter\SelectAttributeOptionLabelFormatter::class)]
class SelectAttributeOptionLabelFormatterTest extends TestCase
{
public function testFormatLabel(): void
{
- $attribute = $this->getMockBuilder(IAttribute::class)->getMockForAbstractClass();
+ $attribute = $this->getMockBuilder(IAttribute::class)->getMock();
$attribute
->expects(self::once())
->method('getName')
diff --git a/tests/Data/FilterBuilderTest.php b/tests/Data/FilterBuilderTest.php
index c225967fe..5bfae230e 100644
--- a/tests/Data/FilterBuilderTest.php
+++ b/tests/Data/FilterBuilderTest.php
@@ -29,12 +29,13 @@
use PHPUnit\Framework\TestCase;
use MetaModels\Attribute\Base;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
+use PHPUnit\Framework\Attributes\CoversClass;
/**
* Test the filter builder.
*
- * @covers \MetaModels\DcGeneral\Data\FilterBuilder
*/
+#[CoversClass(\MetaModels\DcGeneral\Data\FilterBuilder::class)]
class FilterBuilderTest extends TestCase
{
/**
@@ -106,8 +107,8 @@ public function testBuildSqlOnly()
$attribute = $this
->getMockBuilder(Base::class)
->setConstructorArgs([$metaModel, ['colname' => 'test1']])
- ->onlyMethods(['searchFor'])
- ->getMockForAbstractClass();
+ ->onlyMethods(['searchFor', 'setDataFor', 'getFilterOptions'])
+ ->getMock();
$attribute
->expects(self::once())
@@ -177,8 +178,8 @@ public function testIssue700()
$attribute = $this
->getMockBuilder(Base::class)
->setConstructorArgs([$metaModel, ['colname' => 'test1']])
- ->onlyMethods(['searchFor'])
- ->getMockForAbstractClass();
+ ->onlyMethods(['searchFor', 'setDataFor', 'getFilterOptions'])
+ ->getMock();
$attribute
->expects(self::once())
diff --git a/tests/DcGeneral/Events/MetaModel/CopyTranslatedDataTest.php b/tests/DcGeneral/Events/MetaModel/CopyTranslatedDataTest.php
index 1c41188c4..554009519 100644
--- a/tests/DcGeneral/Events/MetaModel/CopyTranslatedDataTest.php
+++ b/tests/DcGeneral/Events/MetaModel/CopyTranslatedDataTest.php
@@ -30,10 +30,11 @@
use MetaModels\ITranslatedMetaModel;
use PHPUnit\Framework\MockObject\MockObject;
use PHPUnit\Framework\TestCase;
+use PHPUnit\Framework\Attributes\CoversClass;
/**
- * @covers \MetaModels\DcGeneral\Events\MetaModel\CopyTranslatedData
*/
+#[CoversClass(\MetaModels\DcGeneral\Events\MetaModel\CopyTranslatedData::class)]
class CopyTranslatedDataTest extends TestCase
{
/**
@@ -50,12 +51,12 @@ private function buildEvent(
string $newId,
string $providerName = 'mm_test'
): PostDuplicateModelEvent {
- $environment = $this->getMockForAbstractClass(EnvironmentInterface::class);
+ $environment = $this->createMock(EnvironmentInterface::class);
- $sourceModel = $this->getMockForAbstractClass(ModelInterface::class);
+ $sourceModel = $this->createMock(ModelInterface::class);
$sourceModel->method('getId')->willReturn($sourceId);
- $newModel = $this->getMockForAbstractClass(ModelInterface::class);
+ $newModel = $this->createMock(ModelInterface::class);
$newModel->method('getId')->willReturn($newId);
$newModel->method('getProviderName')->willReturn($providerName);
@@ -73,7 +74,7 @@ private function buildEvent(
private function buildListener(?IMetaModel $metaModel, string $providerName = 'mm_test'): CopyTranslatedData
{
/** @var IFactory&MockObject $factory */
- $factory = $this->getMockForAbstractClass(IFactory::class);
+ $factory = $this->createMock(IFactory::class);
$factory->method('getMetaModel')->with($providerName)->willReturn($metaModel);
return new CopyTranslatedData($factory);
@@ -85,7 +86,7 @@ private function buildListener(?IMetaModel $metaModel, string $providerName = 'm
public function testHandleDoesNothingWhenIdsAreEqual(): void
{
/** @var ITranslatedMetaModel&MockObject $metaModel */
- $metaModel = $this->getMockForAbstractClass(ITranslatedMetaModel::class);
+ $metaModel = $this->createMock(ITranslatedMetaModel::class);
$metaModel->expects(self::never())->method('getLanguages');
$listener = $this->buildListener($metaModel);
@@ -98,7 +99,7 @@ public function testHandleDoesNothingWhenIdsAreEqual(): void
public function testHandleDoesNothingWhenSourceIdIsEmpty(): void
{
/** @var ITranslatedMetaModel&MockObject $metaModel */
- $metaModel = $this->getMockForAbstractClass(ITranslatedMetaModel::class);
+ $metaModel = $this->createMock(ITranslatedMetaModel::class);
$metaModel->expects(self::never())->method('getLanguages');
$listener = $this->buildListener($metaModel);
@@ -111,7 +112,7 @@ public function testHandleDoesNothingWhenSourceIdIsEmpty(): void
public function testHandleDoesNothingWhenNewIdIsEmpty(): void
{
/** @var ITranslatedMetaModel&MockObject $metaModel */
- $metaModel = $this->getMockForAbstractClass(ITranslatedMetaModel::class);
+ $metaModel = $this->createMock(ITranslatedMetaModel::class);
$metaModel->expects(self::never())->method('getLanguages');
$listener = $this->buildListener($metaModel);
@@ -124,7 +125,7 @@ public function testHandleDoesNothingWhenNewIdIsEmpty(): void
public function testHandleDoesNothingForNonTranslatedMetaModel(): void
{
/** @var IMetaModel&MockObject $metaModel */
- $metaModel = $this->getMockForAbstractClass(IMetaModel::class);
+ $metaModel = $this->createMock(IMetaModel::class);
$metaModel->expects(self::never())->method('getAttributes');
$listener = $this->buildListener($metaModel);
@@ -137,11 +138,11 @@ public function testHandleDoesNothingForNonTranslatedMetaModel(): void
public function testHandleSkipsAttributesWithoutFallbackControlInterface(): void
{
/** @var ITranslated&MockObject $attribute */
- $attribute = $this->getMockForAbstractClass(ITranslated::class);
+ $attribute = $this->createMock(ITranslated::class);
$attribute->expects(self::never())->method('setTranslatedDataFor');
/** @var ITranslatedMetaModel&MockObject $metaModel */
- $metaModel = $this->getMockForAbstractClass(ITranslatedMetaModel::class);
+ $metaModel = $this->createMock(ITranslatedMetaModel::class);
$metaModel->method('getLanguages')->willReturn(['de', 'en']);
$metaModel->method('getAttributes')->willReturn([$attribute]);
@@ -155,12 +156,12 @@ public function testHandleSkipsAttributesWithoutFallbackControlInterface(): void
public function testHandleSkipsLanguagesWithNoData(): void
{
/** @var ITranslatedWithFallbackControl&MockObject $attribute */
- $attribute = $this->getMockForAbstractClass(ITranslatedWithFallbackControl::class);
+ $attribute = $this->createMock(ITranslatedWithFallbackControl::class);
$attribute->method('getTranslatedDataForWithoutFallback')->willReturn([]);
$attribute->expects(self::never())->method('applyTranslatedDataFor');
/** @var ITranslatedMetaModel&MockObject $metaModel */
- $metaModel = $this->getMockForAbstractClass(ITranslatedMetaModel::class);
+ $metaModel = $this->createMock(ITranslatedMetaModel::class);
$metaModel->method('getLanguages')->willReturn(['de', 'en']);
$metaModel->method('getAttributes')->willReturn([$attribute]);
@@ -180,7 +181,7 @@ public function testHandleCopiesDataForAllLanguages(): void
$dataEN = ['item_id' => $sourceId, 'langcode' => 'en', 'value' => 'Hello'];
/** @var ITranslatedWithFallbackControl&MockObject $attribute */
- $attribute = $this->getMockForAbstractClass(ITranslatedWithFallbackControl::class);
+ $attribute = $this->createMock(ITranslatedWithFallbackControl::class);
$attribute->method('getTranslatedDataForWithoutFallback')->willReturnMap([
[[$sourceId], 'de', [$sourceId => $dataDE]],
[[$sourceId], 'en', [$sourceId => $dataEN]],
@@ -198,7 +199,7 @@ static function (array $arrValues, string $lang) use ($newId, $dataDE, $dataEN):
);
/** @var ITranslatedMetaModel&MockObject $metaModel */
- $metaModel = $this->getMockForAbstractClass(ITranslatedMetaModel::class);
+ $metaModel = $this->createMock(ITranslatedMetaModel::class);
$metaModel->method('getLanguages')->willReturn(['de', 'en']);
$metaModel->method('getAttributes')->willReturn([$attribute]);
@@ -217,7 +218,7 @@ public function testHandleCopiesOnlyLanguagesWithActualData(): void
$dataDE = ['item_id' => $sourceId, 'langcode' => 'de', 'value' => 'Hallo'];
/** @var ITranslatedWithFallbackControl&MockObject $attribute */
- $attribute = $this->getMockForAbstractClass(ITranslatedWithFallbackControl::class);
+ $attribute = $this->createMock(ITranslatedWithFallbackControl::class);
$attribute->method('getTranslatedDataForWithoutFallback')->willReturnMap([
[[$sourceId], 'de', [$sourceId => $dataDE]],
[[$sourceId], 'en', []],
@@ -227,7 +228,7 @@ public function testHandleCopiesOnlyLanguagesWithActualData(): void
->with([$newId => $dataDE], 'de');
/** @var ITranslatedMetaModel&MockObject $metaModel */
- $metaModel = $this->getMockForAbstractClass(ITranslatedMetaModel::class);
+ $metaModel = $this->createMock(ITranslatedMetaModel::class);
$metaModel->method('getLanguages')->willReturn(['de', 'en']);
$metaModel->method('getAttributes')->willReturn([$attribute]);
@@ -247,17 +248,17 @@ public function testHandleProcessesMultipleAttributes(): void
$data2 = ['item_id' => $sourceId, 'langcode' => 'de', 'value' => 'Attr2'];
/** @var ITranslatedWithFallbackControl&MockObject $attribute1 */
- $attribute1 = $this->getMockForAbstractClass(ITranslatedWithFallbackControl::class);
+ $attribute1 = $this->createMock(ITranslatedWithFallbackControl::class);
$attribute1->method('getTranslatedDataForWithoutFallback')->willReturn([$sourceId => $data1]);
$attribute1->expects(self::once())->method('applyTranslatedDataFor')->with([$newId => $data1], 'de');
/** @var ITranslatedWithFallbackControl&MockObject $attribute2 */
- $attribute2 = $this->getMockForAbstractClass(ITranslatedWithFallbackControl::class);
+ $attribute2 = $this->createMock(ITranslatedWithFallbackControl::class);
$attribute2->method('getTranslatedDataForWithoutFallback')->willReturn([$sourceId => $data2]);
$attribute2->expects(self::once())->method('applyTranslatedDataFor')->with([$newId => $data2], 'de');
/** @var ITranslatedMetaModel&MockObject $metaModel */
- $metaModel = $this->getMockForAbstractClass(ITranslatedMetaModel::class);
+ $metaModel = $this->createMock(ITranslatedMetaModel::class);
$metaModel->method('getLanguages')->willReturn(['de']);
$metaModel->method('getAttributes')->willReturn([$attribute1, $attribute2]);
diff --git a/tests/DcGeneral/Events/MetaModel/ResetLanguageAfterDuplicateTest.php b/tests/DcGeneral/Events/MetaModel/ResetLanguageAfterDuplicateTest.php
index 0fe76e54e..3e36ec84c 100644
--- a/tests/DcGeneral/Events/MetaModel/ResetLanguageAfterDuplicateTest.php
+++ b/tests/DcGeneral/Events/MetaModel/ResetLanguageAfterDuplicateTest.php
@@ -29,10 +29,11 @@
use MetaModels\ITranslatedMetaModel;
use PHPUnit\Framework\MockObject\MockObject;
use PHPUnit\Framework\TestCase;
+use PHPUnit\Framework\Attributes\CoversClass;
/**
- * @covers \MetaModels\DcGeneral\Events\MetaModel\ResetLanguageAfterDuplicate
*/
+#[CoversClass(\MetaModels\DcGeneral\Events\MetaModel\ResetLanguageAfterDuplicate::class)]
class ResetLanguageAfterDuplicateTest extends TestCase
{
/**
@@ -46,13 +47,13 @@ class ResetLanguageAfterDuplicateTest extends TestCase
private function buildEvent(string $providerName, SessionStorageInterface $sessionStorage): PostDuplicateModelEvent
{
/** @var SessionStorageInterface&MockObject $sessionStorage */
- $environment = $this->getMockForAbstractClass(EnvironmentInterface::class);
+ $environment = $this->createMock(EnvironmentInterface::class);
$environment->method('getSessionStorage')->willReturn($sessionStorage);
- $sourceModel = $this->getMockForAbstractClass(ModelInterface::class);
+ $sourceModel = $this->createMock(ModelInterface::class);
$sourceModel->method('getId')->willReturn('1');
- $newModel = $this->getMockForAbstractClass(ModelInterface::class);
+ $newModel = $this->createMock(ModelInterface::class);
$newModel->method('getId')->willReturn('2');
$newModel->method('getProviderName')->willReturn($providerName);
@@ -72,7 +73,7 @@ private function buildListener(
string $providerName = 'mm_test'
): ResetLanguageAfterDuplicate {
/** @var IFactory&MockObject $factory */
- $factory = $this->getMockForAbstractClass(IFactory::class);
+ $factory = $this->createMock(IFactory::class);
$factory->method('getMetaModel')->with($providerName)->willReturn($metaModel);
return new ResetLanguageAfterDuplicate($factory);
@@ -84,11 +85,11 @@ private function buildListener(
public function testHandleDoesNothingForNonTranslatedMetaModel(): void
{
/** @var SessionStorageInterface&MockObject $sessionStorage */
- $sessionStorage = $this->getMockForAbstractClass(SessionStorageInterface::class);
+ $sessionStorage = $this->createMock(SessionStorageInterface::class);
$sessionStorage->expects(self::never())->method('set');
/** @var IMetaModel&MockObject $metaModel */
- $metaModel = $this->getMockForAbstractClass(IMetaModel::class);
+ $metaModel = $this->createMock(IMetaModel::class);
$listener = $this->buildListener($metaModel);
$listener->handle($this->buildEvent('mm_test', $sessionStorage));
@@ -100,7 +101,7 @@ public function testHandleDoesNothingForNonTranslatedMetaModel(): void
public function testHandleDoesNothingWhenMetaModelNotFound(): void
{
/** @var SessionStorageInterface&MockObject $sessionStorage */
- $sessionStorage = $this->getMockForAbstractClass(SessionStorageInterface::class);
+ $sessionStorage = $this->createMock(SessionStorageInterface::class);
$sessionStorage->expects(self::never())->method('set');
$listener = $this->buildListener(null);
@@ -116,7 +117,7 @@ public function testHandleWritesFallbackLanguageToSession(): void
$fallbackLanguage = 'de';
/** @var SessionStorageInterface&MockObject $sessionStorage */
- $sessionStorage = $this->getMockForAbstractClass(SessionStorageInterface::class);
+ $sessionStorage = $this->createMock(SessionStorageInterface::class);
$sessionStorage->method('get')->with('dc_general')->willReturn([]);
$sessionStorage
->expects(self::once())
@@ -129,7 +130,7 @@ public function testHandleWritesFallbackLanguageToSession(): void
);
/** @var ITranslatedMetaModel&MockObject $metaModel */
- $metaModel = $this->getMockForAbstractClass(ITranslatedMetaModel::class);
+ $metaModel = $this->createMock(ITranslatedMetaModel::class);
$metaModel->method('getMainLanguage')->willReturn($fallbackLanguage);
$listener = $this->buildListener($metaModel, $providerName);
@@ -145,7 +146,7 @@ public function testHandlePreservesExistingSessionData(): void
$fallbackLanguage = 'en';
/** @var SessionStorageInterface&MockObject $sessionStorage */
- $sessionStorage = $this->getMockForAbstractClass(SessionStorageInterface::class);
+ $sessionStorage = $this->createMock(SessionStorageInterface::class);
$sessionStorage->method('get')->with('dc_general')->willReturn([
'ml_support' => ['mm_other' => 'fr'],
'some_key' => 'some_value',
@@ -165,7 +166,7 @@ static function (array $session) use ($providerName, $fallbackLanguage): bool {
);
/** @var ITranslatedMetaModel&MockObject $metaModel */
- $metaModel = $this->getMockForAbstractClass(ITranslatedMetaModel::class);
+ $metaModel = $this->createMock(ITranslatedMetaModel::class);
$metaModel->method('getMainLanguage')->willReturn($fallbackLanguage);
$listener = $this->buildListener($metaModel, $providerName);
diff --git a/tests/FactoryTest.php b/tests/FactoryTest.php
index c55de6fa4..aee5d278a 100644
--- a/tests/FactoryTest.php
+++ b/tests/FactoryTest.php
@@ -26,12 +26,13 @@
use PHPUnit\Framework\TestCase;
use Symfony\Component\EventDispatcher\EventDispatcher;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
+use PHPUnit\Framework\Attributes\CoversClass;
/**
* Test the attribute factory.
*
- * @covers \MetaModels\Factory
*/
+#[CoversClass(\MetaModels\Factory::class)]
class FactoryTest extends TestCase
{
/**
@@ -41,7 +42,7 @@ class FactoryTest extends TestCase
*/
public function testCreateMetaModelFiresEvent()
{
- $dispatcher = $this->getMockBuilder(EventDispatcherInterface::class)->getMockForAbstractClass();
+ $dispatcher = $this->getMockBuilder(EventDispatcherInterface::class)->getMock();
$factory = new Factory($dispatcher);
$dispatcher
diff --git a/tests/Filter/FilterUrlTest.php b/tests/Filter/FilterUrlTest.php
index f0700d0e4..18cec072f 100644
--- a/tests/Filter/FilterUrlTest.php
+++ b/tests/Filter/FilterUrlTest.php
@@ -22,12 +22,13 @@
use MetaModels\Filter\FilterUrl;
use PHPUnit\Framework\TestCase;
+use PHPUnit\Framework\Attributes\CoversClass;
/**
* This tests the filter url class.
*
- * @covers \MetaModels\Filter\FilterUrl
*/
+#[CoversClass(\MetaModels\Filter\FilterUrl::class)]
class FilterUrlTest extends TestCase
{
/**
diff --git a/tests/Filter/Rules/Comparing/GreaterThanTest.php b/tests/Filter/Rules/Comparing/GreaterThanTest.php
index 443aaeadd..bf3aee9d9 100644
--- a/tests/Filter/Rules/Comparing/GreaterThanTest.php
+++ b/tests/Filter/Rules/Comparing/GreaterThanTest.php
@@ -23,12 +23,13 @@
use MetaModels\Filter\Rules\Comparing\GreaterThan;
use PHPUnit\Framework\TestCase;
use MetaModels\Attribute\IAttribute;
+use PHPUnit\Framework\Attributes\CoversClass;
/**
* Test greater-than filter rules.
*
- * @covers \MetaModels\Filter\Rules\Comparing\GreaterThan
*/
+#[CoversClass(\MetaModels\Filter\Rules\Comparing\GreaterThan::class)]
class GreaterThanTest extends TestCase
{
/**
@@ -38,7 +39,7 @@ class GreaterThanTest extends TestCase
*/
public function testGreaterThan()
{
- $attribute = $this->getMockForAbstractClass(IAttribute::class);
+ $attribute = $this->createMock(IAttribute::class);
$attribute->expects(self::once())->method('filterGreaterThan')->with(10, false)->willReturn(array(1, 2, 3));
$rule = new GreaterThan($attribute, 10);
@@ -53,7 +54,7 @@ public function testGreaterThan()
*/
public function testGreaterThanInclusive()
{
- $attribute = $this->getMockForAbstractClass(IAttribute::class);
+ $attribute = $this->createMock(IAttribute::class);
$attribute->expects(self::once())->method('filterGreaterThan')->with(10, true)->willReturn(array(1, 2, 3));
$rule = new GreaterThan($attribute, 10, true);
diff --git a/tests/Filter/Rules/Comparing/LessThanTest.php b/tests/Filter/Rules/Comparing/LessThanTest.php
index 64b96ddc7..aaeccf9fc 100644
--- a/tests/Filter/Rules/Comparing/LessThanTest.php
+++ b/tests/Filter/Rules/Comparing/LessThanTest.php
@@ -23,12 +23,13 @@
use MetaModels\Filter\Rules\Comparing\LessThan;
use PHPUnit\Framework\TestCase;
use MetaModels\Attribute\IAttribute;
+use PHPUnit\Framework\Attributes\CoversClass;
/**
* Test greater-than filter rules.
*
- * @covers \MetaModels\Filter\Rules\Comparing\LessThan
*/
+#[CoversClass(\MetaModels\Filter\Rules\Comparing\LessThan::class)]
class LessThanTest extends TestCase
{
/**
@@ -38,7 +39,7 @@ class LessThanTest extends TestCase
*/
public function testGreaterThan()
{
- $attribute = $this->getMockForAbstractClass(IAttribute::class);
+ $attribute = $this->createMock(IAttribute::class);
$attribute->expects(self::once())->method('filterLessThan')->with(10, false)->willReturn(array(1, 2, 3));
$rule = new LessThan($attribute, 10);
@@ -53,7 +54,7 @@ public function testGreaterThan()
*/
public function testGreaterThanInclusive()
{
- $attribute = $this->getMockForAbstractClass(IAttribute::class);
+ $attribute = $this->createMock(IAttribute::class);
$attribute->expects(self::once())->method('filterLessThan')->with(10, true)->willReturn(array(1, 2, 3));
$rule = new LessThan($attribute, 10, true);
diff --git a/tests/Filter/Rules/Comparing/NotEqualTest.php b/tests/Filter/Rules/Comparing/NotEqualTest.php
index 2c2af35e0..e0bb2f3d0 100644
--- a/tests/Filter/Rules/Comparing/NotEqualTest.php
+++ b/tests/Filter/Rules/Comparing/NotEqualTest.php
@@ -23,12 +23,13 @@
use MetaModels\Filter\Rules\Comparing\NotEqual;
use PHPUnit\Framework\TestCase;
use MetaModels\Attribute\IAttribute;
+use PHPUnit\Framework\Attributes\CoversClass;
/**
* Test greater-than filter rules.
*
- * @covers \MetaModels\Filter\Rules\Comparing\NotEqual
*/
+#[CoversClass(\MetaModels\Filter\Rules\Comparing\NotEqual::class)]
class NotEqualTest extends TestCase
{
/**
@@ -38,7 +39,7 @@ class NotEqualTest extends TestCase
*/
public function testGreaterThan()
{
- $attribute = $this->getMockForAbstractClass(IAttribute::class);
+ $attribute = $this->createMock(IAttribute::class);
$attribute->expects(self::once())->method('filterNotEqual')->with(10)->willReturn(array(1, 2, 3));
$rule = new NotEqual($attribute, 10);
@@ -53,7 +54,7 @@ public function testGreaterThan()
*/
public function testGreaterThanInclusive()
{
- $attribute = $this->getMockForAbstractClass(IAttribute::class);
+ $attribute = $this->createMock(IAttribute::class);
$attribute->expects(self::once())->method('filterNotEqual')->with(10)->willReturn(array(1, 2, 3));
$rule = new NotEqual($attribute, 10);
diff --git a/tests/Filter/Rules/SearchAttributeTest.php b/tests/Filter/Rules/SearchAttributeTest.php
index 5ad17b5c7..421ac3a46 100644
--- a/tests/Filter/Rules/SearchAttributeTest.php
+++ b/tests/Filter/Rules/SearchAttributeTest.php
@@ -24,12 +24,13 @@
use PHPUnit\Framework\TestCase;
use MetaModels\Attribute\IAttribute;
use MetaModels\Attribute\ITranslated;
+use PHPUnit\Framework\Attributes\CoversClass;
/**
* Test greater-than filter rules.
*
- * @covers \MetaModels\Filter\Rules\SearchAttribute
*/
+#[CoversClass(\MetaModels\Filter\Rules\SearchAttribute::class)]
class SearchAttributeTest extends TestCase
{
/**
@@ -39,7 +40,7 @@ class SearchAttributeTest extends TestCase
*/
public function testSearchAttribute()
{
- $attribute = $this->getMockForAbstractClass(IAttribute::class);
+ $attribute = $this->createMock(IAttribute::class);
$attribute
->expects(self::once())
->method('searchFor')
@@ -58,7 +59,7 @@ public function testSearchAttribute()
*/
public function testSearchTranslatedAttribute()
{
- $attribute = $this->getMockForAbstractClass(ITranslated::class);
+ $attribute = $this->createMock(ITranslated::class);
$attribute
->expects(self::once())
->method('searchForInLanguages')
@@ -77,7 +78,7 @@ public function testSearchTranslatedAttribute()
*/
public function testSearchTranslatedAttributeWithLanguageOverride()
{
- $attribute = $this->getMockForAbstractClass(ITranslated::class);
+ $attribute = $this->createMock(ITranslated::class);
$attribute
->expects(self::once())
->method('searchForInLanguages')
diff --git a/tests/Filter/Rules/SimpleQueryTest.php b/tests/Filter/Rules/SimpleQueryTest.php
index aafb6b8b9..6698ce9ee 100644
--- a/tests/Filter/Rules/SimpleQueryTest.php
+++ b/tests/Filter/Rules/SimpleQueryTest.php
@@ -25,12 +25,13 @@
use Doctrine\DBAL\Result;
use MetaModels\Filter\Rules\SimpleQuery;
use PHPUnit\Framework\TestCase;
+use PHPUnit\Framework\Attributes\CoversClass;
/**
* This tests the simple query filter rule.
*
- * @covers \MetaModels\Filter\Rules\SimpleQuery
*/
+#[CoversClass(\MetaModels\Filter\Rules\SimpleQuery::class)]
class SimpleQueryTest extends TestCase
{
/**
diff --git a/tests/Filter/Setting/CollectionTest.php b/tests/Filter/Setting/CollectionTest.php
index a76afe9a4..1b1924a80 100644
--- a/tests/Filter/Setting/CollectionTest.php
+++ b/tests/Filter/Setting/CollectionTest.php
@@ -24,9 +24,6 @@
use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\TestCase;
-/**
- * @covers \MetaModels\Filter\Setting\Collection
- */
#[CoversClass(Collection::class)]
class CollectionTest extends TestCase
{
diff --git a/tests/Filter/Setting/CustomSqlTest.php b/tests/Filter/Setting/CustomSqlTest.php
index c933300cb..b5395e80b 100644
--- a/tests/Filter/Setting/CustomSqlTest.php
+++ b/tests/Filter/Setting/CustomSqlTest.php
@@ -56,6 +56,7 @@
* @SuppressWarnings(PHPMD.TooManyPublicMethods)
* @SuppressWarnings(PHPMD.TooManyMethods)
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
+ * @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
#[CoversClass(CustomSql::class)]
#[CoversClass(ReplaceParam::class)]
@@ -110,7 +111,7 @@ private function mockCustomSql(
$services[Input::class] = $this
->getMockBuilder(Adapter::class)
->disableOriginalConstructor()
- ->addMethods(['cookie', 'get', 'post'])
+ ->onlyMethods(['__call'])
->getMock();
}
if (!isset($services[Session::class])) {
@@ -141,7 +142,7 @@ private function mockCustomSql(
$services[IMetaModelsServiceContainer::class] = $this
->getMockBuilder(IMetaModelsServiceContainer::class)
->disableOriginalConstructor()
- ->getMockForAbstractClass();
+ ->getMock();
}
if (!isset($services[ContaoFramework::class])) {
$services[ContaoFramework::class] = $this
@@ -184,7 +185,7 @@ private function mockSession(array $values): Session
// key, default => value
$map[] = [$key, null, $value];
}
- $sessionBag = $this->getMockForAbstractClass(AttributeBagInterface::class);
+ $sessionBag = $this->createMock(AttributeBagInterface::class);
$sessionBag->method('get')->willReturnMap($map);
$session->method('getBag')->with('contao_frontend')->willReturn($sessionBag);
@@ -202,8 +203,8 @@ private function mockSession(array $values): Session
*/
protected function generateSql(CustomSql $instance, array $filterUrl = []): array
{
- $filter = new Filter($this->getMockForAbstractClass(IMetaModel::class));
- $container = $this->getMockForAbstractClass(ContainerInterface::class);
+ $filter = new Filter($this->createMock(IMetaModel::class));
+ $container = $this->createMock(ContainerInterface::class);
System::setContainer($container);
$instance->prepareRules($filter, $filterUrl);
@@ -308,9 +309,9 @@ public function testRequestGetWithEmptyParameter(): void
$input = $this
->getMockBuilder(Adapter::class)
->disableOriginalConstructor()
- ->addMethods(['cookie', 'get', 'post'])
+ ->onlyMethods(['__call'])
->getMock();
- $input->expects(self::once())->method('get')->with('category')->willReturn(null);
+ $input->expects(self::once())->method('__call')->with('get', ['category'])->willReturn(null);
$setting = $this->mockCustomSql(
['customsql' => 'SELECT id FROM tableName WHERE catname={{param::get?name=category&default=defaultcat}}'],
@@ -335,9 +336,9 @@ public function testRequestGetWithEmptyParameterAndInsertTag(): void
$input = $this
->getMockBuilder(Adapter::class)
->disableOriginalConstructor()
- ->addMethods(['cookie', 'get', 'post'])
+ ->onlyMethods(['__call'])
->getMock();
- $input->expects(self::once())->method('get')->with('category')->willReturn(null);
+ $input->expects(self::once())->method('__call')->with('get', ['category'])->willReturn(null);
$setting = $this->mockCustomSql(
['customsql' =>
@@ -363,12 +364,12 @@ public function testRequestGetParameter(): void
$input = $this
->getMockBuilder(Adapter::class)
->disableOriginalConstructor()
- ->addMethods(['cookie', 'get', 'post'])
+ ->onlyMethods(['__call'])
->getMock();
$input
->expects(self::once())
- ->method('get')
- ->with('category')
+ ->method('__call')
+ ->with('get', ['category'])
->willReturn('category name');
$setting = $this->mockCustomSql(
@@ -388,12 +389,12 @@ public function testRequestPostParameter(): void
$input = $this
->getMockBuilder(Adapter::class)
->disableOriginalConstructor()
- ->addMethods(['cookie', 'get', 'post'])
+ ->onlyMethods(['__call'])
->getMock();
$input
->expects($this->once())
- ->method('post')
- ->with('category')
+ ->method('__call')
+ ->with('post', ['category'])
->willReturn('category name');
$setting = $this->mockCustomSql(
@@ -413,12 +414,12 @@ public function testRequestCookie(): void
$input = $this
->getMockBuilder(Adapter::class)
->disableOriginalConstructor()
- ->addMethods(['cookie', 'get', 'post'])
+ ->onlyMethods(['__call'])
->getMock();
$input
->expects(self::once())
- ->method('cookie')
- ->with('category')
+ ->method('__call')
+ ->with('cookie', ['category'])
->willReturn('category name');
$setting = $this->mockCustomSql(
@@ -509,12 +510,12 @@ public function testRequestParameterAggregated(): void
$input = $this
->getMockBuilder(Adapter::class)
->disableOriginalConstructor()
- ->addMethods(['cookie', 'get', 'post'])
+ ->onlyMethods(['__call'])
->getMock();
$input
->expects(self::once())
- ->method('get')
- ->with('categories')
+ ->method('__call')
+ ->with('get', ['categories'])
->willReturn(['first', 'second']);
$setting = $this->mockCustomSql(
@@ -539,12 +540,12 @@ public function testRequestParameterAggregatedSet(): void
$input = $this
->getMockBuilder(Adapter::class)
->disableOriginalConstructor()
- ->addMethods(['cookie', 'get', 'post'])
+ ->onlyMethods(['__call'])
->getMock();
$input
->expects(self::once())
- ->method('get')
- ->with('ids')
+ ->method('__call')
+ ->with('get', ['ids'])
->willReturn(['1', '2']);
$setting = $this->mockCustomSql(
@@ -778,12 +779,12 @@ public function testIssue1495NoteDmolineus1448085843WithParameters(): void
$input = $this
->getMockBuilder(Adapter::class)
->disableOriginalConstructor()
- ->addMethods(['cookie', 'get', 'post'])
+ ->onlyMethods(['__call'])
->getMock();
$input
->expects(self::exactly(2))
- ->method('get')
- ->willReturnCallback(fn ($name) => ['act' => 'edit', 'id' => '10'][$name]);
+ ->method('__call')
+ ->willReturnCallback(fn ($method, $args) => ['act' => 'edit', 'id' => '10'][$args[0]]);
$setting = $this->mockCustomSql(
['customsql' => <<getMockForAbstractClass(ICollection::class);
- $eventDispatcher = $this->getMockForAbstractClass(EventDispatcherInterface::class);
+ $filterSetting = $this->createMock(ICollection::class);
+ $eventDispatcher = $this->createMock(EventDispatcherInterface::class);
if (null === $filterUrlBuilder) {
$filterUrlBuilder = $this->getMockBuilder(FilterUrlBuilder::class)
@@ -62,13 +63,14 @@ protected function mockSimpleFilterSetting(
}
if (null === $translator) {
- $translator = $this->getMockForAbstractClass(TranslatorInterface::class);
+ $translator = $this->createMock(TranslatorInterface::class);
}
$setting = $this
->getMockBuilder(Simple::class)
->setConstructorArgs([$filterSetting, $properties, $eventDispatcher, $filterUrlBuilder, $translator])
- ->getMockForAbstractClass();
+ ->onlyMethods(['prepareRules'])
+ ->getMock();
return $setting;
}
@@ -328,7 +330,7 @@ public function testPrepareFrontendFilterOptionsSlugNgetType(): void
*/
public function testPrepareFrontendFilterOptionsBlankOptionAlwaysClears(): void
{
- $translator = $this->getMockForAbstractClass(TranslatorInterface::class);
+ $translator = $this->createMock(TranslatorInterface::class);
$translator->method('trans')->willReturn('- no filter -');
$widget = $this->defaultWidget();
diff --git a/tests/Helper/TableManipulatorTest.php b/tests/Helper/TableManipulatorTest.php
index bccfa00f7..1bb3b3485 100644
--- a/tests/Helper/TableManipulatorTest.php
+++ b/tests/Helper/TableManipulatorTest.php
@@ -25,12 +25,13 @@
use MetaModels\Helper\TableManipulator;
use PHPUnit\Framework\MockObject\MockObject;
use PHPUnit\Framework\TestCase;
+use PHPUnit\Framework\Attributes\CoversClass;
/**
* Class TableManipulatorTest
*
- * @covers \MetaModels\Helper\TableManipulator
*/
+#[CoversClass(\MetaModels\Helper\TableManipulator::class)]
class TableManipulatorTest extends TestCase
{
/**
diff --git a/tests/Helper/ToolBoxFileTest.php b/tests/Helper/ToolBoxFileTest.php
index 6a1927d4e..210fe77b9 100644
--- a/tests/Helper/ToolBoxFileTest.php
+++ b/tests/Helper/ToolBoxFileTest.php
@@ -23,12 +23,13 @@
use MetaModels\Helper\ToolboxFile;
use PHPUnit\Framework\TestCase;
+use PHPUnit\Framework\Attributes\CoversClass;
/**
* Test the attribute factory.
*
- * @covers \MetaModels\Helper\ToolboxFile
*/
+#[CoversClass(\MetaModels\Helper\ToolboxFile::class)]
class ToolBoxFileTest extends TestCase
{
/**
diff --git a/tests/Information/AttributeInformationTest.php b/tests/Information/AttributeInformationTest.php
index 3d3a2c26d..312cce614 100644
--- a/tests/Information/AttributeInformationTest.php
+++ b/tests/Information/AttributeInformationTest.php
@@ -23,12 +23,13 @@
use MetaModels\Information\AttributeInformation;
use PHPUnit\Framework\TestCase;
+use PHPUnit\Framework\Attributes\CoversClass;
/**
* This tests the attribute information.
*
- * @covers \MetaModels\Information\AttributeInformation
*/
+#[CoversClass(\MetaModels\Information\AttributeInformation::class)]
class AttributeInformationTest extends TestCase
{
/**
diff --git a/tests/Information/ConfigurationTraitConsumer.php b/tests/Information/ConfigurationTraitConsumer.php
new file mode 100644
index 000000000..d7a678540
--- /dev/null
+++ b/tests/Information/ConfigurationTraitConsumer.php
@@ -0,0 +1,32 @@
+
+ * @copyright 2012-2026 The MetaModels team.
+ * @license https://github.com/MetaModels/core/blob/master/LICENSE LGPL-3.0-or-later
+ * @filesource
+ */
+
+declare(strict_types=1);
+
+namespace MetaModels\Test\Information;
+
+use MetaModels\Information\ConfigurationTrait;
+
+/**
+ * Concrete consumer of the ConfigurationTrait used as a test fixture.
+ */
+final class ConfigurationTraitConsumer
+{
+ use ConfigurationTrait;
+}
diff --git a/tests/Information/ConfigurationTraitTest.php b/tests/Information/ConfigurationTraitTest.php
index b9085b7c7..042dbd6ca 100644
--- a/tests/Information/ConfigurationTraitTest.php
+++ b/tests/Information/ConfigurationTraitTest.php
@@ -23,12 +23,13 @@
use MetaModels\Information\ConfigurationTrait;
use PHPUnit\Framework\TestCase;
+use PHPUnit\Framework\Attributes\CoversClass;
/**
* This tests the configuration trait.
*
- * @covers \MetaModels\Information\ConfigurationTrait
*/
+#[CoversClass(\MetaModels\Information\ConfigurationTrait::class)]
class ConfigurationTraitTest extends TestCase
{
/**
@@ -38,7 +39,7 @@ class ConfigurationTraitTest extends TestCase
*/
public function testFunctionality(): void
{
- $trait = $this->getMockForTrait(ConfigurationTrait::class);
+ $trait = new ConfigurationTraitConsumer();
$this->assertSame([], $trait->getConfiguration());
$trait->addConfiguration(['string' => 'string', 'int' => 1, 'null' => null]);
@@ -58,7 +59,7 @@ public function testFunctionality(): void
*/
public function testGetConfigurationValueThrowsForUnknown(): void
{
- $trait = $this->getMockForTrait(ConfigurationTrait::class);
+ $trait = new ConfigurationTraitConsumer();
$this->expectException(\InvalidArgumentException::class);
$this->expectExceptionMessage('Configuration key "unknown" does not exist');
diff --git a/tests/Information/MetaModelCollectionTest.php b/tests/Information/MetaModelCollectionTest.php
index f49934afb..af59b5e54 100644
--- a/tests/Information/MetaModelCollectionTest.php
+++ b/tests/Information/MetaModelCollectionTest.php
@@ -24,12 +24,13 @@
use MetaModels\Information\MetaModelInformationInterface;
use MetaModels\Information\MetaModelCollection;
use PHPUnit\Framework\TestCase;
+use PHPUnit\Framework\Attributes\CoversClass;
/**
* This tests the attribute information.
*
- * @covers \MetaModels\Information\MetaModelCollection
*/
+#[CoversClass(\MetaModels\Information\MetaModelCollection::class)]
class MetaModelCollectionTest extends TestCase
{
/**
@@ -54,7 +55,7 @@ public function testAddMetaModel(): void
{
$information = new MetaModelCollection();
- $metamodel = $this->getMockForAbstractClass(MetaModelInformationInterface::class);
+ $metamodel = $this->createMock(MetaModelInformationInterface::class);
$metamodel->expects($this->once())->method('getName')->willReturn('mm_test');
$information->add($metamodel);
@@ -74,14 +75,14 @@ public function testAddThrowsForRegisteredName(): void
{
$information = new MetaModelCollection();
- $metamodel = $this->getMockForAbstractClass(MetaModelInformationInterface::class);
+ $metamodel = $this->createMock(MetaModelInformationInterface::class);
$metamodel->expects($this->once())->method('getName')->willReturn('mm_test');
$information->add($metamodel);
$this->expectException(\InvalidArgumentException::class);
$this->expectExceptionMessage('MetaModel "mm_test" already registered');
- $second = $this->getMockForAbstractClass(MetaModelInformationInterface::class);
+ $second = $this->createMock(MetaModelInformationInterface::class);
$second->expects($this->once())->method('getName')->willReturn('mm_test');
$information->add($second);
diff --git a/tests/Information/MetaModelInformationTest.php b/tests/Information/MetaModelInformationTest.php
index 1e5f72d77..f072a8fc1 100644
--- a/tests/Information/MetaModelInformationTest.php
+++ b/tests/Information/MetaModelInformationTest.php
@@ -24,12 +24,13 @@
use MetaModels\Information\AttributeInformationInterface;
use MetaModels\Information\MetaModelInformation;
use PHPUnit\Framework\TestCase;
+use PHPUnit\Framework\Attributes\CoversClass;
/**
* This tests the attribute information.
*
- * @covers \MetaModels\Information\MetaModelInformation
*/
+#[CoversClass(\MetaModels\Information\MetaModelInformation::class)]
class MetaModelInformationTest extends TestCase
{
/**
@@ -56,7 +57,7 @@ public function testAddAttribute(): void
{
$information = new MetaModelInformation('mm_test');
- $attribute = $this->getMockForAbstractClass(AttributeInformationInterface::class);
+ $attribute = $this->createMock(AttributeInformationInterface::class);
$attribute->expects($this->once())->method('getName')->willReturn('test');
$information->addAttribute($attribute);
@@ -75,14 +76,14 @@ public function testAddThrowsForRegisteredName(): void
{
$information = new MetaModelInformation('mm_test');
- $attribute = $this->getMockForAbstractClass(AttributeInformationInterface::class);
+ $attribute = $this->createMock(AttributeInformationInterface::class);
$attribute->expects($this->once())->method('getName')->willReturn('test');
$information->addAttribute($attribute);
$this->expectException(\InvalidArgumentException::class);
$this->expectExceptionMessage('Attribute "test" already registered');
- $second = $this->getMockForAbstractClass(AttributeInformationInterface::class);
+ $second = $this->createMock(AttributeInformationInterface::class);
$second->expects($this->once())->method('getName')->willReturn('test');
$information->addAttribute($second);
@@ -112,15 +113,15 @@ public function testGetAttributesOfType(): void
{
$information = new MetaModelInformation('mm_test');
- $attribute1 = $this->getMockForAbstractClass(AttributeInformationInterface::class);
+ $attribute1 = $this->createMock(AttributeInformationInterface::class);
$attribute1->expects($this->once())->method('getName')->willReturn('test1');
$attribute1->expects($this->once())->method('getType')->willReturn('searched');
$information->addAttribute($attribute1);
- $attribute2 = $this->getMockForAbstractClass(AttributeInformationInterface::class);
+ $attribute2 = $this->createMock(AttributeInformationInterface::class);
$attribute2->expects($this->once())->method('getName')->willReturn('test2');
$attribute2->expects($this->once())->method('getType')->willReturn('other');
$information->addAttribute($attribute2);
- $attribute3 = $this->getMockForAbstractClass(AttributeInformationInterface::class);
+ $attribute3 = $this->createMock(AttributeInformationInterface::class);
$attribute3->expects($this->once())->method('getName')->willReturn('test3');
$attribute3->expects($this->once())->method('getType')->willReturn('searched');
diff --git a/tests/InformationProvider/MetaModelInformationCollectorTest.php b/tests/InformationProvider/MetaModelInformationCollectorTest.php
index e1a5033a5..0384a1042 100644
--- a/tests/InformationProvider/MetaModelInformationCollectorTest.php
+++ b/tests/InformationProvider/MetaModelInformationCollectorTest.php
@@ -25,12 +25,13 @@
use MetaModels\InformationProvider\MetaModelInformationCollector;
use MetaModels\InformationProvider\InformationProviderInterface;
use PHPUnit\Framework\TestCase;
+use PHPUnit\Framework\Attributes\CoversClass;
/**
* This tests the information collector.
*
- * @covers \MetaModels\InformationProvider\MetaModelInformationCollector
*/
+#[CoversClass(\MetaModels\InformationProvider\MetaModelInformationCollector::class)]
class MetaModelInformationCollectorTest extends TestCase
{
/**
@@ -51,8 +52,8 @@ public function testInstantiation(): void
*/
public function testCollectsNamesFromAllProviders(): void
{
- $provider1 = $this->getMockForAbstractClass(InformationProviderInterface::class);
- $provider2 = $this->getMockForAbstractClass(InformationProviderInterface::class);
+ $provider1 = $this->createMock(InformationProviderInterface::class);
+ $provider2 = $this->createMock(InformationProviderInterface::class);
$provider1->expects($this->once())->method('getNames')->willReturn(['name1', 'name2']);
$provider2->expects($this->once())->method('getNames')->willReturn(['name2', 'name3']);
@@ -71,8 +72,8 @@ public function testCollectsInformationFromAllProviders(): void
{
$information = new MetaModelInformation('mm_test');
- $provider1 = $this->getMockForAbstractClass(InformationProviderInterface::class);
- $provider2 = $this->getMockForAbstractClass(InformationProviderInterface::class);
+ $provider1 = $this->createMock(InformationProviderInterface::class);
+ $provider2 = $this->createMock(InformationProviderInterface::class);
$provider1->expects($this->once())->method('getInformationFor')->with($information);
$provider2->expects($this->once())->method('getInformationFor')->with($information);
diff --git a/tests/ItemListTest.php b/tests/ItemListTest.php
index e2f06d4b7..58c22f51f 100644
--- a/tests/ItemListTest.php
+++ b/tests/ItemListTest.php
@@ -35,21 +35,22 @@
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\RequestStack;
+use PHPUnit\Framework\Attributes\CoversClass;
/**
* Test the base attribute.
*
- * @covers \MetaModels\ItemList
*/
+#[CoversClass(\MetaModels\ItemList::class)]
final class ItemListTest extends TestCase
{
/** @SuppressWarnings(PHPMD.Superglobals) */
public function testGetOutputFormat(): void
{
- $factory = $this->getMockForAbstractClass(IFactory::class);
- $filterFactory = $this->getMockForAbstractClass(IFilterSettingFactory::class);
- $renderSettingFactory = $this->getMockForAbstractClass(IRenderSettingFactory::class);
- $eventDispatcher = $this->getMockForAbstractClass(EventDispatcherInterface::class);
+ $factory = $this->createMock(IFactory::class);
+ $filterFactory = $this->createMock(IFilterSettingFactory::class);
+ $renderSettingFactory = $this->createMock(IRenderSettingFactory::class);
+ $eventDispatcher = $this->createMock(EventDispatcherInterface::class);
$filterUrlBuilder = $this->getMockBuilder(FilterUrlBuilder::class)->disableOriginalConstructor()->getMock();
$itemlist = new ItemList(
$factory,
@@ -76,7 +77,7 @@ public function testGetOutputFormat(): void
$requestStack = new RequestStack();
- $mockContainer = $this->getMockForAbstractClass(ContainerInterface::class);
+ $mockContainer = $this->createMock(ContainerInterface::class);
$mockContainer
->method('get')
->willReturnCallback(fn(string $service) => match ($service) {
diff --git a/tests/ItemTest.php b/tests/ItemTest.php
index b66770d18..a8a997eae 100644
--- a/tests/ItemTest.php
+++ b/tests/ItemTest.php
@@ -27,6 +27,7 @@
use MetaModels\Item;
use PHPUnit\Framework\TestCase;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
+use PHPUnit\Framework\Attributes\CoversClass;
/**
* Tests for Item dirty tracking (IDirtyTracking implementation).
@@ -35,8 +36,8 @@
* Only attributes explicitly set via set() are marked dirty.
* This prevents fallback-language data from being written to the active language on save.
*
- * @covers \MetaModels\Item
*/
+#[CoversClass(\MetaModels\Item::class)]
class ItemTest extends TestCase
{
private function createItem(array $data = []): Item
diff --git a/tests/MetaModelsTest.php b/tests/MetaModelsTest.php
index 474c9e858..ed6829ee0 100644
--- a/tests/MetaModelsTest.php
+++ b/tests/MetaModelsTest.php
@@ -30,12 +30,13 @@
use PHPUnit\Framework\MockObject\MockObject;
use PHPUnit\Framework\TestCase;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
+use PHPUnit\Framework\Attributes\CoversClass;
/**
* Test the base attribute.
*
- * @covers \MetaModels\MetaModel
*/
+#[CoversClass(\MetaModels\MetaModel::class)]
class MetaModelsTest extends TestCase
{
/**
@@ -69,7 +70,7 @@ public function testCreation(): void
$metaModel = new MetaModel(
$serialized,
- $this->getMockForAbstractClass(EventDispatcherInterface::class),
+ $this->createMock(EventDispatcherInterface::class),
$this->mockConnection()
);
self::assertEmpty($metaModel->getAttributes());
@@ -80,7 +81,7 @@ public function testCreation(): void
$metaModel = new MetaModel(
$values,
- $this->getMockForAbstractClass(EventDispatcherInterface::class),
+ $this->createMock(EventDispatcherInterface::class),
$this->mockConnection()
);
@@ -96,7 +97,7 @@ public function testBuildDatabaseParameterList(): void
{
$metaModel = new MetaModel(
[],
- $this->getMockForAbstractClass(EventDispatcherInterface::class),
+ $this->createMock(EventDispatcherInterface::class),
$this->mockConnection()
);
@@ -122,7 +123,7 @@ public function testRetrieveSystemColumns(): void
'languages' => serialize(['en' => ['isfallback' => '1'], 'de' => ['isfallback' => '0']]),
'varsupport' => '',
],
- $this->getMockForAbstractClass(EventDispatcherInterface::class),
+ $this->createMock(EventDispatcherInterface::class),
$this->mockConnection(
(function () {
$builder = $this
@@ -214,7 +215,7 @@ public function testGetIdsFromFilterSortedById(): void
->onlyMethods(['getMatchingIds'])
->setConstructorArgs([
['tableName' => 'mm_test_retrieve'],
- $this->getMockForAbstractClass(EventDispatcherInterface::class),
+ $this->createMock(EventDispatcherInterface::class),
$this->mockConnection()
])
->getMock();
@@ -241,7 +242,7 @@ public function testGetIdsFromFilterSortedByPid(): void
->onlyMethods(['getMatchingIds'])
->setConstructorArgs([
['tableName' => 'mm_test_retrieve'],
- $this->getMockForAbstractClass(EventDispatcherInterface::class),
+ $this->createMock(EventDispatcherInterface::class),
$this->mockConnection(
(function () {
$builder = $this
@@ -329,7 +330,7 @@ public function testGetIdsFromFilterSortedByPidWithCache(): void
->onlyMethods(['getMatchingIds'])
->setConstructorArgs([
['tableName' => 'mm_test_retrieve'],
- $this->getMockForAbstractClass(EventDispatcherInterface::class),
+ $this->createMock(EventDispatcherInterface::class),
$this->mockConnection(
(function () {
$builder = $this
@@ -414,7 +415,7 @@ public function testGetCountForEmptyList(): void
->setConstructorArgs(
[
['tableName' => 'mm_test_retrieve'],
- $this->getMockForAbstractClass(EventDispatcherInterface::class),
+ $this->createMock(EventDispatcherInterface::class),
$this->mockConnection()
]
)
@@ -437,7 +438,7 @@ public function testGetCountForNonEmptyList(): void
->onlyMethods(['getMatchingIdsAuthoritative'])
->setConstructorArgs([
['tableName' => 'mm_test_retrieve'],
- $this->getMockForAbstractClass(EventDispatcherInterface::class),
+ $this->createMock(EventDispatcherInterface::class),
$this->mockConnection()
])
->getMock();
diff --git a/tests/Render/TemplateTest.php b/tests/Render/TemplateTest.php
index ae153c757..910e0c94e 100644
--- a/tests/Render/TemplateTest.php
+++ b/tests/Render/TemplateTest.php
@@ -28,12 +28,13 @@
use PHPUnit\Framework\TestCase;
use ReflectionClass;
use ReflectionMethod;
+use PHPUnit\Framework\Attributes\CoversClass;
/**
* This tests the empty value check helper.
*
- * @covers \MetaModels\Render\Template
*/
+#[CoversClass(\MetaModels\Render\Template::class)]
final class TemplateTest extends TestCase
{
/**
diff --git a/tests/Schema/Doctrine/DoctrineSchemaGeneratorTest.php b/tests/Schema/Doctrine/DoctrineSchemaGeneratorTest.php
index fabe5fba2..689cf22fe 100644
--- a/tests/Schema/Doctrine/DoctrineSchemaGeneratorTest.php
+++ b/tests/Schema/Doctrine/DoctrineSchemaGeneratorTest.php
@@ -27,12 +27,13 @@
use MetaModels\Schema\Doctrine\DoctrineSchemaGeneratorInterface;
use MetaModels\Schema\SchemaInformation;
use PHPUnit\Framework\TestCase;
+use PHPUnit\Framework\Attributes\CoversClass;
/**
* This tests the doctrine schema.
*
- * @covers \MetaModels\Schema\Doctrine\DoctrineSchemaGenerator
*/
+#[CoversClass(\MetaModels\Schema\Doctrine\DoctrineSchemaGenerator::class)]
class DoctrineSchemaGeneratorTest extends TestCase
{
/**
@@ -58,7 +59,7 @@ public function testGenerateAddsSchemaInformationIfNotFound(): void
$information = new SchemaInformation();
- $collection = $this->getMockForAbstractClass(MetaModelCollectionInterface::class);
+ $collection = $this->createMock(MetaModelCollectionInterface::class);
$instance->generate($information, $collection);
@@ -73,9 +74,9 @@ public function testGenerateAddsSchemaInformationIfNotFound(): void
public function testGenerate(): void
{
$doctrineSchema = new DoctrineSchemaInformation();
- $collection = $this->getMockForAbstractClass(MetaModelCollectionInterface::class);
- $generator1 = $this->getMockForAbstractClass(DoctrineSchemaGeneratorInterface::class);
- $generator2 = $this->getMockForAbstractClass(DoctrineSchemaGeneratorInterface::class);
+ $collection = $this->createMock(MetaModelCollectionInterface::class);
+ $generator1 = $this->createMock(DoctrineSchemaGeneratorInterface::class);
+ $generator2 = $this->createMock(DoctrineSchemaGeneratorInterface::class);
$generator1->expects($this->once())->method('generate')->with($doctrineSchema, $collection);
$generator2->expects($this->once())->method('generate')->with($doctrineSchema, $collection);
diff --git a/tests/Schema/Doctrine/DoctrineSchemaInformationTest.php b/tests/Schema/Doctrine/DoctrineSchemaInformationTest.php
index bb9765576..72c6812ba 100644
--- a/tests/Schema/Doctrine/DoctrineSchemaInformationTest.php
+++ b/tests/Schema/Doctrine/DoctrineSchemaInformationTest.php
@@ -25,12 +25,13 @@
use MetaModels\Schema\Doctrine\DoctrineSchemaInformation;
use MetaModels\Schema\Doctrine\SchemaProcessorInterface;
use PHPUnit\Framework\TestCase;
+use PHPUnit\Framework\Attributes\CoversClass;
/**
* This tests the doctrine schema.
*
- * @covers \MetaModels\Schema\Doctrine\DoctrineSchemaInformation
*/
+#[CoversClass(\MetaModels\Schema\Doctrine\DoctrineSchemaInformation::class)]
class DoctrineSchemaInformationTest extends TestCase
{
/**
@@ -63,15 +64,15 @@ public function testAddPreProcessors(): void
$processorNormal = $this
->getMockBuilder(SchemaProcessorInterface::class)
->setMockClassName('TestAddPreProcessorsNormal')
- ->getMockForAbstractClass();
+ ->getMock();
$processorHigh = $this
->getMockBuilder(SchemaProcessorInterface::class)
->setMockClassName('TestAddPreProcessorsHigh')
- ->getMockForAbstractClass();
+ ->getMock();
$processorLow = $this
->getMockBuilder(SchemaProcessorInterface::class)
->setMockClassName('TestAddPreProcessorsLow')
- ->getMockForAbstractClass();
+ ->getMock();
$instance = new DoctrineSchemaInformation($schema);
@@ -94,15 +95,15 @@ public function testAddPostProcessors(): void
$processorNormal = $this
->getMockBuilder(SchemaProcessorInterface::class)
->setMockClassName('TestAddPostProcessorsNormal')
- ->getMockForAbstractClass();
+ ->getMock();
$processorHigh = $this
->getMockBuilder(SchemaProcessorInterface::class)
->setMockClassName('TestAddPostProcessorsHigh')
- ->getMockForAbstractClass();
+ ->getMock();
$processorLow = $this
->getMockBuilder(SchemaProcessorInterface::class)
->setMockClassName('TestAddPostProcessorsLow')
- ->getMockForAbstractClass();
+ ->getMock();
$instance = new DoctrineSchemaInformation($schema);
diff --git a/tests/Schema/Doctrine/DoctrineSchemaManagerTest.php b/tests/Schema/Doctrine/DoctrineSchemaManagerTest.php
index 33d84a442..c6c6487c1 100644
--- a/tests/Schema/Doctrine/DoctrineSchemaManagerTest.php
+++ b/tests/Schema/Doctrine/DoctrineSchemaManagerTest.php
@@ -28,12 +28,13 @@
use MetaModels\Schema\SchemaInformation;
use PHPUnit\Framework\MockObject\MockObject;
use PHPUnit\Framework\TestCase;
+use PHPUnit\Framework\Attributes\CoversClass;
/**
* This tests the doctrine schema.
*
- * @covers \MetaModels\Schema\Doctrine\DoctrineSchemaManager
*/
+#[CoversClass(\MetaModels\Schema\Doctrine\DoctrineSchemaManager::class)]
class DoctrineSchemaManagerTest extends TestCase
{
/**
@@ -57,8 +58,8 @@ public function testInstantiation(): void
*/
public function testPreprocess(): void
{
- $processor1 = $this->getMockForAbstractClass(SchemaProcessorInterface::class);
- $processor2 = $this->getMockForAbstractClass(SchemaProcessorInterface::class);
+ $processor1 = $this->createMock(SchemaProcessorInterface::class);
+ $processor2 = $this->createMock(SchemaProcessorInterface::class);
$processor1->expects($this->once())->method('process');
$processor2->expects($this->once())->method('process');
@@ -138,8 +139,8 @@ public function testProcessSkipsIfNothingToDo(): void
*/
public function testPostProcess(): void
{
- $processor1 = $this->getMockForAbstractClass(SchemaProcessorInterface::class);
- $processor2 = $this->getMockForAbstractClass(SchemaProcessorInterface::class);
+ $processor1 = $this->createMock(SchemaProcessorInterface::class);
+ $processor2 = $this->createMock(SchemaProcessorInterface::class);
$processor1->expects($this->once())->method('process');
$processor2->expects($this->once())->method('process');
@@ -187,12 +188,12 @@ public function testValidate(): void
$manipulator->expects($this->once())->method('getScript')->willReturn(['query1', 'query2']);
- $processor1 = $this->getMockForAbstractClass(SchemaProcessorInterface::class);
- $processor2 = $this->getMockForAbstractClass(SchemaProcessorInterface::class);
+ $processor1 = $this->createMock(SchemaProcessorInterface::class);
+ $processor2 = $this->createMock(SchemaProcessorInterface::class);
$processor1->expects($this->once())->method('__toString')->willReturn('pre1');
$processor2->expects($this->once())->method('__toString')->willReturn('pre2');
- $processor3 = $this->getMockForAbstractClass(SchemaProcessorInterface::class);
- $processor4 = $this->getMockForAbstractClass(SchemaProcessorInterface::class);
+ $processor3 = $this->createMock(SchemaProcessorInterface::class);
+ $processor4 = $this->createMock(SchemaProcessorInterface::class);
$processor3->expects($this->once())->method('__toString')->willReturn('post1');
$processor4->expects($this->once())->method('__toString')->willReturn('post2');
diff --git a/tests/Schema/LegacySchemaGeneratorTest.php b/tests/Schema/LegacySchemaGeneratorTest.php
index a306f297d..0ca053844 100644
--- a/tests/Schema/LegacySchemaGeneratorTest.php
+++ b/tests/Schema/LegacySchemaGeneratorTest.php
@@ -34,14 +34,15 @@
use MetaModels\Schema\LegacySchemaInformation;
use MetaModels\Schema\SchemaInformation;
use PHPUnit\Framework\TestCase;
+use PHPUnit\Framework\Attributes\CoversClass;
/**
* This tests the doctrine schema.
*
- * @covers \MetaModels\Schema\LegacySchemaGenerator
*
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
*/
+#[CoversClass(\MetaModels\Schema\LegacySchemaGenerator::class)]
class LegacySchemaGeneratorTest extends TestCase
{
/**
@@ -51,7 +52,7 @@ class LegacySchemaGeneratorTest extends TestCase
*/
public function testInstantiation(): void
{
- $instance = new LegacySchemaGenerator($this->getMockForAbstractClass(IFactory::class), []);
+ $instance = new LegacySchemaGenerator($this->createMock(IFactory::class), []);
$this->assertInstanceOf(LegacySchemaGenerator::class, $instance);
}
@@ -63,9 +64,9 @@ public function testInstantiation(): void
*/
public function testGenerateAddsSchemaInformationIfNotFound(): void
{
- $instance = new LegacySchemaGenerator($this->getMockForAbstractClass(IFactory::class), []);
+ $instance = new LegacySchemaGenerator($this->createMock(IFactory::class), []);
$information = new SchemaInformation();
- $collection = $this->getMockForAbstractClass(MetaModelCollectionInterface::class);
+ $collection = $this->createMock(MetaModelCollectionInterface::class);
$collection->expects($this->once())->method('getIterator')->willReturn(new \ArrayIterator([]));
@@ -82,15 +83,15 @@ public function testGenerateAddsSchemaInformationIfNotFound(): void
public function testGenerate(): void
{
$information = new SchemaInformation();
- $collection = $this->getMockForAbstractClass(MetaModelCollectionInterface::class);
+ $collection = $this->createMock(MetaModelCollectionInterface::class);
$attribute1 = $this->mockAttribute(ISimple::class, 'attribute1');
$attribute2 = $this->mockAttribute(IComplex::class, 'attribute2');
$attribute3 = $this->mockAttribute(ISimple::class, 'managed-type');
- $attribute4 = $this->getMockForAbstractClass(IInternal::class);
+ $attribute4 = $this->createMock(IInternal::class);
$metaModel = $this->mockMetaModel([$attribute1, $attribute2, $attribute3, $attribute4]);
- $factory = $this->getMockForAbstractClass(IFactory::class);
+ $factory = $this->createMock(IFactory::class);
$factory->expects($this->once())->method('getMetaModel')->with('mm_test')->willReturn($metaModel);
$collection->expects($this->once())->method('getIterator')->willReturn(new \ArrayIterator([
@@ -118,7 +119,7 @@ public function testGenerate(): void
*/
private function mockMetaModel(array $attributes)
{
- $metaModel = $this->getMockForAbstractClass(IMetaModel::class);
+ $metaModel = $this->createMock(IMetaModel::class);
$metaModel->expects($this->once())->method('getAttributes')->willReturn($attributes);
@@ -128,7 +129,7 @@ private function mockMetaModel(array $attributes)
/** @param class-string $interface */
private function mockAttribute(string $interface, string $typeName): IAttribute
{
- $attribute = $this->getMockForAbstractClass($interface);
+ $attribute = $this->createMock($interface);
$attribute
->expects(self::atLeastOnce())
diff --git a/tests/Schema/LegacySchemaInformationTest.php b/tests/Schema/LegacySchemaInformationTest.php
index aca52effc..664549956 100644
--- a/tests/Schema/LegacySchemaInformationTest.php
+++ b/tests/Schema/LegacySchemaInformationTest.php
@@ -26,12 +26,13 @@
use MetaModels\Attribute\ISimple;
use MetaModels\Schema\LegacySchemaInformation;
use PHPUnit\Framework\TestCase;
+use PHPUnit\Framework\Attributes\CoversClass;
/**
* This tests the legacy schema.
*
- * @covers \MetaModels\Schema\LegacySchemaInformation
*/
+#[CoversClass(\MetaModels\Schema\LegacySchemaInformation::class)]
class LegacySchemaInformationTest extends TestCase
{
/**
@@ -57,9 +58,9 @@ public function testAddAttributes(): void
{
$instance = new LegacySchemaInformation();
- $instance->addAttribute($attribute1 = $this->getMockForAbstractClass(ISimple::class));
- $instance->addAttribute($attribute2 = $this->getMockForAbstractClass(IComplex::class));
- $instance->addAttribute($attribute3 = $this->getMockForAbstractClass(IAttribute::class));
+ $instance->addAttribute($attribute1 = $this->createMock(ISimple::class));
+ $instance->addAttribute($attribute2 = $this->createMock(IComplex::class));
+ $instance->addAttribute($attribute3 = $this->createMock(IAttribute::class));
$this->assertSame([$attribute1, $attribute2, $attribute3], $instance->getAttributes());
}
diff --git a/tests/Schema/LegacySchemaManagerTest.php b/tests/Schema/LegacySchemaManagerTest.php
index 802f8a3d3..a0fcf5b31 100644
--- a/tests/Schema/LegacySchemaManagerTest.php
+++ b/tests/Schema/LegacySchemaManagerTest.php
@@ -28,12 +28,13 @@
use MetaModels\Schema\LegacySchemaManager;
use MetaModels\Schema\SchemaInformation;
use PHPUnit\Framework\TestCase;
+use PHPUnit\Framework\Attributes\CoversClass;
/**
* This tests the doctrine schema.
*
- * @covers \MetaModels\Schema\LegacySchemaManager
*/
+#[CoversClass(\MetaModels\Schema\LegacySchemaManager::class)]
class LegacySchemaManagerTest extends TestCase
{
/**
@@ -74,9 +75,9 @@ public function testProcess(): void
$legacy = new LegacySchemaInformation();
$information->add($legacy);
- $legacy->addAttribute($attribute1 = $this->getMockForAbstractClass(ISimple::class));
- $legacy->addAttribute($attribute2 = $this->getMockForAbstractClass(IComplex::class));
- $legacy->addAttribute($attribute3 = $this->getMockForAbstractClass(IAttribute::class));
+ $legacy->addAttribute($attribute1 = $this->createMock(ISimple::class));
+ $legacy->addAttribute($attribute2 = $this->createMock(IComplex::class));
+ $legacy->addAttribute($attribute3 = $this->createMock(IAttribute::class));
$attribute1->expects($this->once())->method('initializeAUX');
$attribute2->expects($this->once())->method('initializeAUX');
@@ -98,9 +99,9 @@ public function testValidate(): void
$legacy = new LegacySchemaInformation();
$information->add($legacy);
- $legacy->addAttribute($attribute1 = $this->getMockForAbstractClass(ISimple::class));
- $legacy->addAttribute($attribute2 = $this->getMockForAbstractClass(IComplex::class));
- $legacy->addAttribute($attribute3 = $this->getMockForAbstractClass(IAttribute::class));
+ $legacy->addAttribute($attribute1 = $this->createMock(ISimple::class));
+ $legacy->addAttribute($attribute2 = $this->createMock(IComplex::class));
+ $legacy->addAttribute($attribute3 = $this->createMock(IAttribute::class));
$attribute1->expects($this->once())->method('getColName')->willReturn('attribute1');
$attribute1->expects($this->once())->method('get')->with('type')->willReturn('type1');
diff --git a/tests/Schema/SchemaGeneratorTest.php b/tests/Schema/SchemaGeneratorTest.php
index 2fbbb0813..16b40ccf7 100644
--- a/tests/Schema/SchemaGeneratorTest.php
+++ b/tests/Schema/SchemaGeneratorTest.php
@@ -26,12 +26,13 @@
use MetaModels\Schema\SchemaGeneratorInterface;
use MetaModels\Schema\SchemaInformation;
use PHPUnit\Framework\TestCase;
+use PHPUnit\Framework\Attributes\CoversClass;
/**
* This tests the schema generator class.
*
- * @covers \MetaModels\Schema\SchemaGenerator
*/
+#[CoversClass(\MetaModels\Schema\SchemaGenerator::class)]
class SchemaGeneratorTest extends TestCase
{
/**
@@ -53,9 +54,9 @@ public function testInstantiation(): void
*/
public function testGenerateSchema(): void
{
- $collection = $this->getMockForAbstractClass(MetaModelCollectionInterface::class);
+ $collection = $this->createMock(MetaModelCollectionInterface::class);
$information = new SchemaInformation();
- $generator = $this->getMockForAbstractClass(SchemaGeneratorInterface::class);
+ $generator = $this->createMock(SchemaGeneratorInterface::class);
$generator->expects($this->once())->method('generate')->with($information, $collection);
$instance = new SchemaGenerator([$generator]);
diff --git a/tests/Schema/SchemaInformationTest.php b/tests/Schema/SchemaInformationTest.php
index 4184d4064..bf3032da9 100644
--- a/tests/Schema/SchemaInformationTest.php
+++ b/tests/Schema/SchemaInformationTest.php
@@ -24,12 +24,13 @@
use MetaModels\Schema\SchemaInformation;
use MetaModels\Schema\SchemaInformationInterface;
use PHPUnit\Framework\TestCase;
+use PHPUnit\Framework\Attributes\CoversClass;
/**
* This tests the schema information.
*
- * @covers \MetaModels\Schema\SchemaInformation
*/
+#[CoversClass(\MetaModels\Schema\SchemaInformation::class)]
class SchemaInformationTest extends TestCase
{
/**
@@ -53,7 +54,7 @@ public function testAdd(): void
{
$instance = new SchemaInformation();
- $mock = $this->getMockForAbstractClass(SchemaInformationInterface::class);
+ $mock = $this->createMock(SchemaInformationInterface::class);
$mock->method('getName')->willReturn('test');
$instance->add($mock);
@@ -71,7 +72,7 @@ public function testAddThrowsForAlreadyRegistered(): void
{
$instance = new SchemaInformation();
- $mock = $this->getMockForAbstractClass(SchemaInformationInterface::class);
+ $mock = $this->createMock(SchemaInformationInterface::class);
$mock->method('getName')->willReturn('test');
$instance->add($mock);
@@ -118,7 +119,7 @@ public function testGetRegisteredNames(): void
{
$instance = new SchemaInformation();
- $mock = $this->getMockForAbstractClass(SchemaInformationInterface::class);
+ $mock = $this->createMock(SchemaInformationInterface::class);
$mock->method('getName')->willReturn('test');
$instance->add($mock);
diff --git a/tests/Schema/SchemaManagerTest.php b/tests/Schema/SchemaManagerTest.php
index 0527c774d..c45c49cbf 100644
--- a/tests/Schema/SchemaManagerTest.php
+++ b/tests/Schema/SchemaManagerTest.php
@@ -25,12 +25,13 @@
use MetaModels\Schema\SchemaManager;
use MetaModels\Schema\SchemaManagerInterface;
use PHPUnit\Framework\TestCase;
+use PHPUnit\Framework\Attributes\CoversClass;
/**
* This tests the schema manager class.
*
- * @covers \MetaModels\Schema\SchemaManager
*/
+#[CoversClass(\MetaModels\Schema\SchemaManager::class)]
class SchemaManagerTest extends TestCase
{
/**
@@ -52,8 +53,8 @@ public function testInstantiation(): void
*/
public function testPreprocess(): void
{
- $manager1 = $this->getMockForAbstractClass(SchemaManagerInterface::class);
- $manager2 = $this->getMockForAbstractClass(SchemaManagerInterface::class);
+ $manager1 = $this->createMock(SchemaManagerInterface::class);
+ $manager2 = $this->createMock(SchemaManagerInterface::class);
$information = new SchemaInformation();
$manager1->expects($this->once())->method('preprocess')->with($information);
$manager2->expects($this->once())->method('preprocess')->with($information);
@@ -70,8 +71,8 @@ public function testPreprocess(): void
*/
public function testProcess(): void
{
- $manager1 = $this->getMockForAbstractClass(SchemaManagerInterface::class);
- $manager2 = $this->getMockForAbstractClass(SchemaManagerInterface::class);
+ $manager1 = $this->createMock(SchemaManagerInterface::class);
+ $manager2 = $this->createMock(SchemaManagerInterface::class);
$information = new SchemaInformation();
$manager1->expects($this->once())->method('process')->with($information);
$manager2->expects($this->once())->method('process')->with($information);
@@ -88,8 +89,8 @@ public function testProcess(): void
*/
public function testPostcess(): void
{
- $manager1 = $this->getMockForAbstractClass(SchemaManagerInterface::class);
- $manager2 = $this->getMockForAbstractClass(SchemaManagerInterface::class);
+ $manager1 = $this->createMock(SchemaManagerInterface::class);
+ $manager2 = $this->createMock(SchemaManagerInterface::class);
$information = new SchemaInformation();
$manager1->expects($this->once())->method('postprocess')->with($information);
$manager2->expects($this->once())->method('postprocess')->with($information);
@@ -106,8 +107,8 @@ public function testPostcess(): void
*/
public function testValidate(): void
{
- $manager1 = $this->getMockForAbstractClass(SchemaManagerInterface::class);
- $manager2 = $this->getMockForAbstractClass(SchemaManagerInterface::class);
+ $manager1 = $this->createMock(SchemaManagerInterface::class);
+ $manager2 = $this->createMock(SchemaManagerInterface::class);
$information = new SchemaInformation();
$manager1->expects($this->once())->method('validate')->with($information)->willReturn(['1', '2']);
$manager2->expects($this->once())->method('validate')->with($information)->willReturn(['3', '4']);