| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990 |
- <?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));
- }
- }
|