setUpOrderTemp(); $this->helper = new SC_Helper_Purchase_Mock(); } protected function tearDown() { parent::tearDown(); } ///////////////////////////////////////// public function testSaveOrderTemp_受注一時情報IDが空の場合_何もしない(){ $this->helper->saveOrderTemp(null, array( 'customer_id' => '1003', 'order_name01' => '受注情報03', 'update_date' => 'CURRENT_TIMESTAMP' ) ); $this->expected = 2; $this->actual = $this->objQuery->count('dtb_order_temp'); $this->verify('件数が変わっていない'); } public function testSaveOrderTemp_既存の情報がない場合_情報が新規登録される(){ $this->helper->saveOrderTemp('1003', array( 'customer_id' => '1003', 'order_name01' => '受注情報03', 'update_date' => 'CURRENT_TIMESTAMP' ) ); $this->expected['count'] = '3'; $this->expected['content'] = array( array( 'order_temp_id' => '1003', 'customer_id' => '1003', 'order_name01' => '受注情報03' ) ); $this->actual['count'] = $this->objQuery->count('dtb_order_temp'); $this->actual['content'] = $this->objQuery->select( 'order_temp_id, customer_id, order_name01', 'dtb_order_temp', 'order_temp_id = ?', array('1003')); $this->verify('件数が一件増える'); } public function testSaveOrderTemp_既存の情報がある場合_情報が更新される(){ $this->helper->saveOrderTemp('1002', array( 'customer_id' => '2002', 'order_name01' => '受注情報92', 'update_date' => 'CURRENT_TIMESTAMP' ) ); $this->expected['count'] = '2'; $this->expected['content'] = array( array( 'order_temp_id' => '1002', 'customer_id' => '2002', 'order_name01' => '受注情報92' ) ); $this->actual['count'] = $this->objQuery->count('dtb_order_temp'); $this->actual['content'] = $this->objQuery->select( 'order_temp_id, customer_id, order_name01', 'dtb_order_temp', 'order_temp_id = ?', array('1002')); $this->verify('件数が変わらず更新される'); } public function testSaveOrderTemp_注文者情報がある場合_情報がコピーされる(){ $this->helper->saveOrderTemp('1003', array( 'order_temp_id' => '1003', 'customer_id' => '1003', 'order_name01' => '受注情報03', 'update_date' => 'CURRENT_TIMESTAMP' ), new SC_Customer_Ex() ); // function呼び出しを確認 $this->expectOutputString('COPY_FROM_CUSTOMER'); $this->expected = 3; $this->actual = $this->objQuery->count('dtb_order_temp'); $this->verify('件数が一件増える'); // 詳細な中身については他のテストで確認 } ////////////////////////////////////////// } class SC_Helper_Purchase_Mock extends SC_Helper_Purchase { function copyFromCustomer($sqlval, $objCustomer) { echo('COPY_FROM_CUSTOMER'); } }