Completed
Push — master ( fb5ff3...430575 )
by Massimiliano
01:16
created

Tests/Entity/AbstractTaggableTest.php (6 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 Beelab\TagBundle\Tests\Entity;
4
5
use Beelab\TagBundle\Test\Entity;
6
use PHPUnit\Framework\TestCase;
7
8
/**
9
 * @group unit
10
 */
11
class AbstractTaggableTest extends TestCase
12
{
13
    public function testHasTag()
14
    {
15
        $tag = $this->getMockBuilder('Beelab\TagBundle\Tag\TagInterface')->getMock();
16
        $entity = new Entity();
17
        $entity->addTag($tag);
0 ignored issues
show
$tag is of type object<PHPUnit\Framework\MockObject\MockObject>, but the function expects a object<Beelab\TagBundle\Tag\TagInterface>.

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...
18
        $this->assertTrue($entity->hasTag($tag));
0 ignored issues
show
$tag is of type object<PHPUnit\Framework\MockObject\MockObject>, but the function expects a object<Beelab\TagBundle\Tag\TagInterface>.

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...
19
    }
20
21
    public function testRemoveTag()
22
    {
23
        $tag = $this->getMockBuilder('Beelab\TagBundle\Tag\TagInterface')->getMock();
24
        $entity = new Entity();
25
        $entity->addTag($tag);
0 ignored issues
show
$tag is of type object<PHPUnit\Framework\MockObject\MockObject>, but the function expects a object<Beelab\TagBundle\Tag\TagInterface>.

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...
26
        $entity->removeTag($tag);
0 ignored issues
show
$tag is of type object<PHPUnit\Framework\MockObject\MockObject>, but the function expects a object<Beelab\TagBundle\Tag\TagInterface>.

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
        $this->assertFalse($entity->hasTag($tag));
0 ignored issues
show
$tag is of type object<PHPUnit\Framework\MockObject\MockObject>, but the function expects a object<Beelab\TagBundle\Tag\TagInterface>.

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...
28
    }
29
30
    public function testGetTags()
31
    {
32
        $tag = $this->getMockBuilder('Beelab\TagBundle\Tag\TagInterface')->getMock();
33
        $entity = new Entity();
34
        $entity->addTag($tag);
0 ignored issues
show
$tag is of type object<PHPUnit\Framework\MockObject\MockObject>, but the function expects a object<Beelab\TagBundle\Tag\TagInterface>.

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...
35
        $this->assertCount(1, $entity->getTags());
36
    }
37
38
    public function testGetTagsText()
39
    {
40
        $tag = $this->getMockBuilder('Beelab\TagBundle\Tag\TagInterface')->getMock();
41
        $entity = new Entity();
42
        $entity->setTagsText('foo, bar, baz');
43
        $this->assertEquals('', $entity->getTagsText());
44
    }
45
46
    public function testGetTagNames()
47
    {
48
        $tag = $this->getMockBuilder('Beelab\TagBundle\Tag\TagInterface')->getMock();
49
        $entity = new Entity();
50
        $this->assertEquals([], $entity->getTagNames());
51
    }
52
}
53