Added multiple tests and started real continuous integration
This commit is contained in:
parent
58f0910f63
commit
c86822f99b
3
.gitignore
vendored
3
.gitignore
vendored
@ -11,4 +11,5 @@ FuzeWorks.esproj/*
|
||||
*.swp
|
||||
*.out
|
||||
Core/Cache/
|
||||
Core/Logs/Error.log
|
||||
Core/Logs/Error.log
|
||||
build/
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
|
||||
|
22
Modules/example/class.main.php
Normal file
22
Modules/example/class.main.php
Normal file
@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
namespace Module\Example;
|
||||
use \FuzeWorks\Module;
|
||||
|
||||
/**
|
||||
* Sections module, see usage documentation
|
||||
* @author TechFuze
|
||||
*/
|
||||
class Main extends Module {
|
||||
|
||||
/**
|
||||
* Loads the module and registers the events
|
||||
* @access public
|
||||
*/
|
||||
public function onLoad() {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
23
Modules/example/moduleInfo.php
Normal file
23
Modules/example/moduleInfo.php
Normal file
@ -0,0 +1,23 @@
|
||||
<?php
|
||||
return array(
|
||||
|
||||
'module_class' => '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,
|
||||
);
|
23
build.xml
23
build.xml
@ -1,7 +1,6 @@
|
||||
<project name="FuzeWorks" default="build" basedir=".">
|
||||
<target name="clean">
|
||||
<delete dir="${basedir}/build" />
|
||||
<delete dir="${basedir}/source/.git" />
|
||||
</target>
|
||||
|
||||
<target name="prepare">
|
||||
@ -10,22 +9,28 @@
|
||||
<mkdir dir="${basedir}/build/phpdoc" />
|
||||
</target>
|
||||
|
||||
<target name="phpdoc">
|
||||
<target name="phpunit">
|
||||
<exec dir="${basedir}" executable="php" failonerror="true">
|
||||
<arg value="phpunit.phar"/>
|
||||
<arg line="--configuration phpunit.xml
|
||||
--log-junit build/logs/phpunit.xml
|
||||
--coverage-clover build/logs/clover.xml
|
||||
--coverage-html build/clover" />
|
||||
</exec>
|
||||
</target>
|
||||
|
||||
<target name="phpdoc">
|
||||
<exec dir="${basedir}" executable="php" failonerror="yes">
|
||||
<arg value="apigen.phar"/>
|
||||
<arg line="generate --source .
|
||||
--exclude 'tests/*'
|
||||
--exclude 'Core/System/Smarty/*'
|
||||
--title 'FuzeWorks Documentation build #${buildNumber}'
|
||||
--destination build/phpdoc" />
|
||||
<arg line="generate --source . --destination 'build/phpdoc' --exclude 'tests/*','build/*','Core/System/Smarty/*' "/>
|
||||
</exec>
|
||||
</target>
|
||||
|
||||
<target name="zip">
|
||||
<exec dir="${basedir}" executable="zip" failonerror="true">
|
||||
<arg line="-r ${basedir}/build/fuzeworks-core.zip . -x build\* tests\* .git\*" />
|
||||
<arg line="-r ${basedir}/build/fuzeworks-core.zip . -x build\* tests\* .git\* phpunit.phar apigen.phar phpunit.xml build.xml" />
|
||||
</exec>
|
||||
</target>
|
||||
|
||||
<target name="build" depends="clean,prepare,phpdoc,zip" />
|
||||
<target name="build" depends="clean,prepare,phpunit,phpdoc,zip" />
|
||||
</project>
|
@ -1,9 +1,13 @@
|
||||
<?php
|
||||
// Include framework
|
||||
require_once( dirname(__FILE__) . "/Core/System/class.core.php");
|
||||
|
||||
require('load.php');
|
||||
|
||||
// Load it
|
||||
$core = new \FuzeWorks\Core();
|
||||
$core->init();
|
||||
$core->loadMod('router');
|
||||
$core->mods->router->setPath( (isset($_GET['path']) ? $_GET['path'] : null) );
|
||||
$core->mods->router->route();
|
||||
$core->mods->router->loadController();
|
||||
|
||||
?>
|
13
load.php
13
load.php
@ -1,13 +0,0 @@
|
||||
<?php
|
||||
// Include framework
|
||||
if (!defined('FUZEPATH')) {
|
||||
define( 'FUZEPATH', dirname(__FILE__) . '/' );
|
||||
}
|
||||
|
||||
require_once( dirname(__FILE__) . "/Core/System/class.core.php");
|
||||
|
||||
// Load it
|
||||
$core = new Core();
|
||||
$core->init();
|
||||
|
||||
?>
|
@ -1,5 +1,5 @@
|
||||
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/4.5/phpunit.xsd"
|
||||
bootstrap="load.php"
|
||||
bootstrap="tests/autoload.php"
|
||||
convertErrorsToExceptions="true"
|
||||
convertNoticesToExceptions="true"
|
||||
convertWarningsToExceptions="true"
|
||||
|
7
tests/autoload.php
Normal file
7
tests/autoload.php
Normal file
@ -0,0 +1,7 @@
|
||||
<?php
|
||||
// Load the abstract
|
||||
require_once("class.abstract.coreTestAbstract.php");
|
||||
require_once( "Core/System/class.core.php");
|
||||
|
||||
|
||||
?>
|
23
tests/class.abstract.coreTestAbstract.php
Normal file
23
tests/class.abstract.coreTestAbstract.php
Normal file
@ -0,0 +1,23 @@
|
||||
<?php
|
||||
/**
|
||||
* Class CoreTestAbstract
|
||||
*
|
||||
* Provides the event tests with some basic functionality
|
||||
*/
|
||||
abstract class CoreTestAbstract extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
/**
|
||||
* This function provides the framework
|
||||
* @returns \FuzeWorks\Core
|
||||
*/
|
||||
static function createCore()
|
||||
{
|
||||
$core = new FuzeWorks\Core();
|
||||
$core->init();
|
||||
|
||||
//Disable debugging
|
||||
$core->mods->logger->disable();
|
||||
|
||||
return $core;
|
||||
}
|
||||
}
|
@ -1,7 +0,0 @@
|
||||
<?php
|
||||
|
||||
class CoreTest extends PHPUnit_Framework_TestCase {
|
||||
public function testCanBeNegated() {
|
||||
|
||||
}
|
||||
}
|
20
tests/core_coreTest.php
Normal file
20
tests/core_coreTest.php
Normal file
@ -0,0 +1,20 @@
|
||||
<?php
|
||||
/**
|
||||
* Class CoreTest
|
||||
*
|
||||
* Core testing suite, will test basic core functionality
|
||||
*/
|
||||
class CoreTest extends CoreTestAbstract
|
||||
{
|
||||
public function testCanLoadStartupFiles(){
|
||||
|
||||
$core = $this->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);
|
||||
}
|
||||
}
|
23
tests/core_modelTest.php
Normal file
23
tests/core_modelTest.php
Normal file
@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Class ModelTest
|
||||
*
|
||||
* Core model testing suite, will test model parent class
|
||||
*
|
||||
*/
|
||||
class ModelTest extends CoreTestAbstract
|
||||
{
|
||||
|
||||
/**
|
||||
* Tests wether FuzeWorks is able to load a simple Dummy Model
|
||||
*/
|
||||
public function testModelLoading() {
|
||||
$core = $this->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
|
||||
}
|
50
tests/core_moduleTest.php
Normal file
50
tests/core_moduleTest.php
Normal file
@ -0,0 +1,50 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Class ModuleTest
|
||||
*
|
||||
* Core module testing suite, will test basic module functionality
|
||||
*
|
||||
*/
|
||||
class ModuleTest extends CoreTestAbstract
|
||||
{
|
||||
|
||||
/**
|
||||
* Tests the loading of a single module located in a folder
|
||||
*/
|
||||
public function testFolderLoading(){
|
||||
|
||||
$core = $this->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());
|
||||
}
|
||||
}
|
13
tests/models/testModelLoading/model.dummy.php
Normal file
13
tests/models/testModelLoading/model.dummy.php
Normal file
@ -0,0 +1,13 @@
|
||||
<?php
|
||||
|
||||
namespace Model;
|
||||
use \FuzeWorks\Model;
|
||||
|
||||
class Dummy extends Model{
|
||||
|
||||
public function __construct(&$core){
|
||||
parent::__construct($core);
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
13
tests/models/testParentInteraction/model.dummy.php
Normal file
13
tests/models/testParentInteraction/model.dummy.php
Normal file
@ -0,0 +1,13 @@
|
||||
<?php
|
||||
|
||||
namespace Model;
|
||||
use \FuzeWorks\Model;
|
||||
|
||||
class Dummy extends Model{
|
||||
|
||||
public function __construct(&$core){
|
||||
parent::__construct($core);
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
Loading…
Reference in New Issue
Block a user