Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
DecimalRowSizeEstimatorTest.php
Go to the documentation of this file.
1 <?php
8 
17 
18 class DecimalRowSizeEstimatorTest extends \PHPUnit\Framework\TestCase
19 {
23  private $model;
24 
28  private $indexerResourceMock;
29 
33  private $storeManagementMock;
34 
38  private $metadataPoolMock;
39 
43  private $connectionMock;
44 
45  protected function setUp()
46  {
47  $this->connectionMock = $this->createMock(AdapterInterface::class);
48  $this->indexerResourceMock = $this->createMock(Decimal::class);
49  $this->indexerResourceMock->expects($this->any())->method('getConnection')->willReturn($this->connectionMock);
50  $this->storeManagementMock = $this->createMock(StoreManagementInterface::class);
51  $this->metadataPoolMock = $this->createMock(MetadataPool::class);
52 
53  $this->model = new DecimalRowSizeEstimator(
54  $this->storeManagementMock,
55  $this->indexerResourceMock,
56  $this->metadataPoolMock
57  );
58  }
59 
60  public function testEstimateRowSize()
61  {
62  $entityMetadataMock = $this->createMock(EntityMetadataInterface::class);
63  $this->metadataPoolMock->expects($this->any())
64  ->method('getMetadata')
65  ->with(ProductInterface::class)
66  ->willReturn($entityMetadataMock);
67 
68  $selectMock = $this->createMock(Select::class);
69 
70  $maxRowsPerStore = 100;
71  $storeCount = 10;
72  $this->connectionMock->expects($this->any())->method('select')->willReturn($selectMock);
73  $this->connectionMock->expects($this->once())->method('fetchOne')->willReturn($maxRowsPerStore);
74  $this->storeManagementMock->expects($this->any())->method('getCount')->willReturn($storeCount);
75 
76  $this->assertEquals($maxRowsPerStore * $storeCount * 500, $this->model->estimateRowSize());
77  }
78 }