source: branches/feature-module-update/test/class/db/SC_DB_MasterData_Test.php @ 16582

Revision 16582, 3.3 KB checked in by nanasess, 16 years ago (diff)

ライセンス表記変更

  • Property charset set to UTF-8
  • Property svn:keywords set to Id Revision Date
  • Property svn:mime-type set to text/x-httpd-php; charset=UTF-8
Line 
1<?php
2/*
3 * This file is part of EC-CUBE
4 *
5 * Copyright(c) 2000-2007 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
25require_once(CLASS_EX_PATH . "db_extends/SC_DB_MasterData_Ex.php");
26require_once("PHPUnit/TestCase.php");
27
28/**
29 * SC_DB_MasterData のテストケース.
30 *
31 * @package DB
32 * @author LOCKON CO.,LTD.
33 * @version $Id:SC_DB_MasterData_Test.php 15532 2007-08-31 14:39:46Z nanasess $
34 */
35class SC_DB_MasterData_Test extends PHPUnit_TestCase {
36
37    // }}}
38    // {{{ functions
39
40    /**
41     * SC_DB_MasterData::getMasterData() のテストケース
42     */
43    function testGetMasterData() {
44        $columns = array("pref_id", "pref_name", "rank");
45        $masterData = new SC_DB_MasterData_Ex();
46        $actual = $masterData->getMasterData("mtb_pref", $columns);
47
48        $objQuery = new SC_Query();
49        $objQuery->setorder($columns[2]);
50        $results = $objQuery->select($columns[0] . ", " . $columns[1], "mtb_pref");
51
52        $expected = array();
53        foreach ($results as $result) {
54
55            $expected[$result[$columns[0]]] = $result[$columns[1]];
56        }
57        $this->assertEquals($expected, $actual);
58    }
59
60    /**
61     * SC_DB_MasterData::updateMasterData() のテストケース
62     */
63    function testUpdateMasterData() {
64
65        $columns = array("pref_id", "pref_name", "rank");
66        $masterData = new SC_DB_MasterData_Ex();
67
68        // Transaction を有効にするため接続しておく
69        $masterData->objQuery = new SC_Query();
70        $masterData->objQuery->begin();
71
72        $expected = array("10" => "北海道", "20" => "愛知", "30" => "岐阜");
73        $masterData->updateMasterData("mtb_pref", $columns, $expected, false);
74
75        $actual = $masterData->getDBMasterData("mtb_pref", $columns);
76
77        $this->assertEquals($expected["10"], $actual["10"]);
78        $this->assertEquals($expected["20"], $actual["20"]);
79        $this->assertEquals($expected["30"], $actual["30"]);
80
81        $masterData->objQuery->rollback();
82        $masterData->clearCache("mtb_pref");
83    }
84
85    /**
86     * SC_DB_MasterData::createCache() のテストケース.
87     */
88    function testCreateCache() {
89        $masterData = new SC_DB_MasterData_Ex();
90        $datas = $masterData->getDBMasterData("mtb_constants");
91        $commentColumn = array("id", "remarks", "rank");
92        $masterData->clearCache("mtb_constants");
93        $masterData->createCache("mtb_constants", $datas, true,
94                                         array("id", "remarks", "rank"));
95        $this->assertEquals(true, defined("ECCUBE_VERSION"));
96    }
97}
98?>
Note: See TracBrowser for help on using the repository browser.