Skip to content

Commit

Permalink
Add PHPCR ODM 2.x compat
Browse files Browse the repository at this point in the history
  • Loading branch information
mbabker committed Apr 10, 2024
1 parent 0dda4d5 commit ca6da20
Show file tree
Hide file tree
Showing 8 changed files with 40 additions and 5 deletions.
15 changes: 13 additions & 2 deletions .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ jobs:
composer-flags: '--prefer-stable --prefer-dist --prefer-lowest'
next-php: false
- php: '8.3'
orm: '^3.0@beta'
orm: '^3.0'
composer-flags: '--prefer-stable --prefer-dist'
next-php: false
- php: '8.3'
Expand Down Expand Up @@ -248,19 +248,26 @@ jobs:
fail-fast: true
matrix:
php: ['8.1', '8.2', '8.3']
odm: ['']
composer-flags: ['--prefer-stable --prefer-dist']
next-php: [false]
patch-packages: [false]
include:
- php: '8.1'
odm: ''
composer-flags: '--prefer-stable --prefer-dist --prefer-lowest'
next-php: false
- php: '8.3'
odm: '^2.0'
composer-flags: '--prefer-dist --prefer-lowest'
next-php: false
- php: '8.3'
odm: ''
composer-flags: '--prefer-stable --prefer-dist'
next-php: false
patch-packages: true

name: Doctrine PHPCR ODM - PHP ${{ matrix.php }} - Composer ${{ matrix.composer-flags }}${{ matrix.patch-packages && ' (Patched Packages)' || '' }}
name: Doctrine PHPCR ODM${{ matrix.odm != '' && format(' {0}', matrix.odm) || '' }} - PHP ${{ matrix.php }} - Composer ${{ matrix.composer-flags }}${{ matrix.patch-packages && ' (Patched Packages)' || '' }}

steps:
- name: Checkout code
Expand All @@ -278,6 +285,10 @@ jobs:
if: ${{ matrix.patch-packages }}
run: php .github/patch-packages.php

- name: Restrict ODM version
if: ${{ matrix.odm }}
run: (cd lib/Adapter/Doctrine/PHPCRODM && composer require --no-update doctrine/phpcr-odm:${{ matrix.odm }})

- name: Install dependencies
run: (cd lib/Adapter/Doctrine/PHPCRODM && composer update ${{ matrix.composer-flags }})

Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"doctrine/dbal": "^3.5 || ^4.0",
"doctrine/mongodb-odm": "^2.4",
"doctrine/orm": "^2.14 || ^3.0",
"doctrine/phpcr-odm": "^1.7",
"doctrine/phpcr-odm": "^1.7 || ^2.0",
"dg/bypass-finals": "^1.5.1",
"jackalope/jackalope-doctrine-dbal": "^1.9",
"phpstan/extension-installer": "^1.3.1",
Expand Down
1 change: 1 addition & 0 deletions lib/Adapter/Doctrine/PHPCRODM/QueryAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use Doctrine\ODM\PHPCR\Query\Builder\QueryBuilder;
use Doctrine\ODM\PHPCR\Query\Query;
use Pagerfanta\Adapter\AdapterInterface;
use PHPCR\Query\QueryResultInterface;

/**
* Adapter which calculates pagination from a Doctrine PHPCR ODM QueryBuilder.
Expand Down
11 changes: 11 additions & 0 deletions lib/Adapter/Doctrine/PHPCRODM/Tests/bootstrap.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?php declare(strict_types=1);

use DG\BypassFinals;

require __DIR__.'/../vendor/autoload.php';

BypassFinals::setWhitelist([
'*/Doctrine/ODM/PHPCR/*',
]);

BypassFinals::enable(bypassReadOnly: false);
3 changes: 2 additions & 1 deletion lib/Adapter/Doctrine/PHPCRODM/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,11 @@
"license": "MIT",
"require": {
"php": "^8.1",
"doctrine/phpcr-odm": "^1.7",
"doctrine/phpcr-odm": "^1.7|| ^2.0",
"pagerfanta/core": "^3.7 || ^4.0"
},
"require-dev": {
"dg/bypass-finals": "^1.5.1",
"jackalope/jackalope-doctrine-dbal": "^1.9",
"phpunit/phpunit": "^10.5"
},
Expand Down
2 changes: 1 addition & 1 deletion lib/Adapter/Doctrine/PHPCRODM/phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<phpunit
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
colors="true"
bootstrap="vendor/autoload.php"
bootstrap="Tests/bootstrap.php"
xsi:noNamespaceSchemaLocation="vendor/phpunit/phpunit/phpunit.xsd"
>
<testsuites>
Expand Down
10 changes: 10 additions & 0 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,16 @@ parameters:
count: 3
path: lib/Adapter/Doctrine/ORM/Tests/QueryAdapterTest.php

-
message: "#^Call to an undefined method Doctrine\\\\Common\\\\Collections\\\\Collection\\|PHPCR\\\\Query\\\\QueryResultInterface\\:\\:getRows\\(\\)\\.$#"
count: 1
path: lib/Adapter/Doctrine/PHPCRODM/QueryAdapter.php

-
message: "#^Call to an undefined method Iterator\\<mixed, PHPCR\\\\Query\\\\RowInterface\\>\\:\\:count\\(\\)\\.$#"
count: 1
path: lib/Adapter/Doctrine/PHPCRODM/QueryAdapter.php

-
message: "#^Call to static method PHPUnit\\\\Framework\\\\Assert\\:\\:assertSame\\(\\) with ArrayIterator\\<\\*NEVER\\*, \\*NEVER\\*\\> and iterable will always evaluate to false\\.$#"
count: 1
Expand Down
1 change: 1 addition & 0 deletions tests/bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

BypassFinals::setWhitelist([
'*/Doctrine/ODM/MongoDB/*',
'*/Doctrine/ODM/PHPCR/*',
]);

BypassFinals::enable(bypassReadOnly: false);

0 comments on commit ca6da20

Please sign in to comment.