Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
IncrementTest.php
Go to the documentation of this file.
1 <?php
7 
11 class IncrementTest extends \PHPUnit\Framework\TestCase
12 {
16  protected $model;
17 
21  protected $eavConfig;
22 
26  protected $type;
27 
28  protected function setUp()
29  {
30  $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
31  $this->eavConfig = $this->createPartialMock(\Magento\Eav\Model\Config::class, ['getEntityType']);
32  $this->model = $objectManager->getObject(
33  \Magento\Sales\Model\Increment::class,
34  ['eavConfig' => $this->eavConfig]
35  );
36  $this->type = $this->createPartialMock(\Magento\Eav\Model\Entity\Type::class, ['fetchNewIncrementId']);
37  }
38 
39  public function testGetCurrentValue()
40  {
41  $this->type->expects($this->once())
42  ->method('fetchNewIncrementId')
43  ->with(1)
44  ->willReturn(2);
45  $this->eavConfig->expects($this->once())
46  ->method('getEntityType')
47  ->with('order')
48  ->willReturn($this->type);
49  $this->model->getNextValue(1);
50  $this->assertEquals(2, $this->model->getCurrentValue());
51  }
52 
53  public function testNextValue()
54  {
55  $this->type->expects($this->once())
56  ->method('fetchNewIncrementId')
57  ->with(1)
58  ->willReturn(2);
59  $this->eavConfig->expects($this->once())
60  ->method('getEntityType')
61  ->with('order')
62  ->willReturn($this->type);
63  $this->assertEquals(2, $this->model->getNextValue(1));
64  }
65 }
$objectManager
Definition: bootstrap.php:17