Passed
Push — master ( 23993f...8bba30 )
by Radosław
02:37
created

FieldTest::testNonIntegerFid()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
3
use PHPUnit\Framework\TestCase;
4
use Radowoj\Yaah\Field;
5
6
class FieldTest extends TestCase
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class must be in a namespace of at least one level to avoid collisions.

You can fix this by adding a namespace to your class:

namespace YourVendor;

class YourClass { }

When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.

Loading history...
7
{
8
9
    /**
10
     * @expectedException Radowoj\Yaah\Exception
11
     * @expectedExceptionMessage fid must be an integer
12
     */
13
    public function testNonIntegerFid()
14
    {
15
        $field = new Field('some string');
0 ignored issues
show
Unused Code introduced by
$field is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
16
    }
17
18
19
    /**
20
     * Tests that output of Field->toArray() has the exact keys expected by WebAPI
21
     */
22
    public function testReturnedArray()
23
    {
24
        $field = new Field(1, 'some string');
25
26
        $this->assertEquals([
27
            'fid' => 1,
28
            'fvalueString' => 'some string',
29
            'fvalueInt' => 0,
30
            'fvalueFloat' => 0,
31
            'fvalueImage' => 0,
32
            'fvalueDatetime' => 0,
33
            'fvalueDate' => '',
34
            'fvalueRangeInt' => [
35
                'fvalueRangeIntMin' => 0,
36
                'fvalueRangeIntMax' => 0,
37
            ],
38
            'fvalueRangeFloat' => [
39
                'fvalueRangeFloatMin' => 0,
40
                'fvalueRangeFloatMax' => 0,
41
            ],
42
            'fvalueRangeDate' => [
43
                'fvalueRangeDateMin' => '',
44
                'fvalueRangeDateMax' => '',
45
            ],
46
47
        ], $field->toArray());
48
49
    }
50
}
51