Skip to content

Commit

Permalink
Add assertSpyWasNotCalledWith assertion
Browse files Browse the repository at this point in the history
  • Loading branch information
sirbrillig committed Jul 27, 2016
1 parent 34a551b commit 5861c44
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 0 deletions.
1 change: 1 addition & 0 deletions API.md
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ These are methods available on instances of `\Spies\TestCase`.
- `assertSpyWasCalled( $spy )`
- `assertSpyWasNotCalled( $spy )`
- `assertSpyWasCalledWith( $spy, $args )`
- `assertSpyWasNotCalledWith( $spy, $args )`
- `assertSpyWasCalledTimes( $spy, $count )`
- `assertSpyWasNotCalledTimes( $spy, $count )`
- `assertSpyWasCalledBefore( $spy, $other_spy )`
Expand Down
4 changes: 4 additions & 0 deletions src/Spies/TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ public static function assertSpyWasNotCalled( $condition, $message = '' ) {
self::assertThat( $condition, self::wasNotCalled(), $message );
}

public static function assertSpyWasNotCalledWith( $condition, $args, $message = '' ) {
self::assertThat( $condition, self::logicalNot( self::wasCalledWith( $args ) ), $message );
}

public static function assertSpyWasCalledWith( $condition, $args, $message = '' ) {
self::assertThat( $condition, self::wasCalledWith( $args ), $message );
}
Expand Down
6 changes: 6 additions & 0 deletions tests/AssertionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,12 @@ public function test_assert_spy_was_called_with_is_true_when_called_with_args()
$this->assertSpyWasCalledWith( $spy, [ 'a', 'b', 'c' ] );
}

public function test_assert_spy_was_not_called_with_is_true_when_not_called_with_args() {
$spy = \Spies\make_spy();
$spy( 'e', 'b', 'c' );
$this->assertSpyWasNotCalledWith( $spy, [ 'a', 'b', 'c' ] );
}

public function test_assert_was_called_times_is_true_when_called_once() {
$spy = \Spies\make_spy();
$spy();
Expand Down

0 comments on commit 5861c44

Please sign in to comment.