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


PHP Form::expects方法代碼示例

本文整理匯總了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));
 }
開發者ID:Doability,項目名稱:magento2dev,代碼行數:8,代碼來源:GalleryTest.php

示例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);
 }
開發者ID:Doability,項目名稱:magento2dev,代碼行數:13,代碼來源:AddFieldsToAttributeObserverTest.php

示例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);
 }
開發者ID:kidaa30,項目名稱:magento2-platformsh,代碼行數:14,代碼來源:PropertyLockerTest.php

示例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');
 }
開發者ID:BlackIkeEagle,項目名稱:magento2-continuousphp,代碼行數:11,代碼來源:WysiwygTest.php

示例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();
 }
開發者ID:shabbirvividads,項目名稱:magento2,代碼行數:13,代碼來源:FormTest.php


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