Download the PHP package alexrili/lumen-test-booster without Composer
On this page you can find all versions of the php package alexrili/lumen-test-booster. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package lumen-test-booster
Lumen Test Booster
Just a small abstraction of lumen test with aspectmock and handler excpetion.
Install
how to use
First of all, you need to make sure you have the Stubs
folder inside your high level test
folder.
Name your clone classes
as YourClassNameStub and put them inside a Stubs
folder
Import LumenTestBooster as a trait
in your high level TestCase class.
use \LumenTestBooster;
How to clone/mock your tests
Just ovewriter the setUp
method and call $this->stubClasses()
method to stub/mock your classes
Make sure you have, a
Stubs
folder inside yourtest
high level folder.
Use case
1st case scenario.
Let's say you have a class name NotificationService and you want to mock/stub this class.
First of all you need to create a NotificationServiceStub inside a tests/Stubs/
folder.
After this, you just call $this->stubClasses([ClassYourWantToMock::class]);
inside your setUp
method.
And That's It.
Don't forget to import
LumenTestBooster
in yourTestCase
class.
2st case scenario. But, if you want to test some different returns of a method? Eg. you need to test a error return.
Inside your StubClass(in this case NotificationServiceStub), you will create a
sendEmailNotificationError()
method. In this case you can disable exception handler by call$this->withoutShowingExceptions()
Other configs
You can change exception handlers to not showing/handler in runtime. Say you have a specific test you want to return an error.
You also can change the default set of stub paths.
This config must be put inside you high level test case class.
Thanks!
@GMBN (the goldenboy) @cadukiz