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

Revision 22567, 3.2 KB checked in by shutta, 11 years ago (diff)

#2043 (typo修正・ソース整形・ソースコメントの改善 for 2.12.4)
Zend Framework PHP 標準コーディング規約のコーディングスタイルへ準拠。
classおよびfunctionの開始波括弧「{」のスタイルを修正。

  • 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    // }}}
39    // {{{ functions
40
41    /**
42     * SC_DB_MasterData::getMasterData() のテストケース
43     */
44    function testGetMasterData()
45    {
46        $columns = array('id', 'name', 'rank');
47        $masterData = new SC_DB_MasterData_Ex();
48        $actual = $masterData->getMasterData('mtb_pref', $columns);
49
50        $objQuery = new SC_Query();
51        $objQuery->setorder($columns[2]);
52        $results = $objQuery->select($columns[0] . ", " . $columns[1], 'mtb_pref');
53
54        $expected = array();
55        foreach ($results as $result) {
56
57            $expected[$result[$columns[0]]] = $result[$columns[1]];
58        }
59        $this->assertEquals($expected, $actual);
60    }
61
62    /**
63     * SC_DB_MasterData::updateMasterData() のテストケース
64     */
65    function testUpdateMasterData()
66    {
67
68        $columns = array('id', 'name', 'rank');
69        $masterData = new SC_DB_MasterData_Ex();
70
71        // Transaction を有効にするため接続しておく
72        $masterData->objQuery = new SC_Query();
73        $masterData->objQuery->begin();
74
75        $expected = array('10' => "北海道", '20' => "愛知", '30' => "岐阜");
76        $masterData->updateMasterData('mtb_pref', $columns, $expected, false);
77
78        $actual = $masterData->getDBMasterData('mtb_pref', $columns);
79
80        $this->assertEquals($expected['10'], $actual['10']);
81        $this->assertEquals($expected['20'], $actual['20']);
82        $this->assertEquals($expected['30'], $actual['30']);
83
84        $masterData->objQuery->rollback();
85        $masterData->clearCache('mtb_pref');
86    }
87
88    /**
89     * SC_DB_MasterData::createCache() のテストケース.
90     */
91    function testCreateCache()
92    {
93        $masterData = new SC_DB_MasterData_Ex();
94        $masterData->clearCache('mtb_constants');
95        $masterData->createCache('mtb_constants', array(), true, array('id', 'remarks'));
96        $this->assertEquals(true, defined('ECCUBE_VERSION'));
97    }
98}
99?>
Note: See TracBrowser for help on using the repository browser.