Completed
Push — master ( 1de9b7...830752 )
by Kristof
38:46 queued 24:09
created

AbstractArticleAuthorAdminListConfiguratorTest.php (4 issues)

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\ArticleBundle\Tests\AdminList;
4
5
use Doctrine\ORM\EntityManager;
6
use Kunstmaan\AdminBundle\Helper\Security\Acl\AclHelper;
7
use Kunstmaan\ArticleBundle\AdminList\AbstractArticleAuthorAdminListConfigurator;
8
use PHPUnit\Framework\TestCase;
9
10
/**
11
 * Class AbstractArticleAuthorAdminListConfiguratorTest
12
 */
13
class AbstractArticleAuthorAdminListConfiguratorTest extends TestCase
14
{
15
    /**
16
     * @var AbstractArticleAuthorAdminListConfigurator
17
     */
18
    protected $object;
19
20
    /**
21
     * Sets up the fixture, for example, opens a network connection.
22
     * This method is called before a test is executed.
23
     */
24
    protected function setUp()
25
    {
26
        $em = $this->createMock(EntityManager::class);
27
        $em->expects($this->any())
28
            ->method($this->anything())
29
            ->willReturn($em);
30
31
        $acl = $this->createMock(AclHelper::class);
32
33
        $this->object = new AbstractArticleAuthorAdminListConfigurator($em, $acl, 'nl', 'admin');
0 ignored issues
show
The call to AbstractArticleAuthorAdm...igurator::__construct() has too many arguments starting with 'admin'.

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.

In this case you can add the @ignore PhpDoc annotation to the duplicate definition and it will be ignored.

Loading history...
$em is of type object<PHPUnit\Framework\MockObject\MockObject>, but the function expects a object<Doctrine\ORM\EntityManager>.

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...
$acl is of type object<PHPUnit\Framework\MockObject\MockObject>, but the function expects a object<Kunstmaan\AdminBu...Security\Acl\AclHelper>.

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...
34
    }
35
36
    public function testGetters()
37
    {
38
        $this->assertEquals('KunstmaanArticleBundle', $this->object->getBundleName());
39
        $this->assertEquals('AbstractArticleAuthor', $this->object->getEntityName());
40
    }
41
42
    public function testBuildFields()
43
    {
44
        $this->object->buildFields();
45
        $this->object->buildFilters();
46
        $fields = $this->object->getFields();
47
        $this->assertCount(2, $fields);
0 ignored issues
show
$fields is of type array<integer,object<Kun...undle\AdminList\Field>>, 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...
48
    }
49
}
50