Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
CHANGELOG for 1.x
===================
## v1.7.0 - (2026-09-21)
### Added
- PHPUnit extension `DeprecationLoggerExtension` and `DeprecationLoggerSubscriber` to intercept and log unhandled deprecations during test execution
- `phpunit-deprecated` make target to run the test suite and export formatted deprecation reports to a log file.
- `docs/front_code_validation.md` standard added and mention on README.md

## v1.6.0 - (2026-09-14)
### TODO When updating
Manual steps `composer recipes:install smartbooster/standard-bundle --reset --force` cannot handle by itself when a project upgrades to `1.6` :
Expand Down
6 changes: 5 additions & 1 deletion make/test.mk
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
##
## Tests
## -----
.PHONY: phpunit coverage-text coverage-html coverage jest
.PHONY: phpunit phpunit-deprecated coverage-text coverage-html coverage jest
phpunit: ## Launch all tests
vendor/bin/simple-phpunit

phpunit-deprecated:
Comment thread
mathieu-ducrot marked this conversation as resolved.
rm -rf var/cache/test # must be done for get all deprecated
DEPRECATIONS_LOG_FILE="var/log/deprecations_test.log" vendor/bin/simple-phpunit

coverage-text: ## Launch all tests with code coverage text
XDEBUG_MODE=coverage vendor/bin/simple-phpunit --coverage-text

Expand Down
1 change: 1 addition & 0 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@

<extensions>
<bootstrap class="DAMA\DoctrineTestBundle\PHPUnit\PHPUnitExtension" />
<bootstrap class="Smart\StandardBundle\Phpunit\DeprecationLoggerExtension"/>
</extensions>
</phpunit>

3 changes: 2 additions & 1 deletion recipes.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@
"1.4.1",
"1.4.2",
"1.5",
"1.6"
"1.6",
"1.7"
]
},
"branch": "main",
Expand Down
32 changes: 32 additions & 0 deletions smartbooster.standard-bundle.1.7.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{
"manifests": {
"smartbooster/standard-bundle": {
"manifest": {
"bundles": {
"DAMA\\DoctrineTestBundle\\DAMADoctrineTestBundle": ["test"],
"Liip\\TestFixturesBundle\\LiipTestFixturesBundle": ["test"],
"Smart\\StandardBundle\\SmartStandardBundle": ["dev", "test"]
},
"copy-from-package": {
"config/packages/dama_doctrine_test_bundle.yaml": "%CONFIG_DIR%/packages/test/dama_doctrine_test_bundle.yaml",
"config/packages/liip_test_fixtures.yaml": "%CONFIG_DIR%/packages/test/liip_test_fixtures.yaml",
"make/dev.mk": "make/dev.mk",
"make/qualimetry.mk": "make/qualimetry.mk",
"make/security.mk": "make/security.mk",
"make/test.mk": "make/test.mk",
"dast_scan/build-plan.sh": "dast_scan/build-plan.sh",
"dast_scan/scripts/": "dast_scan/scripts/",
"tests/bootstrap.php": "tests/bootstrap.php",
".php-cs-fixer.dist.php": ".php-cs-fixer.dist.php",
"phpstan.neon": "phpstan.neon",
"phpstan-baseline.neon": "phpstan-baseline.neon",
"psalm.xml": "psalm.xml",
"psalm-taint-stubs.php": "psalm-taint-stubs.php",
"psalm-taint-baseline.xml": "psalm-taint-baseline.xml",
"phpunit.xml.dist": "phpunit.xml.dist"
}
},
"ref": "3c1c7b7b1b0dd63e1fc6b77bf2549bbd778fb4ac"
}
}
}
65 changes: 65 additions & 0 deletions src/Phpunit/DeprecationLoggerExtension.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
<?php

declare(strict_types=1);

namespace Smart\StandardBundle\Phpunit;

use PHPUnit\Runner\Extension\Extension;
use PHPUnit\Runner\Extension\Facade;
use PHPUnit\Runner\Extension\ParameterCollection;
use PHPUnit\TextUI\Configuration\Configuration;

/**
* PHPUnit extension to log deprecations not caught by native PHPUnit.
*/
final class DeprecationLoggerExtension implements Extension
{
public function bootstrap(Configuration $configuration, Facade $facade, ParameterCollection $parameters): void
{
$logFile = $this->resolveLogFile($parameters);

if (null === $logFile) {
return;
}

$logDir = \dirname($logFile);
if (!is_dir($logDir)) {
@mkdir($logDir, 0o777, true);
}

$facade->registerSubscriber(new DeprecationLoggerSubscriber($logFile));
}

private function resolveLogFile(ParameterCollection $parameters): ?string
{
$path = $_SERVER['DEPRECATIONS_LOG_FILE']
?? $_ENV['DEPRECATIONS_LOG_FILE']
?? getenv('DEPRECATIONS_LOG_FILE')
?: null;

if (!$path || !is_string($path)) {
return null;
}

if ($this->isAbsolutePath($path)) {
return $path;
}

$projectRoot = getcwd() ?: \dirname(__DIR__, 3);

return $projectRoot . DIRECTORY_SEPARATOR . $path;
}

private function isAbsolutePath(string $path): bool
{
if ('' === $path) {
return false;
}

if ('/' === $path[0] || '\\' === $path[0]) {
return true;
}

return (bool) preg_match('/^[A-Za-z]:[\\\\\\/]/', $path);
}
}
Loading
Loading