我想使用PHPUnit在Cakephp2.0中为以下函数创建一个测试:
public function matching($check, $field) {
$return = true;
foreach ($check as $c) {
if ($c != $this->data['User'][$field]) {
$return = false;
}
}
return $return;
}
如何设置值:
$this->data['User'][$field]
我的测试功能是:
public function testMatching() {
$this->data['User']['password'] = 'testpass';
$check = array('testpass');
$result = $this->User->matching($check, 'password');
$this->assertEquals(true, $result);
}
感谢。