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

Revision 15170, 2.1 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
9require_once(CLASS_PATH . "db_extends/SC_DB_MasterData_Ex.php");
10require_once("PHPUnit/TestCase.php");
11
12/**
13 * SC_DB_MasterData のテストケース.
14 *
15 * @package DB
16 * @author LOCKON CO.,LTD.
17 * @version $Id$
18 */
19class SC_DB_MasterData_Test extends PHPUnit_TestCase {
20
21    // }}}
22    // {{{ functions
23
24    /**
25     * SC_DB_MasterData::getMasterData() のテストケース
26     */
27    function testGetMasterData() {
28
29        $columns = array("pref_id", "pref_name", "rank");
30        $masterData = new SC_DB_MasterData_Ex();
31        $actual = $masterData->getMasterData("mtb_pref", $columns);
32
33        $objQuery = new SC_Query();
34        $objQuery->setorder($columns[2]);
35        $results = $objQuery->select($columns[0] . ", " . $columns[1], "mtb_pref");
36
37        $expected = array();
38        foreach ($results as $result) {
39
40            $expected[$result[$columns[0]]] = $result[$columns[1]];
41        }
42        $this->assertEquals($expected, $actual);
43    }
44
45    /**
46     * SC_DB_MasterData::updateMasterData() のテストケース
47     */
48    function testUpdateMasterData() {
49
50        $columns = array("pref_id", "pref_name", "rank");
51        $masterData = new SC_DB_MasterData_Ex();
52
53        // Transaction を有効にするため接続しておく
54        $masterData->objQuery = new SC_Query();
55        $masterData->objQuery->begin();
56
57        $expected = array("10" => "北海道", "20" => "愛知", "30" => "岐阜");
58        $masterData->updateMasterData("mtb_pref", $columns, $expected, false);
59
60        $actual = $masterData->getMasterData("mtb_pref", $columns);
61
62        $this->assertEquals($expected, $actual);
63
64        $masterData->objQuery->rollback();
65        $masterData->clearCache("mtb_pref");
66    }
67
68    /**
69     * SC_DB_MasterData::createCache() のテストケース.
70     */
71    function testCreateCache() {
72        $masterData = new SC_DB_MasterData_Ex();
73        $masterData->createCache("mtb_constants", $masterData->getMasterData("mtb_constants"), true);
74        $this->assertEquals(true, defined("ECCUBE_VERSION"));
75    }
76}
77?>
Note: See TracBrowser for help on using the repository browser.