Commit 2219b31b authored by alexpott's avatar alexpott
Browse files

Issue #2512210 by trgreen17, jhodgdon, liberatr: SimpleTest - WebTestBase...

Issue #2512210 by trgreen17, jhodgdon, liberatr: SimpleTest - WebTestBase method creates binary-text files when the intention was to create text files, and text file creation is broken
parent 897056bb
......@@ -502,11 +502,10 @@ function simpletest_classloader_register() {
* The name of the file, including the path.
*/
function simpletest_generate_file($filename, $width, $lines, $type = 'binary-text') {
$size = $width * $lines - $lines;
// Generate random text
$text = '';
for ($i = 0; $i < $size; $i++) {
for ($i = 0; $i < $lines; $i++) {
// Generate $width - 1 characters to leave space for the "\n" character.
for ($j = 0; $j < $width - 1; $j++) {
switch ($type) {
case 'text':
$text .= chr(rand(32, 126));
......@@ -520,8 +519,8 @@ function simpletest_generate_file($filename, $width, $lines, $type = 'binary-tex
break;
}
}
// Add \n for symmetrical file.
$text = wordwrap($text, $width - 1, "\n", TRUE) . "\n";
$text .= "\n";
}
// Create filename.
file_put_contents('public://' . $filename . '.txt', $text);
......
......@@ -481,7 +481,7 @@ protected function drupalGetTestFiles($type, $size = NULL) {
$lines = array(16, 256, 1024, 2048, 20480);
$count = 0;
foreach ($lines as $line) {
simpletest_generate_file('text-' . $count++, 64, $line);
simpletest_generate_file('text-' . $count++, 64, $line, 'text');
}
// Copy other test files from simpletest.
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment