| 1 | <?php |
||
| 5 | class ParserTest extends \PHPUnit\Framework\TestCase |
||
| 6 | { |
||
| 7 | /** |
||
| 8 | * Dataprovider for Parser |
||
| 9 | * @return array |
||
| 10 | */ |
||
| 11 | public function dpParseValueByContent() |
||
| 12 | { |
||
| 13 | $dateTime = \date_create_immutable_from_format('* Y-m-d H:i:s e', time()); |
||
| 14 | |||
| 15 | $testCases = [ |
||
| 16 | [['test', 'yes'], true], |
||
| 17 | [['test', 'no'], false], |
||
| 18 | [['test', '0'], 0], |
||
| 19 | [['test', 'test'], 'test'], |
||
| 20 | [['test', '0123'], '0123'], |
||
| 21 | [['test', '1234'], 1234], |
||
| 22 | [['test', '18446744073709551615'], '18446744073709551615'], |
||
| 23 | [['Timestamp', (string)$dateTime], $dateTime], |
||
| 24 | [['Environment', 'FOO=bar BAZ=foo'], ['FOO' => 'bar', 'BAZ' => 'foo']], |
||
| 25 | ]; |
||
| 26 | |||
| 27 | // To cover codecoverage |
||
| 28 | foreach (Parser::getArrayTypes() as $arrayType) { |
||
| 29 | $testCases[] = [[$arrayType, 'test1 test2'], ['test1', 'test2']]; |
||
| 30 | } |
||
| 31 | |||
| 32 | return $testCases; |
||
| 33 | } |
||
| 34 | |||
| 35 | /** |
||
| 36 | * @dataProvider dpParseValueByContent |
||
| 37 | * @param $data |
||
| 38 | * @param $expected |
||
| 39 | */ |
||
| 40 | public function testParseValueByContent($data, $expected) |
||
| 41 | { |
||
| 42 | $this->assertEquals($expected, Parser::parseValueByContent($data)); |
||
| 43 | } |
||
| 44 | } |
||
| 45 |