Completed
Push — master ( ba8ed9...770316 )
by Jeroen
06:11
created

ExportListTest::testGetStringValue()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 5
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
namespace Kunstmaan\AdminListBundle\Tests\AdminList;
4
5
use Kunstmaan\AdminListBundle\AdminList\Configurator\AdminListConfiguratorInterface;
6
use Kunstmaan\AdminListBundle\AdminList\Configurator\ExportListConfiguratorInterface;
7
use Kunstmaan\AdminListBundle\AdminList\ExportList;
8
use PHPUnit\Framework\TestCase;
9
10
/**
11
 * Class ExportListTest
12
 */
13
class ExportListTest extends TestCase
14
{
15
    /** @var ExportList */
16
    protected $exportList;
17
18
    public function setUp()
19
    {
20
        /** @var AdminListConfiguratorInterface */
21
        $configurator = $this->createMock(ExportListConfiguratorInterface::class);
22
        $configurator->method('getExportFields')->willReturn(['c', 'd']);
23
        $configurator->method('getIterator')->willReturn($this->createMock(\Iterator::class));
24
        $configurator->method('getStringValue')->willReturn('stringtest');
25
26
        $this->exportList = new ExportList($configurator);
0 ignored issues
show
Documentation introduced by
$configurator is of type object<PHPUnit\Framework\MockObject\MockObject>, but the function expects a object<Kunstmaan\AdminLi...tConfiguratorInterface>.

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...
27
    }
28
29
    public function testGetExportColumns()
30
    {
31
        $this->assertContains('c', $this->exportList->getExportColumns());
32
    }
33
34
    public function testGetIterator()
35
    {
36
        $this->assertInstanceOf(\Iterator::class, $this->exportList->getIterator());
37
    }
38
39
    public function testGetStringValue()
40
    {
41
        $object = new \stdClass();
42
        $this->assertEquals('stringtest', $this->exportList->getStringValue($object, 'test'));
43
    }
44
}
45