diff options
Diffstat (limited to 'tests/UnitTests/framework/common.php')
-rw-r--r-- | tests/UnitTests/framework/common.php | 61 |
1 files changed, 59 insertions, 2 deletions
diff --git a/tests/UnitTests/framework/common.php b/tests/UnitTests/framework/common.php index 80514875..9f52ce41 100644 --- a/tests/UnitTests/framework/common.php +++ b/tests/UnitTests/framework/common.php @@ -6,11 +6,14 @@ if(!defined('SIMPLETEST_DIR')) define('SIMPLETEST_DIR',realpath(dirname(__FILE__).'/../simpletest'));
require_once(SIMPLETEST_DIR.'/unit_tester.php');
+require_once(SIMPLETEST_DIR.'/mock_objects.php');
require_once(SIMPLETEST_DIR.'/reporter.php');
require_once(SIMPLETEST_DIR.'/HtmlReporterWithCoverage.php');
require_once(FRAMEWORK_DIR.'/core.php');
+set_include_path(get_include_path().";".FRAMEWORK_DIR);
+
class Prado extends PradoBase
{
}
@@ -25,13 +28,12 @@ restore_error_handler(); /**
- * PradoTestCase class.
+ * PradoUnitTestCase class.
*
* Extends the simpletest UnitTestCase class to provide some fairly generic extra functionality.
*
* @author Alex Flint <alex@linium.net>
*/
-
class PradoUnitTestCase extends UnitTestCase {
/**
@@ -47,4 +49,59 @@ class PradoUnitTestCase extends UnitTestCase { }
}
+
+/**
+ * Generate a class called MockTApplication to mock the TApplication class
+ * for the purpose of testing IModule objects.
+ */
+__autoload("TApplication");
+Mock::generate("TApplication");
+
+/**
+ * ModuleTestCase class.
+ *
+ * Provides functionality designed to support testing of objects implementing the IModule
+ * interface.
+ *
+ * Also provides some specific tests for IModule objects.
+ *
+ * @author Alex Flint <alex@linium.net>
+ */
+
+class ModuleTestCase extends PradoUnitTestCase {
+
+ protected $module = null;
+ protected $mockApplication = null;
+
+ public function __construct() {
+ $file = "";
+ $tihs->mockApplication =& new MockTApplication($file);
+ }
+
+ public function testGetSetID() {
+ if ($this->module instanceof IModule) {
+ $this->module->setId(123);
+ $this->assertEqual($this->module->getId(123));
+ }
+ }
+
+ /**
+ * Initializes $this->module by calling the init() method with the provided configuration.
+ * If no application object is provided then a mock application object $this->mockApplication.
+ * @param array optional. The configuration array to provide to the module. If none provided then
+ * an empty array will be used.
+ * @param TApplication optional. The TApplication to pass to the init() function of the module.
+ * If none provided then $this->mockApplication will be used.
+ */
+ public function initModule($config=array(), $application=null) {
+ if ($this->module instanceof IModule) {
+ if (is_null($application)) {
+ $application =& $this->mockApplication;
+ }
+ $this->module->init($config, $application);
+ }
+ }
+}
+
+
?>
\ No newline at end of file |