Passed
Push — master ( e71c5f...ad7e69 )
by Robbie
04:06
created

PhpInfoCollectorTest   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 13
dl 0
loc 33
rs 10
c 0
b 0
f 0
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A testTrimLongPhpVersionNumbers() 0 9 1
A longPhpVersionProvider() 0 8 1
1
<?php
2
3
namespace LeKoala\DebugBar\Test\Collector;
4
5
use LeKoala\DebugBar\Collector\PhpInfoCollector;
6
use PHPUnit_Framework_TestCase;
7
use ReflectionClass;
8
9
class PhpInfoCollectorTest extends PHPUnit_Framework_TestCase
10
{
11
    /**
12
     * Note: testing with reflection since it's tidier than moving parent::collect() into its own method just
13
     * so we can mock it.
14
     *
15
     * @dataProvider longPhpVersionProvider
16
     * @param string $phpVersion
17
     * @param string $expected
18
     * @throws \ReflectionException
19
     */
20
    public function testTrimLongPhpVersionNumbers($phpVersion, $expected)
21
    {
22
        $reflection = new ReflectionClass(PhpInfoCollector::class);
23
        $method = $reflection->getMethod('trimVersion');
24
        $method->setAccessible(true);
25
26
        $collector = new PhpInfoCollector();
27
        $result = $method->invokeArgs($collector, [$phpVersion]);
28
        $this->assertSame($expected, $result);
29
    }
30
31
    /**
32
     * @return array[]
33
     */
34
    public function longPhpVersionProvider()
35
    {
36
        return [
37
            ['5.6.13', '5.6.13'],
38
            ['7.3.0', '7.3.0'],
39
            ['7.3.0dev', '7.3.0'],
40
            ['7.3.0-dev123+00', '7.3.0'],
41
            ['7.1.25-1+0~2017093290850938459043.8+jessie~1.gbpebe5d6', '7.1.25'],
42
        ];
43
    }
44
}
45