Removes `final` and `readonly` keywords from source code on-the-fly and allows mocking of final methods and classes. It can be used together with any test tool such as PHPUnit or Mockery.
protected function setUp(): void
{
parent::setUp();
BypassFinals::enable();
}
and also tried to use it inside my test:
public function testCountTokens(): int
{
BypassFinals::enable();
.....
}
I got the same error regardless of the alternative:
Mockery\Exception: The class \Gemini is marked final and its methods cannot be replaced. Classes marked final can be passed in to \Mockery::mock() as instantiated objects to create a partial mock, but only if the mock is not subject to type hinting checks.
I could not make the tool work. I may be doing something wrong.
I'm using phpunit 11 and mockery.
I tried adding the extension to phpunit.xml
And tried to use enable on setUp:
and also tried to use it inside my test:
I got the same error regardless of the alternative:
Mockery\Exception: The class \Gemini is marked final and its methods cannot be replaced. Classes marked final can be passed in to \Mockery::mock() as instantiated objects to create a partial mock, but only if the mock is not subject to type hinting checks.