Ignore:
Timestamp:
2013/03/10 12:54:59 (11 years ago)
Author:
hiro151
Message:

#2186 テストコード 途中

Location:
branches/camp/camp-2_13-tests/tests/class/helper/SC_Helper_Maker
Files:
1 added
1 copied

Legend:

Unmodified
Added
Removed
  • branches/camp/camp-2_13-tests/tests/class/helper/SC_Helper_Maker/SC_Helper_Maker_saveMakerTest.php

    r22695 r22727  
    22 
    33$HOME = realpath(dirname(__FILE__)) . "/../../../.."; 
    4 require_once($HOME . "/tests/class/helper/SC_Helper_BestProducts/SC_Helper_BestProducts_TestBase.php"); 
     4require_once($HOME . "/tests/class/helper/SC_Helper_Maker/SC_Helper_Maker_TestBase.php"); 
    55/* 
    66 * This file is part of EC-CUBE 
     
    2626 
    2727/** 
    28  * SC_Helper_BestProducts::saveBestProducts()のテストクラス. 
    2928 * 
    3029 * @author hiroshi kakuta 
    3130 */ 
    32 class SC_Helper_BestProducts_saveBestProductsTest extends SC_Helper_BestProducts_TestBase 
     31class SC_Helper_Maker_saveMakerTest extends SC_Helper_Maker_TestBase 
    3332{ 
     33    var $objHelperMaker; 
     34 
    3435    protected function setUp() 
    3536    { 
     37 
    3638        parent::setUp(); 
    37         $this->setUpBestProducts(); 
     39        $this->setUpMaker(); 
     40        $this->objHelperMaker = new SC_Helper_Maker_Ex(); 
    3841    } 
    3942 
     
    4447 
    4548 
    46     // best_idを指定して更新される。 
    47     public function testSaveBestProducts_ベストIDがある場合_更新される(){ 
    4849 
     50    public function testSaveMaker_メーカーIDを指定すると更新される(){ 
     51    //public function testSaveMaker_update(){ 
    4952        $sqlVal = array( 
    50             'best_id' => '1001', 
    51             'product_id'=>'3', 
    52             'category_id' => '1', 
    53             'rank' => '2', 
    54             'title' => 'タイトルですよ1001', 
    55             'comment' => 'コメントですよ1001', 
    56             'creator_id' => '2', 
    57             'create_date' => '2000-01-01 00:00:00', 
    58             'update_date' => '2000-01-01 00:00:00', 
    59             'del_flg' => '0' 
     53            'maker_id' => '1001', 
     54            'name' => 'ソニンー', 
    6055        ); 
    6156 
    62         $result = SC_Helper_BestProducts::saveBestProducts($sqlVal); 
     57        $this->objHelperMaker->saveMaker($sqlVal); 
    6358 
    6459        $this->expected = array( 
    65             'product_id'=>'3', 
    66             'category_id' => '1', 
    67             'rank' => '2', 
    68             'title' => 'タイトルですよ1001', 
    69             'comment' => 'コメントですよ1001', 
    70             'creator_id' => '1', //変わらない 
    71             'create_date' => '2000-01-01 00:00:00', 
    72             'del_flg' => '0' 
     60            'name' => 'ソニンー', 
    7361        ); 
    7462 
    75         $this->actual = SC_Helper_BestProducts::getBestProducts('1001'); 
    76  
    77         $arrRet = SC_Helper_BestProducts::getBestProducts('1001'); 
    78  
     63        $arrRet = $this->objHelperMaker->getMaker('1001'); 
    7964 
    8065        $this->actual = Test_Utils::mapArray($arrRet, 
    81             array('product_id', 
    82                 'category_id', 
    83                 'rank', 
    84                 'title', 
    85                 'comment', 
    86                 'creator_id', 
    87                 'create_date', 
    88                 'del_flg' 
    89             ) 
     66            array('name') 
    9067        ); 
    9168 
     
    9471 
    9572 
    96     // best_idがnullでデータインサートされる。 
    97     public function testSaveBestProducts_ベストIDがない場合_インサートされる(){ 
     73 
     74    public function testSaveMaker_メーカーIDがない場合_インサートされる(){ 
     75    //public function testSaveMaker_insert(){ 
    9876 
    9977        if(DB_TYPE != 'pgsql') { //postgresqlだとどうしてもDBエラーになるのでとりいそぎ回避 
    10078            $sqlVal = array( 
    101                 'product_id'=>'4', 
    102                 'category_id' => '2', 
    103                 'rank' => '4', 
    104                 'title' => 'タイトルですよ1004', 
    105                 'comment' => 'コメントですよ1004', 
    106                 'creator_id' => '3', 
     79                'name' => 'フジスリー', 
     80                'creator_id' => '1', 
    10781                'del_flg' => '0' 
    10882            ); 
    10983 
    110             $best_id = SC_Helper_BestProducts::saveBestProducts($sqlVal); 
     84            $maker_id = $this->objHelperMaker->saveMaker($sqlVal); 
     85 
    11186 
    11287            $this->expected = array( 
    113                 'product_id'=>'4', 
    114                 'category_id' => '2', 
    115                 'rank' => '4', 
    116                 'title' => 'タイトルですよ1004', 
    117                 'comment' => 'コメントですよ1004', 
    118                 'creator_id' => '3', 
     88                'name' => 'フジスリー', 
     89                'rank' => '5', 
     90                'creator_id' => '1', 
    11991                'del_flg' => '0' 
    12092            ); 
    12193 
    122             $arrRet = SC_Helper_BestProducts::getBestProducts($best_id); 
    123  
     94            $arrRet = $this->objHelperMaker->getMaker($maker_id); 
    12495 
    12596            $this->actual = Test_Utils::mapArray($arrRet, 
    126                 array('product_id', 
    127                     'category_id', 
     97                array( 
     98                    'name', 
    12899                    'rank', 
    129                     'title', 
    130                     'comment', 
    131100                    'creator_id', 
    132101                    'del_flg' 
     
    137106        } 
    138107 
    139  
    140     } 
    141  
    142  
    143     // best_idがnull、かつrankがnullの場合、想定されたランクが登録される 
    144     public function testSaveBestProducts_インサート処理でrankがsetされてない場合_採番された値がセットされる(){ 
    145  
    146         if(DB_TYPE != 'pgsql') { //postgresqlだとどうしてもDBエラーになるのでとりいそぎ回避 
    147             $sqlVal = array( 
    148                 'product_id'=>'5', 
    149                 'category_id' => '2', 
    150                 'title' => 'タイトルですよ5', 
    151                 'comment' => 'コメントですよ5', 
    152                 'creator_id' => '3', 
    153                 'del_flg' => '0' 
    154             ); 
    155  
    156             $best_id = SC_Helper_BestProducts::saveBestProducts($sqlVal); 
    157  
    158             $this->expected = "4"; //ランク 
    159  
    160             $arrRet = SC_Helper_BestProducts::getBestProducts($best_id); 
    161  
    162  
    163             $this->actual = $arrRet['rank']; 
    164  
    165             $this->verify(); 
    166         } 
    167108    } 
    168109 
Note: See TracChangeset for help on using the changeset viewer.