XInputEntries   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 7
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 3
c 1
b 0
f 0
dl 0
loc 7
rs 10
wmc 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A defaultSource() 0 3 1
1
<?php
2
3
namespace TraitsTests;
4
5
6
use CommonTestClass;
7
use kalanis\kw_input\Entries\Entry;
8
use kalanis\kw_input\Traits;
9
10
11
class InputEntriesTest extends CommonTestClass
12
{
13
    public function testProcess(): void
14
    {
15
        $lib = new XInputEntries();
16
        $this->assertFalse($lib->offsetExists('foo'));
17
        $lib->offsetSet('foo', 'baz');
18
        $this->assertTrue($lib->offsetExists('foo'));
19
        $this->assertEquals('baz', $lib->offsetGet('foo')->getValue());
20
        $lib->offsetSet('foo', 'oag');
21
        $this->assertTrue($lib->offsetExists('foo'));
22
        $this->assertEquals('oag', $lib->offsetGet('foo')->getValue());
23
        $lib->offsetUnset('foo');
24
        $this->assertFalse($lib->offsetExists('foo'));
25
    }
26
27
    public function testSetters(): void
28
    {
29
        $lib = new XInputEntries();
30
        $lib->offsetSet('foo', (new Entry())->setEntry('one', 'there', new \stdClass()));
31
        $lib->offsetSet('foo', (new Entry())->setEntry('two', 'dhh', null));
32
        $this->assertTrue($lib->offsetExists('foo'));
33
        $this->assertNull($lib->offsetGet('foo')->getValue());
34
    }
35
36
    public function testIterator(): void
37
    {
38
        $lib = new XInputEntries();
39
        $this->assertEmpty(iterator_to_array($lib->getIterator()));
40
    }
41
}
42
43
44
class XInputEntries
45
{
46
    use Traits\TInputEntries;
47
48
    protected function defaultSource(): string
49
    {
50
        return Entry::SOURCE_EXTERNAL;
51
    }
52
}
53