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

Remove prophecy usage #6421

Merged
merged 4 commits into from
Sep 27, 2020

Conversation

jordisala1991
Copy link
Member

@jordisala1991 jordisala1991 commented Sep 27, 2020

Subject

I am targeting this branch, because this is a changes on tests plus a patch on src

Changelog

### Fixed
- Call to deprecated `getTargetEntity`

This will allow us to have the php 8 build running without errors. Also it will allow to remove prophecy usage and to upgrade all builds to use phpunit 9 (Except php 7.2)
This is the first step, there are other changes needed on dev-kit and on other repositories

return (
method_exists($fieldDescription, 'getTargetModel') && $class === $fieldDescription->getTargetModel()
) || $class === $fieldDescription->getTargetEntity();
return method_exists($fieldDescription, 'getTargetModel') ?
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I found this while changing all the tests, this can be done on a separate PR if you want.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This PR could take some times before being merged. So maybe it's indeed a good idea to create a separate PR

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's see how this goes, if we see a lot of review process I will revert it from this PR and open a new one. If not, I will change it to patch and add a changelog

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, but at least a separate commit seems needed.

@jordisala1991
Copy link
Member Author

I spent a lot of time trying to fix the BreadcrumbsBuilderTest, this one testUnitChildGetBreadCrumbs I dont have idea on how to fix it.

There was 1 failure:

1) Sonata\AdminBundle\Tests\Admin\BreadcrumbsBuilderTest::testUnitChildGetBreadCrumbs
Failed asserting that actual size 0 matches expected size 5.

Error: /home/runner/work/SonataAdminBundle/SonataAdminBundle/tests/Admin/BreadcrumbsBuilderTest.php:403

@greg0ire maybe you can help me? I need to see what I broke with the change from prophecy to phpunit mocks.

@jordisala1991 jordisala1991 changed the title [WIP] Remove prophecy usage Remove prophecy usage Sep 27, 2020
@jordisala1991
Copy link
Member Author

I leave it as a draft, but the only thing missing before reviews is fixing that one test. The rest should be okay.

@greg0ire
Copy link
Contributor

@greg0ire maybe you can help me? I need to see what I broke with the change from prophecy to phpunit mocks.

Not sure what you broke, but when I wrote this test, I wasn't yet aware that mocking what you don't own is bad it seems. I pushed a new commit that greatly simplifies this test by relying on real classes instead of stubs.

@greg0ire
Copy link
Contributor

My commit removed many expectations though, I will force push equivalent assertions soon.

@jordisala1991
Copy link
Member Author

My commit removed many expectations though, I will force push equivalent assertions soon.

I pushed two more commits to fix builds and the var thing

@greg0ire greg0ire force-pushed the pedantic/remove-prophecy branch from 1dada05 to c1cd54b Compare September 27, 2020 09:59
@greg0ire
Copy link
Contributor

I just force pushed (with lease)

@jordisala1991 jordisala1991 marked this pull request as ready for review September 27, 2020 10:00
@jordisala1991
Copy link
Member Author

Aaaand the php8 is green again! Thank you @greg0ire .

Please review, @sonata-project/contributors

@jordisala1991 jordisala1991 requested a review from a team September 27, 2020 10:01
VincentLanglet
VincentLanglet previously approved these changes Sep 27, 2020
Copy link
Member

@VincentLanglet VincentLanglet left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe some clean up is necessary in the commits ?

For instance the fix of src/Form/DataTransformerResolver.php should be in a separate commit.

@VincentLanglet VincentLanglet requested a review from a team September 27, 2020 10:03
This will allow us to use `assertMatchesRegularExpression` on the
lowest dependencies build
The previous check will call it anyway since the second part
of the comparison can return false, and that would lead to
calling deprecated code.
@jordisala1991
Copy link
Member Author

I squashed some commits, separate the code changed on src. It should be better now.

Copy link
Member

@franmomu franmomu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would replace:

- $this->container = $this->createStub(ContainerInterface::class);
+ $this->container = new Container();

But we could do that in another PR.

Edit: Another PR is fine 🤣

tests/Admin/AdminTest.php Show resolved Hide resolved
tests/Admin/AdminTest.php Show resolved Hide resolved
tests/Controller/HelperControllerTest.php Show resolved Hide resolved
tests/Util/ObjectAclManipulatorTest.php Show resolved Hide resolved
tests/Util/ObjectAclManipulatorTest.php Show resolved Hide resolved
@greg0ire greg0ire merged commit 8380d06 into sonata-project:3.x Sep 27, 2020
@greg0ire
Copy link
Contributor

Oh sorry @franmomu I merged right when you published your review 😅

@franmomu
Copy link
Member

franmomu commented Sep 27, 2020

No worries, that can be change with the Container mock in another one.

@VincentLanglet
Copy link
Member

VincentLanglet commented Sep 27, 2020

@jordisala1991 Big thanks for this PR.
Do you want to also make a merge into master ? There should be some conflict.

@jordisala1991
Copy link
Member Author

Yes, I will do it. I expect big conflict fight

@jordisala1991
Copy link
Member Author

jordisala1991 commented Sep 27, 2020

No worries, that can be change with the Container mock in another one.

Can you make another PR to fix those things? I wont have time today to do it

Edit: wait, I have time to fix them now

@jordisala1991 jordisala1991 deleted the pedantic/remove-prophecy branch September 27, 2020 11:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants