Completed
Push — master ( 203e38...2cdd54 )
by Gerrit
13:04
created

FieldMappingTest::shouldStoreOrigin()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
/**
3
 * Copyright (C) 2017  Gerrit Addiks.
4
 * This package (including this file) was released under the terms of the GPL-3.0.
5
 * You should have received a copy of the GNU General Public License along with this program.
6
 * If not, see <http://www.gnu.org/licenses/> or send me a mail so i can send you a copy.
7
 * @license GPL-3.0
8
 * @author Gerrit Addiks <[email protected]>
9
 */
10
11
namespace Addiks\RDMBundle\Tests\Mapping;
12
13
use PHPUnit\Framework\TestCase;
14
use Addiks\RDMBundle\Mapping\FieldMapping;
15
use Doctrine\DBAL\Schema\Column;
16
17
final class FieldMappingTest extends TestCase
18
{
19
20
    /**
21
     * @var FieldMapping
22
     */
23
    private $fieldMapping;
24
25
    /**
26
     * @var Column
27
     */
28
    private $dbalColumn;
29
30
    public function setUp()
31
    {
32
        $this->dbalColumn = $this->createMock(Column::class);
0 ignored issues
show
Documentation Bug introduced by
It seems like $this->createMock(\Doctr...L\Schema\Column::class) of type object<PHPUnit\Framework\MockObject\MockObject> is incompatible with the declared type object<Doctrine\DBAL\Schema\Column> of property $dbalColumn.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
33
34
        $this->fieldMapping = new FieldMapping($this->dbalColumn, "some origin");
0 ignored issues
show
Documentation introduced by
$this->dbalColumn is of type object<PHPUnit\Framework\MockObject\MockObject>, but the function expects a object<Doctrine\DBAL\Schema\Column>.

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...
35
    }
36
37
    /**
38
     * @test
39
     */
40
    public function shouldStoreDBALColumn()
41
    {
42
        $this->assertSame($this->dbalColumn, $this->fieldMapping->getDBALColumn());
43
    }
44
45
    /**
46
     * @test
47
     */
48
    public function shouldStoreOrigin()
49
    {
50
        $this->assertSame("some origin", $this->fieldMapping->describeOrigin());
51
    }
52
53
    /**
54
     * @test
55
     */
56
    public function shouldCollectDBALColumns()
57
    {
58
        $this->assertSame([$this->dbalColumn], $this->fieldMapping->collectDBALColumns());
59
    }
60
61
}
62