AbstractTaggableTest   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 45
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 5
eloc 21
dl 0
loc 45
rs 10
c 0
b 0
f 0

5 Methods

Rating   Name   Duplication   Size   Complexity  
A testHasTag() 0 7 1
A testGetTagsText() 0 7 1
A testGetTagNames() 0 6 1
A testRemoveTag() 0 8 1
A testGetTags() 0 7 1
1
<?php
2
3
namespace Beelab\TagBundle\Tests\Entity;
4
5
use Beelab\TagBundle\Tag\TagInterface;
6
use Beelab\TagBundle\Tests\Entity;
7
use PHPUnit\Framework\TestCase;
8
9
/**
10
 * @group unit
11
 */
12
final class AbstractTaggableTest extends TestCase
13
{
14
    public function testHasTag(): void
15
    {
16
        /** @var TagInterface&\PHPUnit\Framework\MockObject\MockObject $tag */
17
        $tag = $this->createMock(TagInterface::class);
18
        $entity = new Entity();
19
        $entity->addTag($tag);
20
        $this->assertTrue($entity->hasTag($tag));
21
    }
22
23
    public function testRemoveTag(): void
24
    {
25
        /** @var TagInterface&\PHPUnit\Framework\MockObject\MockObject $tag */
26
        $tag = $this->createMock(TagInterface::class);
27
        $entity = new Entity();
28
        $entity->addTag($tag);
29
        $entity->removeTag($tag);
30
        $this->assertFalse($entity->hasTag($tag));
31
    }
32
33
    public function testGetTags(): void
34
    {
35
        /** @var TagInterface&\PHPUnit\Framework\MockObject\MockObject $tag */
36
        $tag = $this->createMock(TagInterface::class);
37
        $entity = new Entity();
38
        $entity->addTag($tag);
39
        $this->assertCount(1, $entity->getTags());
40
    }
41
42
    public function testGetTagsText(): void
43
    {
44
        /** @var TagInterface&\PHPUnit\Framework\MockObject\MockObject $tag */
45
        $tag = $this->createMock(TagInterface::class);
0 ignored issues
show
Unused Code introduced by Massimiliano Arione
The assignment to $tag is dead and can be removed.
Loading history...
46
        $entity = new Entity();
47
        $entity->setTagsText('foo, bar, baz');
48
        $this->assertEquals('', $entity->getTagsText());
49
    }
50
51
    public function testGetTagNames(): void
52
    {
53
        /** @var TagInterface&\PHPUnit\Framework\MockObject\MockObject $tag */
54
        $tag = $this->createMock(TagInterface::class);
0 ignored issues
show
Unused Code introduced by Massimiliano Arione
The assignment to $tag is dead and can be removed.
Loading history...
55
        $entity = new Entity();
56
        $this->assertEquals([], $entity->getTagNames());
57
    }
58
}
59