Skip to content

Commit 210264d

Browse files
committed
MC-33069: Stabilize Unit tests
1 parent 031c7fd commit 210264d

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

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

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,19 @@ public function testCurrent()
9797
$this->selectMock->expects($this->once())->method('where')->with($filed . ' > ?', 0);
9898
$this->selectMock->expects($this->once())->method('limit')->with($this->batchSize);
9999
$this->selectMock->expects($this->once())->method('order')->with($filed . ' ASC');
100+
$this->wrapperSelectMock->expects($this->once())
101+
->method('from')
102+
->with(
103+
$this->selectMock,
104+
[
105+
new \Zend_Db_Expr('MAX(' . $this->rangeFieldAlias . ') as max'),
106+
new \Zend_Db_Expr('COUNT(*) as cnt'),
107+
]
108+
);
109+
$this->connectionMock->expects($this->once())
110+
->method('fetchRow')
111+
->with($this->wrapperSelectMock)
112+
->willReturn(['max' => 10, 'cnt' => 10]);
100113
$this->assertEquals($this->selectMock, $this->model->current());
101114
$this->assertEquals($this->selectMock, $this->model->current());
102115
$this->assertEquals(0, $this->model->key());

lib/internal/Magento/Framework/Test/Unit/DB/Query/BatchRangeIteratorTest.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,16 @@ public function testCurrent()
9999
{
100100
$this->selectMock->expects($this->once())->method('limit')->with($this->batchSize, $this->currentBatch);
101101
$this->selectMock->expects($this->once())->method('order')->with('correlationName.rangeField' . ' ASC');
102+
$this->wrapperSelectMock->expects($this->once())
103+
->method('from')
104+
->with(
105+
$this->selectMock,
106+
[new \Zend_Db_Expr('COUNT(*) as cnt')]
107+
);
108+
$this->connectionMock->expects($this->once())
109+
->method('fetchRow')
110+
->with($this->wrapperSelectMock)
111+
->willReturn(['cnt' => 10]);
102112
$this->assertEquals($this->selectMock, $this->model->current());
103113
$this->assertEquals(0, $this->model->key());
104114
}

0 commit comments

Comments
 (0)