* @license PHP License * @package WB * @subpackage unittest */ WBClass::load( 'WBException_Datasource' ); /** * Unit Test * * * * @version 0.3.0 * @package WB * @subpackage unittest */ class TestCaseVFSGallery extends UnitTestCase { /** * table options * @var WBVFS_Explorer */ protected $explorer; protected $gallery; /** * constructor * * - start objects * - source SQL * */ public function __construct() { WBClass::load('WBUnitTest_SQLUte'); WBUnitTest_SQLUte::source(__FILE__, 'construct'); // su user WBClass::load('WBUser'); $this->user = WBUser::getCurrent(); $this->user->load(4); $param = array( ); $this->explorer = WBClass::create('WBVFS_Explorer', $param); $this->gallery = WBClass::create('WBVFS_Gallery', $param); } /** * destruct * * Remove testing tables */ public function __destruct() { // WBUnitTest_SQLUte::source(__FILE__, 'destruct'); } /** * check instance * */ public function testInit() { $this->assertTrue(class_exists( 'WBVFS_Gallery', false)); $this->assertIsA($this->gallery, 'WBVFS_Gallery'); } public function testAddSetDelete() { $id = $this->gallery->add('brand new gallery'); $this->assertNotNull($id); $data = $this->gallery->get(); $this->assertEqual($data['id'], $id); $this->assertEqual($data['title'], 'brand new gallery'); $this->assertEqual($data['description'], ''); $this->assertEqual($data['obscure'] . $id, $this->gallery->getObscureId()); $this->gallery->setTitle('This is a different title'); $data = $this->gallery->get(); $this->assertEqual($data['title'], 'This is a different title'); $this->assertEqual($data['description'], ''); $this->gallery->setDescription('Galleries need wide winding verbose descriptions'); $data = $this->gallery->get(); $this->assertEqual($data['title'], 'This is a different title'); $this->assertEqual($data['description'], 'Galleries need wide winding verbose descriptions'); $this->gallery->delete(); } public function testAddFiles() { $id = $this->gallery->add('Despair', 'Imagine the failures'); $this->assertNotNull($id); $in = $this->gallery->getFiles(); echo '
' . var_export($in, true) . "
\n"; $new = array(31); $this->gallery->addFile($new); $in = $this->gallery->getFiles(); echo '
' . var_export($in, true) . "
\n"; $new = array(31, 32, 32, 33, 34); $this->gallery->addFile($new); $in = $this->gallery->getFiles(); echo '
' . var_export($in, true) . "
\n"; $new = array(31, 32, 32, 33, 34, 81, 82, 83 ,84); $this->gallery->addFile($new); $in = $this->gallery->getFiles(); echo '
' . var_export($in, true) . "
\n"; } } ?>