public static function TestBase::randomObject

Generates a random PHP object.

Parameters

int $size: The number of random keys to add to the object.

Return value

\stdClass The generated object, with the specified number of random keys. Each key has a random string value.

3 calls to TestBase::randomObject()

File

drupal/core/modules/simpletest/lib/Drupal/simpletest/TestBase.php, line 1221
Definition of Drupal\simpletest\TestBase.

Class

TestBase
Base class for Drupal tests.

Namespace

Drupal\simpletest

Code

public static function randomObject($size = 4) {
  $object = new \stdClass();
  for ($i = 0; $i < $size; $i++) {
    $random_key = self::randomName();
    $random_value = self::randomString();
    $object->{$random_key} = $random_value;
  }
  return $object;
}