Passed
Push — master ( de4ed9...5f6eee )
by Petr
10:41
created

EntryTest   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 59
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 45
c 0
b 0
f 0
dl 0
loc 59
rs 10
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A testEntry() 0 23 1
A testFile() 0 32 1
1
<?php
2
3
namespace BasicTests;
4
5
6
use CommonTestClass;
7
use kalanis\kw_input\Entries;
8
use kalanis\kw_input\Interfaces;
9
10
11
class EntryTest extends CommonTestClass
12
{
13
    public function testEntry(): void
14
    {
15
        $data = new Entries\Entry();
16
        $this->assertInstanceOf(Interfaces\IEntry::class, $data);
17
18
        $this->assertEmpty($data->getSource());
19
        $this->assertEmpty($data->getKey());
20
        $this->assertEmpty($data->__toString());
21
22
        $data->setEntry('different', 'foz', 'wuz');
23
        $this->assertEmpty($data->getSource());
24
        $this->assertEquals('foz', $data->getKey());
25
        $this->assertEquals('wuz', $data->getValue());
26
27
        $data->setEntry(Interfaces\IEntry::SOURCE_GET, 'ugg', 'huu');
28
        $this->assertEquals(Interfaces\IEntry::SOURCE_GET, $data->getSource());
29
        $this->assertEquals('ugg', $data->getKey());
30
        $this->assertEquals('huu', $data->getValue());
31
32
        $data->setEntry(Interfaces\IEntry::SOURCE_POST, 'aqq');
33
        $this->assertEquals(Interfaces\IEntry::SOURCE_POST, $data->getSource());
34
        $this->assertEquals('aqq', $data->getKey());
35
        $this->assertEmpty($data->getValue());
0 ignored issues
show
Bug introduced by
Are you sure the usage of $data->getValue() targeting kalanis\kw_input\Entries\Entry::getValue() seems to always return null.

This check looks for function or method calls that always return null and whose return value is used.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
if ($a->getObject()) {

The method getObject() can return nothing but null, so it makes no sense to use the return value.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
36
    }
37
38
    public function testFile(): void
39
    {
40
        $data = new Entries\FileEntry();
41
        $this->assertInstanceOf(Interfaces\IEntry::class, $data);
42
        $this->assertInstanceOf(Interfaces\IFileEntry::class, $data);
43
44
        $this->assertEquals(Interfaces\IEntry::SOURCE_FILES, $data->getSource());
45
        $this->assertEmpty($data->getKey());
46
        $this->assertEmpty($data->getValue());
47
        $this->assertEmpty($data->getMimeType());
48
        $this->assertEmpty($data->getTempName());
49
        $this->assertEmpty($data->getError());
50
        $this->assertEmpty($data->getSize());
51
52
        $data->setEntry('different', 'foz', 'wuz');
53
        $this->assertEquals(Interfaces\IEntry::SOURCE_FILES, $data->getSource());
54
        $this->assertEquals('foz', $data->getKey());
55
        $this->assertEquals('wuz', $data->getValue());
56
        $this->assertEmpty($data->getMimeType());
57
        $this->assertEmpty($data->getTempName());
58
        $this->assertEmpty($data->getError());
59
        $this->assertEmpty($data->getSize());
60
61
        $data->setEntry(Interfaces\IEntry::SOURCE_GET, 'ugg', 'huu');
62
        $data->setFile('foo', 'uff', 'octet', 15, 20);
63
        $this->assertEquals(Interfaces\IEntry::SOURCE_FILES, $data->getSource());
64
        $this->assertEquals('ugg', $data->getKey());
65
        $this->assertEquals('foo', $data->getValue()); // yep, value is file name
66
        $this->assertEquals('uff', $data->getTempName());
67
        $this->assertEquals('octet', $data->getMimeType());
68
        $this->assertEquals(15, $data->getError());
69
        $this->assertEquals(20, $data->getSize());
70
    }
71
}
72