Skip to content

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

Description

@Jekahome
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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions