Revision 582db59d
Added by Assos Assos almost 9 years ago
drupal7/modules/simpletest/simpletest.module | ||
---|---|---|
154 | 154 |
} |
155 | 155 |
|
156 | 156 |
/** |
157 |
* Batch operation callback.
|
|
157 |
* Implements callback_batch_operation().
|
|
158 | 158 |
*/ |
159 | 159 |
function _simpletest_batch_operation($test_list_init, $test_id, &$context) { |
160 | 160 |
simpletest_classloader_register(); |
... | ... | |
205 | 205 |
$context['finished'] = 1 - $size / $max; |
206 | 206 |
} |
207 | 207 |
|
208 |
/** |
|
209 |
* Implements callback_batch_finished(). |
|
210 |
*/ |
|
208 | 211 |
function _simpletest_batch_finished($success, $results, $operations, $elapsed) { |
209 | 212 |
if ($success) { |
210 | 213 |
drupal_set_message(t('The test run finished in @elapsed.', array('@elapsed' => $elapsed))); |
... | ... | |
509 | 512 |
* Generate test file. |
510 | 513 |
*/ |
511 | 514 |
function simpletest_generate_file($filename, $width, $lines, $type = 'binary-text') { |
512 |
$size = $width * $lines - $lines; |
|
513 |
|
|
514 |
// Generate random text |
|
515 | 515 |
$text = ''; |
516 |
for ($i = 0; $i < $size; $i++) { |
|
517 |
switch ($type) { |
|
518 |
case 'text': |
|
519 |
$text .= chr(rand(32, 126)); |
|
520 |
break; |
|
521 |
case 'binary': |
|
522 |
$text .= chr(rand(0, 31)); |
|
523 |
break; |
|
524 |
case 'binary-text': |
|
525 |
default: |
|
526 |
$text .= rand(0, 1); |
|
527 |
break; |
|
516 |
for ($i = 0; $i < $lines; $i++) { |
|
517 |
// Generate $width - 1 characters to leave space for the "\n" character. |
|
518 |
for ($j = 0; $j < $width - 1; $j++) { |
|
519 |
switch ($type) { |
|
520 |
case 'text': |
|
521 |
$text .= chr(rand(32, 126)); |
|
522 |
break; |
|
523 |
case 'binary': |
|
524 |
$text .= chr(rand(0, 31)); |
|
525 |
break; |
|
526 |
case 'binary-text': |
|
527 |
default: |
|
528 |
$text .= rand(0, 1); |
|
529 |
break; |
|
530 |
} |
|
528 | 531 |
} |
532 |
$text .= "\n"; |
|
529 | 533 |
} |
530 |
$text = wordwrap($text, $width - 1, "\n", TRUE) . "\n"; // Add \n for symmetrical file. |
|
531 | 534 |
|
532 | 535 |
// Create filename. |
533 | 536 |
file_put_contents('public://' . $filename . '.txt', $text); |
Also available in: Unified diff
Update Drupal core to version 7.40