File size: 2,272 Bytes
d2897cd
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
<?php

declare(strict_types=1);

namespace Mautic\IntegrationsBundle\Tests\Unit\Integration;

use Mautic\IntegrationsBundle\DTO\Note;
use Mautic\IntegrationsBundle\Integration\ConfigFormNotesTrait;
use Mautic\IntegrationsBundle\Integration\Interfaces\ConfigFormNotesInterface;
use PHPUnit\Framework\TestCase;

class ConfigFormNotesTraitTest extends TestCase
{
    public function testConfigFormNotesTraitFormDefaultValues(): void
    {
        $configFormNotes = new class() implements ConfigFormNotesInterface {
            use ConfigFormNotesTrait;
        };

        $this->assertNull($configFormNotes->getAuthorizationNote());
        $this->assertNull($configFormNotes->getFeaturesNote());
        $this->assertNull($configFormNotes->getFieldMappingNote());
    }

    public function testConfigFormNotesTraitFormForCustomValues(): void
    {
        $configFormNotes = new class() implements ConfigFormNotesInterface {
            use ConfigFormNotesTrait;

            public function getAuthorizationNote(): ?Note
            {
                return new Note('Authorisation', Note::TYPE_WARNING);
            }

            public function getFeaturesNote(): ?Note
            {
                return new Note('Features', Note::TYPE_INFO);
            }

            public function getFieldMappingNote(): ?Note
            {
                return new Note('Field Mapping', Note::TYPE_WARNING);
            }
        };

        $this->assertInstanceOf(Note::class, $configFormNotes->getAuthorizationNote());
        $this->assertSame(Note::TYPE_WARNING, $configFormNotes->getAuthorizationNote()->getType());
        $this->assertSame('Authorisation', $configFormNotes->getAuthorizationNote()->getNote());

        $this->assertInstanceOf(Note::class, $configFormNotes->getFeaturesNote());
        $this->assertSame(Note::TYPE_INFO, $configFormNotes->getFeaturesNote()->getType());
        $this->assertSame('Features', $configFormNotes->getFeaturesNote()->getNote());

        $this->assertInstanceOf(Note::class, $configFormNotes->getFieldMappingNote());
        $this->assertSame(Note::TYPE_WARNING, $configFormNotes->getFieldMappingNote()->getType());
        $this->assertSame('Field Mapping', $configFormNotes->getFieldMappingNote()->getNote());
    }
}