Index: trunk/test/README.txt
===================================================================
--- trunk/test/README.txt	(revision 18758)
+++ trunk/test/README.txt	(revision 18758)
@@ -0,0 +1,80 @@
+                    PHPUnit を使用したテストケースについて
+                 ____________________________________________
+
+	EC-CUBE では, PHPUnit を使用して, テスト駆動開発が可能です.
+	このドキュメントは, PHPUnit の使用方法を説明します.
+
+
+1. PHPUnit について
+-------------------
+
+	PHPUnit
+	http://www.phpunit.de/
+
+	日本語マニュアル
+	http://www.phpunit.de/manual/3.3/ja/index.html
+
+	PHPUnit3.3.x を使用してテストを行います.
+	残念ながら, このバージョンでは PHP4 はサポートされません.
+
+2. 動作環境
+-----------
+
+	http://www.phpunit.de/wiki/Requirements
+
+3. インストール
+---------------
+
+	http://www.phpunit.de/manual/3.3/ja/installation.html
+
+4. 実行方法
+-----------
+
+	テストケースで, EC-CUBE 本体のクラスへアクセスする時に相対パスを
+ 	使用していますので, 必ず test ディレクトリから実行して下さい.
+	また, EC-CUBE のクラス名は, PHPUnit の規約に沿ってないため, 引数で
+	PHPファイルを指定する必要があります.
+
+	
+	すべてのテストを実行するとき
+
+	  TestSuite クラスを実行します.
+          ------------------------------------------------------------
+	  $ phpunit TestSuite TestSuite.php
+	  PHPUnit 3.3.17 by Sebastian Bergmann.
+
+	  .................
+
+	  Time: 0 seconds
+
+	  OK (17 tests, 20 assertions)
+          ------------------------------------------------------------
+
+	パッケージごとにテストを実行するとき
+
+	  Package_AllTests クラスを実行します.
+          ------------------------------------------------------------
+	  $ phpunit DB_AllTests class/db/DB_AllTests.php
+	  PHPUnit 3.3.17 by Sebastian Bergmann.
+
+	  ....
+
+	  Time: 0 seconds
+
+	  OK (4 tests, 6 assertions)
+          ------------------------------------------------------------
+
+	クラスごとにテストを実行するとき
+
+	  テストクラスを指定して実行します.
+          ------------------------------------------------------------
+	  $ phpunit LC_Page_Test class/page/LC_Page_Test.php 
+	  PHPUnit 3.3.17 by Sebastian Bergmann.
+
+	  ..........
+
+	  Time: 0 seconds
+
+	  OK (10 tests, 11 assertions)
+          ------------------------------------------------------------
+
Index: trunk/test/TestSuite.php
===================================================================
--- trunk/test/TestSuite.php	(revision 16582)
+++ trunk/test/TestSuite.php	(revision 18758)
@@ -1,8 +1,7 @@
-#!/usr/local/bin/php
 <?php
 /*
  * This file is part of EC-CUBE
  *
- * Copyright(c) 2000-2007 LOCKON CO.,LTD. All Rights Reserved.
+ * Copyright(c) 2000-2010 LOCKON CO.,LTD. All Rights Reserved.
  *
  * http://www.lockon.co.jp/
@@ -23,22 +22,28 @@
  */
 
-ini_set("include_path", ".:/usr/local/share/pear");
 // {{{ requires
 require_once("../html/require.php");
-require_once("class/page/LC_Page_Test.php");
-require_once("class/db/SC_DB_DBFactory_Test.php");
-require_once("class/db/SC_DB_MasterData_Test.php");
-require_once("class/helper/SC_Helper_DB_Test.php");
-require_once("PHPUnit.php");
+require_once("class/page/Page_AllTests.php");
+require_once("class/db/DB_AllTests.php");
+require_once("class/helper/Helper_AllTests.php");
+require_once("class/util/Util_AllTests.php");
+require_once("PHPUnit/Framework.php");
 
-$suites = array();
-$suites[0] = new PHPUnit_TestSuite("LC_Page_Test");
-$suites[1] = new PHPUnit_TestSuite("SC_DB_DBFactory_Test");
-$suites[2] = new PHPUnit_TestSuite("SC_DB_MasterData_Test");
-$suites[3] = new PHPUnit_TestSuite("SC_Helper_DB_Test");
+/**
+ * EC-CUBE のテストスイート
+ *
+ * @author Kentaro Ohkouchi
+ * @version $Id:LC_Page_Test.php 15116 2007-07-23 11:32:53Z nanasess $
+ */
 
-foreach ($suites as $suite) {
-    $result = PHPUnit::run($suite);
-    print $result->toString();
+class TestSuite {
+    public static function suite() {
+        $suite = new PHPUnit_Framework_TestSuite('ECCUBE');
+        $suite->addTest(Page_AllTests::suite());
+        $suite->addTest(DB_AllTests::suite());
+        $suite->addTest(Helper_AllTests::suite());
+        $suite->addTest(Util_AllTests::suite());
+        return $suite;
+    }
 }
 ?>
Index: trunk/test/class/page/Page_AllTests.php
===================================================================
--- trunk/test/class/page/Page_AllTests.php	(revision 18758)
+++ trunk/test/class/page/Page_AllTests.php	(revision 18758)
@@ -0,0 +1,44 @@
+<?php
+/*
+ * This file is part of EC-CUBE
+ *
+ * Copyright(c) 2000-2010 LOCKON CO.,LTD. All Rights Reserved.
+ *
+ * http://www.lockon.co.jp/
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+ */
+
+// {{{ requires
+require_once 'PHPUnit/Framework.php';
+
+require_once 'LC_Page_Test.php';
+
+/**
+ * Page パッケージのテストケース.
+ *
+ * @package Page
+ * @author Kentaro Ohkouchi
+ * @version $Id:LC_Page_Test.php 15116 2007-07-23 11:32:53Z nanasess $
+ */
+class Page_AllTests extends PHPUnit_Framework_TestCase {
+
+    public static function suite() {
+        $suite = new PHPUnit_Framework_TestSuite('Page');
+        $suite->addTestSuite('LC_Page_Test');
+        return $suite;
+    }
+}
+?>
Index: trunk/test/class/page/LC_Page_Test.php
===================================================================
--- trunk/test/class/page/LC_Page_Test.php	(revision 16582)
+++ trunk/test/class/page/LC_Page_Test.php	(revision 18758)
@@ -3,5 +3,5 @@
  * This file is part of EC-CUBE
  *
- * Copyright(c) 2000-2007 LOCKON CO.,LTD. All Rights Reserved.
+ * Copyright(c) 2000-2010 LOCKON CO.,LTD. All Rights Reserved.
  *
  * http://www.lockon.co.jp/
@@ -23,6 +23,7 @@
 
 // {{{ requires
-require_once(CLASS_PATH . "pages/LC_Page.php");
-require_once("PHPUnit/TestCase.php");
+require_once("../html/require.php");
+require_once("../data/class/pages/LC_Page.php");
+require_once("PHPUnit/Framework.php");
 
 /**
@@ -33,12 +34,18 @@
  * @version $Id:LC_Page_Test.php 15116 2007-07-23 11:32:53Z nanasess $
  */
-class LC_Page_Test extends PHPUnit_TestCase {
+class LC_Page_Test extends PHPUnit_Framework_TestCase {
 
     // }}}
     // {{{ functions
 
+    /*
+     * FIXME LC_Page::sendRedirect() は, リダイレクトしてしまうため,
+     *       PHPUnit3 ではテストできない...
+     */
+
     /**
      * LC_Page::sendRedirect() のテストケース(エラー).
      */
+    /*
     function testSendRedirect() {
         $objPage = new LC_Page();
@@ -47,8 +54,9 @@
         $this->assertEquals(true, empty($result));
     }
-
+    */
     /**
      * LC_Page::sendRedirect() のテストケース(エラー).
      */
+    /*
     function testSendRedirectIsFailed() {
         $objPage = new LC_Page();
@@ -57,4 +65,5 @@
         $this->assertEquals(false, $result);
     }
+    */
 
     /**
@@ -132,6 +141,6 @@
     function testGetLocation() {
         $objPage = new LC_Page();
-        $_SERVER['DOCUMENT_ROOT'] = realpath("../../../html");
-        $url = $objPage->getLocation("../../../html/abouts/index.php");
+        $_SERVER['DOCUMENT_ROOT'] = realpath("../html");
+        $url = $objPage->getLocation("../html/abouts/index.php");
 
         $this->assertEquals(SITE_URL . "abouts/index.php", $url);
@@ -147,5 +156,5 @@
         $objPage = new LC_Page();
         $_SERVER['DOCUMENT_ROOT'] = realpath("../html");
-        $url = $objPage->getLocation("/abouts/index.php");
+        $url = $objPage->getLocation(URL_DIR . 'abouts/index.php');
 
         $this->assertEquals(SITE_URL . "abouts/index.php", $url);
@@ -160,8 +169,8 @@
     function testGetLocationWithQueryString() {
         $objPage = new LC_Page();
-        $_SERVER['DOCUMENT_ROOT'] = realpath("../../../html");
+        $_SERVER['DOCUMENT_ROOT'] = realpath("../html");
 
         $queryString = array("mode" => "update", "type" => "text");
-        $url = $objPage->getLocation("../../../html/abouts/index.php", $queryString);
+        $url = $objPage->getLocation("../html/abouts/index.php", $queryString);
 
         $this->assertEquals(SITE_URL . "abouts/index.php?mode=update&type=text", $url);
@@ -176,8 +185,8 @@
     function testGetLocationUseSSL() {
         $objPage = new LC_Page();
-        $_SERVER['DOCUMENT_ROOT'] = realpath("../../../html");
+        $_SERVER['DOCUMENT_ROOT'] = realpath("../html");
 
         $queryString = array("mode" => "update", "type" => "text");
-        $url = $objPage->getLocation("../../../html/abouts/index.php", $queryString, true);
+        $url = $objPage->getLocation("../html/abouts/index.php", $queryString, true);
 
         $this->assertEquals(SSL_URL . "abouts/index.php?mode=update&type=text", $url);
@@ -192,8 +201,8 @@
     function testGetLocationWithDocumentRoot() {
         $objPage = new LC_Page();
-        $documentRoot = realpath("../../../html");
+        $documentRoot = realpath("../html");
 
         $queryString = array("mode" => "update", "type" => "text");
-        $url = $objPage->getLocation("../../../html/abouts/index.php", array(),
+        $url = $objPage->getLocation("../html/abouts/index.php", array(),
                                      false, $documentRoot);
 
Index: trunk/test/class/SC_DbConn_Test.php
===================================================================
--- trunk/test/class/SC_DbConn_Test.php	(revision 18758)
+++ trunk/test/class/SC_DbConn_Test.php	(revision 18758)
@@ -0,0 +1,288 @@
+<?php
+/*
+ * This file is part of EC-CUBE
+ *
+ * Copyright(c) 2000-2010 LOCKON CO.,LTD. All Rights Reserved.
+ *
+ * http://www.lockon.co.jp/
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+ */
+
+// {{{ requires
+require_once("../html/require.php");
+require_once("../data/class/SC_DbConn.php");
+require_once("PHPUnit/Framework.php");
+
+/**
+ * SC_DbConn のテストケース.
+ *
+ * @author Kentaro Ohkouchi
+ * @version $Id$
+ */
+class SC_DbConn_Test extends PHPUnit_Framework_TestCase {
+
+    /** SC_DbConn インスタンス */
+    var $objDbConn;
+
+    var $expected;
+    var $actual;
+
+    function setUp() {
+        $this->objDbConn = new SC_DbConn();
+        $this->objDbConn->query("BEGIN");
+    }
+
+    function tearDown() {
+        $this->objDbConn->query("ROLLBACK");
+        $this->objDbConn = null;
+    }
+
+    function verify() {
+        $this->assertEquals($this->expected, $this->actual);
+    }
+
+    /**
+     * インスタンスを取得するテストケース.
+     */
+    function testGetInstance() {
+        $this->expected = true;
+        $this->actual = is_object($this->objDbConn);
+
+        $this->verify();
+    }
+
+    /**
+     * SC_DbConn:query() を使用して, CREATE TABLE を実行するテストケース.
+     */
+    function testCreateTable() {
+        $result = $this->createTestTable();
+
+        $this->expected = false;
+        $this->actual = PEAR::isError($result);
+
+        $this->verify();
+    }
+
+    /**
+     * SC_DbConn::getAll() のテストケース.
+     */
+    function testGetAll() {
+        $this->createTestTable();
+        $result = $this->setTestData(1, "2", "f");
+
+        $this->expected =  array(array("id" => "1",
+                                       "column1" => "1",
+                                       "column2" => "2",
+                                       "column3" => "f"));
+        $this->actual = $this->objDbConn->getAll("SELECT * FROM test_table WHERE id = ?", array(1));
+
+        $this->verify();
+    }
+
+    /**
+     * SC_DbConn::getAll() のテストケース(エラー).
+     */
+    function testGetAllIsError() {
+
+        // SC_DbConn::getAll() は接続エラーが発生すると 0 を返す
+        $failur_dsn = "pgsql://user:pass@127.0.0.1:/xxxxx";
+        $failurDbConn = new SC_DbConn($failur_dsn, false, true);
+        $this->expected = 0;
+        $this->actual = $failurDbConn->getAll("SELECT * FROM test_table");
+
+        $this->verify();
+    }
+
+
+    /**
+     * SC_DbConn::getOne() のテストケース.
+     */
+    function testGetOne() {
+        $this->createTestTable();
+        $this->setTestData(1, "2", "f");
+        $this->setTestData(1, "2", "f");
+        $this->setTestData(1, "2", "f");
+
+        $this->expected = 3;
+        $this->actual = $this->objDbConn->getOne("SELECT COUNT(*) FROM test_table");
+
+        $this->verify();
+    }
+
+    /**
+     * SC_DbConn::getOne() のテストケース(エラー).
+     */
+    function testGetOneIsError() {
+        $this->createTestTable();
+        $this->setTestData(1, "2", "f");
+        $this->setTestData(1, "2", "f");
+        $this->setTestData(1, "2", "f");
+
+        //$this->expected = new PEAR_Error();
+        $this->actual = $this->objDbConn->getOne("SELECT COUNT(*) FROM xxx_table");
+        var_dump($this->actual);
+        $this->verify();
+    }
+
+
+    /**
+     * SC_DbConn::getRow() のテストケース.
+     */
+    function testGetRow() {
+        $this->createTestTable();
+        $this->setTestData(1, "1", "f");
+        $this->setTestData(2, "2", "f");
+        $this->setTestData(3, "3", "f");
+
+        $this->expected = array("column1" => 1, "column2" => 1);
+        $this->actual = $this->objDbConn->getRow("SELECT column1, column2 FROM test_table WHERE id = ?", array(1));
+
+        $this->verify();
+    }
+
+    /**
+     * SC_DbConn::getCol() のテストケース.
+     */
+    function testGetCol() {
+        $this->createTestTable();
+        $this->setTestData(1, "1", "f");
+        $this->setTestData(2, "2", "f");
+        $this->setTestData(3, "3", "f");
+
+        $this->expected = array(1, 2);
+        $this->actual = $this->objDbConn->getCol("SELECT column1, column2 FROM test_table WHERE id < ?", "column1", array(3));
+
+        $this->verify();
+
+    }
+
+    /**
+     * SC_DbConn::autoExecute() で INSERT を実行するテストケース.
+     */
+    function testAutoExecuteOfInsert() {
+        $this->createTestTable();
+        $result = $this->setTestData(1, "2", "f");
+
+        $this->expected =  array(array("id" => "1",
+                                       "column1" => "1",
+                                       "column2" => "2",
+                                       "column3" => "f"));
+        $this->actual = $this->objDbConn->getAll("SELECT * FROM test_table");
+
+        //$this->assertEquals(1, $result);
+        $this->verify();
+    }
+
+    /**
+     * SC_DbConn::autoExecute() で UPDATE を実行するテストケース.
+     */
+    function testAutoExecuteOfUpdate() {
+        $this->createTestTable();
+        $this->setTestData(1, "2", "f");
+
+        $data = array("id" => "1",
+                      "column1" => "2",
+                      "column2" => "3",
+                      "column3" => "t");
+
+        $result = $this->objDbConn->autoExecute("test_table", $data, "id = 1");
+
+        $this->expected =  array($data);
+        $this->actual = $this->objDbConn->getAll("SELECT * FROM test_table");
+
+        $this->assertEquals(1, $result);
+        $this->verify();
+    }
+
+    /**
+     * SC_DbConn::query() で INSERT を実行するテストケース.
+     */
+    function testQuery1() {
+        $this->createTestTable();
+        $sql = "INSERT INTO test_table VALUES (?, ?, ?, ?)";
+        $data = array("1", "1", "1", "f");
+
+        $this->objDbConn->query($sql, $data);
+
+        $this->expected =  array(array("id" => "1",
+                                       "column1" => "1",
+                                       "column2" => "1",
+                                       "column3" => "f"));
+
+        $this->actual = $this->objDbConn->getAll("SELECT * FROM test_table");
+
+        $this->verify();
+    }
+
+    /**
+     * SC_DbConn::query() で UPDATE を実行するテストケース.
+     */
+    function testQuery2() {
+        $this->createTestTable();
+        $this->setTestData(1, "2", "f");
+
+        $sql = "UPDATE test_table SET column1 = ?, column2 = ? WHERE id = ?";
+        $data = array("2", "2", "1");
+
+        $this->objDbConn->query($sql, $data);
+
+        $this->expected =  array(array("id" => "1",
+                                       "column1" => "2",
+                                       "column2" => "2",
+                                       "column3" => "f"));
+
+        $this->actual = $this->objDbConn->getAll("SELECT * FROM test_table");
+
+        $this->verify();
+    }
+
+
+    /**
+     * SC_DbConn::prepare() は未使用
+     */
+    function testPrepare() {
+    }
+
+    /**
+     * SC_DbConn::execute() は未使用
+     */
+    function testExecute() {
+    }
+
+    /**
+     * SC_DbConn::reset() は未使用
+     */
+    function testReset() {
+    }
+
+    function createTestTable() {
+        $sql = "CREATE TABLE test_table ("
+            . "id SERIAL PRIMARY KEY,"
+            . "column1 numeric(9),"
+            . "column2 varchar(20),"
+            . "column3 char(1)"
+            . ")";
+        return $this->objDbConn->query($sql);
+    }
+
+    function setTestData($column1, $column2, $column3) {
+        $fields_values = array("column1" => $column1,
+                               "column2" => $column2,
+                               "column3" => $column3);
+        return $this->objDbConn->autoExecute("test_table", $fields_values);
+    }
+}
+?>
Index: trunk/test/class/util/SC_Utils_Test.php
===================================================================
--- trunk/test/class/util/SC_Utils_Test.php	(revision 18758)
+++ trunk/test/class/util/SC_Utils_Test.php	(revision 18758)
@@ -0,0 +1,82 @@
+<?php
+/*
+ * This file is part of EC-CUBE
+ *
+ * Copyright(c) 2000-2010 LOCKON CO.,LTD. All Rights Reserved.
+ *
+ * http://www.lockon.co.jp/
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+ */
+
+// {{{ requires
+require_once("../html/require.php");
+require_once("../data/class/pages/LC_Page.php");
+require_once("PHPUnit/Framework.php");
+
+/**
+ * SC_Utils のテストケース.
+ *
+ * @package Page
+ * @author LOCKON CO.,LTD.
+ * @version $Id:LC_Page_Test.php 15116 2007-07-23 11:32:53Z nanasess $
+ */
+class SC_Utils_Test extends PHPUnit_Framework_TestCase {
+
+    // }}}
+    // {{{ functions
+
+    /**
+     * SC_Utils::getRealURL() のテストケース.
+     *
+     * 変換無し
+     */
+    function testGetRealURL_変換無し() {
+        $url = "http://www.example.jp/admin/index.php";
+
+        $expected = "http://www.example.jp/admin/index.php";
+        $actual = SC_Utils::getRealURL($url);
+
+        $this->assertEquals($expected, $actual);
+    }
+
+    function testGetRealURL_変換有() {
+        $url = "http://www.example.jp/admin/../index.php";
+
+        $expected = "http://www.example.jp/index.php";
+        $actual = SC_Utils::getRealURL($url);
+
+        $this->assertEquals($expected, $actual);
+    }
+
+    function testGetRealURL_空のディレクトリ() {
+        $url = "http://www.example.jp/admin/..///index.php";
+
+        $expected = "http://www.example.jp/index.php";
+        $actual = SC_Utils::getRealURL($url);
+
+        $this->assertEquals($expected, $actual);
+    }
+
+    function testGetRealURL_Dotのディレクトリ() {
+        $url = "http://www.example.jp/admin/././../index.php";
+
+        $expected = "http://www.example.jp/index.php";
+        $actual = SC_Utils::getRealURL($url);
+
+        $this->assertEquals($expected, $actual);
+    }
+}
+?>
Index: trunk/test/class/util/Util_AllTests.php
===================================================================
--- trunk/test/class/util/Util_AllTests.php	(revision 18758)
+++ trunk/test/class/util/Util_AllTests.php	(revision 18758)
@@ -0,0 +1,44 @@
+<?php
+/*
+ * This file is part of EC-CUBE
+ *
+ * Copyright(c) 2000-2010 LOCKON CO.,LTD. All Rights Reserved.
+ *
+ * http://www.lockon.co.jp/
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+ */
+
+// {{{ requires
+require_once 'PHPUnit/Framework.php';
+
+require_once 'SC_Utils_Test.php';
+
+/**
+ * Util パッケージのテストケース.
+ *
+ * @package Util
+ * @author Kentaro Ohkouchi
+ * @version $Id:LC_Page_Test.php 15116 2007-07-23 11:32:53Z nanasess $
+ */
+class Util_AllTests extends PHPUnit_Framework_TestCase {
+
+    public static function suite() {
+        $suite = new PHPUnit_Framework_TestSuite('Util');
+        $suite->addTestSuite('SC_Utils_Test');
+        return $suite;
+    }
+}
+?>
Index: trunk/test/class/helper/SC_Helper_DB_Test.php
===================================================================
--- trunk/test/class/helper/SC_Helper_DB_Test.php	(revision 16582)
+++ trunk/test/class/helper/SC_Helper_DB_Test.php	(revision 18758)
@@ -3,5 +3,5 @@
  * This file is part of EC-CUBE
  *
- * Copyright(c) 2000-2007 LOCKON CO.,LTD. All Rights Reserved.
+ * Copyright(c) 2000-2010 LOCKON CO.,LTD. All Rights Reserved.
  *
  * http://www.lockon.co.jp/
@@ -23,8 +23,7 @@
 
 // {{{ requires
-// {{{ requires
-require_once($include_dir . "/../data/class/helper_extends/SC_Helper_DB_Ex.php"); // FIXME
-require_once("PHPUnit/TestCase.php");
-
+require_once("../html/require.php");
+require_once("../data/class_extends/helper_extends/SC_Helper_DB_Ex.php");
+require_once("PHPUnit/Framework.php");
 
 /**
@@ -35,5 +34,5 @@
  * @version $Id$
  */
-class SC_Helper_DB_Test extends PHPUnit_TestCase {
+class SC_Helper_DB_Test extends PHPUnit_Framework_TestCase {
 
     /**
@@ -53,8 +52,16 @@
     }
 
+    /**
+     * sfIndexExists() のテストケース.
+     *
+     * XXX MySQL では動作しない
+     */
     function testSfIndexExists() {
         $objDb = new SC_Helper_DB_Ex();
-        $this->assertEquals(true, $objDb->sfIndexExists("dtb_products", "category_id",
-                "dtb_products_category_id_key"));
+        if (DB_TYPE == "pgsql") {
+            $this->assertEquals(true, $objDb->sfIndexExists("dtb_products",
+                                                            "product_id",
+                                                            "dtb_products_product_id_key"));
+        }
     }
 }
Index: trunk/test/class/helper/Helper_AllTests.php
===================================================================
--- trunk/test/class/helper/Helper_AllTests.php	(revision 18758)
+++ trunk/test/class/helper/Helper_AllTests.php	(revision 18758)
@@ -0,0 +1,44 @@
+<?php
+/*
+ * This file is part of EC-CUBE
+ *
+ * Copyright(c) 2000-2010 LOCKON CO.,LTD. All Rights Reserved.
+ *
+ * http://www.lockon.co.jp/
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+ */
+
+// {{{ requires
+require_once 'PHPUnit/Framework.php';
+
+require_once 'SC_Helper_DB_Test.php';
+
+/**
+ * Helper パッケージのテストケース.
+ *
+ * @package DB
+ * @author Kentaro Ohkouchi
+ * @version $Id:LC_Page_Test.php 15116 2007-07-23 11:32:53Z nanasess $
+ */
+class Helper_AllTests extends PHPUnit_Framework_TestCase {
+
+    public static function suite() {
+        $suite = new PHPUnit_Framework_TestSuite('SC_Helper');
+        $suite->addTestSuite('SC_Helper_DB_Test');
+        return $suite;
+    }
+}
+?>
Index: trunk/test/class/logger/conf/log4php.properties
===================================================================
--- trunk/test/class/logger/conf/log4php.properties	(revision 18758)
+++ trunk/test/class/logger/conf/log4php.properties	(revision 18758)
@@ -0,0 +1,7 @@
+#---------------------------------
+# root logger test
+#---------------------------------
+log4php.rootLogger=DEBUG, R
+log4php.appender.R=LoggerAppenderEcho
+log4php.appender.R.layout=LoggerPatternLayout
+log4php.appender.R.layout.ConversionPattern="[%p] %m%n"
Index: trunk/test/class/logger/GC_Log_Log4php_Test.php
===================================================================
--- trunk/test/class/logger/GC_Log_Log4php_Test.php	(revision 18758)
+++ trunk/test/class/logger/GC_Log_Log4php_Test.php	(revision 18758)
@@ -0,0 +1,118 @@
+<?php
+/*
+ * This file is part of EC-CUBE
+ *
+ * Copyright(c) 2000-2010 LOCKON CO.,LTD. All Rights Reserved.
+ *
+ * http://www.lockon.co.jp/
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+ */
+
+define('LOG4PHP_CONFIGURATION', realpath(dirname(__FILE__)) . '/conf/log4php.properties');
+require_once(realpath(dirname(__FILE__)) . "/../../../data/class/logger/log/GC_Log_Log4php.php");
+require_once("PHPUnit/Framework.php");
+
+/**
+ * GC_Log_Log4phpのテスト
+ *
+ * プロパティファイルの内容は以下
+ * +---------------------------------------------------------
+ * | log4php.rootLogger=DEBUG, R
+ * | log4php.appender.R=LoggerAppenderEcho
+ * | log4php.appender.R.layout=LoggerPatternLayout
+ * | log4php.appender.R.layout.ConversionPattern="[%p] %m%n"
+ * +---------------------------------------------------------
+ *
+ * @package Logger
+ * @author LOCKON CO.,LTD.
+ * @version $Id$
+ *
+ */
+class GC_Log_Log4php_Test extends PHPUnit_Framework_TestCase
+{
+    /**
+     * DEBUGログのテスト
+     *
+     *
+     */
+    function testGfDebug(){
+        $object = new GC_Log_Log4php();
+
+        ob_start();
+        $object->gfDebug('DEBUGログ');
+        $buff = ob_get_contents();
+        ob_end_clean();
+
+        $output = "[DEBUG] DEBUGログ\n";
+
+        $this->assertEquals($buff, $output);
+    }
+
+    /**
+     * INFOログのテスト
+     *
+     *
+     */
+    function testGfInfo(){
+        $object = new GC_Log_Log4php();
+
+        ob_start();
+        $object->gfInfo('INFOログ');
+        $buff = ob_get_contents();
+        ob_end_clean();
+
+        $output = "[INFO] INFOログ\n";
+
+        $this->assertEquals($buff, $output);
+    }
+
+    /**
+     * ERRORログのテスト
+     *
+     *
+     */
+    function testGfError(){
+        $object = new GC_Log_Log4php();
+
+        ob_start();
+        $object->gfError('ERRORログ');
+        $buff = ob_get_contents();
+        ob_end_clean();
+
+        $output = "[ERROR] ERRORログ\n";
+
+        $this->assertEquals($buff, $output);
+    }
+
+    /**
+     * FATALログのテスト
+     *
+     *
+     */
+    function testGfFatal(){
+        $object = new GC_Log_Log4php();
+
+        ob_start();
+        $object->gfFatal('FATALログ');
+        $buff = ob_get_contents();
+        ob_end_clean();
+
+        $output = "[FATAL] FATALログ\n";
+
+        $this->assertEquals($buff, $output);
+    }
+}
+?>
Index: trunk/test/class/logger/GC_Logger_Test.php
===================================================================
--- trunk/test/class/logger/GC_Logger_Test.php	(revision 18758)
+++ trunk/test/class/logger/GC_Logger_Test.php	(revision 18758)
@@ -0,0 +1,228 @@
+<?php
+/*
+ * This file is part of EC-CUBE
+ *
+ * Copyright(c) 2000-2010 LOCKON CO.,LTD. All Rights Reserved.
+ *
+ * http://www.lockon.co.jp/
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+ */
+
+define('LOG4PHP_CONFIGURATION', realpath(dirname(__FILE__)) . '/conf/log4php.properties');
+require_once(realpath(dirname(__FILE__)) . "/../../../data/class/logger/GC_Logger.php");
+require_once("PHPUnit/Framework.php");
+
+/**
+ * GC_Loggerのテスト
+ *
+ * プロパティファイルの内容は以下
+ * +---------------------------------------------------------
+ * | log4php.rootLogger=DEBUG, R
+ * | log4php.appender.R=LoggerAppenderEcho
+ * | log4php.appender.R.layout=LoggerPatternLayout
+ * | log4php.appender.R.layout.ConversionPattern="[%p] %m%n"
+ * +---------------------------------------------------------
+ *
+ * @package Logger
+ * @author LOCKON CO.,LTD.
+ * @version $Id$
+ *
+ */
+class GC_Logger_Test extends PHPUnit_Framework_TestCase
+{
+
+    /**
+     * インスタンス化のテスト
+     *
+     *
+     */
+    function testGfGetInstance(){
+        $object1 = GC_Logger::gfGetInstance();
+        $object2 = GC_Logger::gfGetInstance();
+
+        $this->assertSame($object1, $object2);
+
+        $object3 = GC_Logger::gfGetInstance('logger3');
+        $object4 = GC_Logger::gfGetInstance('logger4');
+
+        $this->assertNotSame($object3, $object4);
+    }
+
+    /**
+     * DEBUGログのテスト
+     *
+     *
+     */
+    function testGfDebug(){
+        $object = GC_Logger::gfGetInstance();
+
+        ob_start();
+        $object->gfDebug('DEBUGログ');
+        $buff = ob_get_contents();
+        ob_end_clean();
+
+        $output = "[DEBUG] DEBUGログ\n";
+
+        $this->assertEquals($buff,$output);
+    }
+
+    /**
+     * DEBUGログ、ダンプテスト
+     *
+     *
+     */
+    function testGfDebugDump(){
+        $object = GC_Logger::gfGetInstance();
+        $a = array('test');
+        ob_start();
+        $object->gfDebug('a => ', $a);
+        $buff = ob_get_contents();
+        ob_end_clean();
+
+        $output = 
+"[DEBUG] a => Array
+(
+    [0] => test
+)
+
+";
+        $this->assertEquals($buff,$output);
+    }
+
+    /**
+     * INFOログのテスト
+     *
+     *
+     */
+    function testGfInfo(){
+        $object = GC_Logger::gfGetInstance();
+
+        ob_start();
+        $object->gfInfo('INFOログ');
+        $buff = ob_get_contents();
+        ob_end_clean();
+
+        $output = "[INFO] INFOログ\n";
+
+        $this->assertEquals($buff, $output);
+    }
+
+    /**
+     * INFOログ、ダンプのテスト
+     *
+     *
+     */
+    function testGfInfoDump(){
+        $object = GC_Logger::gfGetInstance();
+        $a = array('test');
+        ob_start();
+        $object->gfInfo('a => ', $a);
+        $buff = ob_get_contents();
+        ob_end_clean();
+
+        $output = 
+"[INFO] a => Array
+(
+    [0] => test
+)
+
+";
+        $this->assertEquals($buff, $output);
+    }
+
+    /**
+     * ERRORログのテスト
+     *
+     *
+     */
+    function testGfError(){
+        $object = GC_Logger::gfGetInstance();
+
+        ob_start();
+        $object->gfError('ERRORログ');
+        $buff = ob_get_contents();
+        ob_end_clean();
+
+        $output = "[ERROR] ERRORログ\n";
+
+        $this->assertEquals($buff, $output);
+    }
+
+    /**
+     * ERRORログ、ダンプのテスト
+     *
+     *
+     */
+    function testGfErrorDump(){
+        $object = GC_Logger::gfGetInstance();
+        $a = array('test');
+        ob_start();
+        $object->gfError('a => ', $a);
+        $buff = ob_get_contents();
+        ob_end_clean();
+
+        $output = 
+"[ERROR] a => Array
+(
+    [0] => test
+)
+
+";
+        $this->assertEquals($buff, $output);
+    }
+
+    /**
+     * FATALログのテスト
+     *
+     *
+     */
+    function testGfFatal(){
+        $object = GC_Logger::gfGetInstance();
+
+        ob_start();
+        $object->gfFatal('FATALログ');
+        $buff = ob_get_contents();
+        ob_end_clean();
+
+        $output = "[FATAL] FATALログ\n";
+
+        $this->assertEquals($buff, $output);
+    }
+
+    /**
+     * FATALログ、ダンプのテスト
+     *
+     *
+     */
+    function testGfFatalDump(){
+        $object = GC_Logger::gfGetInstance();
+        $a = array('test');
+        ob_start();
+        $object->gfFatal('a => ', $a);
+        $buff = ob_get_contents();
+        ob_end_clean();
+
+        $output = 
+"[FATAL] a => Array
+(
+    [0] => test
+)
+
+";
+        $this->assertEquals($buff, $output);
+    }
+}
+?>
Index: trunk/test/class/db/SC_DB_DBFactory_Test.php
===================================================================
--- trunk/test/class/db/SC_DB_DBFactory_Test.php	(revision 16582)
+++ trunk/test/class/db/SC_DB_DBFactory_Test.php	(revision 18758)
@@ -3,5 +3,5 @@
  * This file is part of EC-CUBE
  *
- * Copyright(c) 2000-2007 LOCKON CO.,LTD. All Rights Reserved.
+ * Copyright(c) 2000-2010 LOCKON CO.,LTD. All Rights Reserved.
  *
  * http://www.lockon.co.jp/
@@ -23,6 +23,7 @@
 
 // {{{ requires
-require_once($include_dir . "/../data/class/db_extends/SC_DB_DBFactory_Ex.php"); // FIXME
-require_once("PHPUnit/TestCase.php");
+require_once("../html/require.php");
+require_once("../data/class_extends/db_extends/SC_DB_DBFactory_Ex.php");
+require_once("PHPUnit/Framework.php");
 
 /**
@@ -33,5 +34,5 @@
  * @version $Id:SC_DB_DBFactory_Test.php 15532 2007-08-31 14:39:46Z nanasess $
  */
-class SC_DB_DBFactory_Test extends PHPUnit_TestCase {
+class SC_DB_DBFactory_Test extends PHPUnit_Framework_TestCase {
 
     // }}}
Index: trunk/test/class/db/SC_DB_MasterData_Test.php
===================================================================
--- trunk/test/class/db/SC_DB_MasterData_Test.php	(revision 16582)
+++ trunk/test/class/db/SC_DB_MasterData_Test.php	(revision 18758)
@@ -3,5 +3,5 @@
  * This file is part of EC-CUBE
  *
- * Copyright(c) 2000-2007 LOCKON CO.,LTD. All Rights Reserved.
+ * Copyright(c) 2000-2010 LOCKON CO.,LTD. All Rights Reserved.
  *
  * http://www.lockon.co.jp/
@@ -23,6 +23,7 @@
 
 // {{{ requires
-require_once(CLASS_EX_PATH . "db_extends/SC_DB_MasterData_Ex.php");
-require_once("PHPUnit/TestCase.php");
+require_once("../html/require.php");
+require_once("../data/class_extends/db_extends/SC_DB_MasterData_Ex.php");
+require_once("PHPUnit/Framework.php");
 
 /**
@@ -33,5 +34,5 @@
  * @version $Id:SC_DB_MasterData_Test.php 15532 2007-08-31 14:39:46Z nanasess $
  */
-class SC_DB_MasterData_Test extends PHPUnit_TestCase {
+class SC_DB_MasterData_Test extends PHPUnit_Framework_TestCase {
 
     // }}}
@@ -88,9 +89,9 @@
     function testCreateCache() {
         $masterData = new SC_DB_MasterData_Ex();
-        $datas = $masterData->getDBMasterData("mtb_constants");
-        $commentColumn = array("id", "remarks", "rank");
-        $masterData->clearCache("mtb_constants");
+        $datas = $masterData->getDBMasterData("mtb_constants"); 
+        $commentColumn = array("id", "remarks", "rank"); 
+        $masterData->clearCache("mtb_constants"); 
         $masterData->createCache("mtb_constants", $datas, true,
-                                         array("id", "remarks", "rank"));
+                                 array("id", "remarks", "rank"));
         $this->assertEquals(true, defined("ECCUBE_VERSION"));
     }
Index: trunk/test/class/db/DB_AllTests.php
===================================================================
--- trunk/test/class/db/DB_AllTests.php	(revision 18758)
+++ trunk/test/class/db/DB_AllTests.php	(revision 18758)
@@ -0,0 +1,46 @@
+<?php
+/*
+ * This file is part of EC-CUBE
+ *
+ * Copyright(c) 2000-2010 LOCKON CO.,LTD. All Rights Reserved.
+ *
+ * http://www.lockon.co.jp/
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+ */
+
+// {{{ requires
+require_once 'PHPUnit/Framework.php';
+
+require_once 'SC_DB_DBFactory_Test.php';
+require_once 'SC_DB_MasterData_Test.php';
+
+/**
+ * DB パッケージのテストケース.
+ *
+ * @package DB
+ * @author Kentaro Ohkouchi
+ * @version $Id:LC_Page_Test.php 15116 2007-07-23 11:32:53Z nanasess $
+ */
+class DB_AllTests extends PHPUnit_Framework_TestCase {
+
+    public static function suite() {
+        $suite = new PHPUnit_Framework_TestSuite('SC_DB');
+        $suite->addTestSuite('SC_DB_DBFactory_Test');
+        $suite->addTestSuite('SC_DB_MasterData_Test');
+        return $suite;
+    }
+}
+?>
