Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
BatchTest.php
Go to the documentation of this file.
1 <?php
7 
8 class BatchTest extends \PHPUnit\Framework\TestCase
9 {
13  private $object;
14 
15  protected function setUp()
16  {
17  $this->object = new \Magento\Framework\Indexer\SaveHandler\Batch();
18  }
19 
27  public function testGetItems(array $itemsData, $size, array $expected)
28  {
29  $items = new \ArrayObject($itemsData);
30  $data = $this->object->getItems($items, $size);
31  $this->assertSame($expected, iterator_to_array($data));
32  }
33 
37  public function getItemsDataProvider()
38  {
39  return [
40  'empty' => [
41  [],
42  2,
43  [],
44  ],
45  'even, numeric keys' => [
46  [1, 2, 3, 4],
47  2,
48  [
49  [0 => 1, 1 => 2],
50  [2 => 3, 3 => 4],
51  ],
52  ],
53  'odd, numeric keys' => [
54  [1, 2, 3, 4, 5],
55  2,
56  [
57  [0 => 1, 1 => 2],
58  [2 => 3, 3 => 4],
59  [4 => 5],
60  ],
61  ],
62  'even, string keys' => [
63  ['a' => 1, 'b' => 2, 'c' => 3, 'd' => 4],
64  2,
65  [
66  ['a' => 1, 'b' => 2],
67  ['c' => 3, 'd' => 4],
68  ],
69  ],
70  'odd, string keys' => [
71  ['a' => 1, 'b' => 2, 'c' => 3, 'd' => 4, 'e' => 5],
72  2,
73  [
74  ['a' => 1, 'b' => 2],
75  ['c' => 3, 'd' => 4],
76  ['e' => 5],
77  ],
78  ],
79  ];
80  }
81 }
testGetItems(array $itemsData, $size, array $expected)
Definition: BatchTest.php:27
$items