PHPUnit:assertInstanceOf() 不起作用 [英] PHPUnit: assertInstanceOf() not working

查看:28
本文介绍了PHPUnit:assertInstanceOf() 不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要检查一个变量是否是 User 类型的对象.用户是我的类 $user 我的对象

I need to check if a variable is an object of the User type. User is my class $user my object

$this->assertInstanceOf($user,User);

这不起作用,我使用了未定义的常量用户 - 假设为用户"

This is not working, I have a use of undefined constant User - assumed 'User'

预先感谢您的帮助

推荐答案

http://apigen.juzna.cz/doc/sebastianbergmann/phpunit/function-assertInstanceOf.html

我认为您使用此功能是错误的.试试:

I think you are using this function wrong. Try:

$this->assertInstanceOf('User', $user);

这篇关于PHPUnit:assertInstanceOf() 不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆