本文整理汇总了PHP中Magento\Framework\Data\Form::expects方法的典型用法代码示例。如果您正苦于以下问题:PHP Form::expects方法的具体用法?PHP Form::expects怎么用?PHP Form::expects使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Magento\Framework\Data\Form
的用法示例。
在下文中一共展示了Form::expects方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testGetAttributeFieldName
public function testGetAttributeFieldName()
{
$name = 'product[image]';
$attribute = $this->getMock('Magento\\Catalog\\Model\\ResourceModel\\Eav\\Attribute', [], [], '', false);
$attribute->expects($this->once())->method('getAttributeCode')->willReturn('image');
$this->formMock->expects($this->once())->method('addSuffixToName')->willReturn($name);
$this->assertSame($name, $this->gallery->getAttributeFieldName($attribute));
}
示例2: testAddFields
/**
* @dataProvider dataAddFields
*/
public function testAddFields($expected)
{
$this->moduleManagerMock->expects($this->once())->method('isOutputEnabled')->willReturn($expected['isOutputEnabled']);
$this->eventObserverMock->expects($this->exactly($expected['methods_count']))->method('getForm')->willReturn($this->formMock);
$element = $this->getMock('Magento\\Framework\\Data\\Form\\Element\\AbstractElement', [], [], '', false);
$this->formMock->expects($this->exactly($expected['methods_count']))->method('getElement')->with('base_fieldset')->willReturn($element);
$element->expects($this->exactly($expected['addField_count']))->method('addField');
$this->yesNoMock->expects($this->exactly($expected['yesno_count']))->method('toOptionArray');
$this->observerMock->execute($this->eventObserverMock);
}
示例3: testLock
/**
* @covers \Magento\Eav\Block\Adminhtml\Attribute\PropertyLocker::lock
*/
public function testLock()
{
$lockedFields = ['is_searchable' => 'is_searchable', 'is_filterable' => 'is_filterable'];
$this->attributeMock->expects($this->once())->method('getId')->willReturn(1);
$this->attributeConfigMock->expects($this->once())->method('getLockedFields')->willReturn($lockedFields);
$elementMock = $this->getMockBuilder('\\Magento\\Framework\\Data\\Form\\Element\\AbstractElement')->setMethods(['setDisabled', 'setReadonly'])->disableOriginalConstructor()->getMockForAbstractClass();
$elementMock->expects($this->exactly(2))->method('setDisabled');
$elementMock->expects($this->exactly(2))->method('setReadonly');
$this->formMock->expects($this->exactly(2))->method('getElement')->willReturn($elementMock);
$this->object->lock($this->formMock);
}
示例4: setUp
protected function setUp()
{
parent::setUp();
$this->formFactoryMock = $this->getMockBuilder(FormFactory::class)->disableOriginalConstructor()->setMethods(['create'])->getMock();
$this->formMock = $this->getMockBuilder(Form::class)->disableOriginalConstructor()->getMock();
$this->wysiwygConfig = $this->getMockBuilder(ConfigInterface::class)->getMockForAbstractClass();
$this->editorMock = $this->getMockBuilder(Editor::class)->disableOriginalConstructor()->getMock();
$this->formFactoryMock->expects($this->any())->method('create')->willReturn($this->formMock);
$this->formMock->expects($this->once())->method('addField')->willReturn($this->editorMock);
$this->editorMock->expects($this->once())->method('getElementHtml');
}
示例5: testToHtmlCoreRegistryRatingData
public function testToHtmlCoreRegistryRatingData()
{
$this->registry->expects($this->any())->method('registry')->will($this->returnValue($this->rating));
$this->form->expects($this->at(7))->method('getElement')->will($this->returnValue($this->element));
$this->form->expects($this->at(13))->method('getElement')->will($this->returnValue($this->element));
$this->form->expects($this->at(16))->method('getElement')->will($this->returnValue($this->element));
$this->form->expects($this->at(17))->method('getElement')->will($this->returnValue($this->element));
$this->form->expects($this->any())->method('getElement')->will($this->returnValue(false));
$this->session->expects($this->any())->method('getRatingData')->will($this->returnValue(false));
$ratingCodes = ['rating_codes' => ['0' => 'rating_code']];
$this->rating->expects($this->any())->method('getRatingCodes')->will($this->returnValue($ratingCodes));
$this->block->toHtml();
}