NumberValueParserTest   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 69
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 5
c 1
b 0
f 0
lcom 1
cbo 2
dl 0
loc 69
rs 10

5 Methods

Rating   Name   Duplication   Size   Complexity  
A setUp() 0 4 1
A testCanParseValue() 0 4 1
A canParseData() 0 17 1
A testParseValue() 0 4 1
A parseData() 0 12 1
1
<?php
2
/**
3
 * This file is part of graze/csv-token
4
 *
5
 * Copyright (c) 2016 Nature Delivered Ltd. <https://www.graze.com>
6
 *
7
 * For the full copyright and license information, please view the LICENSE
8
 * file that was distributed with this source code.
9
 *
10
 * @license https://github.com/graze/csv-token/blob/master/LICENSE.md
11
 * @link    https://github.com/graze/csv-token
12
 */
13
14
namespace Graze\CsvToken\Test\Unit\ValueParser;
15
16
use Graze\CsvToken\Test\TestCase;
17
use Graze\CsvToken\ValueParser\NumberValueParser;
18
19
class NumberValueParserTest extends TestCase
20
{
21
    /** @var NumberValueParser */
22
    private $parser;
23
24
    public function setUp()
25
    {
26
        $this->parser = new NumberValueParser();
27
    }
28
29
    /**
30
     * @dataProvider canParseData
31
     *
32
     * @param string $string
33
     * @param bool   $expected
34
     */
35
    public function testCanParseValue($string, $expected)
36
    {
37
        static::assertEquals($expected, $this->parser->canParseValue($string));
38
    }
39
40
    /**
41
     * @return array
42
     */
43
    public function canParseData()
44
    {
45
        return [
46
            ['1', true],
47
            ['1.2', true],
48
            ['-1', true],
49
            ['string', false],
50
            ['null', false],
51
            ['1.2e-12', true],
52
            ['4763894692379379723479327842', true],
53
            ['0.000000000001231312', true],
54
            ['some string', false],
55
            ['string12345', false],
56
            ['12345string', false],
57
            ['123,123,123.01', false],
58
        ];
59
    }
60
61
    /**
62
     * @dataProvider parseData
63
     *
64
     * @param string $string
65
     * @param mixed  $expected
66
     */
67
    public function testParseValue($string, $expected)
68
    {
69
        static::assertEquals($expected, $this->parser->parseValue($string));
70
    }
71
72
    /**
73
     * @return array
74
     */
75
    public function parseData()
76
    {
77
        return [
78
            ['1', true],
79
            ['1.2', 1.2],
80
            ['-1', -1],
81
            ['1.2e-12', 1.2e-12],
82
            ['4763894692379379723479327842', 4763894692379379723479327842],
83
            ['0.000000000001231312', 0.000000000001231312],
84
            ['123,123,123.01', 123123123.01],
85
        ];
86
    }
87
}
88