/** * @return AbstractAttribute[]|\PHPUnit_Framework_MockObject_MockObject[] */ protected function getAttributeMock() { $attributeMock = $this->getMockBuilder('Magento\\Eav\\Model\\Entity\\Attribute\\AbstractAttribute')->setMethods(['getAttributeCode', 'getDataUsingMethod', 'usesSource', 'getSource'])->disableOriginalConstructor()->getMockForAbstractClass(); $sourceMock = $this->getMockBuilder('Magento\\Eav\\Model\\Entity\\Attribute\\Source\\AbstractSource')->disableOriginalConstructor()->getMockForAbstractClass(); $sourceMock->expects($this->any())->method('getAllOptions')->willReturn(self::OPTIONS_RESULT); $attributeMock->expects($this->once())->method('getAttributeCode')->willReturn(self::ATTRIBUTE_CODE); $attributeMock->expects($this->any())->method('getDataUsingMethod')->willReturnCallback(function ($origName) { return $origName; }); $attributeMock->expects($this->any())->method('usesSource')->willReturn(true); $attributeMock->expects($this->any())->method('getSource')->willReturn($sourceMock); $this->eavValidationRulesMock->expects($this->any())->method('build')->with($attributeMock, $this->logicalNot($this->isEmpty())); return [$attributeMock]; }