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); |
|
|
|
|
27
|
|
|
} |
28
|
|
|
|
29
|
|
|
public function testConstructor() |
30
|
|
|
{ |
31
|
|
|
$configurator = $this->createMock(ExportListConfiguratorInterface::class); |
32
|
|
|
|
33
|
|
|
$configurator->expects($this->once())->method('buildFilters'); |
34
|
|
|
$configurator->expects($this->once())->method('buildExportFields'); |
35
|
|
|
$configurator->expects($this->once())->method('buildIterator'); |
36
|
|
|
|
37
|
|
|
new ExportList($configurator); |
|
|
|
|
38
|
|
|
} |
39
|
|
|
|
40
|
|
|
public function testGetExportColumns() |
41
|
|
|
{ |
42
|
|
|
$this->assertContains('c', $this->exportList->getExportColumns()); |
43
|
|
|
} |
44
|
|
|
|
45
|
|
|
public function testGetIterator() |
46
|
|
|
{ |
47
|
|
|
$this->assertInstanceOf(\Iterator::class, $this->exportList->getIterator()); |
48
|
|
|
} |
49
|
|
|
|
50
|
|
|
public function testGetStringValue() |
51
|
|
|
{ |
52
|
|
|
$object = new \stdClass(); |
53
|
|
|
$this->assertEquals('stringtest', $this->exportList->getStringValue($object, 'test')); |
54
|
|
|
} |
55
|
|
|
} |
56
|
|
|
|
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: