-
Notifications
You must be signed in to change notification settings - Fork 461
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Nathanael Esayeas <nathanael.esayeas@protonmail.com>
- Loading branch information
Showing
4 changed files
with
87 additions
and
14 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<?php | ||
|
||
namespace Mockery\Matcher; | ||
|
||
class IsSame extends MatcherAbstract | ||
{ | ||
/** | ||
* Check if the actual value matches the expected. | ||
* | ||
* @param mixed $actual | ||
* @return bool | ||
*/ | ||
public function match(&$actual) | ||
{ | ||
return $this->_expected === $actual; | ||
} | ||
|
||
/** | ||
* Return a string representation of this Matcher | ||
* | ||
* @return string | ||
*/ | ||
public function __toString() | ||
{ | ||
return '<IsSame>'; | ||
} | ||
} |
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,17 @@ | ||
<?php | ||
|
||
namespace test\Mockery\Matcher; | ||
|
||
use Mockery\Adapter\Phpunit\MockeryTestCase; | ||
use Mockery\Matcher\IsSame; | ||
|
||
class IsSameTest extends MockeryTestCase | ||
{ | ||
use MatcherDataProviderTrait; | ||
|
||
/** @dataProvider isSameDataProvider */ | ||
public function testItWorks($expected, $actual) | ||
{ | ||
self::assertTrue((new IsSame($expected))->match($actual)); | ||
} | ||
} |
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,23 @@ | ||
<?php | ||
|
||
namespace test\Mockery\Matcher; | ||
|
||
use stdClass; | ||
|
||
trait MatcherDataProviderTrait | ||
{ | ||
public static function isSameDataProvider(): iterable | ||
{ | ||
$object = new stdClass(); | ||
|
||
return [ | ||
'string' => ['#BlackLivesMatter', '#BlackLivesMatter'], | ||
'bool-true' => [true, true], | ||
'bool-false' => [false, false], | ||
'int' => [42, 42], | ||
'float' => [2.0, 2.0], | ||
'null' => [null, null], | ||
'object' => [$object, $object], | ||
]; | ||
} | ||
} |