Skip to content
This repository was archived by the owner on Apr 29, 2019. It is now read-only.

Commit fee2712

Browse files
larsroettiggelanivishal
larsroettig
authored andcommitted
#18956 Add TestCase for no root_category_id set
1 parent 5866a39 commit fee2712

File tree

1 file changed

+37
-18
lines changed
  • app/code/Magento/Store/Test/Unit/Model/Config/Importer/Processor

1 file changed

+37
-18
lines changed

app/code/Magento/Store/Test/Unit/Model/Config/Importer/Processor/CreateTest.php

Lines changed: 37 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -196,14 +196,30 @@ private function initTestData()
196196
'root_category_id' => '1',
197197
'default_store_id' => '1',
198198
'code' => 'default',
199+
],
200+
2 => [
201+
'group_id' => '1',
202+
'website_id' => '1',
203+
'name' => 'Default1',
204+
'default_store_id' => '1',
205+
'code' => 'default1',
199206
]
200207
];
201-
$this->trimmedGroup = [
202-
'name' => 'Default',
203-
'root_category_id' => '1',
204-
'code' => 'default',
205-
'default_store_id' => '1',
206-
];
208+
$this->trimmedGroup =
209+
[
210+
0 => [
211+
'name' => 'Default',
212+
'root_category_id' => '1',
213+
'code' => 'default',
214+
'default_store_id' => '1',
215+
],
216+
1 => [
217+
'name' => 'Default1',
218+
'root_category_id' => '0',
219+
'code' => 'default1',
220+
'default_store_id' => '1'
221+
]
222+
];
207223
$this->stores = [
208224
'default' => [
209225
'store_id' => '1',
@@ -280,43 +296,46 @@ public function testRunGroup()
280296
[ScopeInterface::SCOPE_GROUPS, $this->groups, $this->groups],
281297
]);
282298

283-
$this->websiteMock->expects($this->once())
299+
$this->websiteMock->expects($this->exactly(2))
284300
->method('getResource')
285301
->willReturn($this->abstractDbMock);
286302

287-
$this->groupMock->expects($this->once())
303+
$this->groupMock->expects($this->exactly(2))
288304
->method('setData')
289-
->with($this->trimmedGroup)
290-
->willReturnSelf();
291-
$this->groupMock->expects($this->exactly(3))
305+
->withConsecutive(
306+
[$this->equalTo($this->trimmedGroup[0])],
307+
[$this->equalTo($this->trimmedGroup[1])]
308+
)->willReturnSelf();
309+
310+
$this->groupMock->expects($this->exactly(6))
292311
->method('getResource')
293312
->willReturn($this->abstractDbMock);
294-
$this->groupMock->expects($this->once())
313+
$this->groupMock->expects($this->exactly(2))
295314
->method('getDefaultStoreId')
296315
->willReturn($defaultStoreId);
297-
$this->groupMock->expects($this->once())
316+
$this->groupMock->expects($this->exactly(2))
298317
->method('setDefaultStoreId')
299318
->with($storeId);
300-
$this->groupMock->expects($this->once())
319+
$this->groupMock->expects($this->exactly(2))
301320
->method('setWebsite')
302321
->with($this->websiteMock);
303322

304-
$this->storeMock->expects($this->once())
323+
$this->storeMock->expects($this->exactly(2))
305324
->method('getResource')
306325
->willReturn($this->abstractDbMock);
307-
$this->storeMock->expects($this->once())
326+
$this->storeMock->expects($this->exactly(2))
308327
->method('getStoreId')
309328
->willReturn($storeId);
310329

311330
$this->abstractDbMock->expects($this->any())
312331
->method('load')
313332
->withConsecutive([$this->websiteMock, 'base', 'code'], [$this->storeMock, 'default', 'code'])
314333
->willReturnSelf();
315-
$this->abstractDbMock->expects($this->exactly(2))
334+
$this->abstractDbMock->expects($this->exactly(4))
316335
->method('save')
317336
->with($this->groupMock)
318337
->willReturnSelf();
319-
$this->abstractDbMock->expects($this->once())
338+
$this->abstractDbMock->expects($this->exactly(2))
320339
->method('addCommitCallback')
321340
->willReturnCallback(function ($function) {
322341
return $function();

0 commit comments

Comments
 (0)