Skip to content

Commit

Permalink
Add exists matcher failed message
Browse files Browse the repository at this point in the history
  • Loading branch information
holyshared committed Apr 2, 2015
1 parent d204bf4 commit 250eb08
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
24 changes: 24 additions & 0 deletions spec/matcher/ToBeExists.spec.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,28 @@
});
});
});
describe('#reportFailed', function () {
beforeEach(function () {
$this->tempFile = $this->makeFile();
$this->matcher = new ToBeExists();
$this->message = new FailedMessage();
});
it('report failed message', function() {
$this->matcher->match($this->tempFile->getPath());
$this->matcher->reportFailed($this->message);
Assertion::same((string) $this->message, "Expected '{$this->tempFile->getPath()}' to be exists");
});
});
describe('#reportNegativeFailed', function () {
beforeEach(function () {
$this->tempFile = $this->makeFile();
$this->matcher = new ToBeExists();
$this->message = new FailedMessage();
});
it('report failed message', function() {
$this->matcher->match($this->tempFile->getPath());
$this->matcher->reportNegativeFailed($this->message);
Assertion::same((string) $this->message, "Expected '{$this->tempFile->getPath()}' not to be exists");
});
});
});
6 changes: 6 additions & 0 deletions src/matcher/ToBeExists.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,18 @@ public function match($actual)
*/
public function reportFailed(FailedMessage $message)
{
$message->appendText('Expected ')
->appendValue($this->actual)
->appendText(' to be exists');
}

/**
* {@inheritdoc}
*/
public function reportNegativeFailed(FailedMessage $message)
{
$message->appendText('Expected ')
->appendValue($this->actual)
->appendText(' not to be exists');
}
}

0 comments on commit 250eb08

Please sign in to comment.