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
index ec08833..ff77109 100644
--- a/build.xml
+++ b/build.xml
@@ -1,7 +1,6 @@
-
@@ -10,22 +9,28 @@
-
+
+
+
+
+
+
+
+
-
+
-
+
-
+
\ No newline at end of file
diff --git a/index.php b/index.php
index e1d9b29..89e32ed 100644
--- a/index.php
+++ b/index.php
@@ -1,9 +1,13 @@
init();
$core->loadMod('router');
$core->mods->router->setPath( (isset($_GET['path']) ? $_GET['path'] : null) );
$core->mods->router->route();
+$core->mods->router->loadController();
?>
\ No newline at end of file
diff --git a/load.php b/load.php
deleted file mode 100644
index 1f050f9..0000000
--- a/load.php
+++ /dev/null
@@ -1,13 +0,0 @@
-init();
-
-?>
\ No newline at end of file
diff --git a/phpunit.xml b/phpunit.xml
index c0515ed..2a8d6df 100644
--- a/phpunit.xml
+++ b/phpunit.xml
@@ -1,5 +1,5 @@
\ 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/coreTest.php b/tests/coreTest.php
deleted file mode 100644
index 15251de..0000000
--- a/tests/coreTest.php
+++ /dev/null
@@ -1,7 +0,0 @@
-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