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

Revision 16326, 2.5 KB checked in by naka, 17 years ago (diff)

class_extendsディレクトリの追加

  • 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 * Copyright(c) 2000-2007 LOCKON CO.,LTD. All Rights Reserved.
4 *
5 * http://www.lockon.co.jp/
6 */
7
8// {{{ requires
9require_once(CLASS_EX_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:SC_DB_MasterData_Test.php 15532 2007-08-31 14:39:46Z nanasess $
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        $columns = array("pref_id", "pref_name", "rank");
29        $masterData = new SC_DB_MasterData_Ex();
30        $actual = $masterData->getMasterData("mtb_pref", $columns);
31
32        $objQuery = new SC_Query();
33        $objQuery->setorder($columns[2]);
34        $results = $objQuery->select($columns[0] . ", " . $columns[1], "mtb_pref");
35
36        $expected = array();
37        foreach ($results as $result) {
38
39            $expected[$result[$columns[0]]] = $result[$columns[1]];
40        }
41        $this->assertEquals($expected, $actual);
42    }
43
44    /**
45     * SC_DB_MasterData::updateMasterData() のテストケース
46     */
47    function testUpdateMasterData() {
48
49        $columns = array("pref_id", "pref_name", "rank");
50        $masterData = new SC_DB_MasterData_Ex();
51
52        // Transaction を有効にするため接続しておく
53        $masterData->objQuery = new SC_Query();
54        $masterData->objQuery->begin();
55
56        $expected = array("10" => "北海道", "20" => "愛知", "30" => "岐阜");
57        $masterData->updateMasterData("mtb_pref", $columns, $expected, false);
58
59        $actual = $masterData->getDBMasterData("mtb_pref", $columns);
60
61        $this->assertEquals($expected["10"], $actual["10"]);
62        $this->assertEquals($expected["20"], $actual["20"]);
63        $this->assertEquals($expected["30"], $actual["30"]);
64
65        $masterData->objQuery->rollback();
66        $masterData->clearCache("mtb_pref");
67    }
68
69    /**
70     * SC_DB_MasterData::createCache() のテストケース.
71     */
72    function testCreateCache() {
73        $masterData = new SC_DB_MasterData_Ex();
74        $datas = $masterData->getDBMasterData("mtb_constants");
75        $commentColumn = array("id", "remarks", "rank");
76        $masterData->clearCache("mtb_constants");
77        $masterData->createCache("mtb_constants", $datas, true,
78                                         array("id", "remarks", "rank"));
79        $this->assertEquals(true, defined("ECCUBE_VERSION"));
80    }
81}
82?>
Note: See TracBrowser for help on using the repository browser.