本文整理匯總了PHP中Magento\Framework\Data\Form::setValues方法的典型用法代碼示例。如果您正苦於以下問題:PHP Form::setValues方法的具體用法?PHP Form::setValues怎麽用?PHP Form::setValues使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Magento\Framework\Data\Form
的用法示例。
在下文中一共展示了Form::setValues方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: testSetValue
/**
* @param int $number
* @param string $elementId
* @param string|null $value
*
* @dataProvider setValueDataProvider
*/
public function testSetValue($number, $elementId, $value)
{
$this->_factoryCollectionMock->expects($this->once())->method('create')->will($this->returnValue(array($this->elementMock)));
$this->_form = new Form($this->_factoryElementMock, $this->_factoryCollectionMock, $this->_formKeyMock);
$values = ['element_two' => 'value_two'];
$this->elementMock->expects($this->exactly($number))->method('getId')->will($this->returnValue($elementId));
$this->elementMock->expects($this->once())->method('setValue')->with($value);
$this->_form->setValues($values);
}
示例2: testElementOperations
public function testElementOperations()
{
$buttonElement = $this->getMockBuilder('Magento\\Framework\\Data\\Form\\Element\\Button')->disableOriginalConstructor()->getMock();
$buttonElement->expects($this->any())->method('getId')->will($this->returnValue('1'));
$buttonElement->expects($this->any())->method('getName')->will($this->returnValue('Hero'));
$this->_form->addElement($buttonElement);
$this->_form->addElementToCollection($buttonElement);
$this->_form->addValues(['1', '2', '3']);
$this->_form->setValues(['4', '5', '6']);
$this->_form->addFieldNameSuffix('abc123');
$this->_form->removeField($buttonElement->getId());
$this->assertSame($this->_form->checkElementId($buttonElement->getId()), true);
}