Skip to content

Commit

Permalink
Added test for bugfix
Browse files Browse the repository at this point in the history
  • Loading branch information
danrevah committed Feb 20, 2015
1 parent 234a9e1 commit 4413aca
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
6 changes: 2 additions & 4 deletions src/Matcher/ArgumentMatcher.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,8 @@ protected static function checkMatchingArguments($returnValues, $arguments)
if ($hamcrest[$index] instanceof Matcher) {
assertThat($arg, $hamcrest[$index]);

} else {
if ($arg != $hamcrest[$index]) {
throw new AssertionError();
}
} else if ($arg != $hamcrest[$index]) {
throw new AssertionError();
}

}
Expand Down
15 changes: 15 additions & 0 deletions tests/ShortifyPunitTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -387,4 +387,19 @@ public function testSpies()
// after chaning methods in chain with same arguments are instanceof `MockClassOnTheFly`
$this->assertInstanceOf('ShortifyPunit\Mock\MockClassOnTheFly', $spy->second_method());
}

/**
* Hamcrest API with normal parameters caused problems
* Bug Fix in - v1.0.6
*/
public function testHamcrestWithNormalParam()
{
$mock = ShortifyPunit::mock('SimpleClassForMocking');

ShortifyPunit::when($mock)->first_method(anything(), 'a')->returns(1);
ShortifyPunit::when($mock)->first_method(anything(), 'b')->returns(2);

$this->assertEquals($mock->first_method('anything...', 'a'), 1);
$this->assertEquals($mock->first_method('anything...', 'b'), 2);
}
}

0 comments on commit 4413aca

Please sign in to comment.