function RandomGeneratorTrait::randomObject

Same name in other branches
  1. 9 core/tests/Drupal/Tests/RandomGeneratorTrait.php \Drupal\Tests\RandomGeneratorTrait::randomObject()
  2. 8.9.x core/tests/Drupal/Tests/RandomGeneratorTrait.php \Drupal\Tests\RandomGeneratorTrait::randomObject()
  3. 10 core/tests/Drupal/Tests/RandomGeneratorTrait.php \Drupal\Tests\RandomGeneratorTrait::randomObject()

Generates a random PHP object.

Parameters

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

Return value

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

See also

\Drupal\Component\Utility\Random::object()

3 calls to RandomGeneratorTrait::randomObject()
GarbageCollectionTest::testGarbageCollection in core/tests/Drupal/KernelTests/Core/KeyValueStore/GarbageCollectionTest.php
Tests garbage collection.
StorageTestBase::setUp in core/tests/Drupal/KernelTests/Core/KeyValueStore/StorageTestBase.php
TempStoreDatabaseTest::testSharedTempStore in core/tests/Drupal/KernelTests/Core/TempStore/TempStoreDatabaseTest.php
Tests the SharedTempStore API.

File

core/tests/Drupal/Tests/RandomGeneratorTrait.php, line 66

Class

RandomGeneratorTrait
Provides random generator utility methods.

Namespace

Drupal\Tests

Code

public function randomObject($size = 4) {
    return Random::object($size);
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.