Completed
Pull Request — 5.6 (#2830)
by Jeroen
14:14
created

AdminListBundle/Tests/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
class ExportListTest extends TestCase
11
{
12
    /** @var ExportList */
13
    protected $exportList;
14
15
    public function setUp()
16
    {
17
        /** @var AdminListConfiguratorInterface */
18
        $configurator = $this->createMock(ExportListConfiguratorInterface::class);
19
        $configurator->method('getExportFields')->willReturn(['c', 'd']);
20
        $configurator->method('getIterator')->willReturn($this->createMock(\Iterator::class));
21
        $configurator->method('getStringValue')->willReturn('stringtest');
22
23
        $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...
24
    }
25
26
    public function testConstructor()
27
    {
28
        $configurator = $this->createMock(ExportListConfiguratorInterface::class);
29
30
        $configurator->expects($this->once())->method('buildFilters');
31
        $configurator->expects($this->once())->method('buildExportFields');
32
        $configurator->expects($this->once())->method('buildIterator');
33
34
        new ExportList($configurator);
35
    }
36
37
    public function testGetExportColumns()
38
    {
39
        $this->assertContains('c', $this->exportList->getExportColumns());
40
    }
41
42
    public function testGetIterator()
43
    {
44
        $this->assertInstanceOf(\Iterator::class, $this->exportList->getIterator());
45
    }
46
47
    public function testGetStringValue()
48
    {
49
        $object = new \stdClass();
50
        $this->assertEquals('stringtest', $this->exportList->getStringValue($object, 'test'));
51
    }
52
}
53