diff --git a/core/scripts/run-tests.sh b/core/scripts/run-tests.sh
index 528b39f9c612081ee3e5aea1fc275e12a3e148fe..10475af24bd1b8acf9ccdbc4a547d16f94b9f6b8 100755
--- a/core/scripts/run-tests.sh
+++ b/core/scripts/run-tests.sh
@@ -6,6 +6,7 @@
  */
 
 use Drupal\Component\FileSystem\FileSystem;
+use Drupal\Component\Utility\Environment;
 use Drupal\Component\Utility\Html;
 use Drupal\Component\Utility\Timer;
 use Drupal\Core\Composer\Composer;
@@ -159,7 +160,7 @@
 $test_list = simpletest_script_get_test_list();
 
 // Try to allocate unlimited time to run the tests.
-drupal_set_time_limit(0);
+Environment::setTimeLimit(0);
 simpletest_script_reporter_init();
 
 $tests_to_run = [];