Skip to content

Commit e4a2264

Browse files
The document section has been added for onInstanceCreated method in the MockFactory
1 parent 0a5f563 commit e4a2264

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

README.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -424,4 +424,29 @@ function fetch_data(PDO $PDO):array
424424

425425
$data=fetch_data($mockPdo);
426426
print_r($data);////['id' => 1, 'name' => 'Dilo Surucu']
427+
```
428+
**onInstanceCreated**
429+
430+
This method is triggered when the object is instantiated.
431+
```php
432+
433+
$mockMethod = new MockMethod();
434+
435+
$mockMethod->mockMethod('test', function () {
436+
return 'test foo';
437+
});
438+
$mockMethod->mockMethod('now', function (int $a) {
439+
return $a;
440+
});
441+
442+
443+
$mockFactory = new MockFactory($mockMethod);
444+
$mockFactory
445+
->onInstanceCreated(function (Date $date) {
446+
echo $date->test(); //test foo
447+
448+
//$date->__construct(); for custom constructor
449+
})
450+
->createMock(Date::class, ['a' => 1]);
451+
427452
```

0 commit comments

Comments
 (0)