Unfinalizer
Plugs in the composer autolader and removes the final keywords from autoloaded classes on the fly., (*1)
This allows you to mock the final classes and methods in your unit tests., (*2)
Usage
Add the Unfinalizer to your project:, (*3)
composer require --dev jasir/unfinalizer:dev-master
````
In your tests bootstrap file, load Unfinalizer before your composer loading:
include DIR . '/vendor/jasir/unfinalizer/init.php' //add this line
include DIR . '/vendor/autoload.php';, (*4)
That's all. Now all the files loaded by the composer autoloading process are without the final methods and classes.
Adding own files or files with their own loader
-----------------------------------------------
Some frameworks, like Nette, uses their own loader. You can solve this by adding own files to loader:
include DIR . '/vendor/jasir/unfinalizer/init.php' //add this line
$loader = include DIR . '/vendor/autoload.php';, (*5)
$loader->add('Nette', DIR . '/vendor/nette/nette');, (*6)
```, (*7)
Now you can mock those finals! Happy testing., (*8)
TODO
Please note this project is in a very alpha stage, so the code is very minimalistic., (*9)
I would like to add (maybe):, (*10)
- not evaluate changed files, but saving them in cache for easier debugging
- ... ?