Skip to content

Commit a65e7da

Browse files
author
Oleksii Korshenko
committed
MAGETWO-55589: Wrong algorithm for calculation batch size on category indexing
- fixed static tests
1 parent 92e4efa commit a65e7da

File tree

2 files changed

+45
-7
lines changed

2 files changed

+45
-7
lines changed

lib/internal/Magento/Framework/Test/DB/Query/BatchIteratorTest.php renamed to lib/internal/Magento/Framework/Test/Unit/DB/Query/BatchIteratorTest.php

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,31 @@ class BatchIteratorTest extends \PHPUnit_Framework_TestCase
3131
*/
3232
private $connectionMock;
3333

34+
/**
35+
* @var int
36+
*/
3437
private $batchSize;
38+
39+
/**
40+
* @var string
41+
*/
3542
private $correlationName;
43+
44+
/**
45+
* @var string
46+
*/
3647
private $rangeField;
48+
49+
/**
50+
* @var string
51+
*/
3752
private $rangeFieldAlias;
3853

54+
/**
55+
* Setup test dependencies.
56+
*
57+
* @return void
58+
*/
3959
protected function setUp()
4060
{
4161
$this->batchSize = 10;
@@ -64,6 +84,7 @@ protected function setUp()
6484
* 1. $iterator->current();
6585
* 2. $iterator->current();
6686
* 3. $iterator->key();
87+
* @return void
6788
*/
6889
public function testCurrent()
6990
{
@@ -103,7 +124,7 @@ public function testCurrent()
103124
*
104125
* 1. $iterator->next()
105126
* 2. $iterator->valid();
106-
*
127+
* @return void
107128
*/
108129
public function testIterations()
109130
{
@@ -147,6 +168,7 @@ public function testIterations()
147168
* 3. $iterator->next();
148169
* 4. $iterator->current()
149170
* 5. $iterator->key()
171+
* @return void
150172
*/
151173
public function testNext()
152174
{
@@ -166,10 +188,7 @@ public function testNext()
166188
$this->connectionMock->expects($this->exactly(3))
167189
->method('fetchRow')
168190
->with($this->wrapperSelectMock)
169-
->willReturn([
170-
'max' => 25,
171-
'cnt' => 10
172-
]
191+
->willReturn(['max' => 25, 'cnt' => 10]
173192
);
174193

175194
$this->assertEquals($this->selectMock, $this->model->next());

lib/internal/Magento/Framework/Test/DB/Query/GeneratorTest.php renamed to lib/internal/Magento/Framework/Test/Unit/DB/Query/GeneratorTest.php

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@ class GeneratorTest extends \PHPUnit_Framework_TestCase
3232
*/
3333
private $iteratorMock;
3434

35+
/**
36+
* Setup test dependencies.
37+
*/
3538
protected function setUp()
3639
{
3740
$this->factoryMock = $this->getMock(BatchIteratorFactory::class, [], [], '', false, false);
@@ -40,6 +43,10 @@ protected function setUp()
4043
$this->model = new Generator($this->factoryMock);
4144
}
4245

46+
/**
47+
* Test success generate.
48+
* @return void
49+
*/
4350
public function testGenerate()
4451
{
4552
$map = [
@@ -70,8 +77,11 @@ public function testGenerate()
7077
}
7178

7279
/**
80+
* Test batch generation with invalid select object.
81+
*
7382
* @expectedException \Magento\Framework\Exception\LocalizedException
7483
* @expectedExceptionMessage Select object must have correct "FROM" part
84+
* @return void
7585
*/
7686
public function testGenerateWithoutFromPart()
7787
{
@@ -89,7 +99,11 @@ public function testGenerateWithoutFromPart()
8999
$this->model->generate('entity_id', $this->selectMock, 100);
90100
}
91101

92-
public function testGenerateWithInvalidRangeField()
102+
/**
103+
* Test generate batches with rangeField without alias.
104+
* @return void
105+
*/
106+
public function testGenerateWithRangeFieldWithoutAlias()
93107
{
94108
$map = [
95109
[
@@ -118,7 +132,12 @@ public function testGenerateWithInvalidRangeField()
118132
$this->assertEquals($this->iteratorMock, $this->model->generate('entity_id', $this->selectMock, 100));
119133
}
120134

121-
public function testGenerateWithInvalidRangeFieldValue()
135+
/**
136+
* Test generate batches with wild-card.
137+
*
138+
* @return void
139+
*/
140+
public function testGenerateWithInvalidWithWildcard()
122141
{
123142
$map = [
124143
[

0 commit comments

Comments
 (0)