Completed
Pull Request — master (#114)
by Bart
02:13
created

PluginDataTypeTest::testGetMapperHandle()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 6
rs 9.4285
cc 1
eloc 3
nc 1
nop 0
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
     */
29
    protected function _before()
30
    {
31
        $this->dataType = new PluginDataType();
32
    }
33
34
    //==============================================================================================================
35
    //=================================================  TESTS  ====================================================
36
    //==============================================================================================================
37
38
    /**
39
     * Get mapper handle test.
40
     */
41
    public function testGetMapperHandle()
42
    {
43
        $result = $this->dataType->getMapperHandle();
44
45
        $this->assertSame('pluginMapper', $result);
46
    }
47
48
    /**
49
     * Get records test.
50
     */
51
    public function testGetRecords()
52
    {
53
        $records = [$this->getMockPluginInfo()];
54
55
        Craft::$app->plugins->expects($this->exactly(1))
56
                            ->method('getAllPluginInfo')
57
                            ->willReturn($records);
58
59
        $result = $this->dataType->getRecords();
60
61
        $this->assertSame($records, $result);
62
    }
63
64
    //==============================================================================================================
65
    //================================================  HELPERS  ===================================================
66
    //==============================================================================================================
67
68
    /**
69
     * @return array
70
     */
71
    private function getMockPluginInfo()
72
    {
73
        return ['pluginInfo'];
74
    }
75
}
76