Codeception / AspectMock

The most powerful and flexible mocking framework for PHPUnit / Codeception.
MIT License
790 stars 129 forks source link

Error: Using $this when not in object context #187

Open Jekahome opened 4 years ago

Jekahome commented 4 years ago
namespace app\aspectmockexample;

class AdminUserModel extends UserModel
{
    public function save()
    {
        $this->name = "Admin_111";
        parent::save();
    }
}
testing:
   public function testMagicStaticInherited()
    {
        double::registerClass('app\aspectmockexample\AdminUserModel', ['defaultRole' => 'admin']);
        TestCase::assertEquals('admin', AdminUserModel::defaultRole());
    }
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:

1) StubTest::testMagicStaticInherited
Error: Using $this when not in object context