Issues (3627)

Command/PushDataToPipedriveCommandTest.php (1 issue)

1
<?php
2
3
namespace MauticPlugin\MauticCrmBundle\Tests\Pipedrive\Command;
4
5
use Mautic\PluginBundle\Entity\IntegrationEntity;
6
use MauticPlugin\MauticCrmBundle\Tests\Pipedrive\PipedriveTest;
7
use Symfony\Bundle\FrameworkBundle\Console\Application;
8
use Symfony\Component\Console\Input\ArrayInput;
9
use Symfony\Component\Console\Output\BufferedOutput;
10
11
class PushDataToPipedriveCommandTest extends PipedriveTest
12
{
13
    public function testCommandWithdisableIntegration()
14
    {
15
        $this->installPipedriveIntegration(false,
16
            [
17
                'objects' => [
18
                    'company',
19
                ],
20
                'leadFields' => [
21
                    'first_name' => 'firstname',
22
                    'last_name'  => 'lastname',
23
                    'email'      => 'email',
24
                    'phone'      => 'phone',
25
                ],
26
                'companyFields' => [
27
                    'name'    => 'companyname',
28
                    'address' => 'companyaddress1',
29
                ],
30
            ], [
31
                'url'   => 'Api/Post',
32
                'token' => 'token',
33
            ]
34
        );
35
36
        $this->createLead();
37
38
        $this->executeCommand();
39
40
        $integrationEntities = $this->em->getRepository(IntegrationEntity::class)->findAll();
41
42
        $this->assertEquals(count($integrationEntities), 0);
43
    }
44
45
    public function testCommandWithDisabledComanyFeature()
46
    {
47
        $this->installPipedriveIntegration(true,
48
            [
49
                'leadFields' => [
50
                    'first_name' => 'firstname',
51
                    'last_name'  => 'lastname',
52
                    'email'      => 'email',
53
                    'phone'      => 'phone',
54
                ],
55
                'companyFields' => [
56
                    'name'    => 'companyname',
57
                    'address' => 'companyaddress1',
58
                ],
59
            ], [
60
                'url'   => 'Api/Post',
61
                'token' => 'token',
62
            ]
63
        );
64
65
        $this->createLead();
66
        $this->createCompany();
67
68
        $this->executeCommand();
69
70
        $integrationEntities = $this->em->getRepository(IntegrationEntity::class)->findAll();
71
72
        $this->assertEquals(count($integrationEntities), 1);
73
    }
74
75
    public function testCommand()
76
    {
77
        $this->installPipedriveIntegration(true,
78
            [
79
                'objects' => [
80
                    'company',
81
                ],
82
                'leadFields' => [
83
                    'first_name' => 'firstname',
84
                    'last_name'  => 'lastname',
85
                    'email'      => 'email',
86
                    'phone'      => 'phone',
87
                ],
88
                'companyFields' => [
89
                    'name'    => 'companyname',
90
                    'address' => 'companyaddress1',
91
                ],
92
            ], [
93
                'url'   => 'Api/Post',
94
                'token' => 'token',
95
            ]
96
        );
97
98
        $this->createLead();
99
        $this->createCompany();
100
101
        $this->executeCommand();
102
103
        $integrationEntities = $this->em->getRepository(IntegrationEntity::class)->findAll();
104
105
        $this->assertEquals(count($integrationEntities), 2);
106
    }
107
108
    private function executeCommand()
109
    {
110
        $kernel      = $this->container->get('kernel');
111
        $application = new Application($kernel);
0 ignored issues
show
It seems like $kernel can also be of type null; however, parameter $kernel of Symfony\Bundle\Framework...lication::__construct() does only seem to accept Symfony\Component\HttpKernel\KernelInterface, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

111
        $application = new Application(/** @scrutinizer ignore-type */ $kernel);
Loading history...
112
        $application->setAutoExit(false);
113
114
        $input = new ArrayInput([
115
            'command' => 'mautic:integration:pipedrive:push',
116
        ]);
117
118
        $output = new BufferedOutput();
119
        $application->run($input, $output);
120
    }
121
}
122