Skip to content

Commit 2fc4614

Browse files
committed
Improve exception message for failed setId in Statement
1 parent 7ef39e9 commit 2fc4614

2 files changed

Lines changed: 11 additions & 1 deletion

File tree

src/Statement.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ public function stamp() {
8989

9090
public function setId($value) {
9191
if (isset($value) && ! preg_match(Util::UUID_REGEX, $value)) {
92-
throw new \InvalidArgumentException('arg1 must be a UUID');
92+
throw new \InvalidArgumentException('arg1 must be a UUID "' . $value . '"');
9393
}
9494
$this->id = $value;
9595
return $this;

tests/StatementTest.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,16 @@ public function testStamp() {
6565
$this->assertRegExp(TinCan\Util::UUID_REGEX, $obj->getId(), 'id is UUId');
6666
}
6767

68+
public function testSetId() {
69+
$this->setExpectedException(
70+
'InvalidArgumentException',
71+
'arg1 must be a UUID "some invalid id"'
72+
);
73+
74+
$obj = new Statement();
75+
$obj->setId('some invalid id');
76+
}
77+
6878
/*
6979
// TODO: need to loop possible configs
7080
public function testFromJSONInstantiations() {

0 commit comments

Comments
 (0)