File size: 2,042 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
60
61
62
63
64
65
66
67
68
<?php

declare(strict_types=1);

namespace MauticPlugin\MauticOutlookBundle\Tests\Integration;

use Mautic\PluginBundle\Tests\Integration\AbstractIntegrationTestCase;
use MauticPlugin\MauticOutlookBundle\Integration\OutlookIntegration;

final class OutlookIntegrationTest extends AbstractIntegrationTestCase
{
    private OutlookIntegration $integration;

    protected function setUp(): void
    {
        parent::setUp();

        $this->integration = new OutlookIntegration(
            $this->dispatcher,
            $this->cache,
            $this->em,
            $this->session,
            $this->request,
            $this->router,
            $this->translator,
            $this->logger,
            $this->encryptionHelper,
            $this->leadModel,
            $this->companyModel,
            $this->pathsHelper,
            $this->notificationModel,
            $this->fieldModel,
            $this->integrationEntityModel,
            $this->doNotContact,
        );
    }

    public function testGetNameReturnsOutlook(): void
    {
        $this->assertSame('Outlook', $this->integration->getName());
    }

    public function testGetAuthenticationTypeWillReturnNone(): void
    {
        $this->assertSame('none', $this->integration->getAuthenticationType());
    }

    public function testGetRequiredKeyFieldsContainsSerect(): void
    {
        $this->assertArrayHasKey('secret', $this->integration->getRequiredKeyFields());
    }

    public function testGetFormNotesWillReturnTheCorrectTemplate(): void
    {
        // set server globals
        // @see Mautic\CoreBundle\Helper\UrlHelper::rel2abs
        $_SERVER['SERVER_PROTOCOL'] = 'https';
        $_SERVER['SERVER_PORT']     = '80';
        $_SERVER['SERVER_NAME']     = 'localhost';
        $_SERVER['REQUEST_URI']     = '/';

        $formNotes = $this->integration->getFormNotes('custom');

        $this->assertArrayHasKey('template', $formNotes);
        $this->assertSame('@MauticOutlook/Integration/form.html.twig', $formNotes['template']);
    }
}