- Added a test framework to Drupal along with a first batch of tests for
Drupal core! This is an important milestone for the project so enable
the module and check it out ... :)
Thanks to Rok Žlender, Károly Négyesi, Jimmy Berry, Kevin Bridges, Charlie
Gordon, Douglas Hubler, Miglius Alaburda, Andy Kirkham, Dimitri13, Kieran
Lal, Moshe Weitzman, and the many other people that helped with testing
over the past years and that drove this home.
It all works but it is still rough around the edges (i.e. documentation
is still being written, the coding style is not 100% yet, a number of
tests still fail) but we spent the entire weekend working on it in Paris
and made a ton of progress. The best way to help and to get up to speed,
is to start writing and contributing some tests ... as well as fixing
some of the failures.
For those willing to help with improving the test framework, here are
some next steps and issues to resolve:
- How to best approach unit tests and mock functions?
- How to test drupal_mail() and drupal_http_request()?
- How to improve the admin UI so we have a nice progress bar?
- How best to do code coverage?
- See http://g.d.o/node/10099 for more ...
2008-04-20 18:24:07 +00:00
<?php
// $Id$
/**
* Implementation of hook_install().
*/
function simpletest_install() {
2008-06-24 21:51:03 +00:00
drupal_install_schema('simpletest');
- Added a test framework to Drupal along with a first batch of tests for
Drupal core! This is an important milestone for the project so enable
the module and check it out ... :)
Thanks to Rok Žlender, Károly Négyesi, Jimmy Berry, Kevin Bridges, Charlie
Gordon, Douglas Hubler, Miglius Alaburda, Andy Kirkham, Dimitri13, Kieran
Lal, Moshe Weitzman, and the many other people that helped with testing
over the past years and that drove this home.
It all works but it is still rough around the edges (i.e. documentation
is still being written, the coding style is not 100% yet, a number of
tests still fail) but we spent the entire weekend working on it in Paris
and made a ton of progress. The best way to help and to get up to speed,
is to start writing and contributing some tests ... as well as fixing
some of the failures.
For those willing to help with improving the test framework, here are
some next steps and issues to resolve:
- How to best approach unit tests and mock functions?
- How to test drupal_mail() and drupal_http_request()?
- How to improve the admin UI so we have a nice progress bar?
- How best to do code coverage?
- See http://g.d.o/node/10099 for more ...
2008-04-20 18:24:07 +00:00
// Check for files directory.
$path = file_directory_path() . '/simpletest';
if (file_check_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.
2008-09-20 03:49:24 +00:00
$files = file_scan_directory($path, '/(html|image|javascript|php|sql)-.*/');
- Added a test framework to Drupal along with a first batch of tests for
Drupal core! This is an important milestone for the project so enable
the module and check it out ... :)
Thanks to Rok Žlender, Károly Négyesi, Jimmy Berry, Kevin Bridges, Charlie
Gordon, Douglas Hubler, Miglius Alaburda, Andy Kirkham, Dimitri13, Kieran
Lal, Moshe Weitzman, and the many other people that helped with testing
over the past years and that drove this home.
It all works but it is still rough around the edges (i.e. documentation
is still being written, the coding style is not 100% yet, a number of
tests still fail) but we spent the entire weekend working on it in Paris
and made a ton of progress. The best way to help and to get up to speed,
is to start writing and contributing some tests ... as well as fixing
some of the failures.
For those willing to help with improving the test framework, here are
some next steps and issues to resolve:
- How to best approach unit tests and mock functions?
- How to test drupal_mail() and drupal_http_request()?
- How to improve the admin UI so we have a nice progress bar?
- How best to do code coverage?
- See http://g.d.o/node/10099 for more ...
2008-04-20 18:24:07 +00:00
if (count($files) == 0) {
2008-05-10 06:55:09 +00:00
$original = drupal_get_path('module', 'simpletest') . '/files';
2008-09-20 03:49:24 +00:00
$files = file_scan_directory($original, '/(html|image|javascript|php|sql)-.*/');
- Added a test framework to Drupal along with a first batch of tests for
Drupal core! This is an important milestone for the project so enable
the module and check it out ... :)
Thanks to Rok Žlender, Károly Négyesi, Jimmy Berry, Kevin Bridges, Charlie
Gordon, Douglas Hubler, Miglius Alaburda, Andy Kirkham, Dimitri13, Kieran
Lal, Moshe Weitzman, and the many other people that helped with testing
over the past years and that drove this home.
It all works but it is still rough around the edges (i.e. documentation
is still being written, the coding style is not 100% yet, a number of
tests still fail) but we spent the entire weekend working on it in Paris
and made a ton of progress. The best way to help and to get up to speed,
is to start writing and contributing some tests ... as well as fixing
some of the failures.
For those willing to help with improving the test framework, here are
some next steps and issues to resolve:
- How to best approach unit tests and mock functions?
- How to test drupal_mail() and drupal_http_request()?
- How to improve the admin UI so we have a nice progress bar?
- How best to do code coverage?
- See http://g.d.o/node/10099 for more ...
2008-04-20 18:24:07 +00:00
foreach ($files as $file) {
2008-05-10 06:55:09 +00:00
file_copy($file->filename, $path . '/' . $file->basename);
- Added a test framework to Drupal along with a first batch of tests for
Drupal core! This is an important milestone for the project so enable
the module and check it out ... :)
Thanks to Rok Žlender, Károly Négyesi, Jimmy Berry, Kevin Bridges, Charlie
Gordon, Douglas Hubler, Miglius Alaburda, Andy Kirkham, Dimitri13, Kieran
Lal, Moshe Weitzman, and the many other people that helped with testing
over the past years and that drove this home.
It all works but it is still rough around the edges (i.e. documentation
is still being written, the coding style is not 100% yet, a number of
tests still fail) but we spent the entire weekend working on it in Paris
and made a ton of progress. The best way to help and to get up to speed,
is to start writing and contributing some tests ... as well as fixing
some of the failures.
For those willing to help with improving the test framework, here are
some next steps and issues to resolve:
- How to best approach unit tests and mock functions?
- How to test drupal_mail() and drupal_http_request()?
- How to improve the admin UI so we have a nice progress bar?
- How best to do code coverage?
- See http://g.d.o/node/10099 for more ...
2008-04-20 18:24:07 +00:00
}
$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);
2008-05-10 06:55:09 +00:00
file_put_contents($path . $filename . '-' . ($count + 1) . '.txt', $text);
- Added a test framework to Drupal along with a first batch of tests for
Drupal core! This is an important milestone for the project so enable
the module and check it out ... :)
Thanks to Rok Žlender, Károly Négyesi, Jimmy Berry, Kevin Bridges, Charlie
Gordon, Douglas Hubler, Miglius Alaburda, Andy Kirkham, Dimitri13, Kieran
Lal, Moshe Weitzman, and the many other people that helped with testing
over the past years and that drove this home.
It all works but it is still rough around the edges (i.e. documentation
is still being written, the coding style is not 100% yet, a number of
tests still fail) but we spent the entire weekend working on it in Paris
and made a ton of progress. The best way to help and to get up to speed,
is to start writing and contributing some tests ... as well as fixing
some of the failures.
For those willing to help with improving the test framework, here are
some next steps and issues to resolve:
- How to best approach unit tests and mock functions?
- How to test drupal_mail() and drupal_http_request()?
- How to improve the admin UI so we have a nice progress bar?
- How best to do code coverage?
- See http://g.d.o/node/10099 for more ...
2008-04-20 18:24:07 +00:00
}
/**
* 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) {
2008-05-10 06:55:09 +00:00
if (preg_match('/' . $filename . '.*?/', $file)) {
- Added a test framework to Drupal along with a first batch of tests for
Drupal core! This is an important milestone for the project so enable
the module and check it out ... :)
Thanks to Rok Žlender, Károly Négyesi, Jimmy Berry, Kevin Bridges, Charlie
Gordon, Douglas Hubler, Miglius Alaburda, Andy Kirkham, Dimitri13, Kieran
Lal, Moshe Weitzman, and the many other people that helped with testing
over the past years and that drove this home.
It all works but it is still rough around the edges (i.e. documentation
is still being written, the coding style is not 100% yet, a number of
tests still fail) but we spent the entire weekend working on it in Paris
and made a ton of progress. The best way to help and to get up to speed,
is to start writing and contributing some tests ... as well as fixing
some of the failures.
For those willing to help with improving the test framework, here are
some next steps and issues to resolve:
- How to best approach unit tests and mock functions?
- How to test drupal_mail() and drupal_http_request()?
- How to improve the admin UI so we have a nice progress bar?
- How best to do code coverage?
- See http://g.d.o/node/10099 for more ...
2008-04-20 18:24:07 +00:00
$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');
2008-06-24 21:51:03 +00:00
drupal_uninstall_schema('simpletest');
- Added a test framework to Drupal along with a first batch of tests for
Drupal core! This is an important milestone for the project so enable
the module and check it out ... :)
Thanks to Rok Žlender, Károly Négyesi, Jimmy Berry, Kevin Bridges, Charlie
Gordon, Douglas Hubler, Miglius Alaburda, Andy Kirkham, Dimitri13, Kieran
Lal, Moshe Weitzman, and the many other people that helped with testing
over the past years and that drove this home.
It all works but it is still rough around the edges (i.e. documentation
is still being written, the coding style is not 100% yet, a number of
tests still fail) but we spent the entire weekend working on it in Paris
and made a ton of progress. The best way to help and to get up to speed,
is to start writing and contributing some tests ... as well as fixing
some of the failures.
For those willing to help with improving the test framework, here are
some next steps and issues to resolve:
- How to best approach unit tests and mock functions?
- How to test drupal_mail() and drupal_http_request()?
- How to improve the admin UI so we have a nice progress bar?
- How best to do code coverage?
- See http://g.d.o/node/10099 for more ...
2008-04-20 18:24:07 +00:00
}
2008-04-28 09:30:35 +00:00
/**
* 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':
2008-09-16 23:24:36 +00:00
if (!$has_curl) {
2008-04-28 09:30:35 +00:00
$requirements['simpletest'] = array(
'title' => $t('cURL'),
'severity' => REQUIREMENT_ERROR,
'description' => $t('Simpletest could not be installed because the PHP <a href="!curl_url">cURL</a> library is not available.', array('!curl_url' => 'http://php.net/manual/en/curl.setup.php')),
);
}
break;
}
return $requirements;
}
2008-06-24 21:51:03 +00:00
function simpletest_schema() {
$schema['simpletest'] = array(
'description' => t('Stores simpletest messages'),
'fields' => array(
'message_id' => array(
'type' => 'serial',
'not null' => TRUE,
'description' => t('Primary Key: Unique simpletest message ID.'),
),
'test_id' => array(
'type' => 'int',
'not null' => TRUE,
'default' => 0,
2008-08-13 06:42:04 +00:00
'description' => t('Test ID, messages belonging to the same ID are reported together'),
2008-06-24 21:51:03 +00:00
),
'test_class' => array(
'type' => 'varchar',
'length' => 255,
'not null' => TRUE,
'default' => '',
'description' => t('The name of the class that created this message.'),
),
'status' => array(
'type' => 'varchar',
'length' => 9,
'not null' => TRUE,
'default' => '',
'description' => t('Message status. Core understands pass, fail, exception.'),
),
'message' => array(
2008-08-11 17:43:30 +00:00
'type' => 'text',
2008-06-24 21:51:03 +00:00
'not null' => TRUE,
'description' => t('The message itself.'),
),
'message_group' => array(
'type' => 'varchar',
'length' => 255,
'not null' => TRUE,
'default' => '',
'description' => t('The message group this message belongs to. For example: warning, browser, user.'),
),
2008-09-10 04:13:01 +00:00
'function' => array(
2008-06-24 21:51:03 +00:00
'type' => 'varchar',
'length' => 255,
'not null' => TRUE,
'default' => '',
2008-09-10 04:13:01 +00:00
'description' => t('Name of the assertion function or method that created this message.'),
2008-06-24 21:51:03 +00:00
),
'line' => array(
'type' => 'int',
'not null' => TRUE,
'default' => 0,
2008-09-10 04:13:01 +00:00
'description' => t('Line number on which the function is called.'),
2008-06-24 21:51:03 +00:00
),
'file' => array(
'type' => 'varchar',
'length' => 255,
'not null' => TRUE,
'default' => '',
2008-09-10 04:13:01 +00:00
'description' => t('Name of the file where the function is called.'),
2008-06-24 21:51:03 +00:00
),
),
'primary key' => array('message_id'),
'indexes' => array(
2008-08-16 20:57:14 +00:00
'reporter' => array('test_class', 'message_id'),
2008-06-24 21:51:03 +00:00
),
);
$schema['simpletest_test_id'] = array(
2008-08-13 06:42:04 +00:00
'description' => t('Stores simpletest test IDs, used to auto-incrament the test ID so that a fresh test ID is used.'),
2008-06-24 21:51:03 +00:00
'fields' => array(
2008-08-13 06:42:04 +00:00
'test_id' => array(
2008-06-24 21:51:03 +00:00
'type' => 'serial',
'not null' => TRUE,
2008-08-13 06:42:04 +00:00
'description' => t('Primary Key: Unique simpletest ID used to group test results together. Each time a set of tests
are run a new test ID is used.'),
2008-06-24 21:51:03 +00:00
),
),
2008-08-13 06:42:04 +00:00
'primary key' => array('test_id'),
2008-06-24 21:51:03 +00:00
);
return $schema;
}