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

Revision 15163, 2.2 KB checked in by nanasess, 17 years ago (diff)

定数定義出力に対応

  • Property charset set to UTF-8
  • Property svn:keywords set to Id Revision Date
  • Property svn:mime-type set to application/x-httpd-php;charset=utf-8
Line 
1<?php
2/*
3 * Copyright(c) 2000-2007 LOCKON CO.,LTD. All Rights Reserved.
4 *
5 * http://www.lockon.co.jp/
6 */
7
8// {{{ requires
9if (!defined("CLASS_PATH")) {
10    //define("CLASS_PATH", "../../data/class/");
11}
12require_once(CLASS_PATH . "db_extends/SC_DB_MasterData_Ex.php");
13require_once("PHPUnit/TestCase.php");
14
15/**
16 * SC_DB_MasterData のテストケース.
17 *
18 * @package DB
19 * @author LOCKON CO.,LTD.
20 * @version $Id$
21 */
22class SC_DB_MasterData_Test extends PHPUnit_TestCase {
23
24    // }}}
25    // {{{ functions
26
27    /**
28     * SC_DB_MasterData::getMasterData() のテストケース
29     */
30    function testGetMasterData() {
31
32        $columns = array("pref_id", "pref_name", "rank");
33        $masterData = new SC_DB_MasterData_Ex();
34        $actual = $masterData->getMasterData("mtb_pref", $columns);
35
36        $objQuery = new SC_Query();
37        $objQuery->setorder($columns[2]);
38        $results = $objQuery->select($columns[0] . ", " . $columns[1], "mtb_pref");
39
40        $expected = array();
41        foreach ($results as $result) {
42
43            $expected[$result[$columns[0]]] = $result[$columns[1]];
44        }
45        $this->assertEquals($expected, $actual);
46    }
47
48    /**
49     * SC_DB_MasterData::updateMasterData() のテストケース
50     */
51    function testUpdateMasterData() {
52
53        $columns = array("pref_id", "pref_name", "rank");
54        $masterData = new SC_DB_MasterData_Ex();
55
56        // Transaction を有効にするため接続しておく
57        $masterData->objQuery = new SC_Query();
58        $masterData->objQuery->begin();
59
60        $expected = array("10" => "北海道", "20" => "愛知", "30" => "岐阜");
61        $masterData->updateMasterData("mtb_pref", $columns, $expected, false);
62
63        $actual = $masterData->getMasterData("mtb_pref", $columns);
64
65        $this->assertEquals($expected, $actual);
66
67        $masterData->objQuery->rollback();
68        $masterData->clearCache("mtb_pref");
69    }
70
71    /**
72     * SC_DB_MasterData::createCache() のテストケース.
73     */
74    function testCreateCache() {
75        $masterData = new SC_DB_MasterData_Ex();
76        $masterData->createCache("mtb_constants", $masterData->getMasterData("mtb_constants"), true);
77
78        $this->assertEquals(true, defined("ECCUBE_VERSION"));
79    }
80}
81?>
Note: See TracBrowser for help on using the repository browser.