Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge release 5.2.1 into 5.3.x #790

Merged
merged 9 commits into from
Oct 28, 2022
2 changes: 1 addition & 1 deletion .github/workflows/coding-standards.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@ on:
jobs:
coding-standards:
name: "Coding Standards"
uses: "doctrine/.github/.github/workflows/coding-standards.yml@1.4.1"
uses: "doctrine/.github/.github/workflows/coding-standards.yml@2.1.0"
with:
php-version: '8.1'
20 changes: 20 additions & 0 deletions .github/workflows/composer-lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: "Composer Lint"

on:
pull_request:
branches:
- "*.x"
paths:
- "composer.json"
push:
branches:
- "*.x"
paths:
- "composer.json"

jobs:
composer-lint:
name: "Composer Lint"
uses: "doctrine/.github/.github/workflows/composer-lint.yml@2.1.0"
with:
php-version: "8.1"
69 changes: 6 additions & 63 deletions .github/workflows/continuous-integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,72 +2,15 @@ name: "Continuous Integration"

on:
pull_request:
branches:
- "*.x"
push:
branches:
- '[0-9]+.[0-9]+.x'
- 'refs/pull/*'
- "*.x"

jobs:
phpunit:
name: "PHPUnit"
runs-on: "ubuntu-20.04"

strategy:
matrix:
php-version:
- "7.4"
- "8.0"
- "8.1"
dependencies:
- "highest"
- "lowest"

steps:
- name: "Checkout"
uses: "actions/checkout@v2"
with:
fetch-depth: 2

- name: "Install PHP"
uses: "shivammathur/setup-php@v2"
with:
php-version: "${{ matrix.php-version }}"
coverage: "pcov"
ini-values: "zend.assertions=1"

- name: "Install dependencies with Composer"
uses: "ramsey/composer-install@v1"
with:
dependency-versions: "${{ matrix.dependencies }}"
composer-options: "--prefer-dist"

- name: "Run PHPUnit"
run: "composer test-coverage"

- name: "Upload coverage file"
uses: "actions/upload-artifact@v2"
with:
name: "phpunit-${{ matrix.php-version }}-${{ matrix.dependencies }}.coverage"
path: "coverage.xml"

upload_coverage:
name: "Upload coverage to Codecov"
runs-on: "ubuntu-20.04"
needs:
- "phpunit"

steps:
- name: "Checkout"
uses: "actions/checkout@v2"
with:
fetch-depth: 2

- name: "Download coverage files"
uses: "actions/download-artifact@v2"
with:
path: "reports"

- name: "Upload to Codecov"
uses: "codecov/codecov-action@v1"
with:
directory: "reports"
uses: "doctrine/.github/.github/workflows/continuous-integration.yml@2.1.0"
with:
php-versions: '["7.4", "8.0", "8.1"]'
2 changes: 1 addition & 1 deletion .github/workflows/release-on-milestone-closed.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ on:
jobs:
release:
name: "Git tag, release & create merge-up PR"
uses: "doctrine/.github/.github/workflows/release-on-milestone-closed.yml@1.4.1"
uses: "doctrine/.github/.github/workflows/release-on-milestone-closed.yml@2.1.0"
with:
use-next-minor-as-default-branch: true
secrets:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/static-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@ on:
jobs:
static-analysis:
name: "Static Analysis"
uses: "doctrine/.github/.github/workflows/static-analysis.yml@1.4.1"
uses: "doctrine/.github/.github/workflows/static-analysis.yml@2.1.0"
with:
php-version: '8.1'
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# DoctrineModule for Laminas

[![Build Status](https://github.com/doctrine/DoctrineModule/actions/workflows/continuous-integration.yml/badge.svg)](https://github.com/doctrine/DoctrineModule/actions/workflows/continuous-integration.yml?query=branch%3A4.4.x)
[![Code Coverage](https://codecov.io/gh/doctrine/DoctrineModule/branch/4.4.x/graphs/badge.svg)](https://codecov.io/gh/doctrine/DoctrineModule/branch/4.4.x)
[![Build Status](https://github.com/doctrine/DoctrineModule/actions/workflows/continuous-integration.yml/badge.svg)](https://github.com/doctrine/DoctrineModule/actions/workflows/continuous-integration.yml?query=branch%3A5.2.x)
[![Code Coverage](https://codecov.io/gh/doctrine/DoctrineModule/branch/5.2.x/graphs/badge.svg)](https://codecov.io/gh/doctrine/DoctrineModule/branch/5.2.x)
[![Latest Stable Version](https://poser.pugx.org/doctrine/doctrine-module/v/stable.png)](https://packagist.org/packages/doctrine/doctrine-module)
[![Total Downloads](https://poser.pugx.org/doctrine/doctrine-module/downloads.png)](https://packagist.org/packages/doctrine/doctrine-module)

Expand Down
28 changes: 16 additions & 12 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
{
"name": "doctrine/doctrine-module",
"description": "Laminas Module that provides Doctrine basic functionality required for ORM and ODM modules",
"type": "library",
"license": "MIT",
"homepage": "http://www.doctrine-project.org/",
"type": "library",
"keywords": [
"doctrine",
"module",
Expand Down Expand Up @@ -35,12 +34,7 @@
"homepage": "https://tomhanderson.com"
}
],
"extra": {
"laminas": {
"config-provider": "DoctrineModule\\ConfigProvider",
"module": "DoctrineModule"
}
},
"homepage": "http://www.doctrine-project.org/",
"require": {
"php": "^7.4 || ~8.0.0 || ~8.1.0",
"container-interop/container-interop": "^1.2.0",
Expand All @@ -63,11 +57,9 @@
"laminas/laminas-validator": "^2.16.0",
"symfony/console": "^5.4.3 || ^6.0.3"
},
"provide": {
"laminas/laminas-cache-storage-implementation": "1.0.0"
},
"require-dev": {
"doctrine/coding-standard": "^9.0.0",
"doctrine/mongodb-odm": "^2.3.0",
"doctrine/orm": "^2.11.1",
"jangregor/phpstan-prophecy": "^1.0.0",
"laminas/laminas-cache-storage-adapter-blackhole": "^2.0.0",
Expand All @@ -86,6 +78,9 @@
"conflict": {
"doctrine/orm": "2.12.0"
},
"provide": {
"laminas/laminas-cache-storage-implementation": "1.0.0"
},
"suggest": {
"doctrine/data-fixtures": "Data Fixtures if you want to generate test data or bootstrap data for your deployments"
},
Expand All @@ -103,9 +98,18 @@
"bin/doctrine-module"
],
"config": {
"sort-packages": true,
"allow-plugins": {
"dealerdirect/phpcodesniffer-composer-installer": true
},
"platform": {
"ext-mongodb": "1.8.0"
},
"sort-packages": true
},
"extra": {
"laminas": {
"config-provider": "DoctrineModule\\ConfigProvider",
"module": "DoctrineModule"
}
},
"scripts": {
Expand Down
16 changes: 11 additions & 5 deletions src/Service/DriverFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@
namespace DoctrineModule\Service;

use Doctrine\Common\Annotations;
use Doctrine\ORM\Mapping\Driver\AnnotationDriver;
use Doctrine\ORM\Mapping\Driver\AttributeDriver;
use Doctrine\ODM\MongoDB\Mapping\Driver\AnnotationDriver as MongoODMAnnotationDriver;
use Doctrine\ODM\MongoDB\Mapping\Driver\AttributeDriver as MongoODMAttributeDriver;
use Doctrine\ORM\Mapping\Driver\AnnotationDriver as ORMAnnotationDriver;
use Doctrine\ORM\Mapping\Driver\AttributeDriver as ORMAttributeDriver;
use Doctrine\Persistence\Mapping\Driver\DefaultFileLocator;
use Doctrine\Persistence\Mapping\Driver\FileDriver;
use Doctrine\Persistence\Mapping\Driver\MappingDriver;
Expand All @@ -18,7 +20,7 @@

use function class_exists;
use function get_class;
use function is_subclass_of;
use function is_a;
use function sprintf;

/**
Expand Down Expand Up @@ -71,8 +73,12 @@ protected function createDriver(ContainerInterface $container, Driver $options):

// Special options for AnnotationDrivers.
if (
$class !== AttributeDriver::class &&
($class === AnnotationDriver::class || is_subclass_of($class, AnnotationDriver::class))
$class !== ORMAttributeDriver::class &&
$class !== MongoODMAttributeDriver::class &&
(
is_a($class, ORMAnnotationDriver::class, true) ||
is_a($class, MongoODMAnnotationDriver::class, true)
)
) {
$reader = new Annotations\AnnotationReader();
$reader = new Annotations\CachedReader(
Expand Down
68 changes: 58 additions & 10 deletions tests/Service/DriverFactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,10 @@

use Doctrine\Common\Annotations\Reader;
use Doctrine\Common\Cache\ArrayCache;
use Doctrine\ORM\Mapping\Driver\AnnotationDriver;
use Doctrine\ORM\Mapping\Driver\AttributeDriver;
use Doctrine\ODM\MongoDB\Mapping\Driver\AnnotationDriver as MongoDBODMAnnotationDriver;
use Doctrine\ODM\MongoDB\Mapping\Driver\AttributeDriver as MongoDBODMAttributeDriver;
use Doctrine\ORM\Mapping\Driver\AnnotationDriver as ORMAnnotationDriver;
use Doctrine\ORM\Mapping\Driver\AttributeDriver as ORMAttributeDriver;
use Doctrine\Persistence\Mapping\Driver\MappingDriverChain;
use DoctrineModule\Service\DriverFactory;
use DoctrineModuleTest\Service\Mock\MetadataDriverMock;
Expand Down Expand Up @@ -75,34 +77,80 @@ public function testCreateDriverChain(): void
/**
* @requires PHP 8.0
*/
public function testCreateAttributeDriver(): void
public function testCreateORMAttributeDriver(): void
{
$serviceManager = new ServiceManager();
$serviceManager->setService(
'config',
[
'doctrine' => [
'driver' => [
'testDriver' => ['class' => AttributeDriver::class],
'testDriver' => ['class' => ORMAttributeDriver::class],
],
],
]
);

$factory = new DriverFactory('testDriver');
$driver = $factory->__invoke($serviceManager, AttributeDriver::class);
$this->assertInstanceOf(AttributeDriver::class, $driver);
$driver = $factory->__invoke($serviceManager, ORMAttributeDriver::class);
$this->assertInstanceOf(ORMAttributeDriver::class, $driver);
}

public function testCreateAnnotationDriver(): void
/**
* @requires PHP 8.0
*/
public function testCreateMongoDBODMAttributeDriver(): void
{
$serviceManager = new ServiceManager();
$serviceManager->setService(
'config',
[
'doctrine' => [
'driver' => [
'testDriver' => ['class' => MongoDBODMAttributeDriver::class],
],
],
]
);

$factory = new DriverFactory('testDriver');
$driver = $factory->__invoke($serviceManager, MongoDBODMAttributeDriver::class);
$this->assertInstanceOf(MongoDBODMAttributeDriver::class, $driver);
}

public function testCreateORMAnnotationDriver(): void
{
$serviceManager = new ServiceManager();
$serviceManager->setService(
'config',
[
'doctrine' => [
'driver' => [
'testDriver' => ['class' => ORMAnnotationDriver::class],
],
],
]
);
$serviceManager->setService(
'doctrine.cache.array',
new ArrayCache()
);

$factory = new DriverFactory('testDriver');
$driver = $factory->__invoke($serviceManager, ORMAnnotationDriver::class);
$this->assertInstanceOf(ORMAnnotationDriver::class, $driver);
$this->assertInstanceOf(Reader::class, $driver->getReader());
}

public function testCreateMongoDBODMAnnotationDriver(): void
{
$serviceManager = new ServiceManager();
$serviceManager->setService(
'config',
[
'doctrine' => [
'driver' => [
'testDriver' => ['class' => AnnotationDriver::class],
'testDriver' => ['class' => MongoDBODMAnnotationDriver::class],
],
],
]
Expand All @@ -113,8 +161,8 @@ public function testCreateAnnotationDriver(): void
);

$factory = new DriverFactory('testDriver');
$driver = $factory->__invoke($serviceManager, AnnotationDriver::class);
$this->assertInstanceOf(AnnotationDriver::class, $driver);
$driver = $factory->__invoke($serviceManager, MongoDBODMAnnotationDriver::class);
$this->assertInstanceOf(MongoDBODMAnnotationDriver::class, $driver);
$this->assertInstanceOf(Reader::class, $driver->getReader());
}
}