Codeception / Codeception/AspectMock

Incorrect cache files

未关闭
#184 2 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看
主要语言
PHP
星标
784
派生
132
PR 合并指标
30 天内没有已合并 PR

描述

Invalid cache files creating when I run tests. In directory file looks like:

```
class Settings { if (($__am_res = __amock_before($this, __CLASS__, __FUNCTION__, array(), false)) !== __AM_CONTINUE__) return $__am_res;
...
```
After the test run I get the error message:

`[ParseError] syntax error, unexpected 'if' (T_IF), expecting function (T_FUNCTION) or const (T_CONST)
`

## Environment

- Codeception 4.1
- PHP7.2
- Aspect Mock 3.1

bootstrap.php
```
use AspectMock\Kernel;

define( 'PLUGIN_NAME_PATH', realpath( __DIR__ . '/../../../' ) . '/' );

$kernel = Kernel::getInstance();
$kernel->init(
[
'cacheDir' => PLUGIN_NAME_PATH . '.codeception/_cache/',
'debug' => true,
'includePaths' => [ PLUGIN_NAME_PATH . 'src/' ],
]
);
```

TestCase.php
```
use AspectMock\Test;
use Codeception\Test\Unit;
use AspectMock\Core\Registry;

abstract class TestCase extends Unit {
protected function _after(): void {
if ( Registry::$mocker ) {
Test::clean();
}
parent::_after();
}
}
```

贡献指南

这个仓库没有索引到贡献指南

调研方向

从 bootstrap.php 中配置的 cacheDir 开始,在运行测试后检查生成的缓存文件。将缓存输出与 TestCase.php 的清理流程进行比较,并重现 ParseError;完成的标准是测试运行不再创建无效的 PHP 缓存文件。

由索引模型根据 Issue 内容生成。

评估

技术栈
php
领域
testing
Issue 类型
缺陷
难度
4/5
预计耗时
3-5 天
活跃度
停滞
描述清晰度
需要澄清
新手友好度
25/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。