Skip to content

Commit

Permalink
#18956 Add TestCase for no root_category_id set
Browse files Browse the repository at this point in the history
  • Loading branch information
larsroettig authored and gelanivishal committed Nov 16, 2018
1 parent 5866a39 commit fee2712
Showing 1 changed file with 37 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -196,14 +196,30 @@ private function initTestData()
'root_category_id' => '1',
'default_store_id' => '1',
'code' => 'default',
],
2 => [
'group_id' => '1',
'website_id' => '1',
'name' => 'Default1',
'default_store_id' => '1',
'code' => 'default1',
]
];
$this->trimmedGroup = [
'name' => 'Default',
'root_category_id' => '1',
'code' => 'default',
'default_store_id' => '1',
];
$this->trimmedGroup =
[
0 => [
'name' => 'Default',
'root_category_id' => '1',
'code' => 'default',
'default_store_id' => '1',
],
1 => [
'name' => 'Default1',
'root_category_id' => '0',
'code' => 'default1',
'default_store_id' => '1'
]
];
$this->stores = [
'default' => [
'store_id' => '1',
Expand Down Expand Up @@ -280,43 +296,46 @@ public function testRunGroup()
[ScopeInterface::SCOPE_GROUPS, $this->groups, $this->groups],
]);

$this->websiteMock->expects($this->once())
$this->websiteMock->expects($this->exactly(2))
->method('getResource')
->willReturn($this->abstractDbMock);

$this->groupMock->expects($this->once())
$this->groupMock->expects($this->exactly(2))
->method('setData')
->with($this->trimmedGroup)
->willReturnSelf();
$this->groupMock->expects($this->exactly(3))
->withConsecutive(
[$this->equalTo($this->trimmedGroup[0])],
[$this->equalTo($this->trimmedGroup[1])]
)->willReturnSelf();

$this->groupMock->expects($this->exactly(6))
->method('getResource')
->willReturn($this->abstractDbMock);
$this->groupMock->expects($this->once())
$this->groupMock->expects($this->exactly(2))
->method('getDefaultStoreId')
->willReturn($defaultStoreId);
$this->groupMock->expects($this->once())
$this->groupMock->expects($this->exactly(2))
->method('setDefaultStoreId')
->with($storeId);
$this->groupMock->expects($this->once())
$this->groupMock->expects($this->exactly(2))
->method('setWebsite')
->with($this->websiteMock);

$this->storeMock->expects($this->once())
$this->storeMock->expects($this->exactly(2))
->method('getResource')
->willReturn($this->abstractDbMock);
$this->storeMock->expects($this->once())
$this->storeMock->expects($this->exactly(2))
->method('getStoreId')
->willReturn($storeId);

$this->abstractDbMock->expects($this->any())
->method('load')
->withConsecutive([$this->websiteMock, 'base', 'code'], [$this->storeMock, 'default', 'code'])
->willReturnSelf();
$this->abstractDbMock->expects($this->exactly(2))
$this->abstractDbMock->expects($this->exactly(4))
->method('save')
->with($this->groupMock)
->willReturnSelf();
$this->abstractDbMock->expects($this->once())
$this->abstractDbMock->expects($this->exactly(2))
->method('addCommitCallback')
->willReturnCallback(function ($function) {
return $function();
Expand Down

0 comments on commit fee2712

Please sign in to comment.