本文整理汇总了PHP中RequiredFields::fieldIsRequired方法的典型用法代码示例。如果您正苦于以下问题:PHP RequiredFields::fieldIsRequired方法的具体用法?PHP RequiredFields::fieldIsRequired怎么用?PHP RequiredFields::fieldIsRequired使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类RequiredFields
的用法示例。
在下文中一共展示了RequiredFields::fieldIsRequired方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testFieldIsRequired
public function testFieldIsRequired()
{
//get the validator
$requiredFields = new RequiredFields($fieldNames = array('Title', 'Content', 'Image', 'AnotherField'));
foreach ($fieldNames as $field) {
$this->assertTrue($requiredFields->fieldIsRequired($field), sprintf("Failed to find '%s' field in required list", $field));
}
//add a new field
$requiredFields->addRequiredField('ExtraField1');
//check the new field is required
$this->assertTrue($requiredFields->fieldIsRequired('ExtraField1'), "Failed to find 'ExtraField1' field in required list after adding it to the list");
//check a non-existant field returns false
$this->assertFalse($requiredFields->fieldIsRequired('DoesntExist'), "Unexpectedly returned true for a non-existant field");
}