filename, $path . '/' . $file->basename); } $generated = TRUE; } if ($generated) { drupal_set_message('Extra test files generated.'); } } } /** * 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; } } $text = wordwrap($text, $width - 1, "\n", TRUE) ."\n"; // Add \n for symetrical file. // Create filename. $path = file_directory_path() . '/simpletest/'; $count = simpletest_get_file_count($path, $filename); file_put_contents($path . $filename . '-' . ($count + 1) . '.txt', $text); } /** * Get the number of files that have the specified filename base. */ function simpletest_get_file_count($directory, $filename) { $files = scandir($directory); $count = 0; foreach ($files as $file) { if (preg_match('/' . $filename . '.*?/', $file)) { $count++; } } return $count; } /** * Implementation of hook_uninstall(). */ function simpletest_uninstall() { variable_del('simpletest_httpauth'); variable_del('simpletest_httpauth_username'); variable_del('simpletest_httpauth_pass'); variable_del('simpletest_devel'); } /** * Check that the cURL extension exists for PHP. */ function simpletest_requirements($phase) { $requirements = array(); $t = get_t(); $has_curl = function_exists('curl_init'); switch ($phase) { case 'runtime': $requirements['simpletest'] = array( 'title' => $t('cURL'), 'value' => $has_curl ? $t('Enabled') : $t('Not found'), 'severity' => $has_curl ? REQUIREMENT_OK : REQUIREMENT_ERROR, ); break; case 'install': if ($has_curl) { $requirements['simpletest'] = array( 'title' => $t('cURL'), 'severity' => REQUIREMENT_OK, ); } else { $requirements['simpletest'] = array( 'title' => $t('cURL'), 'severity' => REQUIREMENT_ERROR, 'description' => $t('Simpletest could not be installed because the PHP cURL library is not available.', array('!curl_url' => 'http://php.net/manual/en/curl.setup.php')), ); } break; } return $requirements; }