Exemplo n.º 1
0
 public function testSession()
 {
     $optiondao = new OptionMySQLDAO();
     $config = Config::getInstance();
     $app_path = $config->getValue('source_root_path');
     // set session data
     $optiondao->setSessionData('bla', array('name' => 'value'));
     $key = 'options_data:bla';
     $this->assertIdentical(array('name' => 'value'), SessionCache::get($key));
     // clear session data
     $optiondao->clearSessionData('bla');
     $this->assertFalse(SessionCache::isKeySet($key));
     // get session data
     $this->assertFalse($optiondao->getSessionData('bla'));
     // no data
     // with data
     SessionCache::put($key, array('name' => 'value'));
     $this->assertIdentical(array('name' => 'value'), $optiondao->getSessionData('bla'));
     // test updates
     $data1 = array('namespace' => 'test', 'option_name' => 'testname', 'option_value' => 'test_value');
     $builder1 = FixtureBuilder::build(self::TEST_TABLE, $data1);
     $options = $optiondao->getOptions('test');
     $this->assertNotNull($options);
     # update by name
     $optiondao->updateOptionByName('test', 'testname', 'test_value123');
     $options = $optiondao->getOptions('test');
     $this->assertEqual($options['testname']->option_value, 'test_value123');
     # update by id
     $optiondao->updateOption($options['testname']->option_id, 'test_value1234');
     $options = $optiondao->getOptions('test');
     $this->assertEqual($options['testname']->option_value, 'test_value1234');
     # delete by name
     $optiondao->deleteOptionByName('test', 'testname');
     $options = $optiondao->getOptions('test');
     $this->assertNull($options);
     # delete by id
     $builder1 = null;
     $builder1 = FixtureBuilder::build(self::TEST_TABLE, $data1);
     $optiondao->deleteOption($builder1->columns['last_insert_id']);
     $options = $optiondao->getOptions('test');
     $this->assertNull($options);
 }