* @license PHP License * @package WB * @subpackage unittest */ WBClass::load( 'WBException_Datasource' ); /** * Unit Test * * Test table * * @version 0.1.1 * @package WB * @subpackage unittest */ class TestCaseDatasourceObscureCode extends UnitTestCase { /** * table * @var WBDatasource_Table */ protected $table; /** * table * @var WBDatasource_ObscureCode */ protected $oc; /** * table options * @var array */ protected $options = array(); public function __construct() { WBClass::load('WBUnitTest_SQLUte'); $this->table = WBClass::create( 'WBDatasource_Table', $this->options ); $this->oc = WBClass::create( 'WBDatasource_ObscureCode', $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'); $this->assertTrue(class_exists('WBDatasource_ObscureCode', false)); $this->assertTrue(is_object($this->oc)); $this->assertIsA($this->oc, 'WBDatasource_ObscureCode'); $this->assertIsA($this->oc->setNamespace('unittest'), 'WBDatasource_ObscureCode'); } public function testReturnObject() { $this->assertIsA($this->oc->setNamespace('unittest'), 'WBDatasource_ObscureCode'); $this->assertIsA($this->oc->setId('any'), 'WBDatasource_ObscureCode'); $this->assertIsA($this->oc->create(), 'WBDatasource_ObscureCode'); $this->assertIsA($this->oc->clear(), 'WBDatasource_ObscureCode'); } public function testCreateGetClear() { $this->assertIsA($this->oc->setId('another one'), 'WBDatasource_ObscureCode'); $this->assertIsA($this->oc->create(), 'WBDatasource_ObscureCode'); $code = $this->oc->get(); $this->assertTrue($this->oc->check($code)); $this->assertIsA($this->oc->clear(), 'WBDatasource_ObscureCode'); $code = $this->oc->get(); $this->assertTrue(empty($code)); } public function testCheck() { $this->assertIsA($this->oc->setId(1234), 'WBDatasource_ObscureCode'); $this->assertIsA($this->oc->create(), 'WBDatasource_ObscureCode'); $code = $this->oc->get(); $this->assertTrue($this->oc->check($code)); $this->assertFalse($this->oc->check($code . 'x')); $this->assertFalse($this->oc->check($code . '1')); $this->assertFalse($this->oc->check('x' . $code . '1')); $this->assertFalse($this->oc->check('1' . $code . '1')); $this->assertFalse($this->oc->check('x' . $code)); $this->assertFalse($this->oc->check('1' . $code)); $this->assertTrue($this->oc->check($code, true)); $this->assertFalse($this->oc->check($code)); $this->assertFalse($this->oc->check($code, true)); $this->assertFalse($this->oc->check($code, false)); $this->assertIsA($this->oc->create(), 'WBDatasource_ObscureCode'); $code = $this->oc->get(); $this->assertFalse($this->oc->check($code . 'x', true)); $this->assertFalse($this->oc->check($code)); $this->assertFalse($this->oc->check($code, true)); $this->assertFalse($this->oc->check($code, false)); } } ?>