|
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 = []; |
|
|
|
|
|
|
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
|
|
|
|