initAttributeValueFactoryMock(); $this->groupRepository = $this->getMockForAbstractClass(GroupRepositoryInterface::class); $this->document = new Document($this->attributeValueFactory, $this->groupRepository); } /** * @covers \Magento\Sales\Ui\Component\DataProvider\Document::getCustomAttribute */ public function testGetStateAttribute() { $this->document->setData('state', Invoice::STATE_PAID); $this->groupRepository->expects(static::never()) ->method('getById'); $attribute = $this->document->getCustomAttribute('state'); static::assertEquals('Paid', $attribute->getValue()); } /** * @covers \Magento\Sales\Ui\Component\DataProvider\Document::getCustomAttribute */ public function testGetCustomerGroupAttribute() { $this->document->setData('customer_group_id', 1); $group = $this->getMockForAbstractClass(GroupInterface::class); $this->groupRepository->expects(static::once()) ->method('getById') ->willReturn($group); $group->expects(static::once()) ->method('getCode') ->willReturn('General'); $attribute = $this->document->getCustomAttribute('customer_group_id'); static::assertEquals('General', $attribute->getValue()); } /** * Create mock for attribute value factory * @return void */ private function initAttributeValueFactoryMock() { $this->attributeValueFactory = $this->getMockBuilder(AttributeValueFactory::class) ->disableOriginalConstructor() ->setMethods(['create']) ->getMock(); $attributeValue = new AttributeValue(); $this->attributeValueFactory->expects(static::once()) ->method('create') ->willReturn($attributeValue); } }