yii2 单元测试 codeception preg_match(): Compilation failed: PCRE does not support \L, \l, \N{name},

$ vendor/bin/codecept run unit
Codeception PHP Testing Framework v3.1.2
Powered by PHPUnit 7.5.17 by Sebastian Bergmann and contributors.
Running with seed:


In Run.php line 442:

  preg_match(): Compilation failed: PCRE does not support \L, \l, \N{name}, \U, or \u at offset 7


run [-o|--override OVERRIDE] [-e|--ext EXT] [--report] [--html [HTML]] [--xml [XML]] [--phpunit-xml [PHPUNIT-XML]] [--tap [TAP]] [--json [JSON]] [--colors] [--no-colors] [--silent] [--steps] [-d|--debug] [-
-bootstrap [BOOTSTRAP]] [--no-redirect] [--coverage [COVERAGE]] [--coverage-html [COVERAGE-HTML]] [--coverage-xml [COVERAGE-XML]] [--coverage-text [COVERAGE-TEXT]] [--coverage-crap4j [COVERAGE-CRAP4J]] [--c
overage-phpunit [COVERAGE-PHPUNIT]] [--no-exit] [-g|--group GROUP] [-s|--skip SKIP] [-x|--skip-group SKIP-GROUP] [--env ENV] [-f|--fail-fast] [--no-rebuild] [--seed SEED] [--] [<suite> [<test>]]

使用 vendor/bin/codecept run unit -vvv

$ vendor/bin/codecept run unit -vvv
Codeception PHP Testing Framework v3.1.2
Powered by PHPUnit 7.5.17 by Sebastian Bergmann and contributors.
Running with seed:


In Run.php line 442:

  [yii\base\ErrorException (2)]
  preg_match(): Compilation failed: PCRE does not support \L, \l, \N{name}, \U, or \u at offset 7


Exception trace:
  at C:\work\phpstudy\PHPTutorial\WWW\wzl_api\gzh\vendor\codeception\codeception\src\Codeception\Command\Run.php:442
 yii\base\ErrorHandler->handleError() at n/a:n/a
 preg_match() at C:\work\phpstudy\PHPTutorial\WWW\wzl_api\gzh\vendor\codeception\codeception\src\Codeception\Command\Run.php:442
 Codeception\Command\Run->matchSingleTest() at C:\work\phpstudy\PHPTutorial\WWW\wzl_api\gzh\vendor\codeception\codeception\src\Codeception\Command\Run.php:370
 Codeception\Command\Run->execute() at C:\work\phpstudy\PHPTutorial\WWW\wzl_api\gzh\vendor\symfony\console\Command\Command.php:255
 Symfony\Component\Console\Command\Command->run() at C:\work\phpstudy\PHPTutorial\WWW\wzl_api\gzh\vendor\symfony\console\Application.php:934
 Symfony\Component\Console\Application->doRunCommand() at C:\work\phpstudy\PHPTutorial\WWW\wzl_api\gzh\vendor\symfony\console\Application.php:273
 Symfony\Component\Console\Application->doRun() at C:\work\phpstudy\PHPTutorial\WWW\wzl_api\gzh\vendor\symfony\console\Application.php:149
 Symfony\Component\Console\Application->run() at C:\work\phpstudy\PHPTutorial\WWW\wzl_api\gzh\vendor\codeception\codeception\src\Codeception\Application.php:107
 Codeception\Application->run() at C:\work\phpstudy\PHPTutorial\WWW\wzl_api\gzh\vendor\codeception\codeception\codecept:43

 

找到准确的run.php地址,var_dump()一下发现是:test\unit这个在preg_match时,把‘\’一起转化了

所以在此之前加上  "$testsPath = preg_quote($testsPath);"

 $testsPath = $config['paths']['tests'] . DIRECTORY_SEPARATOR . $suiteConfig['path'];
                if ($suiteConfig['path'] === '.') {
                    $testsPath = $config['paths']['tests'];
                }

                $testsPath = preg_quote($testsPath);

                if (preg_match("~^$testsPath/(.*?)$~", $suite, $matches)) {
                    $matches[2] = $matches[1];
                    $matches[1] = $s;
                    return $matches;
                }

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值