简体   繁体   English

PHP关于assertEquals的解释

[英]php explanation on assertEquals

Inside of a phpunit test I have a $column variable and $actual fetches a $result from a mysql query. 在phpunit测试内部,我有一个$column变量,并且$actual从mysql查询中获取$result Is it possible to simply explain what the below assertEquals statement is doing with the given info without showing all the code? 是否可以简单地解释下面的assertEquals语句对给定信息所做的操作而无需显示所有代码?

$column = 'access_level';

$this->assertEquals($column, $actual['access_level']);

http://phpunit.de/manual/3.7/en/writing-tests-for-phpunit.html#writing-tests-for-phpunit.assertions.assertEquals http://phpunit.de/manual/3.7/zh-CN/writing-tests-for-phpunit.html#writing-tests-for-phpunit.assertions.assertEquals

assertEquals(mixed $expected, mixed $actual[, string $message = ''])

Reports an error identified ... if the two variables $expected and $actual are not equal. 如果两个变量$ expected和$ actual不相等,则报告错误。

Which means in your case that reports an error if $column != $actual['access_level'] 这意味着在您的情况下,如果$column != $actual['access_level']报告错误

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM