| @@ 155-186 (lines=32) @@ | ||
| 152 | * |
|
| 153 | * @return \eZ\Publish\Core\Persistence\Legacy\Content\Mapper |
|
| 154 | */ |
|
| 155 | protected function getContentMapperMock() |
|
| 156 | { |
|
| 157 | $mapperMock = $this->getMock( |
|
| 158 | 'eZ\\Publish\\Core\\Persistence\\Legacy\\Content\\Mapper', |
|
| 159 | array('extractContentInfoFromRows'), |
|
| 160 | array( |
|
| 161 | $this->getFieldRegistry(), |
|
| 162 | $this->getLanguageHandler(), |
|
| 163 | ) |
|
| 164 | ); |
|
| 165 | $mapperMock->expects($this->any()) |
|
| 166 | ->method('extractContentInfoFromRows') |
|
| 167 | ->with($this->isType('array')) |
|
| 168 | ->will( |
|
| 169 | $this->returnCallback( |
|
| 170 | function ($rows) { |
|
| 171 | $contentInfoObjs = array(); |
|
| 172 | foreach ($rows as $row) { |
|
| 173 | $contentId = (int)$row['id']; |
|
| 174 | if (!isset($contentInfoObjs[$contentId])) { |
|
| 175 | $contentInfoObjs[$contentId] = new ContentInfo(); |
|
| 176 | $contentInfoObjs[$contentId]->id = $contentId; |
|
| 177 | } |
|
| 178 | } |
|
| 179 | ||
| 180 | return array_values($contentInfoObjs); |
|
| 181 | } |
|
| 182 | ) |
|
| 183 | ); |
|
| 184 | ||
| 185 | return $mapperMock; |
|
| 186 | } |
|
| 187 | ||
| 188 | /** |
|
| 189 | * Returns a field registry mock object. |
|
| @@ 277-308 (lines=32) @@ | ||
| 274 | * |
|
| 275 | * @return \eZ\Publish\Core\Persistence\Legacy\Content\Mapper |
|
| 276 | */ |
|
| 277 | protected function getContentMapperMock() |
|
| 278 | { |
|
| 279 | $mapperMock = $this->getMock( |
|
| 280 | 'eZ\\Publish\\Core\\Persistence\\Legacy\\Content\\Mapper', |
|
| 281 | array('extractContentInfoFromRows'), |
|
| 282 | array( |
|
| 283 | $this->fieldRegistry, |
|
| 284 | $this->getLanguageHandler(), |
|
| 285 | ) |
|
| 286 | ); |
|
| 287 | $mapperMock->expects($this->any()) |
|
| 288 | ->method('extractContentInfoFromRows') |
|
| 289 | ->with($this->isType('array')) |
|
| 290 | ->will( |
|
| 291 | $this->returnCallback( |
|
| 292 | function ($rows) { |
|
| 293 | $contentInfoObjs = array(); |
|
| 294 | foreach ($rows as $row) { |
|
| 295 | $contentId = (int)$row['id']; |
|
| 296 | if (!isset($contentInfoObjs[$contentId])) { |
|
| 297 | $contentInfoObjs[$contentId] = new ContentInfo(); |
|
| 298 | $contentInfoObjs[$contentId]->id = $contentId; |
|
| 299 | } |
|
| 300 | } |
|
| 301 | ||
| 302 | return array_values($contentInfoObjs); |
|
| 303 | } |
|
| 304 | ) |
|
| 305 | ); |
|
| 306 | ||
| 307 | return $mapperMock; |
|
| 308 | } |
|
| 309 | ||
| 310 | /** |
|
| 311 | * Returns a content field handler mock. |
|