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

Add support for doctrine/orm 3 #43

Draft
wants to merge 46 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
9c89989
permit v3
Firehed Oct 17, 2023
1aca7fa
prep ci matrix
Firehed Oct 17, 2023
c1acb25
stub missing method
Firehed Oct 17, 2023
0961446
start to add return types
Firehed Oct 17, 2023
d693f8b
more types
Firehed Oct 17, 2023
e856b27
more types
Firehed Oct 17, 2023
93ed237
address method remove/rename
Firehed Oct 17, 2023
473e053
type a few
Firehed Oct 17, 2023
d3483cc
more returns
Firehed Oct 17, 2023
68de240
more returns
Firehed Oct 17, 2023
36bd814
hack extends short-term to prototype
Firehed Oct 30, 2023
36186b5
fix xml mappings despite documentation
Firehed Oct 31, 2023
0beaef2
real version
Firehed Feb 10, 2024
fb1f31c
goodbye annotation driver
Firehed Feb 10, 2024
7bb4fff
switch to attrs
Firehed Feb 10, 2024
67c18c0
more switch
Firehed Feb 10, 2024
8657ce0
again
Firehed Feb 10, 2024
76b4356
stub in hacky polyfill thing
Firehed Feb 10, 2024
fa97dec
keep going
Firehed Feb 10, 2024
3a55152
add param type
Firehed Feb 11, 2024
d401381
lint
Firehed Feb 11, 2024
118593c
handle some goofs
Firehed Feb 11, 2024
e7c2aec
update new exception
Firehed Feb 11, 2024
d37c236
chagne ex
Firehed Feb 11, 2024
6264dd9
error fixed
Firehed Feb 11, 2024
083475a
notes
Firehed Feb 11, 2024
86db8dd
Merge branch 'master' into orm-v3
Firehed Feb 11, 2024
5fb780a
Criteria supports default empty now
Firehed Feb 11, 2024
e358993
Merge branch 'master' into orm-v3
Firehed Aug 30, 2024
1a9a73b
add 2.x and 3.x matrix
Firehed Aug 30, 2024
3ed8282
Param-only types for cross-compatibility
Firehed Aug 30, 2024
5e022cb
Roll back some select types
Firehed Aug 30, 2024
0f0fdd3
fix or in composer
Firehed Aug 30, 2024
9ae52c6
3 only
Firehed Aug 30, 2024
c5cecf4
retighten params
Firehed Aug 30, 2024
fb387e9
retighten params
Firehed Aug 30, 2024
23c88e0
sync to new interface
Firehed Aug 30, 2024
bf36878
Finish merge removal
Firehed Aug 30, 2024
1cf47e8
Compatibility note
Firehed Aug 30, 2024
25467e0
Remove redundant type
Firehed Sep 23, 2024
6ce41eb
getPartialReference was removed
Firehed Sep 23, 2024
d5a22e0
copy was removed
Firehed Sep 23, 2024
89ea75f
Removed named queries
Firehed Sep 23, 2024
9d7f59a
Update lock with types
Firehed Sep 23, 2024
27d28ec
Remove getHydrator
Firehed Sep 23, 2024
2cf343c
Actually implement wrapInTransaction, through it will still throw
Firehed Sep 23, 2024
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
14 changes: 2 additions & 12 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,24 +48,14 @@ jobs:
${{ runner.os }}-php-${{ matrix.dependencies }}-
${{ runner.os }}-php-

- name: Install highest dependencies
if: ${{ matrix.dependencies == 'high' }}
- name: Install dependencies
run: composer update
--no-ansi
--no-interaction
--no-progress
--no-suggest
--prefer-dist

- name: Install lowest dependencies
if: ${{ matrix.dependencies == 'low' }}
run: composer update
--no-ansi
--no-interaction
--no-progress
--no-suggest
--prefer-dist
--prefer-lowest
${{ matrix.dependencies == 'low' && '--prefer-lowest' || '' }}

- name: PHPUnit
run: vendor/bin/phpunit
Expand Down
8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ The following methods on Doctrine's `EntityManagerInterface` should all work as
- find
- persist
- remove
- merge
- flush
- getRepository
- getCache (will always return `null`)
Expand Down Expand Up @@ -88,3 +87,10 @@ The following methods are **not** supported at this time:
- getFilters
- isFiltersStateClean
- hasFilters

## ORM v2 Support

As of Mocktrine, 1.0 and newer, Doctrine/ORM v3 is the only supported version.
While it was originally a goal to support v2 and v3 in the same major version of Mocktrine, there are too many BC breaks for this to be practical.

To use Mocktrine to test Doctrine/ORM v2 code, install the 0.x line.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"php": "^8.1",
"doctrine/annotations": "^1.10 || ^2.0",
"doctrine/collections": "^1.6.8 || ^2.0",
"doctrine/orm": "^2.9",
"doctrine/orm": "^3.0",
"doctrine/persistence": "^1.3 || ^2.0 || ^3.0"
},
"require-dev": {
Expand Down
5 changes: 0 additions & 5 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
parameters:
ignoreErrors:
-
message: "#^Return type \\(Firehed\\\\Mocktrine\\\\InMemoryRepository\\<Entity of object\\>\\) of method Firehed\\\\Mocktrine\\\\InMemoryEntityManager\\:\\:getRepository\\(\\) should be compatible with return type \\(Doctrine\\\\ORM\\\\EntityRepository\\<object\\>\\) of method Doctrine\\\\ORM\\\\EntityManagerInterface\\:\\:getRepository\\(\\)$#"
count: 1
path: src/InMemoryEntityManager.php

-
message: "#^Property Firehed\\\\Mocktrine\\\\RepositoryContainer\\:\\:\\$values with generic class Firehed\\\\Mocktrine\\\\InMemoryRepository does not specify its types\\: Entity$#"
count: 1
Expand Down
52 changes: 52 additions & 0 deletions src/ArrayALC.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
<?php

declare(strict_types=1);

namespace Firehed\Mocktrine;

use BadMethodCallException;
use Doctrine\Common\Collections\{
AbstractLazyCollection,
Criteria,
Collection,
Selectable,
};

/**
* Since we're currently forced to extend EntityRepository instead of merely
* implementing the interface in orm:3, we're consequently forced to return an
* implementation-specific `AbstractLazyCollection` intead of the interface's
* `ReadableCollection`. This does some light wrapping to allow things to work
* for the common case.
*
* @see doctrine/orm#11019
*
* @template TKey of array-key
* @template T of object
*
* @extends AbstractLazyCollection<TKey, T>
* @implements Selectable<TKey, T>
*
* @internal
*/
class ArrayALC extends AbstractLazyCollection implements Selectable
{
/**
* @param Collection<TKey, T> $collection
*/
public function __construct(

Check warning on line 37 in src/ArrayALC.php

View check run for this annotation

Codecov / codecov/patch

src/ArrayALC.php#L37

Added line #L37 was not covered by tests
Collection $collection,
) {
$this->collection = $collection;

Check warning on line 40 in src/ArrayALC.php

View check run for this annotation

Codecov / codecov/patch

src/ArrayALC.php#L40

Added line #L40 was not covered by tests
}

protected function doInitialize(): void

Check warning on line 43 in src/ArrayALC.php

View check run for this annotation

Codecov / codecov/patch

src/ArrayALC.php#L43

Added line #L43 was not covered by tests
{
// no-op, constructor does this
}

public function matching(Criteria $criteria)

Check warning on line 48 in src/ArrayALC.php

View check run for this annotation

Codecov / codecov/patch

src/ArrayALC.php#L48

Added line #L48 was not covered by tests
{
throw new BadMethodCallException('Nested matching not supported');

Check warning on line 50 in src/ArrayALC.php

View check run for this annotation

Codecov / codecov/patch

src/ArrayALC.php#L50

Added line #L50 was not covered by tests
}
}
Loading