function RegistryParseFilesTestCase::setUp in SimpleTest 7
Generates a random database prefix, runs the install scripts on the prefixed database and enable the specified modules. After installation many caches are flushed and the internal browser is setup so that the page requests will run on the new prefix. A temporary files directory is created with the same name as the database prefix.
Parameters
...: List of modules to enable for the duration of the test.
Overrides DrupalWebTestCase::setUp
File
- tests/
registry.test, line 58
Class
Code
function setUp() {
parent::setUp();
// Create files with some php to parse - one 'new', one 'existing' so
// we test all the important code paths in _registry_parse_files.
foreach ($this->fileTypes as $fileType) {
$this->{$fileType} = new stdClass();
$this->{$fileType}->fileName = file_directory_path() . '/registry_test_' . md5(rand());
$this->{$fileType}->className = 'registry_test_class' . md5(rand());
$this->{$fileType}->interfaceName = 'registry_test_interface' . md5(rand());
$this->{$fileType}->contents = $this
->getFileContents($fileType);
file_save_data($this->{$fileType}->contents, $this->{$fileType}->fileName);
if ($fileType == 'existing_changed') {
db_insert('registry_file')
->fields(array(
'filectime' => rand(1, 1000000),
'filemtime' => rand(1, 1000000),
'filename' => $this->{$fileType}->fileName,
))
->execute();
// Insert some fake resource records.
foreach (array(
'class',
'interface',
) as $type) {
db_insert('registry')
->fields(array(
'name' => $type . md5(rand()),
'type' => $type,
'filename' => $this->{$fileType}->fileName,
))
->execute();
}
}
}
}