Completed
Pull Request — master (#130)
by Bart
01:25
created

PluginDataTypeTest   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 60
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

Changes 0
Metric Value
wmc 4
c 0
b 0
f 0
lcom 1
cbo 3
dl 0
loc 60
rs 10
1
<?php
2
3
namespace NerdsAndCompany\Schematic\DataTypes;
4
5
use Craft;
6
use Codeception\Test\Unit;
7
8
/**
9
 * Class PluginDataTypeTest.
10
 *
11
 * @author    Nerds & Company
12
 * @copyright Copyright (c) 2015-2017, Nerds & Company
13
 * @license   MIT
14
 *
15
 * @see      http://www.nerds.company
16
 */
17
class PluginDataTypeTest extends Unit
18
{
19
    /**
20
     * @var PluginDataType
21
     */
22
    private $dataType;
23
24
    /**
25
     * Set the dataType.
26
     *
27
     * @SuppressWarnings(PHPMD.CamelCaseMethodName)
28
     * phpcs:disable PSR2.Methods.MethodDeclaration.Underscore
29
     */
30
    protected function _before()
31
    {
32
        $this->dataType = new PluginDataType();
33
    }
34
35
    //==============================================================================================================
36
    //=================================================  TESTS  ====================================================
37
    //==============================================================================================================
38
39
    /**
40
     * Get mapper handle test.
41
     */
42
    public function testGetMapperHandle()
43
    {
44
        $result = $this->dataType->getMapperHandle();
45
46
        $this->assertSame('pluginMapper', $result);
47
    }
48
49
    /**
50
     * Get records test.
51
     */
52
    public function testGetRecords()
53
    {
54
        $records = [$this->getMockPluginInfo()];
55
56
        Craft::$app->plugins->expects($this->exactly(1))
57
                            ->method('getAllPluginInfo')
58
                            ->willReturn($records);
59
60
        $result = $this->dataType->getRecords();
61
62
        $this->assertSame($records, $result);
63
    }
64
65
    //==============================================================================================================
66
    //================================================  HELPERS  ===================================================
67
    //==============================================================================================================
68
69
    /**
70
     * @return array
71
     */
72
    private function getMockPluginInfo()
73
    {
74
        return ['pluginInfo'];
75
    }
76
}
77