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

Tests/unit/AdminList/ExportListTest.php (1 issue)

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

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
$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