Skip to content

Commit

Permalink
The document section has been added for onInstanceCreated method in t…
Browse files Browse the repository at this point in the history
…he MockFactory
  • Loading branch information
diloabininyeri committed Feb 25, 2025
1 parent 0a5f563 commit e4a2264
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -424,4 +424,29 @@ function fetch_data(PDO $PDO):array

$data=fetch_data($mockPdo);
print_r($data);////['id' => 1, 'name' => 'Dilo Surucu']
```
**onInstanceCreated**

This method is triggered when the object is instantiated.
```php

$mockMethod = new MockMethod();

$mockMethod->mockMethod('test', function () {
return 'test foo';
});
$mockMethod->mockMethod('now', function (int $a) {
return $a;
});


$mockFactory = new MockFactory($mockMethod);
$mockFactory
->onInstanceCreated(function (Date $date) {
echo $date->test(); //test foo

//$date->__construct(); for custom constructor
})
->createMock(Date::class, ['a' => 1]);

```

0 comments on commit e4a2264

Please sign in to comment.