XInputEntries::defaultSource()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 3
rs 10
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