Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
BatchSizeCalculatorTest.php
Go to the documentation of this file.
1 <?php
8 
9 class BatchSizeCalculatorTest extends \PHPUnit\Framework\TestCase
10 {
14  private $model;
15 
19  private $estimatorMock;
20 
24  private $batchRowsCount;
25 
26  protected function setUp()
27  {
28  $this->estimatorMock = $this->createMock(\Magento\Framework\Indexer\BatchSizeManagementInterface::class);
29  $this->batchRowsCount = 200;
30  $this->model = new \Magento\Catalog\Model\ResourceModel\Product\Indexer\Price\BatchSizeCalculator(
31  ['default' => $this->batchRowsCount],
32  ['default' => $this->estimatorMock],
33  []
34  );
35  }
36 
37  public function testEstimateBatchSize()
38  {
39  $connectionMock = $this->createMock(\Magento\Framework\DB\Adapter\AdapterInterface::class);
40  $typeId = 'default';
41  $batchSize = 100500;
42 
43  $this->estimatorMock->expects($this->once())
44  ->method('ensureBatchSize')
45  ->with($connectionMock, $this->batchRowsCount)
46  ->willReturn($batchSize);
47 
48  $this->model->estimateBatchSize($connectionMock, $typeId);
49  }
50 }