[22141] | 1 | <?php |
---|
| 2 | |
---|
| 3 | $HOME = realpath(dirname(__FILE__)) . "/../../../.."; |
---|
[22656] | 4 | require_once($HOME . "/tests/class/helper/SC_Helper_BestProducts/SC_Helper_BestProducts_TestBase.php"); |
---|
[22141] | 5 | /* |
---|
| 6 | * This file is part of EC-CUBE |
---|
| 7 | * |
---|
[22206] | 8 | * Copyright(c) 2000-2013 LOCKON CO.,LTD. All Rights Reserved. |
---|
[22141] | 9 | * |
---|
| 10 | * http://www.lockon.co.jp/ |
---|
| 11 | * |
---|
| 12 | * This program is free software; you can redistribute it and/or |
---|
| 13 | * modify it under the terms of the GNU General Public License |
---|
| 14 | * as published by the Free Software Foundation; either version 2 |
---|
| 15 | * of the License, or (at your option) any later version. |
---|
| 16 | * |
---|
| 17 | * This program is distributed in the hope that it will be useful, |
---|
| 18 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
| 19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
| 20 | * GNU General Public License for more details. |
---|
| 21 | * |
---|
| 22 | * You should have received a copy of the GNU General Public License |
---|
| 23 | * along with this program; if not, write to the Free Software |
---|
| 24 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
---|
| 25 | */ |
---|
| 26 | |
---|
| 27 | /** |
---|
[22656] | 28 | * SC_Helper_BestProducts::getBestProducts()のテストクラス. |
---|
[22141] | 29 | * |
---|
[22656] | 30 | * @author hiroshi kakuta |
---|
[22141] | 31 | */ |
---|
[22656] | 32 | class SC_Helper_BestProducts_getBestProductsTest extends SC_Helper_BestProducts_TestBase |
---|
[22567] | 33 | { |
---|
[22656] | 34 | protected function setUp() |
---|
| 35 | { |
---|
| 36 | parent::setUp(); |
---|
| 37 | $this->setUpBestProducts(); |
---|
| 38 | } |
---|
[22141] | 39 | |
---|
[22656] | 40 | protected function tearDown() |
---|
| 41 | { |
---|
| 42 | parent::tearDown(); |
---|
| 43 | } |
---|
[22141] | 44 | |
---|
[22656] | 45 | /** best_idが存在しない場合、空を返す。 |
---|
| 46 | */ |
---|
| 47 | public function testGetBestProducts_おすすめidが存在しない場合、空を返す() |
---|
| 48 | { |
---|
| 49 | $best_id = '9999'; |
---|
[22141] | 50 | |
---|
[22656] | 51 | $this->expected = null; |
---|
| 52 | $this->actual = SC_Helper_BestProducts::getBestProducts($best_id); |
---|
[22141] | 53 | |
---|
[22656] | 54 | $this->verify(); |
---|
| 55 | } |
---|
[22141] | 56 | |
---|
[22656] | 57 | // best_idが存在する場合、対応した結果を取得できる。 |
---|
| 58 | public function testGetBestProducts_おすすめIDが存在する場合、対応した結果を取得できる(){ |
---|
[22141] | 59 | |
---|
[22656] | 60 | $best_id = '1001'; |
---|
[22141] | 61 | |
---|
| 62 | |
---|
[22656] | 63 | $this->expected = array( |
---|
| 64 | 'category_id' => '0', |
---|
| 65 | 'rank' => '1', |
---|
| 66 | 'title' => 'タイトルですよ', |
---|
| 67 | 'comment' => 'コメントですよ', |
---|
| 68 | 'del_flg' => '0' |
---|
| 69 | ); |
---|
[22141] | 70 | |
---|
[22656] | 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 | )); |
---|
[22141] | 79 | |
---|
[22656] | 80 | $this->verify(); |
---|
[22141] | 81 | |
---|
[22656] | 82 | } |
---|
[22141] | 83 | |
---|
| 84 | |
---|
[22656] | 85 | // best_idが存在するが、del_flg=1の場合、空が帰る。 |
---|
| 86 | public function testGetBestProducts_おすすめIDがあり、かつ削除済みの場合、空が返る(){ |
---|
[22141] | 87 | |
---|
[22656] | 88 | $best_id = '1002'; |
---|
[22141] | 89 | |
---|
[22656] | 90 | $this->expected = null; |
---|
| 91 | $this->actual = SC_Helper_BestProducts::getBestProducts($best_id); |
---|
[22141] | 92 | |
---|
[22656] | 93 | $this->verify(); |
---|
[22141] | 94 | |
---|
[22656] | 95 | } |
---|
| 96 | |
---|
| 97 | // best_idが存在するが、del_flg=1の場合、かつ。$has_deleted=trueを指定 |
---|
| 98 | public function testGetBestProducts_削除済みでかつhas_deletedがtrueの場合、対応した結果が返る(){ |
---|
| 99 | |
---|
| 100 | $best_id = '1002'; |
---|
| 101 | |
---|
| 102 | |
---|
| 103 | $this->expected = array( |
---|
| 104 | 'category_id' => '0', |
---|
| 105 | 'rank' => '2', |
---|
| 106 | 'title' => 'タイトルですよ', |
---|
| 107 | 'comment' => 'コメントですよ', |
---|
| 108 | 'del_flg' => '1' |
---|
| 109 | ); |
---|
| 110 | |
---|
| 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 | )); |
---|
| 119 | |
---|
| 120 | $this->verify(); |
---|
| 121 | } |
---|
[22141] | 122 | } |
---|
| 123 | |
---|