Mock Object variable in PHPUnit
-
19-10-2022 - |
Question
I want to create a test for the following function in Cakephp2.0 with PHPUnit:
public function matching($check, $field) {
$return = true;
foreach ($check as $c) {
if ($c != $this->data['User'][$field]) {
$return = false;
}
}
return $return;
}
How do I set the value of:
$this->data['User'][$field]
My test function is:
public function testMatching() {
$this->data['User']['password'] = 'testpass';
$check = array('testpass');
$result = $this->User->matching($check, 'password');
$this->assertEquals(true, $result);
}
Thanks.
No correct solution
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow