-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #8 from sirbrillig/improve-expectation-errors
Refactor Expectations to use PHPUnit custom assertions
- Loading branch information
Showing
8 changed files
with
206 additions
and
181 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
<?php | ||
namespace Spies; | ||
|
||
class SpiesConstraintWasCalledTimesWith extends \PHPUnit_Framework_Constraint { | ||
private $expected_args; | ||
private $count; | ||
|
||
public function __construct( $count, $args ) { | ||
parent::__construct(); | ||
$this->expected_args = $args; | ||
$this->count = $count; | ||
} | ||
|
||
public function matches( $other ) { | ||
if ( ! $other instanceof \Spies\Spy ) { | ||
return false; | ||
} | ||
return $other->was_called_times_with_array( $this->count, $this->expected_args ); | ||
} | ||
|
||
protected function failureDescription( $other ) { | ||
$generator = new FailureGenerator(); | ||
$generator->spy_was_not_called_with( $other, $this->expected_args ); | ||
return $generator->get_message(); | ||
} | ||
|
||
protected function additionalFailureDescription( $other ) { | ||
$generator = new FailureGenerator(); | ||
$generator->spy_was_not_called_with_additional( $other ); | ||
return $generator->get_message(); | ||
} | ||
|
||
public function toString() { | ||
return ''; | ||
} | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.