From a30b1369e06b35a9a36c77178999409cfcb71a9a Mon Sep 17 00:00:00 2001 From: Marius Orcsik Date: Fri, 1 May 2009 21:28:20 +0200 Subject: [PATCH] * actual testing of the tdo createSQL method --- _tests/models/footdoTest.php | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/_tests/models/footdoTest.php b/_tests/models/footdoTest.php index ca20413..cd77a1f 100644 --- a/_tests/models/footdoTest.php +++ b/_tests/models/footdoTest.php @@ -5,7 +5,7 @@ define ('DB_TYPE', 'mysql'); define ('DB_HOST', 'localhost'); define ('DB_USER', 'root'); define ('DB_PASS', 'ASD'); -define ('DB_NAME', 'b'); +define ('DB_NAME', 'test'); usingPackage ('models/foo'); usingPackage ('models/sqldrivers'); @@ -15,26 +15,32 @@ 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(); + private $state; + + public function setUp () { + $this->state = new fooTdo(); + } + public function tearDown() {} - $this->assertIsA($o, 'fooTdoA'); + public function test_Instantiation () { + $this->assertIsA($this->state, 'fooTdo'); + $this->assertIsA($this->state, 'fooTdoA'); } public function testGetConnection () { - $o = new fooTdo (); - $o->setConnection (sqlFactory::connect('mysql')); - $this->assertIsA($o->getConnection(), 'mySqlIm'); + $this->state->setConnection (sqlFactory::connect('mysql')); + $this->assertIsA($this->state->getConnection(), 'mySqlIm'); } 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(); - $createSQL = $oC->outputCreateSQL($o); + $createSQL = $this->state->outputCreateSQL($o); + $this->state->getConnection()->selectDatabase('test'); + $i = $this->state->getConnection()->query($createSQL); - d (alltrim($createSQL)); + $this->assertTrue($i, 'The create table sql is not correct!'); } } -- 2.11.4.GIT