summaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
authorDavid Rothstein <drothstein@gmail.com>2015-10-12 23:39:43 -0400
committerDavid Rothstein <drothstein@gmail.com>2015-10-12 23:39:43 -0400
commit3b96a7d9124037c9e6f2e43ba5dd2de89175580b (patch)
treebcbd6a7317a477ed0f1810d0871d19208cd85fd3 /modules
parent183a425c551969d4f56b04766fca82819a2a7b15 (diff)
downloadbrdo-3b96a7d9124037c9e6f2e43ba5dd2de89175580b.tar.gz
brdo-3b96a7d9124037c9e6f2e43ba5dd2de89175580b.tar.bz2
Issue #2512210 by trgreen17, naveenvalecha, David_Rothstein, jhodgdon, liberatr: SimpleTest - WebTestBase method creates binary-text files when the intention was to create text files, and text file creation is broken
Diffstat (limited to 'modules')
-rw-r--r--modules/simpletest/drupal_web_test_case.php2
-rw-r--r--modules/simpletest/simpletest.module32
2 files changed, 17 insertions, 17 deletions
diff --git a/modules/simpletest/drupal_web_test_case.php b/modules/simpletest/drupal_web_test_case.php
index d7350698c..bf1e9c31c 100644
--- a/modules/simpletest/drupal_web_test_case.php
+++ b/modules/simpletest/drupal_web_test_case.php
@@ -1065,7 +1065,7 @@ class DrupalWebTestCase extends DrupalTestCase {
$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.
diff --git a/modules/simpletest/simpletest.module b/modules/simpletest/simpletest.module
index 91f0f9065..a98e5cfbe 100644
--- a/modules/simpletest/simpletest.module
+++ b/modules/simpletest/simpletest.module
@@ -509,25 +509,25 @@ function simpletest_registry_files_alter(&$files, $modules) {
* Generate test file.
*/
function simpletest_generate_file($filename, $width, $lines, $type = 'binary-text') {
- $size = $width * $lines - $lines;
-
- // Generate random text
$text = '';
- for ($i = 0; $i < $size; $i++) {
- switch ($type) {
- case 'text':
- $text .= chr(rand(32, 126));
- break;
- case 'binary':
- $text .= chr(rand(0, 31));
- break;
- case 'binary-text':
- default:
- $text .= rand(0, 1);
- break;
+ 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));
+ break;
+ case 'binary':
+ $text .= chr(rand(0, 31));
+ break;
+ case 'binary-text':
+ default:
+ $text .= rand(0, 1);
+ break;
+ }
}
+ $text .= "\n";
}
- $text = wordwrap($text, $width - 1, "\n", TRUE) . "\n"; // Add \n for symmetrical file.
// Create filename.
file_put_contents('public://' . $filename . '.txt', $text);