AspectMock icon indicating copy to clipboard operation
AspectMock copied to clipboard

Error: Using $this when not in object context

Open Jekahome opened this issue 3 years ago • 0 comments

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

Jekahome avatar Sep 28 '20 20:09 Jekahome