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 the final keyword for some classes? #201

Open
jmsche opened this issue Apr 29, 2024 · 0 comments
Open

Remove the final keyword for some classes? #201

jmsche opened this issue Apr 29, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@jmsche
Copy link

jmsche commented Apr 29, 2024

Q A
auditor version dev-master
PHP version 8.3.6
Database MySQL/MariaDB (but unrelated)

Summary

Hi, in #168 some classes were marked as final.

In our PHPUnit test suite, we create mocks of some of these classes; in our case:

  • DH\Auditor\Provider\Doctrine\Persistence\Reader\Reader
  • DH\Auditor\Provider\Doctrine\Persistence\Reader\Query

During our journey to upgrade our app to Symfony 7, we have to install the dev-master branch of both Auditor & its bundle, and encounter this issue with classes that we can't mock anymore.

If these classes were implementing an interface, we could create a mock of these, but currently this is unfortunately not an option.

Would it be an option to remove the final keyword to classes that was added in #168?
Or maybe add an interface that would be implemented by these classes?

Current behavior

Can't mock some classes like Reader or Query like this:

$reader = $this->createMock(DH\Auditor\Provider\Doctrine\Persistence\Reader\Reader::class);

How to reproduce

  • Install Auditor in some app
  • Create a PHPUnit test
  • Try to mock a final Auditor class:
$reader = $this->createMock(DH\Auditor\Provider\Doctrine\Persistence\Reader\Reader::class);

Expected behavior

I'd expect the mock to actually be creatable

@jmsche jmsche added the bug Something isn't working label Apr 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant