1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
namespace Magento\SalesSequence\Test\Unit\Model;
/**
* Class ManagerTest
*/
class ManagerTest extends \PHPUnit\Framework\TestCase
{
/**
* @var \Magento\SalesSequence\Model\ResourceModel\Meta | \PHPUnit_Framework_MockObject_MockObject
*/
private $resourceSequenceMeta;
/**
* @var \Magento\SalesSequence\Model\SequenceFactory | \PHPUnit_Framework_MockObject_MockObject
*/
private $sequenceFactory;
/**
* @var \Magento\SalesSequence\Model\Manager
*/
private $sequenceManager;
/**
* @var \Magento\Store\Model\Store | \PHPUnit_Framework_MockObject_MockObject
*/
private $store;
/**
* @var \Magento\SalesSequence\Model\Meta | \PHPUnit_Framework_MockObject_MockObject
*/
private $meta;
/**
* @var \Magento\Framework\DB\Sequence\SequenceInterface | \PHPUnit_Framework_MockObject_MockObject
*/
private $sequence;
/**
* Initialization
*/
protected function setUp()
{
$helper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
$this->sequence = $this->getMockForAbstractClass(
\Magento\Framework\DB\Sequence\SequenceInterface::class,
[],
'',
false,
false,
true,
[]
);
$this->resourceSequenceMeta = $this->createPartialMock(
\Magento\SalesSequence\Model\ResourceModel\Meta::class,
['loadByEntityTypeAndStore']
);
$this->sequenceFactory = $this->createPartialMock(
\Magento\SalesSequence\Model\SequenceFactory::class,
['create']
);
$this->meta = $this->createMock(\Magento\SalesSequence\Model\Meta::class);
$this->store = $this->createPartialMock(\Magento\Store\Model\Store::class, ['getId']);
$this->sequenceManager = $helper->getObject(
\Magento\SalesSequence\Model\Manager::class,
[
'resourceSequenceMeta' => $this->resourceSequenceMeta,
'sequenceFactory' => $this->sequenceFactory
]
);
}
public function testGetSequence()
{
$entityType = 'order';
$storeId = 1;
$this->resourceSequenceMeta->expects($this->once())
->method('loadByEntityTypeAndStore')
->with($entityType, $storeId)
->willReturn($this->meta);
$this->sequenceFactory->expects($this->once())->method('create')->with([
'meta' => $this->meta
])->willReturn($this->sequence);
$this->assertSame($this->sequence, $this->sequenceManager->getSequence($entityType, $storeId));
}
}