SyncTerminalsCommandTest   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 6

Importance

Changes 0
Metric Value
wmc 1
lcom 0
cbo 6
dl 0
loc 23
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A testExecute() 0 20 1
1
<?php
2
3
namespace Loevgaard\DandomainAltapayBundle\Tests\Command;
4
5
use Loevgaard\AltaPay\Client\Client;
6
use Loevgaard\DandomainAltapayBundle\Command\SyncTerminalsCommand;
7
use Loevgaard\DandomainAltapayBundle\Entity\TerminalRepository;
8
use Loevgaard\DandomainAltapayBundle\Synchronizer\TerminalSynchronizer;
9
use PHPUnit\Framework\TestCase;
10
use Symfony\Component\Console\Application;
11
use Symfony\Component\Console\Tester\CommandTester;
12
13
class SyncTerminalsCommandTest extends TestCase
14
{
15
    public function testExecute()
16
    {
17
        $terminalRepository = $this->createMock(TerminalRepository::class);
18
        $altapayClient = $this->createMock(Client::class);
19
        $terminalSynchronizer = new TerminalSynchronizer($terminalRepository, $altapayClient);
0 ignored issues
show
Documentation introduced by
$terminalRepository is of type object<PHPUnit\Framework\MockObject\MockObject>, but the function expects a object<Loevgaard\Dandoma...ity\TerminalRepository>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
Documentation introduced by
$altapayClient is of type object<PHPUnit\Framework\MockObject\MockObject>, but the function expects a object<Loevgaard\AltaPay\Client\Client>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
20
21
        $command = new SyncTerminalsCommand($terminalSynchronizer);
22
23
        $application = new Application();
24
        $application->setAutoExit(false);
25
        $application->add($command);
26
27
        $command = $application->find('loevgaard:dandomain:altapay:sync-terminals');
28
        $commandTester = new CommandTester($command);
29
        $exitCode = $commandTester->execute([
30
            'command' => $command->getName(),
31
        ]);
32
33
        $this->assertSame(0, $exitCode, 'Returns 0 in case of success');
34
    }
35
}
36