Skip to content

Commit 4c4ae53

Browse files
committed
Fix #14958 - add unit tests
1 parent 8529467 commit 4c4ae53

File tree

2 files changed

+56
-0
lines changed

2 files changed

+56
-0
lines changed

app/code/Magento/SalesSequence/Test/Unit/Model/ResourceModel/MetaTest.php

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,34 @@ public function testLoadBy()
128128
$this->assertEquals($this->meta, $this->resource->loadByEntityTypeAndStore($entityType, $storeId));
129129
}
130130

131+
public function testGetIdsByStore()
132+
{
133+
$metaTableName = 'sequence_meta';
134+
$metaIdFieldName = 'meta_id';
135+
$storeId = 1;
136+
$metaIds = [1, 2];
137+
$this->resourceMock->expects($this->any())
138+
->method('getConnection')
139+
->willReturn($this->connectionMock);
140+
$this->resourceMock->expects($this->once())
141+
->method('getTableName')
142+
->willReturn($metaTableName);
143+
$this->connectionMock->expects($this->any())->method('select')->willReturn($this->select);
144+
$this->select->expects($this->at(0))
145+
->method('from')
146+
->with($metaTableName, [$metaIdFieldName])
147+
->willReturn($this->select);
148+
$this->select->expects($this->at(1))
149+
->method('where')
150+
->with('store_id = :store_id')
151+
->willReturn($this->select);
152+
$this->connectionMock->expects($this->once())
153+
->method('fetchCol')
154+
->with($this->select, ['store_id' => $storeId])
155+
->willReturn($metaIds);
156+
$this->assertEquals($metaIds, $this->resource->getIdsByStore($storeId));
157+
}
158+
131159
/**
132160
* @param $metaData
133161
*/

app/code/Magento/SalesSequence/Test/Unit/Model/ResourceModel/ProfileTest.php

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,4 +129,32 @@ public function testLoadActiveProfile()
129129
$this->profile->expects($this->at(1))->method('setData')->with($profileData);
130130
$this->assertEquals($this->profile, $this->resource->loadActiveProfile($metaId));
131131
}
132+
133+
public function testGetProfileIdsByMetadataIds()
134+
{
135+
$profileTableName = 'sequence_profile';
136+
$profileIdFieldName = 'profile_id';
137+
$metadataIds = [1, 2];
138+
$profileIds = [10, 11];
139+
$this->resourceMock->expects($this->any())
140+
->method('getConnection')
141+
->willReturn($this->connectionMock);
142+
$this->resourceMock->expects($this->once())
143+
->method('getTableName')
144+
->willReturn($profileTableName);
145+
$this->connectionMock->expects($this->any())->method('select')->willReturn($this->select);
146+
$this->select->expects($this->at(0))
147+
->method('from')
148+
->with($profileTableName, [$profileIdFieldName])
149+
->willReturn($this->select);
150+
$this->select->expects($this->at(1))
151+
->method('where')
152+
->with('meta_id IN (?)', $metadataIds)
153+
->willReturn($this->select);
154+
$this->connectionMock->expects($this->once())
155+
->method('fetchCol')
156+
->with($this->select)
157+
->willReturn($profileIds);
158+
$this->assertEquals($profileIds, $this->resource->getProfileIdsByMetadataIds($metadataIds));
159+
}
132160
}

0 commit comments

Comments
 (0)