// There are fewer than 100 possibilities so an exception should occur to
// prevent infinite loops.
$random = new Random();
- $this->setExpectedException(\RuntimeException::class);
+ if (method_exists($this, 'expectException')) {
+ $this->expectException(\RuntimeException::class);
+ }
+ else {
+ $this->setExpectedException(\RuntimeException::class);
+ }
for ($i = 0; $i <= 100; $i++) {
$str = $random->name(1, TRUE);
$names[$str] = TRUE;
// There are fewer than 100 possibilities so an exception should occur to
// prevent infinite loops.
$random = new Random();
- $this->setExpectedException(\RuntimeException::class);
+ if (method_exists($this, 'expectException')) {
+ $this->expectException(\RuntimeException::class);
+ }
+ else {
+ $this->setExpectedException(\RuntimeException::class);
+ }
for ($i = 0; $i <= 100; $i++) {
$str = $random->string(1, TRUE);
$names[$str] = TRUE;