public function testAddAndGetFieldsFromTable()
{
Users::setDb(Db::factory('Sqlite', array('database' => __DIR__ . '/../tmp/test.sqlite')));
$f = Fields::factory(Users::getTableInfo());
$f = Fields::factory(Users::getTableInfo(), array('size' => 40), array('id' => array('type' => 'hidden')), array('access'));
$f = Fields::factory(Users::getTableInfo(), array('size' => 40), array('id' => array('type' => 'hidden')), 'access');
$this->assertEquals(4, count($f->getFields()));
$this->assertEquals('Username:', $f->username['label']);
$f->username = array('type' => 'text', 'value' => 'Username here...', 'label' => 'New Username:', 'required' => true, 'attributes' => array('size' => 40));
$this->assertTrue(isset($f->username));
$this->assertEquals('New Username:', $f->username['label']);
$f->setField('username', 'label', 'Other Username:');
$this->assertEquals('Other Username:', $f->username['label']);
$f->setField('username', array('label' => 'Another Username:'));
$this->assertEquals('Another Username:', $f->username['label']);
unset($f->username);
$this->assertFalse(isset($f->username));
}