attributeResolverMock = $this->getMockBuilder(AttributeResolver::class) ->disableOriginalConstructor() ->getMock(); $this->model = new AddressMetadataManagement( $this->attributeResolverMock ); } public function testCanBeSearchableInGrid() { /** @var AttributeMetadataInterface|MockObject $attributeMock */ $attributeMock = $this->getMockBuilder(AttributeMetadataInterface::class) ->getMockForAbstractClass(); /** @var Attribute|MockObject $modelMock */ $modelMock = $this->getMockBuilder(Attribute::class) ->disableOriginalConstructor() ->getMock(); $this->attributeResolverMock->expects($this->once()) ->method('getModelByAttribute') ->with(AddressMetadataManagementInterface::ENTITY_TYPE_ADDRESS, $attributeMock) ->willReturn($modelMock); $modelMock->expects($this->once()) ->method('canBeSearchableInGrid') ->willReturn(true); $this->assertTrue($this->model->canBeSearchableInGrid($attributeMock)); } public function testCanBeFilterableInGrid() { /** @var AttributeMetadataInterface|MockObject $attributeMock */ $attributeMock = $this->getMockBuilder(AttributeMetadataInterface::class) ->getMockForAbstractClass(); /** @var Attribute|MockObject $modelMock */ $modelMock = $this->getMockBuilder(Attribute::class) ->disableOriginalConstructor() ->getMock(); $this->attributeResolverMock->expects($this->once()) ->method('getModelByAttribute') ->with(AddressMetadataManagementInterface::ENTITY_TYPE_ADDRESS, $attributeMock) ->willReturn($modelMock); $modelMock->expects($this->once()) ->method('canBeFilterableInGrid') ->willReturn(true); $this->assertTrue($this->model->canBeFilterableInGrid($attributeMock)); } }