Passed
Pull Request — main (#4)
by Peter
06:09 queued 03:14
created

CollectionTest   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 9
c 1
b 0
f 0
dl 0
loc 28
rs 10
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A allInstanceOfProvider() 0 8 1
A testAllInstanceOf() 0 5 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace AbterPhp\Framework\Html\Helper;
6
7
use AbterPhp\Framework\Html\INode;
8
use AbterPhp\Framework\Html\Node;
9
use AbterPhp\Framework\Html\Tag;
10
use PHPUnit\Framework\TestCase;
11
12
class CollectionTest extends TestCase
13
{
14
    /**
15
     * @return array
16
     */
17
    public function allInstanceOfProvider(): array
18
    {
19
        return [
20
            'empty'               => [[], Node::class, true],
21
            'one-node-node'       => [[new Node()], Node::class, true],
22
            'one-node-inode'      => [[new Node()], INode::class, true],
23
            'first-node-not-tag'  => [[new Node()], INode::class, true],
24
            'second-node-not-tag' => [[new Tag(), new Node()], Tag::class, false],
25
        ];
26
    }
27
28
    /**
29
     * @dataProvider allInstanceOfProvider
30
     *
31
     * @param array  $items
32
     * @param string $className
33
     * @param bool   $expectedResult
34
     */
35
    public function testAllInstanceOf(array $items, string $className, bool $expectedResult): void
36
    {
37
        $actualResult = Collection::allInstanceOf($items, $className);
38
39
        $this->assertEquals($expectedResult, $actualResult);
40
    }
41
}
42