File: LexerTest.php

package info (click to toggle)
php-vlucas-phpdotenv 5.6.1-2
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 652 kB
  • sloc: php: 2,917; xml: 51; makefile: 26
file content (40 lines) | stat: -rw-r--r-- 937 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
<?php

declare(strict_types=1);

namespace Dotenv\Tests\Parser;

use Dotenv\Parser\Lexer;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\TestCase;

final class LexerTest extends TestCase
{
    /**
     * @return array{string,string[]}[]
     */
    public static function provideLexCases()
    {
        return [
            ['', []],
            ['FOO', ['FOO']],
            ['FOO bar', ['FOO', ' ', 'bar']],
            ['FOO\\n()ab', ['FOO', '\\', 'n()ab']],
            ["FOO\n\n   A", ['FOO', "\n\n", '   ', 'A']],
            ['"VA=L"', ['"', 'VA=L', '"']],
            ['\' \'', ['\'', ' ', '\'']],
        ];
    }

    /**
     * @param string   $input
     * @param string[] $output
     *
     * @return void
     */
    #[DataProvider('provideLexCases')]
    public function testLex(string $input, array $output)
    {
        self::assertSame($output, \iterator_to_array(Lexer::lex($input)));
    }
}