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)); }
/** * @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); }
/** * @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); }
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'); }
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(); }