StockItemReserveTest::gettersAndSettersProvider()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 12

Duplication

Lines 12
Ratio 100 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 0
dl 12
loc 12
ccs 0
cts 2
cp 0
crap 2
rs 9.8666
c 0
b 0
f 0
1
<?php
2
3
4
namespace Stockbase\Integration\Test\Unit\Model;
5
6
use PHPUnit\Framework\TestCase;
7
use Stockbase\Integration\Model\StockItemReserve;
8
9
/**
10
 * Class StockItemReserveTest
11
 */
12 View Code Duplication
class StockItemReserveTest extends TestCase
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
13
{
14
    /** @var \Magento\Framework\Model\Context|\PHPUnit_Framework_MockObject_MockObject */
15
    private $context;
16
17
    /** @var \Magento\Framework\Registry|\PHPUnit_Framework_MockObject_MockObject */
18
    private $registry;
19
    
20
    /** @var \Magento\Framework\Model\ResourceModel\AbstractResource|\PHPUnit_Framework_MockObject_MockObject */
21
    private $resource;
22
23
    /**
24
     * {@inheritdoc}
25
     */
26 7
    public function setUp()
27
    {
28 7
        $this->context = $this->createMock(\Magento\Framework\Model\Context::class);
29 7
        $this->registry = $this->createMock(\Magento\Framework\Registry::class);
30 7
        $this->resource = $this->createMock(\Magento\Framework\Model\ResourceModel\Db\AbstractDb::class);
31 7
        $this->resource->method('getIdFieldName')->willReturn('id');
32 7
    }
33
34
    /**
35
     * testGettersAndSetters
36
     * @dataProvider gettersAndSettersProvider
37
     *
38
     * @param mixed $propertyName
39
     * @param mixed $fieldName
40
     */
41 7
    public function testGettersAndSetters($propertyName, $fieldName)
42
    {
43 7
        $model = $this->createModel();
44
        
45 7
        $value = uniqid();
46 7
        $model->{'set'.$propertyName}($value);
47 7
        $this->assertEquals($value, $model->getData($fieldName));
48 7
        $this->assertEquals($value, $model->{'get'.$propertyName}());
49 7
    }
50
51
    /**
52
     * @return array
53
     */
54
    public function gettersAndSettersProvider()
55
    {
56
        return [
57
            ['Ean', 'ean'],
58
            ['Amount', 'amount'],
59
            ['MagentoStockAmount', 'magento_stock_amount'],
60
            ['QuoteItemId', 'quote_item_id'],
61
            ['ProductId', 'product_id'],
62
            ['OrderItemId', 'order_item_id'],
63
            ['CreatedAt', 'created_at'],
64
        ];
65
    }
66
    
67 7
    protected function createModel()
68
    {
69 7
        return new StockItemReserve(
70 7
            $this->context,
71 7
            $this->registry,
72 7
            $this->resource
73
        );
74
    }
75
}
76