Cakephp の単体テストに頭を悩ませようとしていますが、特定のコントローラー メソッドのテストを作成する方法について、誰かが入力できるかどうか疑問に思っています。
public function paymentmethod() {
$this->layout='dashboard';
$billingaddressInfo = $this->Dashboard->find('all',array('fields' => array('Address_book_id','first_name','last_name'),'conditions' => array('Dashboard.customer_id' => $this->Session->read('customer_id'),'address_type'=>'1')));
$billingaddress = array();
if(is_array($billingaddressInfo) && count($billingaddressInfo) > 0) {
foreach($billingaddressInfo as $key=>$value) {
$billingaddress[$value['Dashboard']['Address_book_id']] = $value['Dashboard']['first_name'].' '.$value['Dashboard']['last_name'];
}
}
$this->set('billingaddress',$billingaddress);
$fullbillingaddress = $this->Dashboard->find('all',array('fields' => array('Address_book_id','customer_id','first_name','last_name','address_line_1','address_line_2','city','state','country','zipcode'),
'conditions' => array('Dashboard.customer_id' =>$this->Session->read('customer_id'))));
$this->set('fullbillingaddress',$fullbillingaddress);
$shippingaddress = $this->Dashboard->find('list',array('fields' => array('first_name'),'conditions' => array('Dashboard.customer_id' => $this->Session->read('customer_id'),'address_type'=>'2')));
$this->set('shippingaddress',$shippingaddress);
$this->loadModel('Paymentmethod');
if(!empty ($this->request->data)) {
$getpaymentform = $this->request->data['Paymentmethod'];
$getpaymentform['card_number'] = $this->encryptCard($getpaymentform['card_number']);
if($this->request->data['Paymentmethod']['is_default']==1) {
$this->Paymentmethod->updateAll(array('is_default'=>'0'),array('Paymentmethod.customer_id' =>$this->Session->read('customer_id')));
}
$this->Paymentmethod->save($getpaymentform);
}
$paymentdata = $this->Paymentmethod->find('all',array('conditions' => array('Paymentmethod.customer_id' =>$this->Session->read('customer_id'))));
$this->set('paymentdata',$paymentdata);
$this->render();
if(!empty ($this->request->data)) {
$this->redirect(array('action'=>'paymentmethod'));
}
}
メソッドのどの部分をテストし、何を主張するかについての提案を本当に探しています. 私はそれに非常に慣れていないので、いくつかの情報をいただければ幸いです。