summaryrefslogtreecommitdiff
path: root/modules/simpletest/simpletest.install
diff options
context:
space:
mode:
Diffstat (limited to 'modules/simpletest/simpletest.install')
-rw-r--r--modules/simpletest/simpletest.install91
1 files changed, 0 insertions, 91 deletions
diff --git a/modules/simpletest/simpletest.install b/modules/simpletest/simpletest.install
index 802303192..68eb57815 100644
--- a/modules/simpletest/simpletest.install
+++ b/modules/simpletest/simpletest.install
@@ -7,97 +7,6 @@
*/
/**
- * Implements hook_install().
- */
-function simpletest_install() {
- // Check for files directory.
- $path = 'public://simpletest';
- if (file_prepare_directory($path, FILE_CREATE_DIRECTORY)) {
- // Generate binary and text test files.
- $generated = FALSE;
- if (simpletest_get_file_count($path, 'binary') == 0) {
- $lines = array(64, 1024);
- foreach ($lines as $line) {
- simpletest_generate_file('binary', 64, $line, 'binary');
- }
- $generated = TRUE;
- }
-
- if (simpletest_get_file_count($path, 'text') == 0) {
- $lines = array(16, 256, 1024, 2048, 20480);
- foreach ($lines as $line) {
- simpletest_generate_file('text', 64, $line);
- }
- $generated = TRUE;
- }
-
- // Copy other test files for consistency.
- $original = drupal_get_path('module', 'simpletest') . '/files';
- $files = file_scan_directory($original, '/(html|image|javascript|php|sql)-.*/');
-
- // If there are more files in SimpleTest's files directory than the site's
- // files directory, restore all the files. This situation might occur when
- // an errant test deletes one or more files from the site's files
- // directory. It serves a convenience to developers so that they can get
- // the test files back easily.
- if (count($files) > count(file_scan_directory($path, '/(html|image|javascript|php|sql)-.*/'))) {
- foreach ($files as $file) {
- file_unmanaged_copy($file->uri, $path, FILE_EXISTS_REPLACE);
- }
- $generated = TRUE;
- }
-
- if ($generated) {
- drupal_set_message('Extra test files generated/copied.');
- }
- }
-}
-
-/**
- * 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;
-}
-
-/**
* Implements hook_uninstall().
*/
function simpletest_uninstall() {