source: branches/version-2_12-dev/test/class/db/SC_DB_MasterData_Test.php @ 22796

Revision 22796, 3.2 KB checked in by h_yoshimoto, 11 years ago (diff)

#2236 2.12.3リリース以降の2.12-devへのコミット差し戻し

  • Property svn:eol-style set to LF
  • Property svn:keywords set to Id
  • 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-2013 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(realpath(dirname(__FILE__)) . "/../../require.php");
26require_once(realpath(dirname(__FILE__)) . "/../../../data/class_extends/db_extends/SC_DB_MasterData_Ex.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_Framework_TestCase {
36
37    // }}}
38    // {{{ functions
39
40    /**
41     * SC_DB_MasterData::getMasterData() のテストケース
42     */
43    function testGetMasterData() {
44        $columns = array('id', '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('id', '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        $masterData->clearCache('mtb_constants');
91        $masterData->createCache('mtb_constants', array(), true, array('id', 'remarks'));
92        $this->assertEquals(true, defined('ECCUBE_VERSION'));
93    }
94}
95?>
Note: See TracBrowser for help on using the repository browser.