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 ArrayIterator; |
||
6 | use Doctrine\ORM\AbstractQuery; |
||
7 | use Doctrine\ORM\EntityManager; |
||
8 | use Doctrine\ORM\QueryBuilder; |
||
9 | use Iterator; |
||
10 | use Kunstmaan\AdminListBundle\AdminList\Configurator\AbstractAdminListConfigurator; |
||
11 | use Kunstmaan\AdminListBundle\AdminList\ExportList; |
||
12 | use Kunstmaan\AdminListBundle\AdminList\Field; |
||
13 | use Kunstmaan\FormBundle\AdminList\FormSubmissionExportListConfigurator; |
||
14 | use Kunstmaan\FormBundle\Entity\FormSubmission; |
||
15 | use Kunstmaan\NodeBundle\Entity\Node; |
||
16 | use Kunstmaan\NodeBundle\Entity\NodeTranslation; |
||
17 | use Kunstmaan\TranslatorBundle\Service\Translator\Translator; |
||
18 | use PHPUnit\Framework\TestCase; |
||
19 | use ReflectionClass; |
||
20 | use Symfony\Component\HttpFoundation\Request; |
||
21 | |||
22 | class ExportListTest extends TestCase |
||
23 | { |
||
24 | /** |
||
25 | * @var ExportList |
||
26 | */ |
||
27 | protected $object; |
||
28 | |||
29 | /** |
||
30 | * @var \PHPUnit_Framework_MockObject_MockObject |
||
31 | */ |
||
32 | protected $configurator; |
||
33 | |||
34 | /** |
||
35 | * Sets up the fixture, for example, opens a network connection. |
||
36 | * This method is called before a test is executed. |
||
37 | */ |
||
38 | protected function setUp() |
||
39 | { |
||
40 | $query = $this->createMock(AbstractQuery::class); |
||
41 | $query->expects($this->once())->method('iterate')->willReturn(new ArrayIterator([[new FormSubmission()]])); |
||
42 | |||
43 | $qb = $this->createMock(QueryBuilder::class); |
||
44 | $qb->expects($this->any())->method('select')->willReturn($qb); |
||
45 | $qb->expects($this->any())->method('from')->willReturn($qb); |
||
46 | $qb->expects($this->any())->method('innerJoin')->willReturn($qb); |
||
47 | $qb->expects($this->any())->method('andWhere')->willReturn($qb); |
||
48 | $qb->expects($this->any())->method('setParameter')->willReturn($qb); |
||
49 | $qb->expects($this->any())->method('addOrderBy')->willReturn($qb); |
||
50 | $qb->expects($this->any())->method('getQuery')->willReturn($query); |
||
51 | |||
52 | $em = $this->createMock(EntityManager::class); |
||
53 | $em->expects($this->once())->method('createQueryBuilder')->willReturn($qb); |
||
54 | |||
55 | $node = new Node(); |
||
56 | $node->setId(666); |
||
57 | $nodeTranslation = $this->createMock(NodeTranslation::class); |
||
58 | $nodeTranslation->expects($this->any())->method('getNode')->willReturn($node); |
||
59 | $nodeTranslation->expects($this->any())->method('getLang')->willReturn('nl'); |
||
60 | $translator = $this->createMock(Translator::class); |
||
61 | |||
62 | $this->configurator = new FormSubmissionExportListConfigurator($em, $nodeTranslation, $translator); //$this->createMock('Kunstmaan\AdminListBundle\AdminList\Configurator\ExportListConfiguratorInterface'); |
||
0 ignored issues
–
show
$em is of type object<PHPUnit\Framework\MockObject\MockObject> , but the function expects a object<Doctrine\ORM\EntityManagerInterface> .
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...
$nodeTranslation is of type object<PHPUnit\Framework\MockObject\MockObject> , but the function expects a object<Kunstmaan\NodeBun...Entity\NodeTranslation> .
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...
$translator is of type object<PHPUnit\Framework\MockObject\MockObject> , but the function expects a object<Symfony\Component...on\TranslatorInterface> .
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...
|
|||
63 | |||
64 | $this->object = new ExportList($this->configurator); |
||
65 | } |
||
66 | |||
67 | public function testGetExportColumns() |
||
68 | { |
||
69 | $columns = $this->object->getExportColumns(); |
||
70 | $this->assertCount(3, $columns); |
||
0 ignored issues
–
show
$columns is of type array , but the function expects a object<Countable>|object...nit\Framework\iterable> .
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...
|
|||
71 | $this->assertInstanceOf(Field::class, $columns[0]); |
||
72 | $this->assertInstanceOf(Field::class, $columns[1]); |
||
73 | $this->assertInstanceOf(Field::class, $columns[2]); |
||
74 | } |
||
75 | |||
76 | public function testGetIterator() |
||
77 | { |
||
78 | $this->assertInstanceOf(Iterator::class, $this->object->getIterator()); |
||
79 | } |
||
80 | |||
81 | public function testGetStringValue() |
||
82 | { |
||
83 | $item = array('id' => 1); |
||
84 | |||
85 | $this->assertEquals(1, $this->object->getStringValue($item, 'id')); |
||
86 | } |
||
87 | |||
88 | /** |
||
89 | * @throws \ReflectionException |
||
90 | */ |
||
91 | public function testBindRequest() |
||
92 | { |
||
93 | $configurator = $this->createMock(AbstractAdminListConfigurator::class); |
||
94 | $configurator->expects($this->once())->method('bindRequest')->willReturn(true); |
||
95 | $mirror = new ReflectionClass(ExportList::class); |
||
96 | $property = $mirror->getProperty('configurator'); |
||
97 | $property->setAccessible(true); |
||
98 | $property->setValue($this->object, $configurator); |
||
99 | $this->object->bindRequest(new Request()); |
||
0 ignored issues
–
show
The method
Kunstmaan\AdminListBundl...portList::bindRequest() has been deprecated with message: ? This method is not configured in the configurator interface
This method has been deprecated. The supplier of the class has supplied an explanatory message. The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead.
Loading history...
|
|||
100 | } |
||
101 | } |
||
102 |
Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.
The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.
This check looks for comments that seem to be mostly valid code and reports them.