Completed
Push — master ( 60f6d2...2121c5 )
by
unknown
12s queued 10s
created

EmailSettingsMapperTest   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 82
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

Changes 0
Metric Value
wmc 5
lcom 1
cbo 3
dl 0
loc 82
rs 10
c 0
b 0
f 0

5 Methods

Rating   Name   Duplication   Size   Complexity  
A _before() 0 4 1
A testEmailSettingsServiceExport() 0 9 1
A testEmailSettingsServiceImport() 0 7 1
A getEmailSettingsDefinition() 0 10 1
A setMockServicesForExport() 0 13 1
1
<?php
2
3
namespace NerdsAndCompany\Schematic\Mappers;
4
5
use Craft;
6
use Codeception\Test\Unit;
7
8
/**
9
 * Class EmailSettingsMapperTest.
10
 *
11
 * @author    Nerds & Company
12
 * @copyright Copyright (c) 2015-2018, Nerds & Company
13
 * @license   MIT
14
 *
15
 * @see      http://www.nerds.company
16
 */
17
class EmailSettingsMapperTest extends Unit
18
{
19
    /**
20
     * @var EmailSettingsMapper
21
     */
22
    private $mapper;
23
24
    /**
25
     * Set the mapper.
26
     *
27
     * @SuppressWarnings(PHPMD.CamelCaseMethodName)
28
     */
29
    protected function _before()
30
    {
31
        $this->mapper = new EmailSettingsMapper();
32
    }
33
34
    //==============================================================================================================
35
    //=================================================  TESTS  ====================================================
36
    //==============================================================================================================
37
38
    /**
39
     * Test EmailSettings service export.
40
     */
41
    public function testEmailSettingsServiceExport()
42
    {
43
        $this->setMockServicesForExport();
44
45
        $definition = $this->getEmailSettingsDefinition();
46
        $result = $this->mapper->export();
47
48
        $this->assertSame($definition, $result);
49
    }
50
51
    /**
52
     * Test EmailSettings service import.
53
     */
54
    public function testEmailSettingsServiceImport()
55
    {
56
        $definition = $this->getEmailSettingsDefinition();
57
        $import = $this->mapper->import($definition);
58
59
        $this->assertSame([], $import);
60
    }
61
62
    //==============================================================================================================
63
    //================================================  HELPERS  ===================================================
64
    //==============================================================================================================
65
66
    /**
67
     * Email settings definition.
68
     *
69
     * @return array
70
     */
71
    private function getEmailSettingsDefinition()
72
    {
73
        return [
74
            'settings' => [
75
                'fromEmail' => '[email protected]',
76
                'fromName' => 'Schematic',
77
                'template' => null,
78
            ],
79
        ];
80
    }
81
82
    /**
83
     * Set mock services for export.
84
     */
85
    private function setMockServicesForExport()
86
    {
87
        $settings = [
88
            'fromEmail' => '[email protected]',
89
            'fromName' => 'Schematic',
90
            'template' => null,
91
        ];
92
93
        Craft::$app->systemSettings->expects($this->exactly(1))
94
                                   ->method('getSettings')
95
                                   ->with('email')
96
                                   ->willReturn($settings);
97
    }
98
}
99