Skip to content

Commit 51bf501

Browse files
authored
Trigger a deprecation message when annotation-based configuration is used as the default (#54)
1 parent 697f454 commit 51bf501

File tree

4 files changed

+10
-1
lines changed

4 files changed

+10
-1
lines changed

.github/workflows/tests.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,5 +32,7 @@ jobs:
3232
coverage: none
3333
- name: Install dependencies
3434
run: composer update --no-interaction --prefer-dist --${{ matrix.dependency-version}} --no-progress --no-suggest
35+
- name: Allow self-deprecation notices when testing against ORM 2.0
36+
run: composer show | egrep -q 'doctrine/orm\s+2' && echo "SYMFONY_DEPRECATIONS_HELPER=max[self]=9999" >> "$GITHUB_ENV" || true
3537
- name: Run test suite
3638
run: vendor/bin/phpunit

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,4 @@ This changelog tracks deprecations and changes breaking backwards compatibility.
55
# Version 1.16
66

77
- The `\Webfactory\Doctrine\ORMTestInfrastructure\Query::getExecutionTimeInSeconds()` method has been deprecated without replacement in https://github.com/webfactory/doctrine-orm-test-infrastructure/pull/52, to prepare for the removal of the `DebugStack` class in Doctrine DBAL 4.0.
8+
- Using annotation-based mapping as the default in `ORMInfrastructure::create*()` methods has been deprecated. Pass a mapping driver or upgrade `doctrine/orm` to >= 3.0 to switch to attributes-based mapping. Attributes-based configuration will be the default in the next major version.

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ class MyEntityRepositoryTest extends TestCase
9292
Migrating to attribute-based mapping configuration
9393
--------------------------------------------------
9494

95-
The `ORMInfrastructure::createWithDependenciesFor()` and ``ORMInfrastructure::createOnlyFor()` methods by default
95+
The `ORMInfrastructure::createWithDependenciesFor()` and `ORMInfrastructure::createOnlyFor()` methods by default
9696
assume that the Doctrine ORM mapping is provided through annotations. This has been deprecated in Doctrine ORM 2.x
9797
and is no longer be supported in ORM 3.0.
9898

src/ORMTestInfrastructure/ConfigurationFactory.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
use Doctrine\Common\Annotations\AnnotationReader;
1313
use Doctrine\Common\Annotations\PsrCachedReader;
1414
use Doctrine\Common\Annotations\Reader;
15+
use Doctrine\Deprecations\Deprecation;
1516
use Doctrine\ORM\Mapping\Driver\AnnotationDriver;
1617
use Doctrine\ORM\Mapping\Driver\AttributeDriver;
1718
use Doctrine\ORM\ORMSetup;
@@ -78,6 +79,11 @@ private function createDefaultMappingDriver(array $entityClasses)
7879
$paths = $this->getDirectoryPathsForClassNames($entityClasses);
7980

8081
if (class_exists(AnnotationDriver::class)) {
82+
Deprecation::trigger(
83+
'webfactory/doctrine-orm-test-infrastructure',
84+
'https://github.com/webfactory/doctrine-orm-test-infrastructure/pull/54',
85+
'Since the AnnotationDriver has been removed in ORM 3.0, using annotation-based mapping as the default has been deprecated in 1.16. In 2.0, attribute-based configuration will be the new default. Either upgrade doctrine/orm to >=3.0 or pass a mapping driver when calling `ORMInfrastructure::create*()` methods to make this notice go away.'
86+
);
8187
return new AnnotationDriver($this->getAnnotationReader(), $paths);
8288
}
8389

0 commit comments

Comments
 (0)