public function testExecute() { $this->requestMock->expects($this->any())->method('getParam')->willReturnMap([['frontend_label', null, 'test_frontend_label'], ['attribute_code', null, 'test_attribute_code'], ['new_attribute_set_name', null, 'test_attribute_set_name']]); $this->objectManagerMock->expects($this->exactly(2))->method('create')->willReturnMap([['Magento\\Catalog\\Model\\ResourceModel\\Eav\\Attribute', [], $this->attributeMock], ['Magento\\Eav\\Model\\Entity\\Attribute\\Set', [], $this->attributeSetMock]]); $this->attributeMock->expects($this->once())->method('loadByCode')->willReturnSelf(); $this->requestMock->expects($this->once())->method('has')->with('new_attribute_set_name')->willReturn(true); $this->attributeSetMock->expects($this->once())->method('setEntityTypeId')->willReturnSelf(); $this->attributeSetMock->expects($this->once())->method('load')->willReturnSelf(); $this->attributeSetMock->expects($this->once())->method('getId')->willReturn(false); $this->resultJsonFactoryMock->expects($this->once())->method('create')->willReturn($this->resultJson); $this->resultJson->expects($this->once())->method('setJsonData')->willReturnSelf(); $this->assertInstanceOf(ResultJson::class, $this->getModel()->execute()); }