From ab7ea095fdfbbf4caae989742ab3ba2e1cc7dd07 Mon Sep 17 00:00:00 2001 From: Marius Orcsik Date: Fri, 1 May 2009 20:34:00 +0200 Subject: [PATCH] * changes to the tests --- _tests/models/dataobject.class.php | 9 +++++++++ _tests/models/dummytable.class.php | 2 +- _tests/models/fooentityTest.php | 25 ++++++++++++++----------- _tests/models/footdoTest.php | 20 ++++++++------------ 4 files changed, 32 insertions(+), 24 deletions(-) create mode 100644 _tests/models/dataobject.class.php diff --git a/_tests/models/dataobject.class.php b/_tests/models/dataobject.class.php new file mode 100644 index 0000000..70a310b --- /dev/null +++ b/_tests/models/dataobject.class.php @@ -0,0 +1,9 @@ +setConnection(sqlFactory::connect('mysql')); + } +} diff --git a/_tests/models/dummytable.class.php b/_tests/models/dummytable.class.php index 6187f08..38590c4 100644 --- a/_tests/models/dummytable.class.php +++ b/_tests/models/dummytable.class.php @@ -13,7 +13,7 @@ class dummyTable extends fooEntityA { $this->id->setAutoIncrement (true); $this->payload = new fooFieldVarChar ('payload'); - $this->timestamp = new fooFieldDateTime ('timestamp'); + $this->timestamp = new fooFieldDateTime ('ts'); $this->setPrimaryKey ($this->id); } diff --git a/_tests/models/fooentityTest.php b/_tests/models/fooentityTest.php index 980f746..c782f61 100644 --- a/_tests/models/fooentityTest.php +++ b/_tests/models/fooentityTest.php @@ -6,24 +6,27 @@ */ include_once ('dummytable.class.php'); -class fooUsersTest extends UnitTestCase { +class fooEntityTest extends UnitTestCase { + private $state; + public function setUp() { // begin transaction shit - if the case + $this->state = new dummyTable(); } -// private function getTestData () { -// return array ( -// array ('One', 'Two', 3), -// array (null, 0, 1) -// ); -// } - public function testInstantiation (){ - $ousers = new dummyTable(); - - $this->assertIsA($ousers, 'dummyTable'); + $this->assertIsA($this->state, 'dummyTable'); + $this->assertIsA($this->state, 'fooEntityA'); } public function testFields () { + foreach ($this->state->getMembers() as $oColumn) { + $this->assertIsA($oColumn, 'fooFieldA', 'Column ' . var_export($oColumn, true) . ' is not a valid fooField'); + } + } + + public function testPrimaryKey () { + $this->state->setPrimaryKey($this->state->payload); + $this->assertIsA($this->state->getPrimaryKey(), 'fooKeyPrimary'); } } \ No newline at end of file diff --git a/_tests/models/footdoTest.php b/_tests/models/footdoTest.php index 986150c..ca20413 100644 --- a/_tests/models/footdoTest.php +++ b/_tests/models/footdoTest.php @@ -7,12 +7,14 @@ define ('DB_USER', 'root'); define ('DB_PASS', 'ASD'); define ('DB_NAME', 'b'); -include_once ('dummytable.class.php'); // the definition of the entity usingPackage ('models/foo'); usingPackage ('models/sqldrivers'); usingPackage ('coreexceptions'); -class fooTdoAbstractTest extends UnitTestCase { +include_once ('dummytable.class.php'); // the definition of the entity +include_once ('dataobject.class.php'); // the definition of the data object + +class fooTdoTest extends UnitTestCase { public function test_Instantiation () { $o = new fooTdo(); @@ -26,19 +28,13 @@ class fooTdoAbstractTest extends UnitTestCase { } public function testCreateSQL () { + // we should have a separate test for each type of connection + // the test should be the actual creation $o = new dummyTable(); $oC = new fooTdo(); - $this->assertEqual(1, 1); - $oC->outputCreateSQL($o); - } -} + $createSQL = $oC->outputCreateSQL($o); -/** - * mock object for testing the abstract fooTdoA - */ -class fooTdo extends fooTdoA { - public function __construct () { - $this->setConnection(sqlFactory::connect('mysql')); + d (alltrim($createSQL)); } } -- 2.11.4.GIT