UTDb Class Reference
[Unit Tests - Unit tests for all classes/functions in fareofficelib.]

Unit test for all functions in Db.php. More...

List of all members.

Public Member Functions

 doTest ()

Private Member Functions

 _testDbClass ()
 _testEscN ()
 _testEscS ()


Detailed Description

Unit test for all functions in Db.php.

Author:
Daniel Lindh <daniel@fareoffice.com>

Definition at line 8 of file UTDb.class.php.


Member Function Documentation

UTDb::_testDbClass (  )  [private]

Definition at line 17 of file UTDb.class.php.

Referenced by doTest().

00018   {
00019     $this->setSectionLabel('Db class');
00020     $config = new Config();
00021 
00022     eval($this->needNotEmpty('$db = new Db($config)'));
00023     eval($this->needEmpty('$db->setConfigName("mysql")'));
00024     eval($this->needEqual('$db->getConfigName()', '"mysql"'));
00025     eval($this->needEmpty('$db->pushConfigName("dead_database")'));
00026     eval($this->needEqual('$db->getConfigName()', '"dead_database"'));
00027     eval($this->needEmpty('$db->popConfigName()'));
00028     eval($this->needEqual('$db->getConfigName()', '"mysql"'));
00029     eval($this->needNotEmpty('$conn = $db->getConnection()'));
00030     eval($this->needNotEmpty('$resultSet = $db->executeQuery("select \"Hey, Bishop. Do the thing with the knife. \" as col1")'));
00031     $resultSet->next();
00032     eval($this->needEqual('$resultSet->getRecordCount()', '1'));
00033     eval($this->needEqual('$resultSet->getString("col1")', '"Hey, Bishop. Do the thing with the knife. "'));
00034   }

UTDb::_testEscN (  )  [private]

Definition at line 36 of file UTDb.class.php.

Referenced by doTest().

00037   {
00038     $this->setSectionLabel('escN');
00039 
00040     $emptyString = "";
00041     eval($this->needEqual('escN($emptyString)', '"NULL"'));
00042 
00043     $number23 = 23;
00044     eval($this->needEqual('escN($number23)', 23));
00045 
00046     $zeroNumber = 0;
00047     eval($this->needEqual('escN($zeroNumber)', 0));
00048   }

UTDb::_testEscS (  )  [private]

Definition at line 50 of file UTDb.class.php.

Referenced by doTest().

00051   {
00052     $this->setSectionLabel('escS');
00053 
00054     $emptyString = "";
00055     eval($this->needEqual('escS($emptyString)', '"NULL"'));
00056 
00057     $notEmptyString = "Game over man";
00058     eval($this->needEqual('escS($notEmptyString)', "'\'Game over man\''"));
00059     eval($this->needEqual('escS($notEmptyString, "%", ESC_NONE)', "'\'Game over man\''"));
00060     eval($this->needEqual('escS($notEmptyString, "%", ESC_LAST)', "'\'Game over man%\''"));
00061     eval($this->needEqual('escS($notEmptyString, "%", ESC_FIRST)', "'\'%Game over man\''"));
00062     eval($this->needEqual('escS($notEmptyString, "%", ESC_BOTH)', "'\'%Game over man%\''"));
00063 
00064     $number23 = 23;
00065     eval($this->needEqual('escS($number23)', "'\'23\''"));
00066 
00067     $zeroNumber = 0;
00068     eval($this->needEqual('escS($zeroNumber)', "'\'0\''"));
00069 
00070     $zeroNumber = 0;
00071     eval($this->needEqual('escS($zeroNumber)', 0));
00072   }

UTDb::doTest (  ) 

Definition at line 10 of file UTDb.class.php.

References _testDbClass(), _testEscN(), and _testEscS().

00011   {
00012     $this->_testDbClass();
00013     $this->_testEscN();
00014     $this->_testEscS();
00015   }


The documentation for this class was generated from the following file:

Generated on Wed May 6 23:28:24 2009 for fareofficelib by  doxygen 1.5.8