matura
matura copied to clipboard
Consider to use $this instead of $ctx argument
I know that it will break compability wth php5.3 but hey... php5.3 is no longer supported.
Example:
describe('User Database', function () {
foreach(range(1,5) as $repetition) {
it('should insert a user', function (){
$user = $this->db->findOne([
'username' => $this->username;
]);
expect($user)->to->have->length(1);
});
it('should not accumulate users', function (){
$users = $this->db->find();
expect($users)->to->have->length(1);
});
}
// ...
}
This will allow to add mock injection into closures based on typehint (see phpspec implementation for example).
before_all(function (Database $databaseMock) {
$this->db = $databaseMock;
});
Just made a comment about this on /r/php. I agree and I'm considering it.