* @license PHP License * @package WB * @subpackage unittest */ WBClass::load( 'WBException_Datasource' ); /** * Unit Test * * Test table * * @version 0.1.1 * @package WB * @subpackage unittest */ class TestCaseDatasourceTableBase extends UnitTestCase { /** * table * @var WBDatasource_Table */ protected $_table; /** * table options * @var array */ protected $_options = array(); public function __construct() { WBClass::load('WBUnitTest_SQLUte'); $this->_table = WBClass::create( 'WBDatasource_Table', $this->_options ); WBUnitTest_SQLUte::source( __FILE__, 'construct' ); } public function __destruct() { WBUnitTest_SQLUte::source( __FILE__, 'destruct' ); } /** * check instance * */ public function testInit() { $this->assertTrue( class_exists( 'WBDatasource_Table', false ) ); $this->assertTrue( is_object( $this->_table ) ); $this->assertIsA( $this->_table, 'WBDatasource_Table' ); } /** * get * */ public function testGet() { $user = $this->_table->get( 'user', 10 ); $this->assertEqual( count( $user ), 1 ); $user = $this->_table->get( 'user' ); $this->assertEqual( count( $user ), 3 ); $skin = $this->_table->get( 'skin', 10 ); $this->assertEqual( count( $skin ), 1 ); } /** * Verify correct handling of connect & disconnect * * * */ public function testConnectDisconnect() { // remove the !gobal" table object unset( $this->_table ); $t1 = WBClass::create( 'WBDatasource_Table' ); /* @var $t1 WBDatasource_Table */ $this->assertIsA( $t1, 'WBDatasource_Table' ); $t2 = WBClass::create( 'WBDatasource_Table' ); /* @var $t2 WBDatasource_Table */ $this->assertIsA( $t2, 'WBDatasource_Table' ); try{ $user = $t1->get( 'user', 10 ); $this->assertEqual( count( $user ), 1 ); } catch( WBException_Datasource $e ) { $this->assertTrue( false ); } unset( $t1 ); try{ $skin = $t2->get( 'skin', 10 ); $this->assertEqual( count( $skin ), 1 ); } catch( WBException_Datasource $e ) { $this->assertTrue( false ); } $this->_table = WBClass::create( 'WBDatasource_Table', $this->_options ); } } ?>