本文整理汇总了PHP中Field::setOptions方法的典型用法代码示例。如果您正苦于以下问题:PHP Field::setOptions方法的具体用法?PHP Field::setOptions怎么用?PHP Field::setOptions使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Field
的用法示例。
在下文中一共展示了Field::setOptions方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testSettersAndGettersDoWhatTheyShould
public function testSettersAndGettersDoWhatTheyShould()
{
$field = new Field('type', 'element', 'label', 'description');
$field->setOptions(['options' => 'options']);
$field->setValidationRules('rules');
$field->setValue('foo');
$expectations = ['getOptions' => ['options' => 'options'], 'getValidationRules' => 'rules', 'getValue' => 'foo'];
foreach ($expectations as $method => $value) {
static::assertEquals($field->{$method}(), $value);
}
}
示例2: testSetOptionsException
/**
* Test setOptions exception
*
* @expectedException \InvalidArgumentException
* @expectedExceptionMessage Invalid option
*/
public function testSetOptionsException()
{
$object = new Field('PAGE');
$object->setOptions(array('foo' => 'bar'));
}
示例3: testAdminCheckbox
/**
* Unit Test case-9 to test Check Boxes
*/
public function testAdminCheckbox()
{
$test = new Field(6);
$test->setType("checkbox");
$test->setIsRequired(true);
$test->setTextBefore("CHECK BOX!");
$test->setOptions("option1|-etm-|option2|-etm-|option3");
$html = $test->getAdminHtml();
/**
* test to see the textbeforechanges
*/
preg_match_all('/CHECK BOX!/', $html, $matches);
$this->assertEquals(2, count($matches[0]));
/**
* test to see we see the id 6
*/
preg_match_all('/etm_element_(\\d+)/', $html, $matches);
$this->assertEquals(6, $matches[1][0]);
/**
* test to see we see input types of type select
*/
preg_match_all('/<input type=\'checkbox\'/', $html, $matches);
$this->assertEquals(3, count($matches[0]));
}