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,26 +502,25 @@ function simpletest_classloader_register() { ...@@ -502,26 +502,25 @@ function simpletest_classloader_register() {
* The name of the file, including the path. * The name of the file, including the path.
*/ */
function simpletest_generate_file($filename, $width, $lines, $type = 'binary-text') { function simpletest_generate_file($filename, $width, $lines, $type = 'binary-text') {
$size = $width * $lines - $lines;
// Generate random text
$text = ''; $text = '';
for ($i = 0; $i < $size; $i++) { for ($i = 0; $i < $lines; $i++) {
switch ($type) { // Generate $width - 1 characters to leave space for the "\n" character.
case 'text': for ($j = 0; $j < $width - 1; $j++) {
$text .= chr(rand(32, 126)); switch ($type) {
break; case 'text':
case 'binary': $text .= chr(rand(32, 126));
$text .= chr(rand(0, 31)); break;
break; case 'binary':
case 'binary-text': $text .= chr(rand(0, 31));
default: break;
$text .= rand(0, 1); case 'binary-text':
break; default:
$text .= rand(0, 1);
break;
}
}
$text .= "\n";
} }
}
// Add \n for symmetrical file.
$text = wordwrap($text, $width - 1, "\n", TRUE) . "\n";
// Create filename. // Create filename.
file_put_contents('public://' . $filename . '.txt', $text); file_put_contents('public://' . $filename . '.txt', $text);
......
...@@ -481,7 +481,7 @@ protected function drupalGetTestFiles($type, $size = NULL) { ...@@ -481,7 +481,7 @@ protected function drupalGetTestFiles($type, $size = NULL) {
$lines = array(16, 256, 1024, 2048, 20480); $lines = array(16, 256, 1024, 2048, 20480);
$count = 0; $count = 0;
foreach ($lines as $line) { 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. // 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