namespace Drupal\Tests\Component\Utility;
use Drupal\Component\Utility\Random;
-use Drupal\Tests\UnitTestCase;
+use PHPUnit\Framework\TestCase;
/**
* Tests random data generation.
*
* @coversDefaultClass \Drupal\Component\Utility\Random
*/
-class RandomTest extends UnitTestCase {
+class RandomTest extends TestCase {
/**
* The first random string passed to the test callback.
// 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;