Skip to content

Commit 4413aca

Browse files
committed
Added test for bugfix
1 parent 234a9e1 commit 4413aca

File tree

2 files changed

+17
-4
lines changed

2 files changed

+17
-4
lines changed

src/Matcher/ArgumentMatcher.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,8 @@ protected static function checkMatchingArguments($returnValues, $arguments)
4343
if ($hamcrest[$index] instanceof Matcher) {
4444
assertThat($arg, $hamcrest[$index]);
4545

46-
} else {
47-
if ($arg != $hamcrest[$index]) {
48-
throw new AssertionError();
49-
}
46+
} else if ($arg != $hamcrest[$index]) {
47+
throw new AssertionError();
5048
}
5149

5250
}

tests/ShortifyPunitTest.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -387,4 +387,19 @@ public function testSpies()
387387
// after chaning methods in chain with same arguments are instanceof `MockClassOnTheFly`
388388
$this->assertInstanceOf('ShortifyPunit\Mock\MockClassOnTheFly', $spy->second_method());
389389
}
390+
391+
/**
392+
* Hamcrest API with normal parameters caused problems
393+
* Bug Fix in - v1.0.6
394+
*/
395+
public function testHamcrestWithNormalParam()
396+
{
397+
$mock = ShortifyPunit::mock('SimpleClassForMocking');
398+
399+
ShortifyPunit::when($mock)->first_method(anything(), 'a')->returns(1);
400+
ShortifyPunit::when($mock)->first_method(anything(), 'b')->returns(2);
401+
402+
$this->assertEquals($mock->first_method('anything...', 'a'), 1);
403+
$this->assertEquals($mock->first_method('anything...', 'b'), 2);
404+
}
390405
}

0 commit comments

Comments
 (0)