1 | <?php |
---|
2 | |
---|
3 | $HOME = realpath(dirname(__FILE__)) . "/../../../.."; |
---|
4 | require_once($HOME . "/tests/class/helper/SC_Helper_DB/SC_Helper_DB_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_DB::sfMoveRank()のテストクラス. |
---|
29 | * |
---|
30 | * @author Hiroko Tamagawa |
---|
31 | * @version $Id: SC_Helper_DB_sfMoveRank.php 22567 2013-02-18 10:09:54Z shutta $ |
---|
32 | */ |
---|
33 | class SC_Helper_DB_sfMoveRank extends SC_Helper_DB_TestBase |
---|
34 | { |
---|
35 | |
---|
36 | protected function setUp() |
---|
37 | { |
---|
38 | parent::setUp(); |
---|
39 | $this->helper = new SC_Helper_DB_Ex(); |
---|
40 | } |
---|
41 | |
---|
42 | protected function tearDown() |
---|
43 | { |
---|
44 | parent::tearDown(); |
---|
45 | } |
---|
46 | |
---|
47 | ///////////////////////////////////////// |
---|
48 | public function testSfMoveRank_一番下に移動する場合_RANK1を返す() |
---|
49 | { |
---|
50 | $this->setUpNews(); |
---|
51 | $table = 'dtb_news'; |
---|
52 | $keyIdColum = 'news_id'; |
---|
53 | $keyId = '3'; |
---|
54 | $pos = '3'; |
---|
55 | $where = null; |
---|
56 | $this->expected = 1; |
---|
57 | $this->helper->sfMoveRank($table, $keyIdColum, $keyId, $pos, $where); |
---|
58 | $col = 'rank'; |
---|
59 | $getWhere = 'news_id = ?'; |
---|
60 | $arrWhereVal = array($keyId); |
---|
61 | $this->actual = $this->objQuery->get($col, $table, $getWhere, $arrWhereVal); |
---|
62 | $this->verify(); |
---|
63 | } |
---|
64 | |
---|
65 | public function testSfMoveRank_一番上に移動する場合_RANKはMAXを返す() |
---|
66 | { |
---|
67 | $this->setUpNews(); |
---|
68 | $table = 'dtb_news'; |
---|
69 | $keyIdColum = 'news_id'; |
---|
70 | $keyId = '2'; |
---|
71 | $pos = '1'; |
---|
72 | $where = null; |
---|
73 | $this->expected = $this->objQuery->max('rank', $table); |
---|
74 | $this->helper->sfMoveRank($table, $keyIdColum, $keyId, $pos, $where); |
---|
75 | $col = 'rank'; |
---|
76 | $getWhere = 'news_id = ?'; |
---|
77 | $arrWhereVal = array($keyId); |
---|
78 | $this->actual = $this->objQuery->get($col, $table, $getWhere, $arrWhereVal); |
---|
79 | $this->verify(); |
---|
80 | } |
---|
81 | |
---|
82 | public function testSfMoveRank_同じ位置に移動する場合_RANKは変わらない() |
---|
83 | { |
---|
84 | $this->setUpNews(); |
---|
85 | $table = 'dtb_news'; |
---|
86 | $keyIdColum = 'news_id'; |
---|
87 | $keyId = '3'; |
---|
88 | $pos = '1'; |
---|
89 | $where = null; |
---|
90 | $this->expected = 3; |
---|
91 | $this->helper->sfMoveRank($table, $keyIdColum, $keyId, $pos, $where); |
---|
92 | $col = 'rank'; |
---|
93 | $getWhere = 'news_id = ?'; |
---|
94 | $arrWhereVal = array($keyId); |
---|
95 | $this->actual = $this->objQuery->get($col, $table, $getWhere, $arrWhereVal); |
---|
96 | $this->verify(); |
---|
97 | } |
---|
98 | |
---|
99 | public function testSfMoveRank_マイナスの位置に移動する場合_RANKはMAX() |
---|
100 | { |
---|
101 | $this->setUpNews(); |
---|
102 | $table = 'dtb_news'; |
---|
103 | $keyIdColum = 'news_id'; |
---|
104 | $keyId = '2'; |
---|
105 | $pos = '-1'; |
---|
106 | $where = null; |
---|
107 | $this->expected = $this->objQuery->max('rank', $table); |
---|
108 | $this->helper->sfMoveRank($table, $keyIdColum, $keyId, $pos, $where); |
---|
109 | $col = 'rank'; |
---|
110 | $getWhere = 'news_id = ?'; |
---|
111 | $arrWhereVal = array($keyId); |
---|
112 | $this->actual = $this->objQuery->get($col, $table, $getWhere, $arrWhereVal); |
---|
113 | $this->verify(); |
---|
114 | } |
---|
115 | |
---|
116 | public function testSfMoveRank_最大値以上の位置を与える場合_RANKは1となる() |
---|
117 | { |
---|
118 | $this->setUpNews(); |
---|
119 | $table = 'dtb_news'; |
---|
120 | $keyIdColum = 'news_id'; |
---|
121 | $keyId = '2'; |
---|
122 | $pos = '4'; |
---|
123 | $where = null; |
---|
124 | $this->expected = 1; |
---|
125 | $this->helper->sfMoveRank($table, $keyIdColum, $keyId, $pos, $where); |
---|
126 | $col = 'rank'; |
---|
127 | $getWhere = 'news_id = ?'; |
---|
128 | $arrWhereVal = array($keyId); |
---|
129 | $this->actual = $this->objQuery->get($col, $table, $getWhere, $arrWhereVal); |
---|
130 | $this->verify(); |
---|
131 | } |
---|
132 | |
---|
133 | } |
---|
134 | |
---|
135 | |
---|