Passed
Pull Request — main (#3)
by Peter
08:08
created

AttributesTest::testRemove()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 9
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 4
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 9
rs 10
1
<?php
2
3
declare(strict_types=1);
4
5
namespace AbterPhp\Framework\Html;
6
7
use PHPUnit\Framework\TestCase;
8
9
class AttributesTest extends TestCase
10
{
11
    /** @var Attributes - System Under Test */
12
    protected Attributes $sut;
13
14
    public function setUp(): void
15
    {
16
        $this->sut = new Attributes(['foo' => ['bar baz'], 'bar' => ['baz', 'quix']]);
17
    }
18
19
    public function testMerge()
20
    {
21
        $expectedResult = ' foo="bar baz foo bar" bar="baz quix" baz="foo bar"';
22
23
        $attributes = new Attributes(['baz' => ['foo', 'bar'], 'foo' => ['foo', 'bar']]);
24
25
        $this->sut->merge($attributes);
26
27
        $actualResult = (string)$this->sut;
28
29
        $this->assertSame($expectedResult, $actualResult);
30
    }
31
32
    public function testReplace()
33
    {
34
        $expectedResult = ' foo="foo bar" bar="baz quix" baz="foo bar"';
35
36
        $attributes = new Attributes(['baz' => ['foo', 'bar'], 'foo' => ['foo', 'bar']]);
37
38
        $this->sut->replace($attributes);
39
40
        $actualResult = (string)$this->sut;
41
42
        $this->assertSame($expectedResult, $actualResult);
43
    }
44
45
    public function testRemove()
46
    {
47
        $expectedResult = ' foo="bar baz"';
48
49
        $this->sut->remove('bar');
50
51
        $actualResult = (string)$this->sut;
52
53
        $this->assertSame($expectedResult, $actualResult);
54
    }
55
}