Skip to content

Commit 4f21fa4

Browse files
authored
Merge branch '2.x' into update-test-matrix
2 parents 8664d5c + c4148a5 commit 4f21fa4

File tree

55 files changed

+211
-1040
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

55 files changed

+211
-1040
lines changed

.github/workflows/dependencies.yml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
name: AllDependenciesDeclared
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
pull_request:
8+
9+
env:
10+
PHP_VERSION: 8.4
11+
12+
jobs:
13+
composer-require-checker:
14+
name: Check missing composer requirements
15+
runs-on: ubuntu-latest
16+
steps:
17+
- name: Configure PHP version
18+
uses: shivammathur/setup-php@v2
19+
with:
20+
php-version: ${{ env.PHP_VERSION }}
21+
coverage: none
22+
tools: composer:v2
23+
- uses: actions/checkout@v4
24+
- name: Cache Composer Dependencies
25+
uses: actions/cache@v4
26+
with:
27+
path: vendor/
28+
key: composer-${{ env.PHP_VERSION }}-${{ hashFiles('composer.*') }}
29+
restore-keys: |
30+
composer-${{ env.PHP_VERSION }}-${{ github.ref }}
31+
composer-${{ env.PHP_VERSION }}-
32+
- run: |
33+
composer update --no-interaction --no-scripts --no-progress
34+
composer show
35+
- name: ComposerRequireChecker
36+
uses: docker://ghcr.io/webfactory/composer-require-checker:4.12.0

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,13 @@
22

33
This changelog tracks deprecations and changes breaking backwards compatibility. For more details on particular releases, consult the [GitHub releases page](https://github.com/webfactory/doctrine-orm-test-infrastructure/releases).
44

5+
# Version 2.0
6+
7+
- The `ORMInfrastructure::create*()` methods by default read ORM mapping configuration through PHP attributes; annotations support has been removed in https://github.com/webfactory/doctrine-orm-test-infrastructure/pull/55/. You can, however, still create an instance of the `AnnotationDriver` mapping driver yourself (when using ORM 2.0) and pass it into these methods.
8+
- `\Webfactory\Doctrine\ORMTestInfrastructure\ORMInfrastructure::__construct()` is now a private method. Use the `::create*` methods to instantiate the `ORMInfrastructure`.
9+
- The `\Webfactory\Doctrine\ORMTestInfrastructure\Query::getExecutionTimeInSeconds()` method has been removed.
10+
- The `DetachingObjectManagerDecorator` and `MemorizingObjectManagerDecorator` classes have been removed.
11+
512
# Version 1.16
613

714
- 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.

README.md

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -89,12 +89,11 @@ class MyEntityRepositoryTest extends TestCase
8989
}
9090
```
9191

92-
Migrating to attribute-based mapping configuration
93-
--------------------------------------------------
92+
Migrating to attribute-based mapping configuration (with version 1.x)
93+
---------------------------------------------------------------------
9494

95-
The `ORMInfrastructure::createWithDependenciesFor()` and `ORMInfrastructure::createOnlyFor()` methods by default
96-
assume that the Doctrine ORM mapping is provided through annotations. This has been deprecated in Doctrine ORM 2.x
97-
and is no longer be supported in ORM 3.0.
95+
In versions 1.x of this library, the `ORMInfrastructure::createWithDependenciesFor()` and `ORMInfrastructure::createOnlyFor()` methods
96+
by default assume that the Doctrine ORM mapping is provided through annotations. Annotations-based configuration is no supported anymore in ORM 3.0.
9897

9998
To allow for a seamless transition towards attribute-based or other types of mapping, a mapping driver can be passed
10099
when creating instances of the `ORMInfrastructure`.
@@ -106,6 +105,8 @@ For hybrid (annotations and attributes) mapping configurations, you can use `\Do
106105
Multiple mapping drivers can be registered on the driver chain by providing namespace prefixes. For every namespace prefix,
107106
only one mapping driver can be used.
108107

108+
Starting in version 2.0.0, attributes-based mapping will be the default.
109+
109110
Testing the library itself
110111
--------------------------
111112

composer.json

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,20 +16,20 @@
1616
}
1717
],
1818
"require": {
19-
"php": "^7.4|^8.0",
20-
"doctrine/annotations": "^1.8|^2.0",
19+
"php": "^8.0",
2120
"doctrine/common": "^2.11|^3.0",
22-
"doctrine/dbal": "^2.12|^3.0",
21+
"doctrine/dbal": "^3.2",
22+
"doctrine/deprecations": "^1.1",
2323
"doctrine/event-manager": "^1.1|^2.0",
2424
"doctrine/orm": "^2.14|^3.0",
2525
"doctrine/persistence": "^2.0|^3.0",
26-
"symfony/cache": "^5.0|^6.0|^7.0",
27-
"symfony/deprecation-contracts": "^2.0|^3.0"
26+
"psr/log": "^2.0|^3.0",
27+
"symfony/cache": "^5.0|^6.0|^7.0"
2828
},
2929
"require-dev": {
3030
"doctrine/collections": "^1.6.8|^2.2.1",
31-
"phpunit/phpunit": "^9.6.19",
32-
"symfony/phpunit-bridge": "^6.0|^7.0"
31+
"phpunit/phpunit": "^10.5",
32+
"symfony/error-handler": "^5.4|^6.0|^7.0"
3333
},
3434
"autoload": {
3535
"psr-4": {

phpunit.xml.dist

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,16 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.6/phpunit.xsd" bootstrap="vendor/autoload.php">
2+
<phpunit
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.5/phpunit.xsd"
5+
bootstrap="tests/bootstrap.php"
6+
colors="true"
7+
displayDetailsOnAllIssues="true"
8+
>
9+
<source ignoreSuppressionOfDeprecations="true">
10+
<include>
11+
<directory>src</directory>
12+
</include>
13+
</source>
314
<testsuites>
415
<testsuite name="Library Test Suite">
516
<directory>tests/</directory>
@@ -8,11 +19,7 @@
819
<php>
920
<server name="KERNEL_CLASS" value="Webfactory\Bundle\PolyglotBundle\Tests\Fixtures\TestKernel" />
1021
<server name="KERNEL_DIR" value="tests/Fixtures/" />
11-
<env name="SYMFONY_DEPRECATIONS_HELPER" value="max[self]=0" />
1222
<env name="DOCTRINE_DEPRECATIONS" value="trigger" />
1323
<server name="SHELL_VERBOSITY" value="-1" />
1424
</php>
15-
<listeners>
16-
<listener class="Symfony\Bridge\PhpUnit\SymfonyTestsListener" />
17-
</listeners>
1825
</phpunit>

src/ORMTestInfrastructure/ConfigurationFactory.php

Lines changed: 0 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,7 @@
99

1010
namespace Webfactory\Doctrine\ORMTestInfrastructure;
1111

12-
use Doctrine\Common\Annotations\AnnotationReader;
13-
use Doctrine\Common\Annotations\PsrCachedReader;
14-
use Doctrine\Common\Annotations\Reader;
1512
use Doctrine\Deprecations\Deprecation;
16-
use Doctrine\ORM\Mapping\Driver\AnnotationDriver;
1713
use Doctrine\ORM\Mapping\Driver\AttributeDriver;
1814
use Doctrine\ORM\ORMSetup;
1915
use Doctrine\Persistence\Mapping\Driver\MappingDriver;
@@ -27,16 +23,6 @@
2723
*/
2824
class ConfigurationFactory
2925
{
30-
/**
31-
* Shared annotation reader or null, if not created yet.
32-
*
33-
* A shared reader is used for performance reasons. As annotations cannot
34-
* change during a test run, it is save to use a shared reader.
35-
*
36-
* @var Reader|null
37-
*/
38-
protected static $defaultAnnotationReader = null;
39-
4026
/** @var ?CacheItemPoolInterface */
4127
private static $metadataCache = null;
4228

@@ -78,15 +64,6 @@ private function createDefaultMappingDriver(array $entityClasses)
7864
{
7965
$paths = $this->getDirectoryPathsForClassNames($entityClasses);
8066

81-
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-
);
87-
return new AnnotationDriver($this->getAnnotationReader(), $paths);
88-
}
89-
9067
return new AttributeDriver($paths);
9168
}
9269

@@ -116,18 +93,4 @@ protected function getDirectoryPathForClassName($className)
11693
$info = new \ReflectionClass($className);
11794
return dirname($info->getFileName());
11895
}
119-
120-
/**
121-
* Returns the default annotation reader and creates it if necessary.
122-
*
123-
* @return Reader|AnnotationReader
124-
*/
125-
protected function getAnnotationReader()
126-
{
127-
if (static::$defaultAnnotationReader === null) {
128-
static::$defaultAnnotationReader = new PsrCachedReader(new AnnotationReader(), new ArrayAdapter());
129-
}
130-
131-
return static::$defaultAnnotationReader;
132-
}
13396
}

src/ORMTestInfrastructure/DetachingObjectManagerDecorator.php

Lines changed: 0 additions & 78 deletions
This file was deleted.

src/ORMTestInfrastructure/Importer.php

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -160,12 +160,10 @@ protected function importFromFile($path)
160160
*/
161161
protected function importFromCallback($callback)
162162
{
163-
$import = function (ObjectManager $objectManager) use ($callback) {
164-
$decorator = new MemorizingObjectManagerDecorator($objectManager);
165-
call_user_func($callback, $decorator);
166-
return $decorator->getSeenEntities();
167-
};
168-
$this->entityManager->wrapInTransaction($import);
163+
$this->entityManager->wrapInTransaction(function (ObjectManager $objectManager) use ($callback) {
164+
call_user_func($callback, $objectManager);
165+
});
166+
169167
// Clear the entity manager to ensure that there are no leftovers in the identity map.
170168
$this->entityManager->clear();
171169
}

src/ORMTestInfrastructure/MemorizingObjectManagerDecorator.php

Lines changed: 0 additions & 64 deletions
This file was deleted.

0 commit comments

Comments
 (0)