本文整理匯總了PHP中RequiredFields::removeRequiredField方法的典型用法代碼示例。如果您正苦於以下問題:PHP RequiredFields::removeRequiredField方法的具體用法?PHP RequiredFields::removeRequiredField怎麽用?PHP RequiredFields::removeRequiredField使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類RequiredFields
的用法示例。
在下文中一共展示了RequiredFields::removeRequiredField方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: testAddRequiredField
public function testAddRequiredField()
{
//set up the validator
$requiredFields = new RequiredFields('Title');
//add a field
$requiredFields->addRequiredField('Content');
//check it was added
$this->assertEquals(array('Title', 'Content'), $requiredFields->getRequired(), "Failed to add a new field to the required list");
//add another for good measure
$requiredFields->addRequiredField('Image');
//check it was added
$this->assertEquals(array('Title', 'Content', 'Image'), $requiredFields->getRequired(), "Failed to add a second new field to the required list");
//remove a field
$requiredFields->removeRequiredField('Title');
//check it was removed
$this->assertEquals(array('Content', 'Image'), $requiredFields->getRequired(), "Failed to remove 'Title' field from required list");
//add the same field back to check we can add and remove at will
$requiredFields->addRequiredField('Title');
//check it's in there
$this->assertEquals(array('Content', 'Image', 'Title'), $requiredFields->getRequired(), "Failed to add 'Title' back to the required field list");
//add a field that already exists (we can't have the same field twice, can we?)
$requiredFields->addRequiredField('Content');
//check the field wasn't added
$this->assertEquals(array('Content', 'Image', 'Title'), $requiredFields->getRequired(), "Adding a duplicate field to required field list had unexpected behaviour");
}