Merge branch 'Issue_#7,_Continuous_Integration' into 'master'

Issue #7, continuous integration

Real work done

See merge request !18
This commit is contained in:
Abel Hoogeveen 2015-05-01 22:48:02 +02:00
commit 1d01e44b36
14 changed files with 260 additions and 3 deletions

3
.gitignore vendored
View File

@ -11,4 +11,5 @@ FuzeWorks.esproj/*
*.swp
*.out
Core/Cache/
Core/Logs/Error.log
Core/Logs/Error.log
build/

View File

@ -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;
}
}

View File

@ -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);

View 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() {
}
}
?>

View 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,
);

36
build.xml Normal file
View File

@ -0,0 +1,36 @@
<project name="FuzeWorks" default="build" basedir=".">
<target name="clean">
<delete dir="${basedir}/build" />
</target>
<target name="prepare">
<mkdir dir="${basedir}/build/logs" />
<mkdir dir="${basedir}/build/clover" />
<mkdir dir="${basedir}/build/phpdoc" />
</target>
<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 . --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\* phpunit.phar apigen.phar phpunit.xml build.xml" />
</exec>
</target>
<target name="build" depends="clean,prepare,phpunit,phpdoc,zip" />
</project>

25
phpunit.xml Normal file
View File

@ -0,0 +1,25 @@
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/4.5/phpunit.xsd"
bootstrap="tests/autoload.php"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
forceCoversAnnotation="false"
mapTestClassNameToCoveredClassName="false"
printerClass="PHPUnit_TextUI_ResultPrinter"
processIsolation="false"
stopOnError="false"
stopOnFailure="false"
stopOnIncomplete="false"
stopOnSkipped="false"
testSuiteLoaderClass="PHPUnit_Runner_StandardTestSuiteLoader"
timeoutForSmallTests="1"
timeoutForMediumTests="10"
timeoutForLargeTests="60"
verbose="true">
<testsuites>
<testsuite name="Core Functionality">
<directory>tests</directory>
</testsuite>
</testsuites>
</phpunit>

7
tests/autoload.php Normal file
View File

@ -0,0 +1,7 @@
<?php
// Load the abstract
require_once("class.abstract.coreTestAbstract.php");
require_once( "Core/System/class.core.php");
?>

View 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;
}
}

20
tests/core_coreTest.php Normal file
View 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
View 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
View 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());
}
}

View File

@ -0,0 +1,13 @@
<?php
namespace Model;
use \FuzeWorks\Model;
class Dummy extends Model{
public function __construct(&$core){
parent::__construct($core);
}
}
?>

View File

@ -0,0 +1,13 @@
<?php
namespace Model;
use \FuzeWorks\Model;
class Dummy extends Model{
public function __construct(&$core){
parent::__construct($core);
}
}
?>