source: branches/camp/camp-2_13-tests/tests/class/helper/SC_Helper_BestProducts/SC_Helper_BestProducts_getByRankTest.php @ 22719

Revision 22719, 3.5 KB checked in by hiro151, 9 years ago (diff)

#2183 SC_Helper_BestProductsを拡張クラスを使うよう修正

  • Property svn:executable set to *
Line 
1<?php
2
3$HOME = realpath(dirname(__FILE__)) . "/../../../..";
4require_once($HOME . "/tests/class/helper/SC_Helper_BestProducts/SC_Helper_BestProducts_TestBase.php");
5/*
6 * This file is part of EC-CUBE
7 *
8 * Copyright(c) 2000-2013 LOCKON CO.,LTD. All Rights Reserved.
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/**
28 * SC_Helper_BestProducts::getByRank()のテストクラス.
29 *
30 * @author hiroshi kakuta
31 */
32class SC_Helper_BestProducts_getByRankTest extends SC_Helper_BestProducts_TestBase
33{
34    protected function setUp()
35    {
36        parent::setUp();
37        $this->setUpBestProducts();
38    }
39
40    protected function tearDown()
41    {
42        parent::tearDown();
43    }
44
45    /** rankが存在しない場合、空を返す。
46     */
47    public function testGetByRank_ランクが存在しない場合_空を返す()
48    {
49        $rank = '9999';
50
51        $this->expected = null;
52        $this->actual = SC_Helper_BestProducts_Ex::getByRank($rank);
53
54        $this->verify();
55    }
56
57    // $rankが存在する場合、対応した結果を取得できる。
58    public function testGetByRank_ランクが存在する場合_対応した結果を取得できる(){
59
60        $rank = '1';
61
62        $this->expected = array(
63            'best_id' => '1001',
64            'category_id' => '0',
65            'title' => 'タイトルですよ',
66            'comment' => 'コメントですよ',
67            'del_flg' => '0'
68        );
69
70        $result = SC_Helper_BestProducts_Ex::getByRank($rank);
71        $this->actual = Test_Utils::mapArray($result,
72            array(
73                'best_id',
74                'category_id',
75                'title',
76                'comment',
77                'del_flg'
78            ));
79
80        $this->verify();
81
82    }
83
84
85    // rankが存在するが、del_flg=1の場合、空が帰る。
86    public function testGetByRank_ランクが存在かつ_削除の場合_空が返る(){
87
88        $rank = '2';
89
90        $this->expected = null;
91        $this->actual = SC_Helper_BestProducts_Ex::getByRank($rank);
92
93        $this->verify();
94
95    }
96
97    // rankが存在するが、del_flg=1の場合、かつ。$has_deleted=trueを指定
98    public function testGetByRank_ランクが存在かつ_has_deletedの場合_対応した結果が返る(){
99
100        $rank = '2';
101
102        $this->expected = array(
103            'best_id' => '1002',
104            'category_id' => '0',
105            'title' => 'タイトルですよ',
106            'comment' => 'コメントですよ',
107            'del_flg' => '1'
108        );
109
110        $result = SC_Helper_BestProducts_Ex::getByRank($rank,true);
111        $this->actual = Test_Utils::mapArray($result,
112            array(
113                'best_id',
114                'category_id',
115                'title',
116                'comment',
117                'del_flg'
118            ));
119
120        $this->verify();
121    }
122}
123
Note: See TracBrowser for help on using the repository browser.