Example #1
0
 public function testAddValue()
 {
     $this->_factoryCollectionMock->expects($this->once())->method('create')->will($this->returnValue($this->allElementsMock));
     $this->_form = new Form($this->_factoryElementMock, $this->_factoryCollectionMock, $this->_formKeyMock);
     $values = ['element_id' => 'value_one'];
     $this->elementMock->expects($this->once())->method('getId')->will($this->returnValue('element_id'));
     $this->allElementsMock->expects($this->once())->method('add')->with($this->elementMock);
     $this->elementMock->expects($this->once())->method('setValue')->with('value_one');
     $this->_form->addElementToCollection($this->elementMock);
     $this->_form->addValues($values);
 }
Example #2
0
 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);
 }