DamienHarper / auditor

auditor, the missing audit log library
MIT License
164 stars 53 forks source link

Remove the final keyword for some classes? #201

Open jmsche opened 6 months ago

jmsche commented 6 months ago
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:

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

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

Expected behavior

I'd expect the mock to actually be creatable