More unit tests

This commit is contained in:
Timothy Warren 2012-01-17 08:10:30 -05:00
parent 454a59123c
commit 309846ee8f

View File

@ -3,6 +3,9 @@
require_once('simpletest/autorun.php');
require_once('../src/sys/common.php');
/**
* Test class for /src/sys/common.php
*/
class commonTest extends UnitTestCase {
function __construct()
@ -19,7 +22,9 @@ class commonTest extends UnitTestCase {
function tearDown()
{
unset($this->empty);
unset($this->object);
unset($this->array_like);
}
function testCreation()
@ -33,6 +38,45 @@ class commonTest extends UnitTestCase {
}
// --------------------------------------------------------------------------
/**
* Test Class for JSObject class
*/
class JSObjectTest extends UnitTestCase {
function __construct()
{
parent::__construct('JSObject Class Tests');
}
function setUp()
{
$this->JSO = new JSObject(array(
'foo' => 54,
'bar' => 'baz',
));
}
function tearDown()
{
unset($this->JSO);
}
function testCreation()
{
// __toString produces same output as print_r by default
$this->assertIdentical($this->JSO->__toString(), '<pre>'.print_r($this->JSO, TRUE).'</pre>');
}
}
// --------------------------------------------------------------------------
/**
* Test class for miniMVC class
*/
class miniMVCTest extends UnitTestCase {
function __construct()
@ -62,35 +106,38 @@ class miniMVCTest extends UnitTestCase {
// miniMVC extends JSObject, right?
$this->assertIsA($this->mm, 'JSObject');
// Invoke function should return the same reference than miniMVC::get_instance() does
$mm = $this->mm;
$this->assertIdentical($mm(), miniMVC::get_instance());
$this->assertIdentical($this->mm->__invoke(), miniMVC::get_instance());
}
}
class JSObjectTest extends UnitTestCase {
// --------------------------------------------------------------------------
class DBTest extends UnitTestCase {
function __construct()
{
parent::__construct('JSObject Class Tests');
}
function setUp()
{
$this->JSO = new JSObject(array(
'foo' => 54,
'bar' => 'baz',
));
}
function tearDown()
{
unset($this->JSO);
}
function testCreation()
{
// __toString produces same output as print_r by default
$this->assertIdentical($this->JSO->__toString(), '<pre>'.print_r($this->JSO, TRUE).'</pre>');
}
}