Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
ManagerTest.php
Go to the documentation of this file.
1 <?php
7 
11 class ManagerTest extends \PHPUnit\Framework\TestCase
12 {
16  private $resourceSequenceMeta;
17 
21  private $sequenceFactory;
22 
26  private $sequenceManager;
27 
31  private $store;
32 
36  private $meta;
37 
41  private $sequence;
42 
46  protected function setUp()
47  {
48  $helper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
49  $this->sequence = $this->getMockForAbstractClass(
50  \Magento\Framework\DB\Sequence\SequenceInterface::class,
51  [],
52  '',
53  false,
54  false,
55  true,
56  []
57  );
58  $this->resourceSequenceMeta = $this->createPartialMock(
59  \Magento\SalesSequence\Model\ResourceModel\Meta::class,
60  ['loadByEntityTypeAndStore']
61  );
62  $this->sequenceFactory = $this->createPartialMock(
63  \Magento\SalesSequence\Model\SequenceFactory::class,
64  ['create']
65  );
66  $this->meta = $this->createMock(\Magento\SalesSequence\Model\Meta::class);
67  $this->store = $this->createPartialMock(\Magento\Store\Model\Store::class, ['getId']);
68  $this->sequenceManager = $helper->getObject(
69  \Magento\SalesSequence\Model\Manager::class,
70  [
71  'resourceSequenceMeta' => $this->resourceSequenceMeta,
72  'sequenceFactory' => $this->sequenceFactory
73  ]
74  );
75  }
76 
77  public function testGetSequence()
78  {
79  $entityType = 'order';
80  $storeId = 1;
81  $this->resourceSequenceMeta->expects($this->once())
82  ->method('loadByEntityTypeAndStore')
83  ->with($entityType, $storeId)
84  ->willReturn($this->meta);
85  $this->sequenceFactory->expects($this->once())->method('create')->with([
86  'meta' => $this->meta
87  ])->willReturn($this->sequence);
88  $this->assertSame($this->sequence, $this->sequenceManager->getSequence($entityType, $storeId));
89  }
90 }
$helper
Definition: iframe.phtml:13