Ignore:
Timestamp:
2013/03/09 23:43:23 (11 years ago)
Author:
hiro151
Message:

#2183 SC_Helper_BestProductsクラスのテストコード(途中)

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

Legend:

Unmodified
Added
Removed
  • branches/camp/camp-2_13-tests/tests/class/helper/SC_Helper_BestProducts/SC_Helper_BestProducts_getBestProductsTest.php

    r22567 r22656  
    22 
    33$HOME = realpath(dirname(__FILE__)) . "/../../../.."; 
    4 require_once($HOME . "/tests/class/helper/SC_Helper_Purchase/SC_Helper_Purchase_TestBase.php"); 
     4require_once($HOME . "/tests/class/helper/SC_Helper_BestProducts/SC_Helper_BestProducts_TestBase.php"); 
    55/* 
    66 * This file is part of EC-CUBE 
     
    2626 
    2727/** 
    28  * SC_Helper_Purchase::getOrder()のテストクラス. 
     28 * SC_Helper_BestProducts::getBestProducts()のテストクラス. 
    2929 * 
    30  * 
    31  * @author Hiroko Tamagawa 
    32  * @version $Id$ 
     30 * @author hiroshi kakuta 
    3331 */ 
    34 class SC_Helper_Purchase_getOrderTest extends SC_Helper_Purchase_TestBase 
     32class SC_Helper_BestProducts_getBestProductsTest extends SC_Helper_BestProducts_TestBase 
    3533{ 
     34    protected function setUp() 
     35    { 
     36        parent::setUp(); 
     37        $this->setUpBestProducts(); 
     38    } 
     39 
     40    protected function tearDown() 
     41    { 
     42        parent::tearDown(); 
     43    } 
     44 
     45    /** best_idが存在しない場合、空を返す。 
     46     */ 
     47    public function testGetBestProducts_おすすめidが存在しない場合、空を返す() 
     48    { 
     49        $best_id = '9999'; 
     50 
     51        $this->expected = null; 
     52        $this->actual = SC_Helper_BestProducts::getBestProducts($best_id); 
     53 
     54        $this->verify(); 
     55    } 
     56 
     57    // best_idが存在する場合、対応した結果を取得できる。 
     58    public function testGetBestProducts_おすすめIDが存在する場合、対応した結果を取得できる(){ 
     59 
     60        $best_id = '1001'; 
    3661 
    3762 
    38   protected function setUp() 
    39   { 
    40     parent::setUp(); 
    41     $this->setUpOrder(); 
    42   } 
     63        $this->expected = array( 
     64            'category_id' => '0', 
     65            'rank' => '1', 
     66            'title' => 'タイトルですよ', 
     67            'comment' => 'コメントですよ', 
     68            'del_flg' => '0' 
     69        ); 
    4370 
    44   protected function tearDown() 
    45   { 
    46     parent::tearDown(); 
    47   } 
     71        $result = SC_Helper_BestProducts::getBestProducts($best_id); 
     72        $this->actual = Test_Utils::mapArray($result, 
     73            array('category_id', 
     74                'rank', 
     75                'title', 
     76                'comment', 
     77                'del_flg' 
     78            )); 
    4879 
    49   ///////////////////////////////////////// 
    50   public function testGetOrder_存在しない受注IDを指定した場合_結果が空になる() 
    51   { 
    52     $order_id = '9999'; 
     80        $this->verify(); 
    5381 
    54     $this->expected = null; 
    55     $this->actual = SC_Helper_Purchase::getOrder($order_id); 
     82    } 
    5683 
    57     $this->verify(); 
    58   } 
    5984 
    60   public function testGetOrder_存在しない顧客IDを指定した場合_結果が空になる() 
    61   { 
    62     $order_id = '1002'; 
    63     $customer_id = '9999'; 
     85    // best_idが存在するが、del_flg=1の場合、空が帰る。 
     86    public function testGetBestProducts_おすすめIDがあり、かつ削除済みの場合、空が返る(){ 
    6487 
    65     $this->expected = null; 
    66     $this->actual  = SC_Helper_Purchase::getOrder($order_id, $customer_id); 
     88        $best_id = '1002'; 
    6789 
    68     $this->verify(); 
    69   } 
     90        $this->expected = null; 
     91        $this->actual = SC_Helper_BestProducts::getBestProducts($best_id); 
    7092 
    71   public function testGetOrder_顧客IDを指定しなかった場合_受注IDに対応する結果が取得できる() 
    72   { 
    73     $order_id = '1002'; 
     93        $this->verify(); 
    7494 
    75     $this->expected = array( 
    76       'order_id' => '1002', 
    77       'customer_id' => '1002', 
    78       'order_name01' => '受注情報02' 
    79     ); 
    80     $result = SC_Helper_Purchase::getOrder($order_id); 
    81     $this->actual = Test_Utils::mapArray($result, array('order_id', 'customer_id', 'order_name01')); 
     95    } 
    8296 
    83     $this->verify(); 
    84   } 
     97    // best_idが存在するが、del_flg=1の場合、かつ。$has_deleted=trueを指定 
     98    public function testGetBestProducts_削除済みでかつhas_deletedがtrueの場合、対応した結果が返る(){ 
    8599 
    86   public function testGetOrder_存在する顧客IDを指定した場合_対応する結果が取得できる() 
    87   { 
    88     $order_id = '1002'; 
    89     $customer_id = '1002'; 
     100        $best_id = '1002'; 
    90101 
    91     $this->expected = array( 
    92       'order_id' => '1002', 
    93       'customer_id' => '1002', 
    94       'order_name01' => '受注情報02' 
    95     ); 
    96     $result = SC_Helper_Purchase::getOrder($order_id, $customer_id); 
    97     $this->actual = Test_Utils::mapArray($result, array('order_id', 'customer_id', 'order_name01')); 
    98102 
    99     $this->verify(); 
    100   } 
     103        $this->expected = array( 
     104            'category_id' => '0', 
     105            'rank' => '2', 
     106            'title' => 'タイトルですよ', 
     107            'comment' => 'コメントですよ', 
     108            'del_flg' => '1' 
     109        ); 
    101110 
    102   ////////////////////////////////////////// 
     111        $result = SC_Helper_BestProducts::getBestProducts($best_id,true); 
     112        $this->actual = Test_Utils::mapArray($result, 
     113            array('category_id', 
     114                'rank', 
     115                'title', 
     116                'comment', 
     117                'del_flg' 
     118            )); 
    103119 
     120        $this->verify(); 
     121    } 
    104122} 
    105123 
Note: See TracChangeset for help on using the changeset viewer.