當前位置: 首頁>>代碼示例>>PHP>>正文


PHP RequiredFields::removeRequiredField方法代碼示例

本文整理匯總了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");
 }
開發者ID:ivoba,項目名稱:silverstripe-framework,代碼行數:25,代碼來源:RequiredFieldsTest.php


注:本文中的RequiredFields::removeRequiredField方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。