/** * Initializes default values. * * @param xfField $field The field * @param string $value The value * @param string $encoding The encoding (optional) */ public function __construct(xfField $field, $value, $encoding = 'utf8') { $this->field = $field; $this->value = $field->transformValue($value); $this->encoding = $encoding; }
$t->pass($msg); } catch (Exception $e) { $t->fail($constructorMsg); $t->skip($msg); } } foreach ($invalidTypes as $type) { $msg = '->__construct() rejects the invalid type ' . $type; try { $field = new xfField('foobar', $type); $t->fail($msg); } catch (Exception $e) { $t->pass($msg); } } $t->diag('->getName(), ->getType()'); $field = new xfField('foobar', xfField::KEYWORD); $t->is($field->getName(), 'foobar', '->getName() returns the name'); $t->is($field->getType(), xfField::KEYWORD, '->getType() returns the type'); $t->diag('->registerCallback(), ->getCallbacks(), ->transformValue()'); $field = new xfField('foobar', xfField::KEYWORD); $field->registerCallback('strtoupper'); $field->registerCallback('md5'); $t->is($field->transformValue('foobar'), md5(strtoupper('foobar')), '->transformValue() calls callbacks in registered order'); $t->diag('->setBoost(), ->getBoost()'); $field = new xfField('foobar', xfField::KEYWORD); $t->is($field->getBoost(), 1.0, '->getBoost() is 1.0 initially'); $field->setBoost(M_PI); $t->is($field->getBoost(), M_PI, '->setBoost() changes the boost'); $field->setBoost('42foobar'); $t->is($field->getBoost(), 42, '->setBoost() casts the input to a float');