MyDSL/tests/Reader/FileReaderTest.php

46 lines
1.6 KiB
PHP

<?php
/**
* @filename FileReaderTest.php
* @author Jerry Yan <792602257@qq.com>
* @date 2021/1/26 13:52
*/
namespace JerryYan\DSL\Test\Reader;
use JerryYan\DSL\Exception\FileNotFoundException;
use JerryYan\DSL\Reader\FileReader;
use JerryYan\DSL\Reader\ReaderInterface;
class FileReaderTest extends StringReaderTest
{
protected $files = [
__DIR__ . DIRECTORY_SEPARATOR . 'test.jdsl'
];
/** @var ReaderInterface[] */
protected $readerArray = [];
protected $things = [
[
'original' => "当 这个 等于 那个 的时候 则\r\n对 用户表 中的 该用户 更新 字段 状态 为 禁用",
'tokens' => ["", "这个", "等于", "那个", "的时候", "", "", "用户表", "中的", "该用户", "更新", "字段", "状态", "", "禁用"],
'nextTokens' => ["这个", "等于", "那个", "的时候", "", "", "用户表", "中的", "该用户", "更新", "字段", "状态", "", "禁用", ""],
'positions' => [0, 2, 5, 8, 11, 15, 18, 20, 24, 27, 31, 34, 37, 40, 42, 45, 47],
'lines' => [1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2],
'linePositions' => [0, 2, 5, 8, 11, 15, 0, 2, 6, 9, 13, 16, 19, 22, 24, 27, 29],
'moveToNextLines' => [6],
],
];
protected function setUp(): void
{
foreach ($this->files as $file) {
$this->readerArray[] = new FileReader($file);
}
}
public function testFileNotFoundException()
{
$this->expectException(FileNotFoundException::class);
new FileReader('Not Exist File');
}
}