Completed
Branch develop (b42baf)
by Adrien
11:23
created

DataSeriesValuesTest::testGetDataType()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 10
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 6
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 10
rs 9.4285
1
<?php
2
3
namespace PhpSpreadsheetTests\Chart;
4
5
use PhpSpreadsheet\Chart\DataSeriesValues;
6
use PhpSpreadsheet\Exception;
7
8
class DataSeriesValuesTest extends \PHPUnit_Framework_TestCase
9
{
10
    public function testSetDataType()
11
    {
12
        $dataTypeValues = [
13
            'Number',
14
            'String',
15
        ];
16
17
        $testInstance = new DataSeriesValues();
18
19
        foreach ($dataTypeValues as $dataTypeValue) {
20
            $result = $testInstance->setDataType($dataTypeValue);
21
            $this->assertTrue($result instanceof DataSeriesValues);
22
        }
23
    }
24
25
    public function testSetInvalidDataTypeThrowsException()
26
    {
27
        $testInstance = new DataSeriesValues();
28
29
        try {
30
            $result = $testInstance->setDataType('BOOLEAN');
0 ignored issues
show
Unused Code introduced by
$result 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...
31
        } catch (Exception $e) {
32
            $this->assertEquals($e->getMessage(), 'Invalid datatype for chart data series values');
33
34
            return;
35
        }
36
        $this->fail('An expected exception has not been raised.');
37
    }
38
39
    public function testGetDataType()
40
    {
41
        $dataTypeValue = 'String';
42
43
        $testInstance = new DataSeriesValues();
44
        $setValue = $testInstance->setDataType($dataTypeValue);
0 ignored issues
show
Unused Code introduced by
$setValue 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...
45
46
        $result = $testInstance->getDataType();
47
        $this->assertEquals($dataTypeValue, $result);
48
    }
49
}
50