Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
NumericTest.php
Go to the documentation of this file.
1 <?php
7 
9 
10 class NumericTest extends \PHPUnit\Framework\TestCase
11 {
15  private $model;
16 
17  protected function setUp()
18  {
19  $this->model = new \Magento\Eav\Model\Entity\Increment\NumericValue();
20  }
21 
28  public function testGetNextId($lastId, $prefix, $expectedResult)
29  {
30  $this->model->setLastId($lastId);
31  $this->model->setPrefix($prefix);
32  $this->assertEquals($expectedResult, $this->model->getNextId());
33  }
34 
38  public function getLastIdDataProvider()
39  {
40  return [
41  [
42  'lastId' => 1,
43  'prefix' => 'prefix',
44  'expectedResult' => 'prefix00000002',
45  ],
46  [
47  'lastId' => 'prefix00000001',
48  'prefix' => 'prefix',
49  'expectedResult' => 'prefix00000002'
50  ],
51  ];
52  }
53 
54  public function testGetPadLength()
55  {
56  $this->assertEquals(8, $this->model->getPadLength());
57  $this->model->setPadLength(10);
58  $this->assertEquals(10, $this->model->getPadLength());
59  }
60 
61  public function getPadChar()
62  {
63  $this->assertEquals('0', $this->model->getPadChar());
64  $this->model->setPadChar('z');
65  $this->assertEquals('z', $this->model->getPadChar());
66  }
67 
68  public function testFormat()
69  {
70  $this->model->setPrefix('prefix');
71  $this->model->setPadLength(3);
72  $this->model->setPadChar('z');
73  $this->assertEquals('prefixzz1', $this->model->format(1));
74  }
75 
76  public function testFrontendFormat()
77  {
78  $this->assertEquals('value', $this->model->frontendFormat('value'));
79  }
80 }
testGetNextId($lastId, $prefix, $expectedResult)
Definition: NumericTest.php:28
$prefix
Definition: name.phtml:25