Skip to content

Commit

Permalink
Add factory methods for IsEqual and IsSame matchers (#1336)
Browse files Browse the repository at this point in the history
Signed-off-by: Nathanael Esayeas <nathanael.esayeas@protonmail.com>
  • Loading branch information
ghostwriter committed Nov 11, 2023
1 parent fab5c13 commit c1f6f09
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 2 deletions.
24 changes: 24 additions & 0 deletions library/Mockery.php
Expand Up @@ -17,6 +17,8 @@
use Mockery\Generator\StringManipulationGenerator;
use Mockery\Loader\EvalLoader;
use Mockery\Loader\Loader;
use Mockery\Matcher\IsEqual;
use Mockery\Matcher\IsSame;
use Mockery\Matcher\MatcherAbstract;
use Mockery\Reflector;

Expand Down Expand Up @@ -462,6 +464,28 @@ public static function mustBe($expected)
return new \Mockery\Matcher\MustBe($expected);
}

/**
* Return instance of IsEqual matcher.
*
* @template TExpected
* @param TExpected $expected
*/
public static function isEqual($expected): IsEqual

Check failure on line 473 in library/Mockery.php

View workflow job for this annotation

GitHub Actions / Psalm

PossiblyUnusedMethod

library/Mockery.php:473:28: PossiblyUnusedMethod: Cannot find any calls to method Mockery::isEqual (see https://psalm.dev/087)
{
return new IsEqual($expected);
}

/**
* Return instance of IsSame matcher.
*
* @template TExpected
* @param TExpected $expected
*/
public static function isSame($expected): IsSame

Check failure on line 484 in library/Mockery.php

View workflow job for this annotation

GitHub Actions / Psalm

PossiblyUnusedMethod

library/Mockery.php:484:28: PossiblyUnusedMethod: Cannot find any calls to method Mockery::isSame (see https://psalm.dev/087)
{
return new IsSame($expected);
}

/**
* Return instance of NOT matcher.
*
Expand Down
3 changes: 2 additions & 1 deletion tests/Mockery/Matcher/IsEqualTest.php
Expand Up @@ -2,6 +2,7 @@

namespace test\Mockery\Matcher;

use Mockery;
use Mockery\Adapter\Phpunit\MockeryTestCase;
use Mockery\Matcher\IsEqual;

Expand All @@ -12,6 +13,6 @@ class IsEqualTest extends MockeryTestCase
/** @dataProvider isEqualDataProvider */
public function testItWorks($expected, $actual)
{
self::assertTrue((new IsEqual($expected))->match($actual));
self::assertTrue(Mockery::isEqual($expected)->match($actual));
}
}
3 changes: 2 additions & 1 deletion tests/Mockery/Matcher/IsSameTest.php
Expand Up @@ -2,6 +2,7 @@

namespace test\Mockery\Matcher;

use Mockery;
use Mockery\Adapter\Phpunit\MockeryTestCase;
use Mockery\Matcher\IsSame;

Expand All @@ -12,6 +13,6 @@ class IsSameTest extends MockeryTestCase
/** @dataProvider isSameDataProvider */
public function testItWorks($expected, $actual)
{
self::assertTrue((new IsSame($expected))->match($actual));
self::assertTrue(Mockery::isSame($expected)->match($actual));
}
}

0 comments on commit c1f6f09

Please sign in to comment.