-
Notifications
You must be signed in to change notification settings - Fork 326
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
Replacing the mocks in phpunit dataproviders with actual objects #7412
Conversation
a22c0fd
to
a00fe76
Compare
use PHPCR\NodeInterface; | ||
use Sulu\Component\Content\Extension\AbstractExtension; | ||
|
||
class TestExtension extends AbstractExtension |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
would not create a TestExtension
class here instead use anonymous class inside the specific test case: e.g.:
private static function createTestExtension(): AbstractExtension
{
return new class extends AbstractExtension() {
// ..
};
}
We should target the 2.5 to make backmerge of bugfixes easier. |
fc3949e
to
19905d0
Compare
19905d0
to
266f65e
Compare
8d23d10
to
7a5587f
Compare
7a5587f
to
1741ea8
Compare
self::setPrivateProperty($entity, 'id', $id); | ||
self::setPrivateProperty($entity, 'number', $id); | ||
self::setPrivateProperty($entity, 'name', $name); | ||
self::setPrivateProperty($entity, 'tags', new ArrayCollection($tags)); | ||
self::setPrivateProperty($entity, 'placeOfJurisdiction', ''); | ||
self::setPrivateProperty($entity, 'uid', ''); | ||
self::setPrivateProperty($entity, 'corporation', ''); | ||
self::setPrivateProperty($entity, 'created', new \DateTime()); | ||
self::setPrivateProperty($entity, 'changed', new \DateTime()); | ||
self::setPrivateProperty($entity, 'medias', new ArrayCollection([])); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is highly in efficient because we are reflecting on this class with every method call. But it's just the tests.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mamazu for properties providing a setter I would directly call the setter method and not go over reflection. So in our case the reflection mostly only used for the primary keys.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed. The only place I have also left with the function is the cache in the MediaDataProvider
.
af9ad1d
to
421d4f9
Compare
@mamazu Thank you! |
What's in this PR?
Replacing the mock object with real objects in the dataproviders
Why?
For the phpunit 10 upgrade and mocking hides implementation problems.