Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
Jekahome opened this issue Sep 28, 2020 · 0 comments
Open

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

Jekahome opened this issue Sep 28, 2020 · 0 comments

Comments

@Jekahome
Copy link

Jekahome commented Sep 28, 2020

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant