@@ -89,10 +89,6 @@ public function testGenerateWithoutFromPart()
89
89
$ this ->model ->generate ('entity_id ' , $ this ->selectMock , 100 );
90
90
}
91
91
92
- /**
93
- * @expectedException \Magento\Framework\Exception\LocalizedException
94
- * @expectedExceptionMessage Select object must have correct range field name "entity_id"
95
- */
96
92
public function testGenerateWithInvalidRangeField ()
97
93
{
98
94
$ map = [
@@ -105,19 +101,23 @@ public function testGenerateWithInvalidRangeField()
105
101
[
106
102
Select::COLUMNS ,
107
103
[
108
- ['cp ' , 'row_id ' , ' product_id ' ]
104
+ ['cp ' , 'entity_id ' , null ]
109
105
]
110
106
]
111
107
];
112
108
$ this ->selectMock ->expects ($ this ->exactly (2 ))->method ('getPart ' )->willReturnMap ($ map );
113
- $ this ->factoryMock ->expects ($ this ->never ())->method ('create ' );
114
- $ this ->model ->generate ('entity_id ' , $ this ->selectMock , 100 );
109
+ $ this ->factoryMock ->expects ($ this ->once ())->method ('create ' )->with (
110
+ [
111
+ 'select ' => $ this ->selectMock ,
112
+ 'batchSize ' => 100 ,
113
+ 'correlationName ' => 'cp ' ,
114
+ 'rangeField ' => 'entity_id ' ,
115
+ 'rangeFieldAlias ' => 'entity_id '
116
+ ]
117
+ )->willReturn ($ this ->iteratorMock );
118
+ $ this ->assertEquals ($ this ->iteratorMock , $ this ->model ->generate ('entity_id ' , $ this ->selectMock , 100 ));
115
119
}
116
120
117
- /**
118
- * @expectedException \Magento\Framework\Exception\LocalizedException
119
- * @expectedExceptionMessage Select object must have correct range field name "entity_id"
120
- */
121
121
public function testGenerateWithInvalidRangeFieldValue ()
122
122
{
123
123
$ map = [
@@ -130,12 +130,20 @@ public function testGenerateWithInvalidRangeFieldValue()
130
130
[
131
131
Select::COLUMNS ,
132
132
[
133
- ['cp ' , new \ Zend_Db_Expr ( ' MAX(entity_id) as max ' ), ' product_id ' ]
133
+ ['cp ' , ' * ' , null ]
134
134
]
135
135
]
136
136
];
137
137
$ this ->selectMock ->expects ($ this ->exactly (2 ))->method ('getPart ' )->willReturnMap ($ map );
138
- $ this ->factoryMock ->expects ($ this ->never ())->method ('create ' );
139
- $ this ->model ->generate ('entity_id ' , $ this ->selectMock , 100 );
138
+ $ this ->factoryMock ->expects ($ this ->once ())->method ('create ' )->with (
139
+ [
140
+ 'select ' => $ this ->selectMock ,
141
+ 'batchSize ' => 100 ,
142
+ 'correlationName ' => 'cp ' ,
143
+ 'rangeField ' => 'entity_id ' ,
144
+ 'rangeFieldAlias ' => 'entity_id '
145
+ ]
146
+ )->willReturn ($ this ->iteratorMock );
147
+ $ this ->assertEquals ($ this ->iteratorMock , $ this ->model ->generate ('entity_id ' , $ this ->selectMock , 100 ));
140
148
}
141
149
}
0 commit comments