diff options
author | Dries Buytaert <dries@buytaert.net> | 2008-05-07 06:48:35 +0000 |
---|---|---|
committer | Dries Buytaert <dries@buytaert.net> | 2008-05-07 06:48:35 +0000 |
commit | 4e25a321c814526143baca5ca33994c54185b01a (patch) | |
tree | 5f3747e3f370d3dee274c3207694df10b60ac309 | |
parent | e4e2205bfe46444898e7b222864ad7ab7a62509b (diff) | |
download | brdo-4e25a321c814526143baca5ca33994c54185b01a.tar.gz brdo-4e25a321c814526143baca5ca33994c54185b01a.tar.bz2 |
- Patch #243967 by justinrandell: first very basic test for the registry's file parsing.
-rw-r--r-- | includes/registry.test | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/includes/registry.test b/includes/registry.test new file mode 100644 index 000000000..4cf190cef --- /dev/null +++ b/includes/registry.test @@ -0,0 +1,56 @@ +<?php + +class RegistryParseFileTestCase extends DrupalWebTestCase { + + /** + * Implementation of getInfo(). + */ + function getInfo() { + return array( + 'name' => t('Registry parse file test'), + 'description' => t('Parse a simple file and check that its resources are saved to the database.'), + 'group' => t('System') + ); + } + + /** + * Implementation of setUp(). + */ + function setUp() { + $this->fileName = 'registry_test_' . md5(rand()); + $this->functionName = 'registry_test_function' . md5(rand()); + $this->className = 'registry_test_class' . md5(rand()); + $this->interfaceName = 'registry_test_interface' . md5(rand()); + parent::setUp(); + } + + /** + * testRegistryParseFile + */ + function testRegistryParseFile() { + _registry_parse_file($this->fileName, $this->getFileContents()); + foreach (array('functionName', 'className', 'interfaceName') as $resource) { + $foundName = db_result(db_query("SELECT name FROM {registry} WHERE name = '%s'", $this->$resource)); + $this->assertTrue($this->$resource == $foundName, t('Resource "@resource" found.', array('@resource' => $this->$resource))); + } + } + + /** + * getFileContents + */ + function getFileContents() { + $file_contents = <<<CONTENTS +<?php + +function {$this->functionName}() {} + +class {$this->className} {} + +interface {$this->interfaceName} {} + +CONTENTS; + return $file_contents; + } + +} + |