You've already forked MyDSL
优化测试,文件读取测试
This commit is contained in:
45
tests/Reader/FileReaderTest.php
Normal file
45
tests/Reader/FileReaderTest.php
Normal file
@ -0,0 +1,45 @@
|
||||
<?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');
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user