Commit e1050c7b authored by catch's avatar catch
Browse files

Issue #3358416 by Spokje, mondrake: Use RandomGeneratorTrait in UnitTestCase...

Issue #3358416 by Spokje, mondrake: Use RandomGeneratorTrait in UnitTestCase and remove direct implementations of randomMachineName and getRandomGenerator
parent ca3d4fe5
Loading
Loading
Loading
Loading
+1 −25
Original line number Diff line number Diff line
@@ -30,6 +30,7 @@ abstract class UnitTestCase extends TestCase {
  use PhpUnitCompatibilityTrait;
  use ProphecyTrait;
  use ExpectDeprecationTrait;
  use RandomGeneratorTrait;

  /**
   * The app root.
@@ -73,31 +74,6 @@ public function __get(string $name) {
    }
  }

  /**
   * Generates a unique random string containing letters and numbers.
   *
   * @param int $length
   *   Length of random string to generate.
   *
   * @return string
   *   Randomly generated unique string.
   *
   * @see \Drupal\Component\Utility\Random::name()
   */
  public function randomMachineName($length = 8) {
    return Random::machineName($length);
  }

  /**
   * Gets the random generator for the utility methods.
   *
   * @return \Drupal\Component\Utility\Random
   *   The random generator
   */
  protected function getRandomGenerator() {
    return Random::getGenerator();
  }

  /**
   * Returns a stub config factory that behaves according to the passed array.
   *