Skip to content

Commit

Permalink
Improve exception message for failed setId in Statement
Browse files Browse the repository at this point in the history
  • Loading branch information
brianjmiller committed May 28, 2014
1 parent 7ef39e9 commit 2fc4614
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/Statement.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ public function stamp() {

public function setId($value) {
if (isset($value) && ! preg_match(Util::UUID_REGEX, $value)) {
throw new \InvalidArgumentException('arg1 must be a UUID');
throw new \InvalidArgumentException('arg1 must be a UUID "' . $value . '"');
}
$this->id = $value;
return $this;
Expand Down
10 changes: 10 additions & 0 deletions tests/StatementTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,16 @@ public function testStamp() {
$this->assertRegExp(TinCan\Util::UUID_REGEX, $obj->getId(), 'id is UUId');
}

public function testSetId() {
$this->setExpectedException(
'InvalidArgumentException',
'arg1 must be a UUID "some invalid id"'
);

$obj = new Statement();
$obj->setId('some invalid id');
}

/*
// TODO: need to loop possible configs
public function testFromJSONInstantiations() {
Expand Down

0 comments on commit 2fc4614

Please sign in to comment.