Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add factory methods for IsEqual and IsSame matchers #1336

Merged
merged 1 commit into from
Nov 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
24 changes: 24 additions & 0 deletions library/Mockery.php
Original file line number Diff line number Diff line change
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 @@
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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));
}
}