/** * @expectedException \Magento\Framework\Exception\InputException */ public function testCreateInvalidInput() { $dataMock = $this->getMock('\\Magento\\Catalog\\Service\\V1\\Data\\Eav\\AttributeMetadata', [], [], '', false); $dataMock->expects($this->at(0))->method('__toArray')->will($this->returnValue(array())); $dataMock->expects($this->at(1))->method('getFrontendLabel')->will($this->returnValue([$this->frontendLabelMock])); $dataMock->expects($this->at(2))->method('getFrontendLabel')->will($this->returnValue([$this->frontendLabelMock])); $dataMock->expects($this->at(3))->method('getAttributeCode')->will($this->returnValue('code_111')); $dataMock->expects($this->at(4))->method('getFrontendInput')->will($this->returnValue('textarea')); $this->inputValidator->expects($this->at(0))->method('isValid')->will($this->returnValue(false)); $this->attributeWriteService->create($dataMock); }
public function testExecute() { $data = ['new_attribute_set_name' => 'Test attribute set name', 'frontend_input' => 'test_frontend_input']; $this->requestMock->expects($this->once())->method('getPostValue')->willReturn($data); $this->resultFactoryMock->expects($this->once())->method('create')->willReturn($this->redirectMock); $this->redirectMock->expects($this->any())->method('setPath')->willReturnSelf(); $this->builderMock->expects($this->once())->method('setEntityTypeId')->willReturnSelf(); $this->builderMock->expects($this->once())->method('setSkeletonId')->willReturnSelf(); $this->builderMock->expects($this->once())->method('setName')->willReturnSelf(); $this->builderMock->expects($this->once())->method('getAttributeSet')->willReturn($this->attributeSetMock); $this->requestMock->expects($this->any())->method('getParam')->willReturnMap([['set', null, 1], ['attribute_code', null, 'test_attribute_code']]); $this->inputTypeValidatorMock->expects($this->once())->method('getMessages')->willReturn([]); $this->assertInstanceOf(ResultRedirect::class, $this->getModel()->execute()); }
public function testAddInputType() { $this->model->addInputType('new_type'); $this->assertEquals(['type', 'new_type'], $this->model->getHaystack()); }