FieldsTest::testFields()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 23
Code Lines 17

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 17
dl 0
loc 23
rs 9.7
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Artack\Dsn;
6
7
use Artack\Dsn\Field\ValueField;
8
use PHPUnit\Framework\TestCase;
9
10
class FieldsTest extends TestCase
11
{
12
    public function testFields(): void
13
    {
14
        $firstValueField = new ValueField('fiRst', 'value', null);
15
        $secondValueField = new ValueField('Second', 'value', null);
16
        $thirdValueField = new ValueField('ThirD', 'value', null);
17
        $fields = new Fields($firstValueField, $secondValueField, $thirdValueField);
18
19
        $this->assertCount(3, $fields->getAll());
20
        $this->assertSame($firstValueField, $fields->get('first'));
21
        $this->assertSame($firstValueField, $fields->get('FiRsT'));
22
        $this->assertNull($fields->get('non-existent'));
23
24
        $this->assertSame([
25
            'first',
26
            'second',
27
            'third',
28
        ], $fields->getNames());
29
30
        $fields->remove('second');
31
        $this->assertCount(2, $fields->getAll());
32
33
        $fields->remove('tHirD');
34
        $this->assertCount(1, $fields->getAll());
35
    }
36
}
37