16 private $sequenceBuilder;
21 private $resourceSequenceMeta;
41 private $profileFactory;
46 private $connectionMock;
56 private $resourceMock;
60 $this->connectionMock = $this->getMockForAbstractClass(
61 \
Magento\Framework\DB\Adapter\AdapterInterface::class,
69 $this->resourceSequenceMeta = $this->createPartialMock(
71 [
'loadByEntityTypeAndStore',
'save',
'createSequence']
73 $this->meta = $this->createPartialMock(
74 \
Magento\SalesSequence\Model\Meta::class,
75 [
'getId',
'setData',
'save',
'getSequenceTable']
77 $this->sequence = $this->createMock(\
Magento\Framework\DB\Ddl\Sequence::class);
78 $this->resourceMock = $this->createMock(\
Magento\Framework\
App\ResourceConnection::class);
79 $this->profile = $this->createPartialMock(
80 \
Magento\SalesSequence\Model\Profile::class,
81 [
'getId',
'setData',
'getStartValue']
83 $this->metaFactory = $this->createPartialMock(\
Magento\SalesSequence\Model\MetaFactory::class, [
'create']);
84 $this->metaFactory->expects($this->any())->method(
'create')->willReturn($this->meta);
85 $this->profileFactory = $this->createPartialMock(
86 \
Magento\SalesSequence\Model\ProfileFactory::class,
89 $this->profileFactory->expects($this->any())->method(
'create')->willReturn($this->profile);
90 $this->resourceMock->expects($this->atLeastOnce())
91 ->method(
'getTableName')
92 ->willReturn(
'sequence_lalalka_1');
94 $helper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
95 $this->sequenceBuilder =
$helper->getObject(
96 \
Magento\SalesSequence\Model\Builder::class,
98 'resourceMetadata' => $this->resourceSequenceMeta,
99 'metaFactory' => $this->metaFactory,
100 'profileFactory' => $this->profileFactory,
101 'appResource' => $this->resourceMock,
102 'ddlSequence' => $this->sequence
111 $this->resourceSequenceMeta->expects($this->once())
112 ->method(
'loadByEntityTypeAndStore')
114 ->willReturn($this->meta);
115 $this->meta->expects($this->once())
116 ->method(
'getSequenceTable')
117 ->willReturn(
'sequence_lalalka_1');
118 $this->profileFactory->expects($this->never())
126 ->setWarningValue(9999999)
127 ->setMaxValue(912992192)
140 $warningValue = 110000;
141 $this->resourceSequenceMeta->expects($this->once())
142 ->method(
'loadByEntityTypeAndStore')
144 ->willReturn($this->meta);
145 $this->meta->expects($this->once())
146 ->method(
'getSequenceTable')
148 $this->profileFactory->expects($this->once())
154 'start_value' => $startValue,
156 'max_value' => $maxValue,
157 'warning_value' => $warningValue,
160 ])->willReturn($this->profile);
162 $this->metaFactory->expects($this->once())
168 'sequence_table' => $sequenceTable,
169 'active_profile' => $this->profile
171 ])->willReturn($this->meta);
172 $this->resourceSequenceMeta->expects($this->once())->method(
'save')->willReturn($this->meta);
173 $this->stepCreateSequence($sequenceTable, $startValue);
178 ->setStartValue($startValue)
180 ->setMaxValue($maxValue)
181 ->setWarningValue($warningValue)
191 private function stepCreateSequence($sequenceName, $startNumber)
194 $this->resourceMock->expects($this->atLeastOnce())
195 ->method(
'getTableName');
196 $this->resourceMock->expects($this->any())
197 ->method(
'getConnection')
199 ->willReturn($this->connectionMock);
200 $this->sequence->expects($this->once())
201 ->method(
'getCreateSequenceDdl')
202 ->with($sequenceName, $startNumber)
204 $this->connectionMock->expects($this->once())->method(
'query')->with($sql);
testAddSequenceExistMeta()