1 | <?php |
---|
2 | /* |
---|
3 | * This file is part of EC-CUBE |
---|
4 | * |
---|
5 | * Copyright(c) 2000-2010 LOCKON CO.,LTD. All Rights Reserved. |
---|
6 | * |
---|
7 | * http://www.lockon.co.jp/ |
---|
8 | * |
---|
9 | * This program is free software; you can redistribute it and/or |
---|
10 | * modify it under the terms of the GNU General Public License |
---|
11 | * as published by the Free Software Foundation; either version 2 |
---|
12 | * of the License, or (at your option) any later version. |
---|
13 | * |
---|
14 | * This program is distributed in the hope that it will be useful, |
---|
15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
17 | * GNU General Public License for more details. |
---|
18 | * |
---|
19 | * You should have received a copy of the GNU General Public License |
---|
20 | * along with this program; if not, write to the Free Software |
---|
21 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
---|
22 | */ |
---|
23 | |
---|
24 | // {{{ requires |
---|
25 | require_once("../html/require.php"); |
---|
26 | require_once("../data/class_extends/db_extends/SC_DB_MasterData_Ex.php"); |
---|
27 | require_once("PHPUnit/Framework.php"); |
---|
28 | |
---|
29 | /** |
---|
30 | * SC_DB_MasterData のテストケース. |
---|
31 | * |
---|
32 | * @package DB |
---|
33 | * @author LOCKON CO.,LTD. |
---|
34 | * @version $Id:SC_DB_MasterData_Test.php 15532 2007-08-31 14:39:46Z nanasess $ |
---|
35 | */ |
---|
36 | class SC_DB_MasterData_Test extends PHPUnit_Framework_TestCase { |
---|
37 | |
---|
38 | // }}} |
---|
39 | // {{{ functions |
---|
40 | |
---|
41 | /** |
---|
42 | * SC_DB_MasterData::getMasterData() のテストケース |
---|
43 | */ |
---|
44 | function testGetMasterData() { |
---|
45 | $columns = array("pref_id", "pref_name", "rank"); |
---|
46 | $masterData = new SC_DB_MasterData_Ex(); |
---|
47 | $actual = $masterData->getMasterData("mtb_pref", $columns); |
---|
48 | |
---|
49 | $objQuery = new SC_Query(); |
---|
50 | $objQuery->setorder($columns[2]); |
---|
51 | $results = $objQuery->select($columns[0] . ", " . $columns[1], "mtb_pref"); |
---|
52 | |
---|
53 | $expected = array(); |
---|
54 | foreach ($results as $result) { |
---|
55 | |
---|
56 | $expected[$result[$columns[0]]] = $result[$columns[1]]; |
---|
57 | } |
---|
58 | $this->assertEquals($expected, $actual); |
---|
59 | } |
---|
60 | |
---|
61 | /** |
---|
62 | * SC_DB_MasterData::updateMasterData() のテストケース |
---|
63 | */ |
---|
64 | function testUpdateMasterData() { |
---|
65 | |
---|
66 | $columns = array("pref_id", "pref_name", "rank"); |
---|
67 | $masterData = new SC_DB_MasterData_Ex(); |
---|
68 | |
---|
69 | // Transaction を有効にするため接続しておく |
---|
70 | $masterData->objQuery = new SC_Query(); |
---|
71 | $masterData->objQuery->begin(); |
---|
72 | |
---|
73 | $expected = array("10" => "北海道", "20" => "愛知", "30" => "岐阜"); |
---|
74 | $masterData->updateMasterData("mtb_pref", $columns, $expected, false); |
---|
75 | |
---|
76 | $actual = $masterData->getDBMasterData("mtb_pref", $columns); |
---|
77 | |
---|
78 | $this->assertEquals($expected["10"], $actual["10"]); |
---|
79 | $this->assertEquals($expected["20"], $actual["20"]); |
---|
80 | $this->assertEquals($expected["30"], $actual["30"]); |
---|
81 | |
---|
82 | $masterData->objQuery->rollback(); |
---|
83 | $masterData->clearCache("mtb_pref"); |
---|
84 | } |
---|
85 | |
---|
86 | /** |
---|
87 | * SC_DB_MasterData::createCache() のテストケース. |
---|
88 | */ |
---|
89 | function testCreateCache() { |
---|
90 | $masterData = new SC_DB_MasterData_Ex(); |
---|
91 | $datas = $masterData->getDBMasterData("mtb_constants"); |
---|
92 | $commentColumn = array("id", "remarks", "rank"); |
---|
93 | $masterData->clearCache("mtb_constants"); |
---|
94 | $masterData->createCache("mtb_constants", $datas, true, |
---|
95 | array("id", "remarks", "rank")); |
---|
96 | $this->assertEquals(true, defined("ECCUBE_VERSION")); |
---|
97 | } |
---|
98 | } |
---|
99 | ?> |
---|