SerializationExceptionTests::testClass()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 7
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 4
nc 1
nop 0
1
<?php
2
3
/**
4
 * This file is part of the Cubiche/Serializer component.
5
 *
6
 * Copyright (c) Cubiche
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Cubiche\Core\Serializer\Tests\Units\Exception;
13
14
use Cubiche\Core\Serializer\Exception\SerializationException;
15
use Cubiche\Core\Serializer\Tests\Units\TestCase;
16
17
/**
18
 * SerializationException class.
19
 *
20
 * Generated by TestGenerator on 2016-04-29 at 17:37:57.
21
 */
22
class SerializationExceptionTests extends TestCase
23
{
24
    /**
25
     * Test class.
26
     */
27
    public function testClass()
28
    {
29
        $this
30
            ->testedClass
31
                ->extends(\RuntimeException::class)
32
        ;
33
    }
34
35
    /*
36
     * Test forObject method.
37
     */
38
    public function testForObject()
39
    {
40
        $this
41
            ->given($cause = new \Exception('some cause'))
42
            ->when($exception = SerializationException::forObject('foo', $cause))
0 ignored issues
show
Documentation introduced by
'foo' is of type string, but the function expects a object.

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...
43
            ->then()
44
                ->object($exception)
45
                    ->isInstanceOf(SerializationException::class)
46
                ->integer($exception->getCode())
47
                    ->isEqualTo(0)
48
                ->object($exception->getPrevious())
49
                    ->isIdenticalTo($cause)
50
        ;
51
52
        $this
53
            ->given($exception = SerializationException::forObject('bar'))
0 ignored issues
show
Documentation introduced by
'bar' is of type string, but the function expects a object.

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...
54
            ->then()
55
                ->variable($exception->getPrevious())
56
                    ->isNull()
57
        ;
58
    }
59
}
60