Passed
Push — master ( 6af672...0107a4 )
by Peter
07:37
created

ContentListTest::createEntity()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 9
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 5
c 0
b 0
f 0
nc 2
nop 2
dl 0
loc 9
rs 10
1
<?php
2
3
namespace AbterPhp\Website\Template\Builder\ContentList;
4
5
use AbterPhp\Website\Domain\Entities\ContentList as Entity;
6
use AbterPhp\Website\Domain\Entities\ContentListItem as Item;
7
use PHPUnit\Framework\TestCase;
8
9
abstract class ContentListTest extends TestCase
10
{
11
    /**
12
     * @param string $identifier
13
     * @param string ...$itemIds
14
     *
15
     * @return Entity
16
     */
17
    protected function createEntity(string $identifier, string ...$itemIds): Entity
18
    {
19
        $entity = new Entity("list-$identifier", '', $identifier, '', false, false, false, false, false, false);
20
        $items  = [];
0 ignored issues
show
Unused Code introduced by
The assignment to $items is dead and can be removed.
Loading history...
21
        foreach ($itemIds as $itemId) {
22
            $entity->addItem($this->createItem("item-$itemId", $itemId));
23
        }
24
25
        return $entity;
26
    }
27
28
    /**
29
     * @param string $id
30
     * @param string $postfix
31
     *
32
     * @return Item
33
     */
34
    protected function createItem(string $id, string $postfix): Item
35
    {
36
        $label       = "Foo $postfix";
37
        $labelHref   = "/foo-$postfix";
38
        $content     = "Bar $postfix";
39
        $contentHref = "/bar-$postfix";
40
        $imgSrc      = "/baz-$postfix.png";
41
        $imgAlt      = "Baz $postfix";
42
        $imgHref     = "/baz-$postfix";
43
        $classes     = "$postfix";
44
45
        return new Item($id, $id, $label, $labelHref, $content, $contentHref, $imgSrc, $imgAlt, $imgHref, $classes);
46
    }
47
}
48