PaymentExceptionTest   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 14
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A testGettersSetters() 0 11 1
1
<?php
2
3
namespace Loevgaard\DandomainAltapayBundle\Tests\Exception;
4
5
use Loevgaard\DandomainAltapayBundle\Entity\Payment;
6
use Loevgaard\DandomainAltapayBundle\Exception\PaymentException;
7
use PHPUnit\Framework\TestCase;
8
use Symfony\Component\HttpFoundation\Request;
9
10
class PaymentExceptionTest extends TestCase
11
{
12
    public function testGettersSetters()
13
    {
14
        $message = 'message';
15
        $request = Request::create('/test');
16
        $payment = $this->getMockForAbstractClass(Payment::class);
17
        $e = PaymentException::create($message, $request, $payment);
0 ignored issues
show
Documentation introduced by
$payment is of type object<PHPUnit\Framework\MockObject\MockObject>, but the function expects a object<Loevgaard\Dandoma...yBundle\Entity\Payment>.

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...
18
19
        $this->assertSame($message, $e->getMessage());
20
        $this->assertSame($request, $e->getRequest());
21
        $this->assertSame($payment, $e->getPayment());
22
    }
23
}
24