Completed
Push — master ( 250fa5...0b3aa1 )
by Massimiliano
06:03
created

AbstractTaggableTest::testHasTag()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 7
rs 9.4285
cc 1
eloc 5
nc 1
nop 0
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
Documentation introduced by
$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
Documentation introduced by
$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
Documentation introduced by
$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
Documentation introduced by
$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
Documentation introduced by
$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
Documentation introduced by
$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