diff --git a/.gitignore b/.gitignore
index 97cd0ae..8c35911 100644
--- a/.gitignore
+++ b/.gitignore
@@ -11,4 +11,5 @@ FuzeWorks.esproj/*
*.swp
*.out
Core/Cache/
-Core/Logs/Error.log
\ No newline at end of file
+Core/Logs/Error.log
+build/
diff --git a/Core/Events/event.modelLoadEvent.php b/Core/Events/event.modelLoadEvent.php
index ef5c08a..89d9097 100644
--- a/Core/Events/event.modelLoadEvent.php
+++ b/Core/Events/event.modelLoadEvent.php
@@ -7,8 +7,9 @@ class ModelLoadEvent extends Event {
public $directory;
public $model;
- public function init($model){
+ public function init($model, $directory){
$this->model = $model;
+ $this->directory = $directory;
}
}
diff --git a/Core/System/class.models.php b/Core/System/class.models.php
index b414037..e4fc425 100644
--- a/Core/System/class.models.php
+++ b/Core/System/class.models.php
@@ -23,7 +23,7 @@ class Models extends Bus{
public function loadModel($name, $directory = null){
// Model load event
- $event = $this->events->fireEvent('modelLoadEvent', $name);
+ $event = $this->events->fireEvent('modelLoadEvent', $name, $directory);
$directory = ($event->directory === null ? "Application/Models" : $event->directory);
$name = ($event->model === null ? $name : $event->model);
diff --git a/Modules/example/class.main.php b/Modules/example/class.main.php
new file mode 100644
index 0000000..1ea3324
--- /dev/null
+++ b/Modules/example/class.main.php
@@ -0,0 +1,22 @@
+
\ No newline at end of file
diff --git a/Modules/example/moduleInfo.php b/Modules/example/moduleInfo.php
new file mode 100644
index 0000000..970dc09
--- /dev/null
+++ b/Modules/example/moduleInfo.php
@@ -0,0 +1,23 @@
+ 'Module\Example\Main',
+ 'module_file' => 'class.main.php',
+ 'module_name' => 'Example',
+
+ 'abstract' => false,
+ 'dependencies' => array(),
+ 'events' => array(),
+ 'sections' => array(),
+
+ 'name' => 'FuzeWorks Example Module',
+ 'description' => 'A descriptive module that functions as an example',
+ 'author' => 'MyCorp',
+ 'version' => '1.0.0',
+ 'website' => 'http://fuzeworks.techfuze.net/',
+
+ 'date_created' => '29-04-2015',
+ 'date_updated' => '29-04-2015',
+
+ 'enabled' => true,
+);
diff --git a/build.xml b/build.xml
new file mode 100644
index 0000000..ff77109
--- /dev/null
+++ b/build.xml
@@ -0,0 +1,36 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/phpunit.xml b/phpunit.xml
new file mode 100644
index 0000000..2a8d6df
--- /dev/null
+++ b/phpunit.xml
@@ -0,0 +1,25 @@
+
+
+
+
+ tests
+
+
+
\ No newline at end of file
diff --git a/tests/autoload.php b/tests/autoload.php
new file mode 100644
index 0000000..0ae30fc
--- /dev/null
+++ b/tests/autoload.php
@@ -0,0 +1,7 @@
+
\ No newline at end of file
diff --git a/tests/class.abstract.coreTestAbstract.php b/tests/class.abstract.coreTestAbstract.php
new file mode 100644
index 0000000..f18317e
--- /dev/null
+++ b/tests/class.abstract.coreTestAbstract.php
@@ -0,0 +1,23 @@
+init();
+
+ //Disable debugging
+ $core->mods->logger->disable();
+
+ return $core;
+ }
+}
\ No newline at end of file
diff --git a/tests/core_coreTest.php b/tests/core_coreTest.php
new file mode 100644
index 0000000..91d4b57
--- /dev/null
+++ b/tests/core_coreTest.php
@@ -0,0 +1,20 @@
+createCore();
+
+ // Assert
+ $this->assertInstanceOf('\FuzeWorks\Config', $core->mods->config);
+ $this->assertInstanceOf('\FuzeWorks\Logger', $core->mods->logger);
+ $this->assertInstanceOf('\FuzeWorks\Events', $core->mods->events);
+ $this->assertInstanceOf('\FuzeWorks\Layout', $core->mods->layout);
+ $this->assertInstanceOf('\FuzeWorks\Models', $core->mods->models);
+ }
+}
\ No newline at end of file
diff --git a/tests/core_modelTest.php b/tests/core_modelTest.php
new file mode 100644
index 0000000..e32e547
--- /dev/null
+++ b/tests/core_modelTest.php
@@ -0,0 +1,23 @@
+createCore();
+
+ $core->mods->models->loadModel('dummy', 'tests/models/testModelLoading/');
+ $this->assertInstanceOf('\Model\Dummy', $core->mods->models->dummy);
+ }
+
+ // PARENT INTERACTION VIA A DUMMY MODELSERVER IN DUMMY MODULE
+}
\ No newline at end of file
diff --git a/tests/core_moduleTest.php b/tests/core_moduleTest.php
new file mode 100644
index 0000000..2f0ca2e
--- /dev/null
+++ b/tests/core_moduleTest.php
@@ -0,0 +1,50 @@
+createCore();
+
+ $mod = $core->loadMod('mycorp/example');
+ $this->assertInstanceOf('\Module\Example\Main', $mod);
+ }
+
+ /**
+ * Test if a reloaded module is the same Id
+ */
+ public function testDuplicateInstance() {
+
+ $core = $this->createCore();
+
+ // The 2 instances which should be the same
+ $mod = $core->loadMod('mycorp/example');
+ $mod2 = $core->loadMod('mycorp/example');
+
+ $this->assertEquals(spl_object_hash($mod), spl_object_hash($mod2));
+ }
+
+ /**
+ * Test if the retrieved module info is correct
+ */
+ public function testModuleInfo() {
+ $core = $this->createCore();
+ $mod = $core->loadMod('mycorp/example');
+
+ // The name
+ $this->assertEquals('mycorp/example', $mod->getModuleName());
+
+ // The directory
+ $this->assertEquals('Modules/example/', $mod->getModulePath());
+ }
+}
\ No newline at end of file
diff --git a/tests/models/testModelLoading/model.dummy.php b/tests/models/testModelLoading/model.dummy.php
new file mode 100644
index 0000000..16c1a77
--- /dev/null
+++ b/tests/models/testModelLoading/model.dummy.php
@@ -0,0 +1,13 @@
+
\ No newline at end of file
diff --git a/tests/models/testParentInteraction/model.dummy.php b/tests/models/testParentInteraction/model.dummy.php
new file mode 100644
index 0000000..16c1a77
--- /dev/null
+++ b/tests/models/testParentInteraction/model.dummy.php
@@ -0,0 +1,13 @@
+
\ No newline at end of file