diff -u b/core/tests/Drupal/Tests/Component/Utility/RandomTest.php b/core/tests/Drupal/Tests/Component/Utility/RandomTest.php --- b/core/tests/Drupal/Tests/Component/Utility/RandomTest.php +++ b/core/tests/Drupal/Tests/Component/Utility/RandomTest.php @@ -103,2 +103,14 @@ } + + /** + * Tests Random::object() to ensure it has the expected number of properties. + */ + public function testRandomObject() { + // For values of 0 and 1 random object will have a different execution path. + for ($i = 0; $i <= 1; $i++) { + $obj = Random::object($i); + $this->assertEquals($i, count(get_object_vars($obj)), 'Generated random object has expected number of properties'); + } + } + }