-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
General improvements were made for onMockInstanceCreated and tests we…
…re written for construct parameters.
- Loading branch information
1 parent
31492f6
commit f578b35
Showing
4 changed files
with
50 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<?php | ||
|
||
namespace Zeus\Mock\Tests\stubs; | ||
|
||
class ExampleForOnInstanced | ||
{ | ||
|
||
public function __construct(string $message,bool $status) | ||
{ | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
<?php | ||
|
||
namespace Zeus\Mock\Tests\unit; | ||
|
||
use PHPUnit\Framework\Attributes\Test; | ||
use PHPUnit\Framework\TestCase; | ||
use ReflectionException; | ||
use Zeus\Mock\MockFactory; | ||
use Zeus\Mock\Tests\stubs\ExampleForOnInstanced; | ||
|
||
class OnInstanceClosureTest extends TestCase | ||
{ | ||
|
||
#[Test] | ||
/** | ||
* | ||
* @throws ReflectionException | ||
*/ | ||
public function onInstanceClosure(): void | ||
{ | ||
$mockFactory = new MockFactory(); | ||
$mockFactory->onMockInstanceCreated(function (ExampleForOnInstanced $example, string $message, bool $status) { | ||
|
||
$this->assertEquals('hello', $message); | ||
$this->assertTrue($status); | ||
$this->assertInstanceOf(ExampleForOnInstanced::class, $example); | ||
}); | ||
|
||
$mockFactory->createMock(ExampleForOnInstanced::class, | ||
[ | ||
'message' => 'hello', | ||
'status' => true | ||
]); | ||
} | ||
} |