Skip to content

Commit 867717d

Browse files
committed
TestSetterAndGetter: Use InvalidUsageExceptions.
1 parent d3a896f commit 867717d

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

src/TestCase/TestSetterAndGetterTrait.php

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -198,10 +198,8 @@ private function setterAndGetterNormalizeSpec($spec, string $name, object $targe
198198
return $normalized;
199199
}
200200

201-
$err = __TRAIT__ . ': ' . get_class($this) . ': ';
202-
203201
if (!is_array($spec)) {
204-
throw new \PHPUnit\Framework\Exception($err . 'Invalid specification. Must be array.');
202+
throw InvalidUsageException::fromTrait(__TRAIT__, __CLASS__, 'Invalid specification. Must be array.');
205203
}
206204

207205
foreach ($spec as $key => $value) {
@@ -258,7 +256,11 @@ private function setterAndGetterNormalizeSpec($spec, string $name, object $targe
258256
}
259257

260258
if (!is_callable($value)) {
261-
throw new \PHPUnit\Framework\Exception($err . 'Invalid callback for "' . $key . '".');
259+
throw InvalidUsageException::fromTrait(
260+
__TRAIT__,
261+
__CLASS__,
262+
'Invalid callback for "' . $key . '".'
263+
);
262264
}
263265

264266
$key = substr($key, 0, -9);
@@ -277,7 +279,11 @@ private function setterAndGetterNormalizeSpec($spec, string $name, object $targe
277279
}
278280

279281
if (!is_callable($value)) {
280-
throw new \PHPUnit\Framework\Exception($err . 'Invalid callback for "' . $key . '".');
282+
throw InvalidUsageException::fromTrait(
283+
__TRAIT__,
284+
__CLASS__,
285+
'Invalid callback for "' . $key . '".'
286+
);
281287
}
282288

283289
break;

0 commit comments

Comments
 (0)