* @license PHP License * @package WB * @subpackage unittest */ WBClass::load( 'WBException_Datasource' ); /** * Unit Test * * Test table * * @version 0.1.1 * @package WB * @subpackage unittest */ class TestCaseDatasourceTableUndelete 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', 11); $this->assertEqual(count($user), 1); } public function testDeleteUndelete() { $this->assertEqual($this->table->delete('user', 10), 1, 'Count deleted user expected to be one'); $this->assertTrue($this->table->undelete('user', 10), 'failed to undelete user id 10'); } public function testException() { WBClass::load('WBException_Config' , 'WBException_Argument'); try { $this->table->undelete('rating', null); $this->assertTrue(false, 'Exception Argument expected'); } catch (WBException_Argument $e) { $this->assertTrue(true); } try { $this->table->undelete('rating', 10); $this->assertTrue(false, 'Exception Config expected'); } catch (WBException_Config $e) { $this->assertTrue(true); } } }