| Q | A
| ------------- | ---
| Bug fix? | no
| New feature? | yes
| Fixed tickets | #143
Summary of the API:
A quick summary of this RFC's API.
extends can be used to extend a method or methods.
For extending a method supply the method name and the new value. You can also supply an array of method/value sets for overriding multiple methods or chain extends call.
uses(MyTestCase::class)
->extends(
'createBill',
fn(string $name) => $this->billService->create($name)
)
->extends([
'containerProvides' => ['BillService', 'UserService', 'LoginService'],
'initializeContainer' => function() {
$container = parent::initializeContainer();
$container->add(GoogleStorage::class, Mockery::spy(GoogleStorage::class));
},
]);
For calling the parent instance method, simply use self::parent(). Calling static parent methods is currently not supported due to limitations within PHP itself.
with can be used to override a property.
For overriding a property, we can use the with method. It works the same way as extends except that it does not support closures, as statements in properties are forbidden.
uses(MyTestCase::class)
->with('appName', 'MyAwesomePestApp')
->with([
'useDatabase' => true,
'databaseMode' => DatabaseMode::TRANSACTION,
]);
Fixes #143