Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
AddressMetadataManagementTest.php
Go to the documentation of this file.
1 <?php
7 
12 
13 class AddressMetadataManagementTest extends \PHPUnit\Framework\TestCase
14 {
16  protected $model;
17 
20 
21  protected function setUp()
22  {
23  $this->attributeResolverMock = $this->getMockBuilder(\Magento\Customer\Model\Metadata\AttributeResolver::class)
24  ->disableOriginalConstructor()
25  ->getMock();
26 
27  $this->model = new AddressMetadataManagement(
28  $this->attributeResolverMock
29  );
30  }
31 
32  public function testCanBeSearchableInGrid()
33  {
35  $attributeMock = $this->getMockBuilder(\Magento\Customer\Api\Data\AttributeMetadataInterface::class)
36  ->getMockForAbstractClass();
37 
39  $modelMock = $this->getMockBuilder(\Magento\Customer\Model\Attribute::class)
40  ->disableOriginalConstructor()
41  ->getMock();
42 
43  $this->attributeResolverMock->expects($this->once())
44  ->method('getModelByAttribute')
46  ->willReturn($modelMock);
47 
48  $modelMock->expects($this->once())
49  ->method('canBeSearchableInGrid')
50  ->willReturn(true);
51 
52  $this->assertTrue($this->model->canBeSearchableInGrid($attributeMock));
53  }
54 
55  public function testCanBeFilterableInGrid()
56  {
58  $attributeMock = $this->getMockBuilder(\Magento\Customer\Api\Data\AttributeMetadataInterface::class)
59  ->getMockForAbstractClass();
60 
62  $modelMock = $this->getMockBuilder(\Magento\Customer\Model\Attribute::class)
63  ->disableOriginalConstructor()
64  ->getMock();
65 
66  $this->attributeResolverMock->expects($this->once())
67  ->method('getModelByAttribute')
69  ->willReturn($modelMock);
70 
71  $modelMock->expects($this->once())
72  ->method('canBeFilterableInGrid')
73  ->willReturn(true);
74 
75  $this->assertTrue($this->model->canBeFilterableInGrid($attributeMock));
76  }
77 }