Codeception / Codeception/AspectMock
Error: Using $this when not in object context
- 主要言語
- PHP
- スター
- 784
- フォーク
- 132
- PR マージ指標
- 30日以内にマージされた PR はありません
説明
```php
namespace app\aspectmockexample;
class AdminUserModel extends UserModel
{
public function save()
{
$this->name = "Admin_111";
parent::save();
}
}
```
```php
testing:
public function testMagicStaticInherited()
{
double::registerClass('app\aspectmockexample\AdminUserModel', ['defaultRole' => 'admin']);
TestCase::assertEquals('admin', AdminUserModel::defaultRole());
}
```
```php
cache file generic:
public static function __callStatic($name, $args)
{
if ($name == 'defaultRole') { if (($__am_res = __amock_before($this, __CLASS__, __FUNCTION__, array(), false)) !== __AM_CONTINUE__) return $__am_res;
return "member";
}
}
```
Error message:
```text
1) StubTest::testMagicStaticInherited
Error: Using $this when not in object context
```
コントリビューションガイド
このリポジトリのコントリビューションガイドは索引されていません
調査の方向性
Start with StubTest::testMagicStaticInherited and reproduce the error using the AdminUserModel example. Then inspect the generated cache file's __callStatic method and the __amock_before call shown in the report. Done means the test completes without “Using $this when not in object context” and still returns the expected admin role.
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- php
- 領域
- testing
- issue の種類
- バグ
- 難易度
- 3/5
- 見積もり時間
- 1〜2日
- 活発さ
- 停滞
- 明瞭さ
- おおむね明確
- 初心者へのやさしさ
- 45/100