protected function EckTestHelper::randomSentence in Entity Construction Kit (ECK) 7.2
Generate a random string with multiple words of random lengths.
Parameters
int $word_count: How many words to have in the sentence; if not a positive, whole number a random number of words will be generated (between three and fifty).
bool $proper: Proper English, so the first letter will be uppercase and the sentence will end in a period; defaults to FALSE.
Return value
string The final sentences.
2 calls to EckTestHelper::randomSentence()
- EckEntityTranslationTest::testTranslations in tests/
EckEntityTranslationTest.test - Test translating an entity type.
- EckTestHelper::createEntity in tests/
EckTestHelper.test - Create a test entity object.
File
- tests/
EckTestHelper.test, line 190 - The EckTestHelper class.
Class
- EckTestHelper
- Helper logic for the other ECK tests.
Code
protected function randomSentence($word_count = NULL, $proper = FALSE) {
$word_count = intval($word_count);
if (empty($word_count) || $word_count < 1) {
$word_count = intval(rand(3, 50));
}
$words = array();
for ($ctr = 0; $ctr < $word_count; $ctr++) {
$words[] = strtolower(parent::randomName(intval(rand(3, 8))));
}
$sentence = implode(' ', $words);
if ($proper) {
$sentence = ucfirst($sentence) . '.';
}
return $sentence;
}