嗨,我在控制器中有这个方法
public function registeruser($data){
var_dump($data);
if(($data) && ($this->User->create($data))) {
if($data['User']['password'] != Security::hash($data['User']['confirm_password'], null, true) ){
$this->Session->setFlash('las contraseñas no coinciden');
// unset($this->data['User']['password']);
// unset($this->data['User']['confirm_password']);
$this->redirect('index');
}
else if($this->User->save($data)) {
$this->_subscribMailchimp($data);
}else {
$this->Session->setFlash('El mail no es valido o ya está registrado.');
unset($data['User']['password']);
unset($data['User']['confirm_password']);
$this->redirect('index');
}
}else {
$this->Session->setFlash('No se ha podido registrar.');
$this->redirect('index');
}
return $this->User->getLastInsertID();
}
我需要通过 $data 表单测试控制器
$data = array('User' => array('name' => 'Luis jose',
'address' => 'el quinto pino',
'zip' => '28012',
'city' => 'Madrid',
'province' => '5',
'email' => 'luis@hotmail.com',
'password' => Security::hash(Configure::read('Security.salt') . '12345'),
'confirm_password' => '12345'));
$this->testAction('/users/registeruser', array('data' => $data, 'method' => 'get'));
我试过这个数组('data' => $data,'method' => 'get')。控制器函数没有接收到数组