Created
July 25, 2012 08:17
-
-
Save mistermarco/3175037 to your computer and use it in GitHub Desktop.
Sites/People test
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<pre> | |
<?php | |
$site_name = exec('whoami'); | |
echo "Starting Testing...\n"; | |
echo 'Running as ' . $site_name . "\n"; | |
echo 'Server that responded: ' . exec('uname -a') . "\n\n"; | |
/* | |
* | |
* Testing Working Directory | |
* Should start with /var/www and end with public_html | |
* | |
*/ | |
echo "Testing working directory..."; | |
$expected_cwd = '/var/www/' . $site_name . '/public_html'; | |
$cwd = getcwd(); | |
if ($cwd === $expected_cwd) { | |
echo "OK\n"; | |
} | |
else { | |
echo "not OK\n"; | |
echo "Expected $expected_cwd got $cwd\n"; | |
} | |
/* | |
* | |
* Testing Working Directory | |
* Should start with /var/www and end with public_html | |
* | |
*/ | |
echo "Testing realpath..."; | |
$expected_rp = '/var/www/' . $site_name . '/public_html'; | |
$rp = realpath('./'); | |
if ($rp === $expected_rp) { | |
echo "OK\n"; | |
} | |
else { | |
echo "not OK\n"; | |
echo "Expected $expected_rp got $rp\n"; | |
} | |
/* | |
* | |
* Testing Files Directory | |
* Should be readable | |
* | |
*/ | |
echo "Testing files directory..."; | |
$file_dir = getcwd() . '/' . file_directory_path(); | |
if (is_dir($file_dir)) { | |
echo "OK\n"; | |
} else { | |
echo "not OK\nCan't find files directory\n"; | |
} | |
/* | |
* | |
* Testing Theme | |
* | |
*/ | |
echo "Testing current theme..."; | |
$theme = variable_get('theme_default', ''); | |
if (empty($theme)) { | |
echo "not OK, blank\n"; | |
} | |
else { | |
echo "($theme)..."; | |
} | |
$theme_location = getcwd() . '/' . drupal_get_path('theme', variable_get('theme_default', '')); | |
if (is_dir($theme_location)) { | |
echo "OK\n"; | |
} else { | |
echo "not OK\nCan't find theme directory ($theme_location)\n"; | |
} | |
/* | |
* | |
* Testing Stanford Basic Theme | |
* | |
*/ | |
echo "Testing Stanford Basic..."; | |
$theme_location = drupal_get_path('theme', 'stanford_basic'); | |
if ($theme_location === 'themes/stanford_basic') { | |
echo "not OK, Stanford Basic in root themes directory.\n"; | |
} | |
else { | |
echo "OK\n"; | |
} | |
/* | |
* | |
* Testing system table | |
* | |
*/ | |
// check that all enabled modules exist | |
echo 'Testing system table...'; | |
$errors = ''; | |
$cwd = getcwd(); | |
$q = "SELECT filename FROM {system} WHERE status = 1"; | |
$result = db_query($q); | |
while ($fetch = db_fetch_array($result)) { | |
$file = $cwd . '/' . $fetch['filename']; | |
if (!(file_exists($file))) { | |
$errors .= $file . ' does not exist.' . "\n"; | |
} | |
} | |
if (empty($errors)) { | |
echo "OK\n"; | |
} else { | |
echo "not OK.\n$errors\n"; | |
} | |
/* | |
* | |
* Testing Configuration Path | |
* | |
*/ | |
echo "Testing configuration path..."; | |
if (conf_path() !== 'sites/default') { | |
echo "not ideal, configuration path should be sites/default.\n"; | |
} | |
else { | |
echo "OK\n"; | |
} | |
/* | |
* | |
* Testing sites/default directory | |
* | |
*/ | |
echo "Testing sites/default directory..."; | |
$dir = "sites/default"; | |
global $db_url; | |
$settings = file_get_contents($dir . '/settings.php'); | |
if (strpos($settings, $db_url)) { | |
echo "OK\n"; | |
} else { | |
echo "not OK - possibly reading wrong sites/default directory\n"; | |
} | |
//echo "</pre>"; | |
/* | |
* | |
* Details | |
* | |
*/ | |
echo "\nDetails:\n"; | |
echo 'Current working directory is ' . getcwd() . "\n"; | |
echo 'Realpath is ' . realpath('./') . "\n"; | |
echo 'Configuration path is ' . conf_path() . "\n"; | |
echo 'Base_path set to ' . base_path() . "\n"; | |
$file_dir = getcwd() . '/' . file_directory_path(); | |
echo 'File directory is: ' . $file_dir . "\n"; | |
echo 'Default Theme Location: ' . getcwd() . '/' . drupal_get_path('theme', variable_get('theme_default', '')) . "\n"; | |
global $base_url; | |
echo "Base URL: $base_url\n"; | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment