diff --git a/core/modules/node/src/NodeTypeGenerator.php b/core/modules/node/src/NodeTypeGenerator.php index 5639de60c2..00d5b08c85 100644 --- a/core/modules/node/src/NodeTypeGenerator.php +++ b/core/modules/node/src/NodeTypeGenerator.php @@ -1,24 +1,32 @@ $this->getSampleSentence(1), - 'name' => $this->getSampleSentence(1), - 'description' => $this->getSampleSentence(), - 'help' => $this->getSampleSentence(), + 'type' => $random->name(), + 'name' => $random->string(), + 'description' => $random->paragraphs(1), + 'help' => $random->paragraphs(2), 'new_revision' => $this->getBoolean(), 'preview_mode' => $this->getPreviewMode(), 'display_submitted' => $this->getBoolean(), @@ -27,28 +35,30 @@ public function generate(array $values = []) { return NodeType::create($values); } - protected function getSampleSentence($words = NULL) { - $random = new Random(); - $words = $words ? $words : mt_rand(10, 20); - $text = ""; - for ($i = 0; $i < $words; $i++) { - $text .= $random->word(mt_rand(2, 7)) . ' '; - } - return $text; - } - + /** + * Generates a random preview mode for node types. + * + * @return integer + * The preview mode to use. + */ protected function getPreviewMode() { $options = [ DRUPAL_DISABLED, DRUPAL_OPTIONAL, DRUPAL_REQUIRED, ]; - $key = rand(0, 2); + $key = mt_rand(0, 2); return $options[$key]; } + /** + * Generates a random boolean value. + * + * @return bool + * The boolean value. + */ protected function getBoolean() { - return (bool) rand(0, 1); + return (bool) mt_rand(0, 1); } -} \ No newline at end of file +}