Abel Hoogeveen
9d665e2ae1
- Modules can now be loaded using routes by adding a routes[] array to the moduleInfo.php. When it matches, the module gets loaded, and a route() function in the main class gets called. (Fixes #79) - Composer can now load from a different file - License headers have been added to all core files (Fixes #66) - Table model has been renamed to sqltable. Interpret model has been removed - layoutLoadViewEvent added - Controllers now extend the \FuzeWorks\ControllerAbstract class - Controllers are now in the \Application\Controller namespace - Models are now in the \Application\Model namespace - Events are now in the \FuzeWorks\Event namespace - Moved some classes in a different namespace for a better overview - Events can now properly load function listeners (fixes #81) - Documentation added to more classes. (Partially fixes #58) - Added replace() command to DatabaseUtils Abstract Model - Added more unit tests for router, query and events
81 lines
2.2 KiB
PHP
81 lines
2.2 KiB
PHP
<?php
|
|
use \FuzeWorks\Core;
|
|
use \FuzeWorks\Models;
|
|
|
|
/**
|
|
* Class ModelTest
|
|
*
|
|
* Core model testing suite, will test basic model functionality
|
|
*
|
|
*/
|
|
class ModelTest extends CoreTestAbstract
|
|
{
|
|
/**
|
|
* Select
|
|
*/
|
|
|
|
public function testSelectSimple()
|
|
{
|
|
$query = Models::get('sqltable')->select();
|
|
$this->assertEquals('SELECT * FROM table', $query->getSql());
|
|
}
|
|
|
|
public function testSelectSimpleOneField(){
|
|
|
|
$query = Models::get('sqltable')->select('field1');
|
|
$this->assertEquals('SELECT field1 FROM table', $query->getSql());
|
|
}
|
|
|
|
public function testSelectSimpleTwoFields(){
|
|
|
|
$query = Models::get('sqltable')->select('field1', 'field2');
|
|
$this->assertEquals('SELECT field1, field2 FROM table', $query->getSql());
|
|
}
|
|
|
|
/**
|
|
* Delete
|
|
*/
|
|
|
|
public function testDeleteSimple(){
|
|
|
|
$query = Models::get('sqltable')->delete()->from('table');
|
|
$this->assertEquals('DELETE FROM table', $query->getSql());
|
|
}
|
|
|
|
/**
|
|
* Insert
|
|
*/
|
|
|
|
public function testInsertSimple(){
|
|
|
|
$query = Models::get('sqltable')->insert(array('field' => 'value'));
|
|
$this->assertEquals('INSERT INTO table (field) VALUES (?)', $query->getSql());
|
|
$this->assertEquals(array('value'), $query->getBinds());
|
|
}
|
|
|
|
public function testInsertMultiple(){
|
|
|
|
$query = Models::get('sqltable')->insert(array('field1' => 'value1', 'field2' => 'value2'), 'table');
|
|
$this->assertEquals('INSERT INTO table (field1,field2) VALUES (?,?)', $query->getSql());
|
|
$this->assertEquals(array('value1', 'value2'), $query->getBinds());
|
|
}
|
|
|
|
/**
|
|
* Replace
|
|
*/
|
|
|
|
public function testReplaceSimple(){
|
|
|
|
$query = Models::get('sqltable')->replace(array('field' => 'value'));
|
|
$this->assertEquals('REPLACE INTO table (field) VALUES (?)', $query->getSql());
|
|
$this->assertEquals(array('value'), $query->getBinds());
|
|
}
|
|
|
|
public function testReplaceMultiple(){
|
|
|
|
$query = Models::get('sqltable')->replace(array('field1' => 'value1', 'field2' => 'value2'), 'table');
|
|
$this->assertEquals('REPLACE INTO table (field1,field2) VALUES (?,?)', $query->getSql());
|
|
$this->assertEquals(array('value1', 'value2'), $query->getBinds());
|
|
}
|
|
|
|
} |