[Svn-src-all:3227] [version-2_12-dev 22128] 単体テスト用基盤クラスと一部テストコードを追加

shift_hiroko.tamagawa admin @ mail.ec-cube.net
2012年 12月 9日 (日) 08:22:46 JST


Subversion committed to /home/svn/open 22128
http://svn.ec-cube.net/open_trac/changeset/22128
┌────────────────────────────┐
│更新者 :  shift_hiroko.tamagawa                        │
│更新日時:  2012-12-09 08:22:45 +0900 (日, 09 12月 2012)│
└────────────────────────────┘

Log:
--------------------------------------------------------
単体テスト用基盤クラスと一部テストコードを追加

Changed:                      [U:修正,A:追加,D:削除]
--------------------------------------------------------
A   branches/version-2_12-dev/build.xml
_U  branches/version-2_12-dev/tests/
A   branches/version-2_12-dev/tests/class/
A   branches/version-2_12-dev/tests/class/Common_TestCase.php
A   branches/version-2_12-dev/tests/class/helper/
A   branches/version-2_12-dev/tests/class/helper/SC_Helper_Purchase/
A   branches/version-2_12-dev/tests/class/helper/SC_Helper_Purchase/SC_Helper_Purchase_BaseTest.php
A   branches/version-2_12-dev/tests/class/helper/SC_Helper_Purchase/SC_Helper_Purchase_clearShipmentItemTempTest.php
A   branches/version-2_12-dev/tests/class/helper/SC_Helper_Purchase/SC_Helper_Purchase_getShippingPrefTest.php
A   branches/version-2_12-dev/tests/class/helper/SC_Helper_Purchase/SC_Helper_Purchase_getShippingTempTest.php
A   branches/version-2_12-dev/tests/class/helper/SC_Helper_Purchase/SC_Helper_Purchase_isAddPointTest.php
A   branches/version-2_12-dev/tests/class/helper/SC_Helper_Purchase/SC_Helper_Purchase_isUsePointTest.php
A   branches/version-2_12-dev/tests/class/helper/SC_Helper_Purchase/SC_Helper_Purchase_saveShippingTempTest.php
A   branches/version-2_12-dev/tests/class/helper/SC_Helper_Purchase/SC_Helper_Purchase_unsetAllShippingTempTest.php
A   branches/version-2_12-dev/tests/class/helper/SC_Helper_Purchase/SC_Helper_Purchase_unsetOneShippingTest.php
A   branches/version-2_12-dev/tests/class/helper/SC_Helper_Purchase/SC_Helper_Purchase_unsetShippingTempTest.php
A   branches/version-2_12-dev/tests/class/replace/
A   branches/version-2_12-dev/tests/class/replace/SC_Display_Ex.php
A   branches/version-2_12-dev/tests/class/replace/SC_Response_Ex.php
A   branches/version-2_12-dev/tests/class/test/
A   branches/version-2_12-dev/tests/class/test/util/
A   branches/version-2_12-dev/tests/class/test/util/User_Utils.php
A   branches/version-2_12-dev/tests/class/util/
A   branches/version-2_12-dev/tests/class/util/SC_Utils/
A   branches/version-2_12-dev/tests/class/util/SC_Utils/SC_Utils_getTableTagTest.php
A   branches/version-2_12-dev/tests/class/util/SC_Utils/SC_Utils_repeatStrWithSeparatorTest.php
A   branches/version-2_12-dev/tests/class/util/SC_Utils/SC_Utils_sfCalcIncTaxTest.php
A   branches/version-2_12-dev/tests/class/util/SC_Utils/SC_Utils_sfGetCommaListTest.php
A   branches/version-2_12-dev/tests/class/util/SC_Utils/SC_Utils_sfGetRandomStringTest.php
A   branches/version-2_12-dev/tests/class/util/SC_Utils/SC_Utils_sfIsIntTest.php
A   branches/version-2_12-dev/tests/class/util/SC_Utils/SC_Utils_sfIsZeroFillingTest.php
A   branches/version-2_12-dev/tests/class/util/SC_Utils/SC_Utils_sfTaxTest.php
A   branches/version-2_12-dev/tests/class/util/SC_Utils/SC_Utils_sfTrimTest.php
A   branches/version-2_12-dev/tests/phpunit.xml.base
A   branches/version-2_12-dev/tests/phpunit.xml.jenkins
A   branches/version-2_12-dev/tests/require.php.base
A   branches/version-2_12-dev/tests/require.php.jenkins
A   branches/version-2_12-dev/tests/ruleset.xml

追加: branches/version-2_12-dev/build.xml
===================================================================
--- branches/version-2_12-dev/build.xml	                        (rev 0)
+++ branches/version-2_12-dev/build.xml	2012-12-08 23:22:45 UTC (rev 22128)
@@ -0,0 +1,33 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<project name="EC-CUBE" basedir="." default="test">
+  <!-- Jenkins上でのみ実行するタスク -->
+  <target name="prepare-jenkins">
+    <copy overwrite="true" file="data/config/config.php.jenkins" tofile="data/config/config.php"/>
+    <copy overwrite="true" file="tests/phpunit.xml.jenkins" tofile="tests/phpunit.xml"/>
+  </target>
+
+  <target name="test">
+    <delete>
+      <fileset dir="data/cache">
+        <include name="*"/>
+      </fileset>
+    </delete>
+    <delete dir="reports" includeemptydirs="true" />
+    <mkdir dir="reports/coverage" />
+    <exec dir="."
+      command="phpunit --log-tap reports/tap.log
+               --log-junit reports/unitreport.xml
+                       --coverage-html reports/coverage
+                       --coverage-clover reports/coverage/coverage.xml
+                       --configuration tests/phpunit.xml
+                       tests/" />
+  </target>
+  <target name="checkstyle">
+    <exec command="phpcs --standard=tests/ruleset.xml
+    --report=checkstyle
+    --extensions=php
+    -pv data/
+    --report-file=reports/checkstyle.xml
+    --ignore=data/module,data/Smarty,data/smarty_extends" />
+  </target>
+</project>


Property changes on: branches/version-2_12-dev/tests
___________________________________________________________________
追加: svn:ignore
   + phpunit.xml
require.php



追加: branches/version-2_12-dev/tests/class/Common_TestCase.php
===================================================================
--- branches/version-2_12-dev/tests/class/Common_TestCase.php	                        (rev 0)
+++ branches/version-2_12-dev/tests/class/Common_TestCase.php	2012-12-08 23:22:45 UTC (rev 22128)
@@ -0,0 +1,97 @@
+<?php
+
+$HOME = realpath(dirname(__FILE__)) . "/../..";
+require_once($HOME . "/tests/class/replace/SC_Display_Ex.php");
+require_once($HOME . "/tests/class/replace/SC_Response_Ex.php");
+require_once($HOME . "/tests/class/test/util/User_Utils.php");
+require_once($HOME . "/tests/require.php");
+
+require_once($HOME . "/data/class/pages/LC_Page_Index.php");
+/**
+ * 全テストケースの基底クラスです。
+ * SC_Queryのテスト以外は基本的にこのクラスを継承して作成してください。
+ *
+ */
+class Common_TestCase extends PHPUnit_Framework_TestCase {
+
+  /** SC_Query インスタンス */
+  protected $objQuery;
+
+  /** 期待値 */
+  protected $expected;
+  /** 実際の値 */
+  protected $actual;
+
+  protected function setUp() {
+    $this->objQuery = SC_Query_Ex::getSingletonInstance();
+    $this->objQuery->begin();
+  }
+
+  protected function tearDown() {
+    $this->objQuery->rollback();
+    $this->objQuery = null;
+  }
+
+  /**
+   * 各テストfunctionの末尾で呼び出し、期待値と実際の値の比較を行います。
+   * 呼び出す前に、$expectedに期待値を、$actualに実際の値を導入してください。
+   */
+  protected function verify($message = null) {
+    $this->assertEquals($this->expected, $this->actual, $message);
+  }
+
+  //////////////////////////////////////////////////////////////////
+  // 以下はテスト用のユーティリティを使うためのサンプルです。
+  // 実際に動作させる場合にはコメントアウトを外して下さい。
+
+  /**
+   * actionExit()呼び出しを書き換えてexit()させない例です。
+   */
+  /**
+  public function testExit() {
+    $resp = new SC_Response_Ex();
+    $resp->actionExit();
+
+    $this->expected = TRUE;
+    $this->actual = $resp->isExited();
+    $this->verify('exitしたかどうか');
+  }
+  */
+
+  /**
+   * 端末種別をテストケースから自由に設定する例です。
+   */
+  /**
+  public function testDeviceType() {
+    $this->expected = array(DEVICE_TYPE_MOBILE, DEVICE_TYPE_SMARTPHONE);
+    $this->actual = array();
+
+    // 端末種別を設定
+    User_Utils::setDeviceType(DEVICE_TYPE_MOBILE);
+    $this->actual[0] = SC_Display_Ex::detectDevice();
+    User_Utils::setDeviceType(DEVICE_TYPE_SMARTPHONE);
+    $this->actual[1] = SC_Display_Ex::detectDevice();
+
+    $this->verify('端末種別');
+  }
+  */
+
+  /**
+   * ログイン状態をテストケースから自由に切り替える例です。
+   */
+  /**
+  public function testLoginState() {
+    $this->expected = array(FALSE, TRUE);
+    $this->actual = array();
+
+    $objCustomer = new SC_Customer_Ex();
+    User_Utils::setLoginState(FALSE);
+    $this->actual[0] = $objCustomer->isLoginSuccess();
+    User_Utils::setLoginState(TRUE, null, $this->objQuery);
+    $this->actual[1] = $objCustomer->isLoginSuccess();
+
+    $this->verify('ログイン状態');
+  }
+  */
+}
+

追加: branches/version-2_12-dev/tests/class/helper/SC_Helper_Purchase/SC_Helper_Purchase_BaseTest.php
===================================================================
--- branches/version-2_12-dev/tests/class/helper/SC_Helper_Purchase/SC_Helper_Purchase_BaseTest.php	                        (rev 0)
+++ branches/version-2_12-dev/tests/class/helper/SC_Helper_Purchase/SC_Helper_Purchase_BaseTest.php	2012-12-08 23:22:45 UTC (rev 22128)
@@ -0,0 +1,60 @@
+<?php
+
+$HOME = realpath(dirname(__FILE__)) . "/../../../..";
+require_once($HOME . "/tests/class/Common_TestCase.php");
+/**
+ *
+ */
+class SC_Helper_Purchase_BaseTest extends Common_TestCase {
+
+  protected function setUp() {
+    parent::setUp();
+  }
+
+  protected function tearDown() {
+    parent::tearDown();
+  }
+
+  /////////////////////////////////////////
+  /**
+   * セッションに配送情報を設定します。
+   */
+  protected function setUpShipping($shipping) {
+    if (!$shipping) {
+      $shipping = getSingleShipping(); 
+    }
+
+    $_SESSION['shipping'] = $shipping;
+  }
+
+  protected function getSingleShipping() {
+    return array(
+      '00001' => array(
+        'shipment_id' => '00001',
+        'shipment_item' => '商品1',
+        'shipping_pref' => '東京都')
+    );
+  }
+
+  protected function getMultipleShipping() {
+    return array(
+      '00001' => array(
+        'shipment_id' => '00001',
+        'shipment_item' => array('商品1'),
+        'shipping_pref' => '東京都'),
+      '00002' => array(
+        'shipment_id' => '00002',
+        'shipment_item' => array('商品2'),
+        'shipping_pref' => '沖縄県'),
+      '00003' => array(
+        'shipment_id' => '00003',
+        'shipment_item' => array(),
+        'shipping_pref' => '埼玉県')
+    );
+  }
+
+  protected function setUpShippingDb($shipping) {
+    
+  }
+}
+

追加: branches/version-2_12-dev/tests/class/helper/SC_Helper_Purchase/SC_Helper_Purchase_clearShipmentItemTempTest.php
===================================================================
--- branches/version-2_12-dev/tests/class/helper/SC_Helper_Purchase/SC_Helper_Purchase_clearShipmentItemTempTest.php	                        (rev 0)
+++ branches/version-2_12-dev/tests/class/helper/SC_Helper_Purchase/SC_Helper_Purchase_clearShipmentItemTempTest.php	2012-12-08 23:22:45 UTC (rev 22128)
@@ -0,0 +1,79 @@
+<?php
+
+$HOME = realpath(dirname(__FILE__)) . "/../../../..";
+require_once($HOME . "/tests/class/helper/SC_Helper_Purchase/SC_Helper_Purchase_BaseTest.php");
+/**
+ *
+ */
+class SC_Helper_Purchase_clearShipmentItemTempTest extends SC_Helper_Purchase_BaseTest {
+
+  protected function setUp() {
+    parent::setUp();
+  }
+
+  protected function tearDown() {
+    parent::tearDown();
+  }
+
+  /////////////////////////////////////////
+  public function testClearShipmentItem_配送先ID未指定の場合_全ての配送商品がクリアされる() {
+    $this->setUpShipping($this->getMultipleShipping());
+
+    $helper = new SC_Helper_Purchase();
+    $helper->clearShipmentItemTemp(); // default:null
+
+    $this->expected = array('00001'=>null, '00002'=>null, '00003'=>null);
+    $this->actual['00001'] = $_SESSION['shipping']['00001']['shipment_item'];
+    $this->actual['00002'] = $_SESSION['shipping']['00002']['shipment_item'];
+    $this->actual['00003'] = $_SESSION['shipping']['00003']['shipment_item'];
+
+    $this->verify('配送商品');
+  }
+
+  public function testClearShipmentItem_配送先ID指定の場合_指定したIDの配送商品がクリアされる() {
+    $this->setUpShipping($this->getMultipleShipping());
+
+    $helper = new SC_Helper_Purchase();
+    $helper->clearShipmentItemTemp('00001');
+
+    $this->expected = array('00001'=>null, '00002'=>array('商品2'), '00003'=>array());
+    $this->actual['00001'] = $_SESSION['shipping']['00001']['shipment_item'];
+    $this->actual['00002'] = $_SESSION['shipping']['00002']['shipment_item'];
+    $this->actual['00003'] = $_SESSION['shipping']['00003']['shipment_item'];
+
+    $this->verify('配送商品');
+  }
+
+  public function testClearShipmentItem_存在しないIDを指定した場合_何も変更されない() {
+    $this->setUpShipping($this->getMultipleShipping());
+
+    $helper = new SC_Helper_Purchase();
+    $helper->clearShipmentItemTemp('00004');
+
+    $this->expected = array('00001'=>array('商品1'), '00002'=>array('商品2'), '00003'=>array());
+    $this->actual['00001'] = $_SESSION['shipping']['00001']['shipment_item'];
+    $this->actual['00002'] = $_SESSION['shipping']['00002']['shipment_item'];
+    $this->actual['00003'] = $_SESSION['shipping']['00003']['shipment_item'];
+
+    $this->verify('配送商品');
+  }
+
+  public function testClearShipmentItem_商品情報が配列でない場合_何も変更されない() {
+    $this->setUpShipping($this->getMultipleShipping());
+    // 内容を配列でないように変更
+    $_SESSION['shipping']['00001'] = 'temp';
+
+    $helper = new SC_Helper_Purchase();
+    $helper->clearShipmentItemTemp('00001');
+
+    // '00001'は配列でないので全体を取得
+    $this->expected = array('00001'=>'temp', '00002'=>array('商品2'), '00003'=>array());
+    $this->actual['00001'] = $_SESSION['shipping']['00001'];
+    $this->actual['00002'] = $_SESSION['shipping']['00002']['shipment_item'];
+    $this->actual['00003'] = $_SESSION['shipping']['00003']['shipment_item'];
+
+    $this->verify('配送商品');
+  }
+
+}
+

追加: branches/version-2_12-dev/tests/class/helper/SC_Helper_Purchase/SC_Helper_Purchase_getShippingPrefTest.php
===================================================================
--- branches/version-2_12-dev/tests/class/helper/SC_Helper_Purchase/SC_Helper_Purchase_getShippingPrefTest.php	                        (rev 0)
+++ branches/version-2_12-dev/tests/class/helper/SC_Helper_Purchase/SC_Helper_Purchase_getShippingPrefTest.php	2012-12-08 23:22:45 UTC (rev 22128)
@@ -0,0 +1,39 @@
+<?php
+
+$HOME = realpath(dirname(__FILE__)) . "/../../../..";
+require_once($HOME . "/tests/class/helper/SC_Helper_Purchase/SC_Helper_Purchase_BaseTest.php");
+/**
+ *
+ */
+class SC_Helper_Purchase_getShippingPrefTest extends SC_Helper_Purchase_BaseTest {
+
+  protected function setUp() {
+    parent::setUp();
+  }
+
+  protected function tearDown() {
+    parent::tearDown();
+  }
+
+  /////////////////////////////////////////
+  // TODO 要確認:引数の名前がおかしい(is_multipleではないはず)
+  public function testGetShippingPref_保有フラグがOFFの場合_全配送情報を取得する() {
+    $this->setUpShipping($this->getMultipleShipping());
+
+    $this->expected = array('東京都', '沖縄県', '埼玉県');
+    $this->actual = SC_Helper_Purchase::getShippingPref();
+
+    $this->verify('配送先の都道府県');
+  }
+
+  public function testGetShippingPref_保有フラグがONの場合_商品のある配送情報のみ取得する() {
+    $this->setUpShipping($this->getMultipleShipping());
+
+    $this->expected = array('東京都', '沖縄県');
+    $this->actual = SC_Helper_Purchase::getShippingPref(TRUE);
+
+    $this->verify('配送先の都道府県');
+  }
+
+}
+

追加: branches/version-2_12-dev/tests/class/helper/SC_Helper_Purchase/SC_Helper_Purchase_getShippingTempTest.php
===================================================================
--- branches/version-2_12-dev/tests/class/helper/SC_Helper_Purchase/SC_Helper_Purchase_getShippingTempTest.php	                        (rev 0)
+++ branches/version-2_12-dev/tests/class/helper/SC_Helper_Purchase/SC_Helper_Purchase_getShippingTempTest.php	2012-12-08 23:22:45 UTC (rev 22128)
@@ -0,0 +1,47 @@
+<?php
+
+$HOME = realpath(dirname(__FILE__)) . "/../../../..";
+require_once($HOME . "/tests/class/helper/SC_Helper_Purchase/SC_Helper_Purchase_BaseTest.php");
+/**
+ *
+ */
+class SC_Helper_Purchase_getShippingTempTest extends SC_Helper_Purchase_BaseTest {
+
+  protected function setUp() {
+    parent::setUp();
+  }
+
+  protected function tearDown() {
+    parent::tearDown();
+  }
+
+  /////////////////////////////////////////
+  public function testGetShippingTemp_保有フラグがOFFの場合_セッション情報を取得する() {
+    $this->setUpShipping($this->getMultipleShipping());
+
+    $this->expected = $this->getMultipleShipping();
+    $this->actual = SC_Helper_Purchase::getShippingTemp();
+
+    $this->verify('配送情報');
+  }
+
+  public function testGetShippingTemp_保有フラグがONの場合_商品のある情報のみ取得する() {
+    $this->setUpShipping($this->getMultipleShipping());
+
+    $this->expected = array(
+      '00001' => array(
+        'shipment_id' => '00001',
+        'shipment_item' => array('商品1'),
+        'shipping_pref' => '東京都'),
+      '00002' => array(
+        'shipment_id' => '00002',
+        'shipment_item' => array('商品2'),
+        'shipping_pref' => '沖縄県')
+    );
+    $this->actual = SC_Helper_Purchase::getShippingTemp(TRUE);
+
+    $this->verify('配送情報');
+  }
+
+}
+

追加: branches/version-2_12-dev/tests/class/helper/SC_Helper_Purchase/SC_Helper_Purchase_isAddPointTest.php
===================================================================
--- branches/version-2_12-dev/tests/class/helper/SC_Helper_Purchase/SC_Helper_Purchase_isAddPointTest.php	                        (rev 0)
+++ branches/version-2_12-dev/tests/class/helper/SC_Helper_Purchase/SC_Helper_Purchase_isAddPointTest.php	2012-12-08 23:22:45 UTC (rev 22128)
@@ -0,0 +1,69 @@
+<?php
+
+$HOME = realpath(dirname(__FILE__)) . "/../../../..";
+require_once($HOME . "/tests/class/helper/SC_Helper_Purchase/SC_Helper_Purchase_BaseTest.php");
+/**
+ *
+ */
+class SC_Helper_Purchase_isAddPointTest extends SC_Helper_Purchase_BaseTest {
+
+  protected function setUp() {
+    parent::setUp();
+  }
+
+  protected function tearDown() {
+    parent::tearDown();
+  }
+
+  /////////////////////////////////////////
+  public function testIsAddPoint_新規注文の場合_FALSEが返る() {
+    $this->expected = FALSE;
+    $this->actual = SC_Helper_Purchase::isAddPoint(ORDER_NEW);
+
+    $this->verify('ポイント加算するかどうか');
+  }
+
+  public function testIsAddPoint_入金待ちの場合_FALSEが返る() {
+    $this->expected = FALSE;
+    $this->actual = SC_Helper_Purchase::isAddPoint(ORDER_PAY_WAIT);
+
+    $this->verify('ポイント加算するかどうか');
+  }
+
+  public function testIsAddPoint_入金済みの場合_FALSEが返る() {
+    $this->expected = FALSE;
+    $this->actual = SC_Helper_Purchase::isAddPoint(ORDER_PRE_END);
+
+    $this->verify('ポイント加算するかどうか');
+  }
+
+  public function testIsAddPoint_キャンセルの場合_FALSEが返る() {
+    $this->expected = FALSE;
+    $this->actual = SC_Helper_Purchase::isAddPoint(ORDER_CANCEL);
+
+    $this->verify('ポイント加算するかどうか');
+  }
+
+  public function testIsAddPoint_取り寄せ中の場合_FALSEが返る() {
+    $this->expected = FALSE;
+    $this->actual = SC_Helper_Purchase::isAddPoint(ORDER_BACK_ORDER);
+
+    $this->verify('ポイント加算するかどうか');
+  }
+
+  public function testIsAddPoint_発送済みの場合_TRUEが返る() {
+    $this->expected = TRUE;
+    $this->actual = SC_Helper_Purchase::isAddPoint(ORDER_DELIV);
+
+    $this->verify('ポイント加算するかどうか');
+  }
+
+  public function testIsAddPoint_その他の場合_FALSEが返る() {
+    $this->expected = FALSE;
+    $this->actual = SC_Helper_Purchase::isAddPoint(ORDER_PENDING);
+
+    $this->verify('ポイント加算するかどうか');
+  }
+
+}
+

追加: branches/version-2_12-dev/tests/class/helper/SC_Helper_Purchase/SC_Helper_Purchase_isUsePointTest.php
===================================================================
--- branches/version-2_12-dev/tests/class/helper/SC_Helper_Purchase/SC_Helper_Purchase_isUsePointTest.php	                        (rev 0)
+++ branches/version-2_12-dev/tests/class/helper/SC_Helper_Purchase/SC_Helper_Purchase_isUsePointTest.php	2012-12-08 23:22:45 UTC (rev 22128)
@@ -0,0 +1,42 @@
+<?php
+
+$HOME = realpath(dirname(__FILE__)) . "/../../../..";
+require_once($HOME . "/tests/class/helper/SC_Helper_Purchase/SC_Helper_Purchase_BaseTest.php");
+/**
+ *
+ */
+class SC_Helper_Purchase_isUsePointTest extends SC_Helper_Purchase_BaseTest {
+
+  protected function setUp() {
+    parent::setUp();
+  }
+
+  protected function tearDown() {
+    parent::tearDown();
+  }
+
+  /////////////////////////////////////////
+  public function testIsUsePoint_ステータスがnullの場合_FALSEが返る() {
+    $this->expected = FALSE;
+    $this->actual = SC_Helper_Purchase::isUsePoint(null);
+
+    $this->verify('ポイントを使用するかどうか');
+  }
+
+  public function testIsUsePoint_ステータスがキャンセルの場合_FALSEが返る() {
+    $this->expected = FALSE;
+    $this->actual = SC_Helper_Purchase::isUsePoint(ORDER_CANCEL);
+
+    $this->verify('ポイントを使用するかどうか');
+  }
+
+  // TODO 要確認:本当にキャンセルのとき以外はすべてTRUEで良いのか、現在の使われ方の都合か
+  public function testIsUsePoint_ステータスがキャンセル以外の場合_TRUEが返る() {
+    $this->expected = TRUE;
+    $this->actual = SC_Helper_Purchase::isUsePoint(ORDER_NEW);
+
+    $this->verify('ポイント加算するかどうか');
+  }
+
+}
+

追加: branches/version-2_12-dev/tests/class/helper/SC_Helper_Purchase/SC_Helper_Purchase_saveShippingTempTest.php
===================================================================
--- branches/version-2_12-dev/tests/class/helper/SC_Helper_Purchase/SC_Helper_Purchase_saveShippingTempTest.php	                        (rev 0)
+++ branches/version-2_12-dev/tests/class/helper/SC_Helper_Purchase/SC_Helper_Purchase_saveShippingTempTest.php	2012-12-08 23:22:45 UTC (rev 22128)
@@ -0,0 +1,63 @@
+<?php
+
+$HOME = realpath(dirname(__FILE__)) . "/../../../..";
+require_once($HOME . "/tests/class/helper/SC_Helper_Purchase/SC_Helper_Purchase_BaseTest.php");
+/**
+ *
+ */
+class SC_Helper_Purchase_saveShippingTempTest extends SC_Helper_Purchase_BaseTest {
+
+  protected function setUp() {
+    parent::setUp();
+  }
+
+  protected function tearDown() {
+    parent::tearDown();
+  }
+
+  /////////////////////////////////////////
+  public function testSaveShippingTemp_元々存在しない配送先IDの場合_新規に配列が作られる() {
+    $this->setUpShipping($this->getMultipleShipping());
+
+    SC_Helper_Purchase::saveShippingTemp(
+      array('shipment_item' => '商品4', 'shipping_pref' => '大阪府')
+    );
+
+    $this->expected = array(
+      'count'=>4,                // 配送情報全体の件数 
+      'shipping_id'=>0,
+      'shipment_item'=>null,
+      'shipping_pref'=>'大阪府'
+    );
+    $this->actual['count'] = count($_SESSION['shipping']);
+    $this->actual['shipping_id'] = $_SESSION['shipping']['0']['shipping_id'];
+    $this->actual['shipment_item'] = $_SESSION['shipping']['0']['shipment_item'];
+    $this->actual['shipping_pref'] = $_SESSION['shipping']['0']['shipping_pref'];
+
+    $this->verify('登録した配送情報');
+  }
+
+  public function testSaveShippingTemp_元々存在する配送先IDの場合_情報がマージされる() {
+    $this->setUpShipping($this->getMultipleShipping());
+
+    SC_Helper_Purchase::saveShippingTemp(
+      array('shipment_item' => '商品4', 'shipping_pref' => '大阪府'),
+      '00001'
+    );
+
+    $this->expected = array(
+      'count'=>3,                // 配送情報全体の件数 
+      'shipping_id'=>'00001',
+      'shipment_item'=>array('商品1'),
+      'shipping_pref'=>'大阪府'
+    );
+    $this->actual['count'] = count($_SESSION['shipping']);
+    $this->actual['shipping_id'] = $_SESSION['shipping']['00001']['shipping_id'];
+    $this->actual['shipment_item'] = $_SESSION['shipping']['00001']['shipment_item'];
+    $this->actual['shipping_pref'] = $_SESSION['shipping']['00001']['shipping_pref'];
+    
+    $this->verify('更新した配送情報');
+  }
+
+}
+

追加: branches/version-2_12-dev/tests/class/helper/SC_Helper_Purchase/SC_Helper_Purchase_unsetAllShippingTempTest.php
===================================================================
--- branches/version-2_12-dev/tests/class/helper/SC_Helper_Purchase/SC_Helper_Purchase_unsetAllShippingTempTest.php	                        (rev 0)
+++ branches/version-2_12-dev/tests/class/helper/SC_Helper_Purchase/SC_Helper_Purchase_unsetAllShippingTempTest.php	2012-12-08 23:22:45 UTC (rev 22128)
@@ -0,0 +1,44 @@
+<?php
+
+$HOME = realpath(dirname(__FILE__)) . "/../../../..";
+require_once($HOME . "/tests/class/helper/SC_Helper_Purchase/SC_Helper_Purchase_BaseTest.php");
+/**
+ *
+ */
+class SC_Helper_Purchase_unsetAllShippingTempTest extends SC_Helper_Purchase_BaseTest {
+
+  protected function setUp() {
+    parent::setUp();
+
+    // 空にするだけなので適当な値を設定
+    $_SESSION['shipping'] = 'temp01';
+    $_SESSION['multiple_temp'] = 'temp02';
+  }
+
+  protected function tearDown() {
+    parent::tearDown();
+  }
+
+  /////////////////////////////////////////
+  public function testUnsetAllShippingTemp_複数配送も破棄するフラグがOFFの場合_情報の一部が破棄される() {
+    SC_Helper_Purchase::unsetAllShippingTemp();
+
+    $this->expected = array('shipping'=>TRUE, 'multiple_temp'=>FALSE);
+    $this->actual['shipping'] = empty($_SESSION['shipping']);
+    $this->actual['multiple_temp'] = empty($_SESSION['multiple_temp']);
+
+    $this->verify('セッション情報が空かどうか');
+  }
+
+  public function testUnsetAllShippingTemp_複数配送も破棄するフラグがONの場合_全ての情報が破棄される() {
+    SC_Helper_Purchase::unsetAllShippingTemp(TRUE);
+
+    $this->expected = array('shipping'=>TRUE, 'multiple_temp'=>TRUE);
+    $this->actual['shipping'] = empty($_SESSION['shipping']);
+    $this->actual['multiple_temp'] = empty($_SESSION['multiple_temp']);
+
+    $this->verify('セッション情報が空かどうか');
+  }
+
+}
+

追加: branches/version-2_12-dev/tests/class/helper/SC_Helper_Purchase/SC_Helper_Purchase_unsetOneShippingTest.php
===================================================================
--- branches/version-2_12-dev/tests/class/helper/SC_Helper_Purchase/SC_Helper_Purchase_unsetOneShippingTest.php	                        (rev 0)
+++ branches/version-2_12-dev/tests/class/helper/SC_Helper_Purchase/SC_Helper_Purchase_unsetOneShippingTest.php	2012-12-08 23:22:45 UTC (rev 22128)
@@ -0,0 +1,40 @@
+<?php
+
+$HOME = realpath(dirname(__FILE__)) . "/../../../..";
+require_once($HOME . "/tests/class/helper/SC_Helper_Purchase/SC_Helper_Purchase_BaseTest.php");
+/**
+ *
+ */
+class SC_Helper_Purchase_unsetOneShippingTempTest extends SC_Helper_Purchase_BaseTest {
+
+  protected function setUp() {
+    parent::setUp();
+  }
+
+  protected function tearDown() {
+    parent::tearDown();
+  }
+
+  /////////////////////////////////////////
+  public function testUnsetOneShippingTemp__指定したIDの配送情報のみが破棄される() {
+    $this->setUpShipping($this->getMultipleShipping());
+
+    SC_Helper_Purchase::unsetOneShippingTemp('00002');
+
+    $this->expected = array(
+      '00001' => array(
+        'shipment_id' => '00001',
+        'shipment_item' => array('商品1'),
+        'shipping_pref' => '東京都'),
+      '00003' => array(
+        'shipment_id' => '00003',
+        'shipment_item' => array(),
+        'shipping_pref' => '埼玉県')
+    );
+    $this->actual = $_SESSION['shipping'];
+
+    $this->verify('配送情報');
+  }
+
+}
+

追加: branches/version-2_12-dev/tests/class/helper/SC_Helper_Purchase/SC_Helper_Purchase_unsetShippingTempTest.php
===================================================================
--- branches/version-2_12-dev/tests/class/helper/SC_Helper_Purchase/SC_Helper_Purchase_unsetShippingTempTest.php	                        (rev 0)
+++ branches/version-2_12-dev/tests/class/helper/SC_Helper_Purchase/SC_Helper_Purchase_unsetShippingTempTest.php	2012-12-08 23:22:45 UTC (rev 22128)
@@ -0,0 +1,34 @@
+<?php
+
+$HOME = realpath(dirname(__FILE__)) . "/../../../..";
+require_once($HOME . "/tests/class/helper/SC_Helper_Purchase/SC_Helper_Purchase_BaseTest.php");
+/**
+ *
+ */
+class SC_Helper_Purchase_unsetShippingTempTest extends SC_Helper_Purchase_BaseTest {
+
+  protected function setUp() {
+    parent::setUp();
+
+    // 空にするだけなので適当な値を設定
+    $_SESSION['shipping'] = 'temp01';
+    $_SESSION['multiple_temp'] = 'temp02';
+  }
+
+  protected function tearDown() {
+    parent::tearDown();
+  }
+
+  /////////////////////////////////////////
+  public function testUnsetShippingTemp__配送情報がすべて破棄される() {
+    SC_Helper_Purchase::unsetShippingTemp(TRUE);
+
+    $this->expected = array('shipping'=>TRUE, 'multiple_temp'=>TRUE);
+    $this->actual['shipping'] = empty($_SESSION['shipping']);
+    $this->actual['multiple_temp'] = empty($_SESSION['multiple_temp']);
+
+    $this->verify('セッション情報が空かどうか');
+  }
+
+}
+

追加: branches/version-2_12-dev/tests/class/replace/SC_Display_Ex.php
===================================================================
--- branches/version-2_12-dev/tests/class/replace/SC_Display_Ex.php	                        (rev 0)
+++ branches/version-2_12-dev/tests/class/replace/SC_Display_Ex.php	2012-12-08 23:22:45 UTC (rev 22128)
@@ -0,0 +1,32 @@
+<?php
+require_once(realpath(dirname(__FILE__)) . "/../../../data/class/SC_Display.php");
+/**
+ * テスト用にSC_Displayクラスを変更してユーザエージェントを自在に設定できるようにしたクラスです。
+ */
+class SC_Display_Ex extends SC_Display {
+
+  /** テスト用に設定した端末種別 */
+  static $dummyDevice = DEVICE_TYPE_PC;
+
+  /**
+   * 予めテスト用に設定された端末種別を取得します。
+   * @static
+   * @param     $reset  boolean
+   * @return    integer 端末種別ID
+   */
+  public static function detectDevice($reset = FALSE) {
+    return self::$dummyDevice;
+  }
+
+  /**
+   * テスト用に端末種別を設定します。
+   *
+   * @static
+   * @param     $deviceType 端末種別ID
+   */
+  public static function setDummyDevice($deviceType) {
+    self::$dummyDevice = $deviceType;
+  }
+}
+
+

追加: branches/version-2_12-dev/tests/class/replace/SC_Response_Ex.php
===================================================================
--- branches/version-2_12-dev/tests/class/replace/SC_Response_Ex.php	                        (rev 0)
+++ branches/version-2_12-dev/tests/class/replace/SC_Response_Ex.php	2012-12-08 23:22:45 UTC (rev 22128)
@@ -0,0 +1,44 @@
+<?php
+require_once(realpath(dirname(__FILE__)) . "/../../../data/class/SC_Response.php");
+/**
+ * テスト用にexitしないSC_Responseクラスです。
+ */
+class SC_Response_Ex extends SC_Response {
+
+  /** exitしたかどうかを保持するフラグ */
+  var $exited = FALSE;
+  /** リダイレクト先のパスを保持するフラグ */
+  var $redirectPath = '';
+
+  /**
+   * SC_Response::actionExit()をラップし、PHPをexitさせないようにします。
+   */
+  function actionExit() {
+    $this->exited = TRUE;
+  }
+
+  /**
+   * SC_Response::sendRedirect()をラップし、PHPをexitさせないようにします。
+   * また、リダイレクト先のパスを取得できるようにします。
+   */
+  function sendRedirect($location, $arrQueryString = array(), $inheritQuerySring = false, $useSsl = null) {
+    $this->exited = TRUE;
+    $this->redirectPath = $location;
+  }
+
+  /**
+   * actionExit()が呼ばれたかどうかを取得します。
+   */
+  public function isExited() {
+    return $this->exited;
+  }
+
+  /**
+   * sendRedirect()で指定されたパスを取得します。 
+   */
+  public function getRedirectPath() {
+    return $this->redirectPath;
+  }
+}
+
+

追加: branches/version-2_12-dev/tests/class/test/util/User_Utils.php
===================================================================
--- branches/version-2_12-dev/tests/class/test/util/User_Utils.php	                        (rev 0)
+++ branches/version-2_12-dev/tests/class/test/util/User_Utils.php	2012-12-08 23:22:45 UTC (rev 22128)
@@ -0,0 +1,57 @@
+<?php
+
+/**
+ * ユーザの状態をテストに合わせて変化させるユーティリティクラスです。
+ *
+ */
+class User_Utils {
+
+  /**
+   * 端末種別を設定します。
+   *
+   * @static
+   * @param deviceType  端末種別ID
+   */
+  public static function setDeviceType($deviceType) {
+    SC_Display_Ex::setDummyDevice($deviceType);
+  }
+
+  /**
+   * ログイン状態を設定します。
+   *
+   * @static
+   * @param isLogin true:ログインしている、false:ログインしていない
+   */
+  public static function setLoginState($isLogin, $customer = null, $objQuery = null) {
+    if (!$isLogin) {
+      $_SESSION['customer']['customer_id'] = null;
+      $_SESSION['customer']['email'] = null;
+      return;
+    }
+    if ($customer == null) {
+      $customer = self::getDefaultCustomer();
+    }
+    $_SESSION['customer']['customer_id'] = $customer['customer_id'];
+    $_SESSION['customer']['email'] = $customer['email'];
+    $objQuery->insert('dtb_customer', $customer);
+  }
+
+  /**
+   * ユーザ情報を外部から設定しなかった場合のデフォルト値を取得します。
+   */
+  private static function getDefaultCustomer() {
+    $arrValue['customer_id'] = '999999998';
+    $arrValue['name01'] = '苗字';
+    $arrValue['name02'] = '名前';
+    $arrValue['kana01'] = 'みょうじ';
+    $arrValue['kana02'] = 'なまえ';
+    $arrValue['email'] = 'sample @ sample.co.jp';
+    $arrValue['secret_key'] = 'aaaaaa';
+    $arrValue['status'] = 2;
+    $arrValue['create_date'] = 'CURRENT_TIMESTAMP';
+    $arrValue['update_date'] = 'CURRENT_TIMESTAMP';
+
+    return $arrValue;
+  }
+}
+

追加: branches/version-2_12-dev/tests/class/util/SC_Utils/SC_Utils_getTableTagTest.php
===================================================================
--- branches/version-2_12-dev/tests/class/util/SC_Utils/SC_Utils_getTableTagTest.php	                        (rev 0)
+++ branches/version-2_12-dev/tests/class/util/SC_Utils/SC_Utils_getTableTagTest.php	2012-12-08 23:22:45 UTC (rev 22128)
@@ -0,0 +1,39 @@
+<?php
+
+$HOME = realpath(dirname(__FILE__)) . "/../../../..";
+require_once($HOME . "/tests/class/Common_TestCase.php");
+/**
+ *
+ */
+class SC_Utils_getTableTagTest extends Common_TestCase {
+
+  protected function setUp() {
+    parent::setUp();
+  }
+
+  protected function tearDown() {
+    parent::tearDown();
+  }
+
+  /////////////////////////////////////////
+  // TODO 要確認(現在は使われていないが、ソースコードの意味が不明確)
+  public function testGetTableTag__配列の内容がHTMLに変換される() {
+    $this->expected = 
+      '<table>' .
+      '<tr><th>名前</th><th>住所</th><th>電話番号</th></tr>' .
+      '<tr><td>名前1</td><td>住所1</td><td>12345678901</td></tr>' .
+      '<tr><td>名前2</td><td>住所2</td><td>12345678902</td></tr>' .
+      '<tr><td>名前3</td><td>住所3</td><td>12345678903</td></tr>' .
+      '</table>';
+    $this->actual = SC_Utils::getTableTag(array(
+      array('名前', '住所', '電話番号'),
+      array('名前1', '住所1', '12345678901'),
+      array('名前2', '住所2', '12345678902'),
+      array('名前2', '住所3', '12345678903'),
+    ));
+
+    $this->verify('生成されたHTML');
+  }
+
+}
+

追加: branches/version-2_12-dev/tests/class/util/SC_Utils/SC_Utils_repeatStrWithSeparatorTest.php
===================================================================
--- branches/version-2_12-dev/tests/class/util/SC_Utils/SC_Utils_repeatStrWithSeparatorTest.php	                        (rev 0)
+++ branches/version-2_12-dev/tests/class/util/SC_Utils/SC_Utils_repeatStrWithSeparatorTest.php	2012-12-08 23:22:45 UTC (rev 22128)
@@ -0,0 +1,48 @@
+<?php
+
+$HOME = realpath(dirname(__FILE__)) . "/../../../..";
+require_once($HOME . "/tests/class/Common_TestCase.php");
+/**
+ *
+ */
+class SC_Utils_repeatStrWithSeparatorTest extends Common_TestCase {
+
+  protected function setUp() {
+    parent::setUp();
+  }
+
+  protected function tearDown() {
+    parent::tearDown();
+  }
+
+  /////////////////////////////////////////
+  public function testRepeatStrWithSeparator_反復回数が0回の場合_結果が0バイト文字列になる() {
+    $this->expected = '';
+    $this->actual = SC_Utils::repeatStrWithSeparator('ECサイト', 0, '#');
+
+    $this->verify('連結済みの文字列');
+  }
+
+  public function testRepeatStrWithSeparator_反復回数が1回の場合_区切り文字が入らない() {
+    $this->expected = 'ECサイト';
+    $this->actual = SC_Utils::repeatStrWithSeparator('ECサイト', 1, '#');
+
+    $this->verify('連結済みの文字列');
+  }
+
+  public function testRepeatStrWithSeparator_反復回数が2回以上の場合_区切り文字が入って出力される() {
+    $this->expected = 'ECサイト#ECサイト#ECサイト#ECサイト#ECサイト';
+    $this->actual = SC_Utils::repeatStrWithSeparator('ECサイト', 5, '#');
+
+    $this->verify('連結済みの文字列');
+  }
+
+  public function testRepeatStrWithSeparator_区切り文字が未指定の場合_カンマ区切りとなる() {
+    $this->expected = 'ECサイト,ECサイト,ECサイト';
+    $this->actual = SC_Utils::repeatStrWithSeparator('ECサイト', 3);
+
+    $this->verify('連結済みの文字列');
+  }
+
+}
+

追加: branches/version-2_12-dev/tests/class/util/SC_Utils/SC_Utils_sfCalcIncTaxTest.php
===================================================================
--- branches/version-2_12-dev/tests/class/util/SC_Utils/SC_Utils_sfCalcIncTaxTest.php	                        (rev 0)
+++ branches/version-2_12-dev/tests/class/util/SC_Utils/SC_Utils_sfCalcIncTaxTest.php	2012-12-08 23:22:45 UTC (rev 22128)
@@ -0,0 +1,52 @@
+<?php
+
+$HOME = realpath(dirname(__FILE__)) . "/../../../..";
+require_once($HOME . "/tests/class/Common_TestCase.php");
+/**
+ *
+ */
+class SC_Utils_sfCalcIncTaxTest extends Common_TestCase {
+
+  protected function setUp() {
+    parent::setUp();
+  }
+
+  protected function tearDown() {
+    parent::tearDown();
+  }
+
+  /////////////////////////////////////////
+  public function testSfCalcIncTax_四捨五入の場合_四捨五入の結果になる() {
+    $this->expected = array(141, 152);
+    $this->actual[0] = SC_Utils::sfCalcIncTax(140, 1, 1); // 1:四捨五入
+    $this->actual[1] = SC_Utils::sfCalcIncTax(150, 1, 1); // 1:四捨五入
+
+    $this->verify('税込価格');
+  }
+
+  public function testSfCalcIncTax_切り捨ての場合_切り捨ての結果になる() {
+    $this->expected = array(142, 153);
+    $this->actual[0] = SC_Utils::sfCalcIncTax(140, 2, 2); // 2:切り捨て
+    $this->actual[1] = SC_Utils::sfCalcIncTax(150, 2, 2); // 2:切り捨て
+
+    $this->verify('税込価格');
+  }
+
+  public function testSfCalcIncTax_切り上げの場合_切り上げの結果になる() {
+    $this->expected = array(142, 152);
+    $this->actual[0] = SC_Utils::sfCalcIncTax(140, 1, 3); // 3:切り上げ
+    $this->actual[1] = SC_Utils::sfCalcIncTax(150, 1, 3); // 3:切り上げ
+
+    $this->verify('税込価格');
+  }
+
+  public function testSfCalcIncTax_それ以外の場合_切り上げの結果になる() {
+    $this->expected = array(142, 152);
+    $this->actual[0] = SC_Utils::sfCalcIncTax(140, 1, 4);
+    $this->actual[1] = SC_Utils::sfCalcIncTax(150, 1, 4);
+
+    $this->verify('税込価格');
+  }
+
+}
+

追加: branches/version-2_12-dev/tests/class/util/SC_Utils/SC_Utils_sfGetCommaListTest.php
===================================================================
--- branches/version-2_12-dev/tests/class/util/SC_Utils/SC_Utils_sfGetCommaListTest.php	                        (rev 0)
+++ branches/version-2_12-dev/tests/class/util/SC_Utils/SC_Utils_sfGetCommaListTest.php	2012-12-08 23:22:45 UTC (rev 22128)
@@ -0,0 +1,58 @@
+<?php
+
+$HOME = realpath(dirname(__FILE__)) . "/../../../..";
+require_once($HOME . "/tests/class/Common_TestCase.php");
+/**
+ *
+ */
+class SC_Utils_sfGetCommaListTest extends Common_TestCase {
+
+  protected function setUp() {
+    parent::setUp();
+  }
+
+  protected function tearDown() {
+    parent::tearDown();
+  }
+
+  /////////////////////////////////////////
+  public function testSfGetCommaList_配列が空の場合_FALSEが返る() {
+    $this->expected = FALSE;
+    $this->actual = SC_Utils::sfGetCommaList(array());
+
+    $this->verify('連結済みの文字列');
+  }
+
+  public function testSfGetCommaList_スペースフラグが立っている場合_スペース付きで連結される() {
+    $this->expected = 'りんご, ミカン, バナナ';
+    $this->actual = SC_Utils::sfGetCommaList(
+      array('りんご', 'ミカン', 'バナナ'),
+      TRUE,
+      array());
+
+    $this->verify('連結済みの文字列');
+  }
+
+  public function testSfGetCommaList_スペースフラグが倒れている場合_スペース付きで連結される() {
+    $this->expected = 'りんご,ミカン,バナナ';
+    $this->actual = SC_Utils::sfGetCommaList(
+      array('りんご', 'ミカン', 'バナナ'),
+      FALSE,
+      array());
+
+    $this->verify('連結済みの文字列');
+  }
+
+  // TODO 要確認:arrpopの役割
+  public function testSfGetCommaList_除外リストが指定されている場合_スペース付きで連結される() {
+    $this->expected = 'りんご, バナナ';
+    $this->actual = SC_Utils::sfGetCommaList(
+      array('りんご', 'ミカン', 'バナナ'),
+      TRUE,
+      array('梨', 'ミカン', '柿'));
+
+    $this->verify('連結済みの文字列');
+  }
+
+}
+

追加: branches/version-2_12-dev/tests/class/util/SC_Utils/SC_Utils_sfGetRandomStringTest.php
===================================================================
--- branches/version-2_12-dev/tests/class/util/SC_Utils/SC_Utils_sfGetRandomStringTest.php	                        (rev 0)
+++ branches/version-2_12-dev/tests/class/util/SC_Utils/SC_Utils_sfGetRandomStringTest.php	2012-12-08 23:22:45 UTC (rev 22128)
@@ -0,0 +1,35 @@
+<?php
+
+$HOME = realpath(dirname(__FILE__)) . "/../../../..";
+require_once($HOME . "/tests/class/Common_TestCase.php");
+/**
+ *
+ */
+class SC_Utils_Test extends Common_TestCase {
+
+  protected function setUp() {
+    parent::setUp();
+  }
+
+  protected function tearDown() {
+    parent::tearDown();
+  }
+
+  /////////////////////////////////////////
+  // ランダムな文字列取得なので、文字列長のみ確認します。
+  public function testSfGetRandomString_文字列長未指定の場合_長さ1の文字列が取得できる() {
+    $this->expected = 1;
+    $this->actual = strlen(SC_Utils::sfGetRandomString());
+    
+    $this->verify('文字列長');
+  }
+
+  public function testSfGetRandomString_文字列長指定ありの場合_指定した長さの文字列が取得できる() {
+    $this->expected = 10;
+    $this->actual = strlen(SC_Utils::sfGetRandomString(10));
+    
+    $this->verify('文字列長');
+  }
+
+}
+

追加: branches/version-2_12-dev/tests/class/util/SC_Utils/SC_Utils_sfIsIntTest.php
===================================================================
--- branches/version-2_12-dev/tests/class/util/SC_Utils/SC_Utils_sfIsIntTest.php	                        (rev 0)
+++ branches/version-2_12-dev/tests/class/util/SC_Utils/SC_Utils_sfIsIntTest.php	2012-12-08 23:22:45 UTC (rev 22128)
@@ -0,0 +1,87 @@
+<?php
+
+$HOME = realpath(dirname(__FILE__)) . "/../../../..";
+require_once($HOME . "/tests/class/Common_TestCase.php");
+/**
+ *
+ */
+class SC_Utils_sfIsIntTest extends Common_TestCase {
+
+  protected function setUp() {
+    parent::setUp();
+  }
+
+  protected function tearDown() {
+    parent::tearDown();
+  }
+
+  /////////////////////////////////////////
+  public function testSfIsInt_0バイト文字列の場合_FALSEが返る() {
+    $this->expected = FALSE;
+    $this->actual = SC_Utils::sfIsInt('');
+
+    $this->verify('整数かどうか');
+  }
+
+  public function testSfIsInt_intの最大長より長い場合_FALSEが返る() {
+    $this->expected = FALSE;
+    $this->actual = SC_Utils::sfIsInt('10000000000');
+
+    $this->verify('整数かどうか');
+  }
+
+  // TODO 要確認
+  public function testSfIsInt_intの最大値ギリギリの場合_TRUEが返る() {
+    $this->expected = FALSE;
+    $this->actual = SC_Utils::sfIsInt('2147483647');
+
+    $this->verify('整数かどうか');
+  }
+
+  // TODO 要確認
+  public function testSfIsInt_intの最大値を超える場合_FALSEが返る() {
+    $this->expected = FALSE;
+    $this->actual = SC_Utils::sfIsInt('2147483648');
+
+    $this->verify('整数かどうか');
+  }
+
+  public function testSfIsInt_数値でない場合_FALSEが返る() {
+    $this->expected = FALSE;
+    $this->actual = SC_Utils::sfIsInt('HELLO123');
+
+    $this->verify('整数かどうか');
+  }
+
+  public function testSfIsInt_正の整数の場合_TRUEが返る() {
+    $this->expected = TRUE;
+    $this->actual = SC_Utils::sfIsInt('123456789');
+
+    $this->verify('整数かどうか');
+  }
+
+  // TODO 要確認
+  public function testSfIsInt_正の小数の場合_FALSEが返る() {
+    $this->expected = FALSE;
+    $this->actual = SC_Utils::sfIsInt('123.456');
+
+    $this->verify('整数かどうか');
+  }
+
+  public function testSfIsInt_負の整数の場合_TRUEが返る() {
+    $this->expected = TRUE;
+    $this->actual = SC_Utils::sfIsInt('-12345678');
+
+    $this->verify('整数かどうか');
+  }
+
+  // TODO 要確認
+  public function testSfIsInt_負の整数で桁数が最大の場合_TRUEが返る() {
+    $this->expected = TRUE;
+    $this->actual = SC_Utils::sfIsInt('-123456789');
+
+    $this->verify('整数かどうか');
+  }
+
+}
+

追加: branches/version-2_12-dev/tests/class/util/SC_Utils/SC_Utils_sfIsZeroFillingTest.php
===================================================================
--- branches/version-2_12-dev/tests/class/util/SC_Utils/SC_Utils_sfIsZeroFillingTest.php	                        (rev 0)
+++ branches/version-2_12-dev/tests/class/util/SC_Utils/SC_Utils_sfIsZeroFillingTest.php	2012-12-08 23:22:45 UTC (rev 22128)
@@ -0,0 +1,41 @@
+<?php
+
+$HOME = realpath(dirname(__FILE__)) . "/../../../..";
+require_once($HOME . "/tests/class/Common_TestCase.php");
+/**
+ *
+ */
+class SC_Utils_sfIsZeroFillingTest extends Common_TestCase {
+
+  protected function setUp() {
+    parent::setUp();
+  }
+
+  protected function tearDown() {
+    parent::tearDown();
+  }
+
+  /////////////////////////////////////////
+  public function testSfIsZeroFilling_桁数が1の場合_FALSEを返す() {
+    $this->expected = FALSE;
+    $this->actual = SC_Utils::sfIsZeroFilling('0');
+
+    $this->verify('ゼロ詰めされているかどうか');
+  }
+
+  public function testSfIsZeroFilling_桁数が2以上で0埋めされていない場合_FALSEを返す() {
+    $this->expected = FALSE;
+    $this->actual = SC_Utils::sfIsZeroFilling('12');
+
+    $this->verify('ゼロ詰めされているかどうか');
+  }
+
+  public function testSfIsZeroFilling_桁数が2以上で0埋めされている場合_TRUEを返す() {
+    $this->expected = TRUE;
+    $this->actual = SC_Utils::sfIsZeroFilling('01');
+
+    $this->verify('ゼロ詰めされているかどうか');
+  }
+
+}
+

追加: branches/version-2_12-dev/tests/class/util/SC_Utils/SC_Utils_sfTaxTest.php
===================================================================
--- branches/version-2_12-dev/tests/class/util/SC_Utils/SC_Utils_sfTaxTest.php	                        (rev 0)
+++ branches/version-2_12-dev/tests/class/util/SC_Utils/SC_Utils_sfTaxTest.php	2012-12-08 23:22:45 UTC (rev 22128)
@@ -0,0 +1,52 @@
+<?php
+
+$HOME = realpath(dirname(__FILE__)) . "/../../../..";
+require_once($HOME . "/tests/class/Common_TestCase.php");
+/**
+ *
+ */
+class SC_Utils_sfTaxTest extends Common_TestCase {
+
+  protected function setUp() {
+    parent::setUp();
+  }
+
+  protected function tearDown() {
+    parent::tearDown();
+  }
+
+  /////////////////////////////////////////
+  public function testSfTax_四捨五入の場合_四捨五入の結果になる() {
+    $this->expected = array(1, 2);
+    $this->actual[0] = SC_Utils::sfTax(140, 1, 1); // 1:四捨五入
+    $this->actual[1] = SC_Utils::sfTax(150, 1, 1); // 1:四捨五入
+
+    $this->verify('税額');
+  }
+
+  public function testSfTax_切り捨ての場合_切り捨ての結果になる() {
+    $this->expected = array(2, 3);
+    $this->actual[0] = SC_Utils::sfTax(140, 2, 2); // 2:切り捨て
+    $this->actual[1] = SC_Utils::sfTax(150, 2, 2); // 2:切り捨て
+
+    $this->verify('税額');
+  }
+
+  public function testSfTax_切り上げの場合_切り上げの結果になる() {
+    $this->expected = array(2, 2);
+    $this->actual[0] = SC_Utils::sfTax(140, 1, 3); // 3:切り上げ
+    $this->actual[1] = SC_Utils::sfTax(150, 1, 3); // 3:切り上げ
+
+    $this->verify('税額');
+  }
+
+  public function testSfTax_それ以外の場合_切り上げの結果になる() {
+    $this->expected = array(2, 2);
+    $this->actual[0] = SC_Utils::sfTax(140, 1, 4);
+    $this->actual[1] = SC_Utils::sfTax(150, 1, 4);
+
+    $this->verify('税額');
+  }
+
+}
+

追加: branches/version-2_12-dev/tests/class/util/SC_Utils/SC_Utils_sfTrimTest.php
===================================================================
--- branches/version-2_12-dev/tests/class/util/SC_Utils/SC_Utils_sfTrimTest.php	                        (rev 0)
+++ branches/version-2_12-dev/tests/class/util/SC_Utils/SC_Utils_sfTrimTest.php	2012-12-08 23:22:45 UTC (rev 22128)
@@ -0,0 +1,36 @@
+<?php
+
+$HOME = realpath(dirname(__FILE__)) . "/../../../..";
+require_once($HOME . "/tests/class/Common_TestCase.php");
+/**
+ *
+ */
+class SC_Utils_sfTrimTest extends Common_TestCase {
+
+  protected function setUp() {
+    parent::setUp();
+  }
+
+  protected function tearDown() {
+    parent::tearDown();
+  }
+
+  /////////////////////////////////////////
+  public function testSfTrim_文頭と途中にホワイトスペースがある場合_文頭だけが除去できる() {
+    $this->expected = 'あ い うえ' . chr(0x0D) . 'お';
+    // 0x0A=CR, 0x0d=LF
+    $this->actual = SC_Utils::sfTrim(chr(0x0A) . chr(0x0D) . '  あ い うえ' . chr(0x0D) . 'お');
+
+    $this->verify('トリム結果');
+  }
+  
+  public function testSfTrim_途中と文末にホワイトスペースがある場合_文末だけが除去できる() {
+    $this->expected = 'あ い うえ' . chr(0x0D) . 'お';
+    // 0x0A=CR, 0x0d=LF
+    $this->actual = SC_Utils::sfTrim('あ い うえ' .chr(0x0D) . 'お  ' . chr(0x0A) . chr(0x0D));
+
+    $this->verify('トリム結果');
+  }
+
+}
+

追加: branches/version-2_12-dev/tests/phpunit.xml.base
===================================================================
--- branches/version-2_12-dev/tests/phpunit.xml.base	                        (rev 0)
+++ branches/version-2_12-dev/tests/phpunit.xml.base	2012-12-08 23:22:45 UTC (rev 22128)
@@ -0,0 +1,16 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<phpunit>
+  <filter>
+    <!-- カバレッジ測定の対象になるファイルを設定します。
+         ローカルの環境に応じて編集してください -->
+    <blacklist>
+        <directory suffix=".php">/usr/local/lib</directory>
+        <directory suffix=".php">../tests/class</directory>
+        <directory suffix=".php">../data/module</directory>
+    </blacklist>
+    <whitelist addUncoveredFileFromWhitelist="true">
+        <directory suffix=".php">data/class/</directory>
+        <directory suffix=".php">data/class_extends/</directory>
+    </whitelist>
+  </filter>
+</phpunit>

追加: branches/version-2_12-dev/tests/phpunit.xml.jenkins
===================================================================
--- branches/version-2_12-dev/tests/phpunit.xml.jenkins	                        (rev 0)
+++ branches/version-2_12-dev/tests/phpunit.xml.jenkins	2012-12-08 23:22:45 UTC (rev 22128)
@@ -0,0 +1,14 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<phpunit>
+  <filter>
+    <blacklist>
+        <directory suffix=".php">/usr/local/lib</directory>
+        <directory suffix=".php">../tests/class</directory>
+        <directory suffix=".php">../data/module</directory>
+    </blacklist>
+    <whitelist addUncoveredFileFromWhitelist="true">
+        <directory suffix=".php">data/class/</directory>
+        <directory suffix=".php">data/class_extends/</directory>
+    </whitelist>
+  </filter>
+</phpunit>

追加: branches/version-2_12-dev/tests/require.php.base
===================================================================
--- branches/version-2_12-dev/tests/require.php.base	                        (rev 0)
+++ branches/version-2_12-dev/tests/require.php.base	2012-12-08 23:22:45 UTC (rev 22128)
@@ -0,0 +1,10 @@
+<?php
+$HOME = realpath(dirname(__FILE__)) . '/../';
+require_once "$HOME/html/require.php";
+// ローカルの環境に応じて追加・編集し、phpunitが使えるように設定してください。
+set_include_path(get_include_path() . PATH_SEPARATOR . '/usr/share/pear');
+set_include_path(get_include_path() . PATH_SEPARATOR . '/usr/local/lib/php');
+set_include_path(get_include_path() . PATH_SEPARATOR . '/usr/lib/php/pear');
+set_include_path(get_include_path() . PATH_SEPARATOR . 'c:/pleiades/xampp/php/PEAR');
+require_once "$HOME/tests/class/Common_TestCase.php";
+?>

追加: branches/version-2_12-dev/tests/require.php.jenkins
===================================================================
--- branches/version-2_12-dev/tests/require.php.jenkins	                        (rev 0)
+++ branches/version-2_12-dev/tests/require.php.jenkins	2012-12-08 23:22:45 UTC (rev 22128)
@@ -0,0 +1,8 @@
+<?php
+$HOME = realpath(dirname(__FILE__)) . '/../';
+require_once "$HOME/html/require.php";
+set_include_path(get_include_path() . PATH_SEPARATOR . '/usr/share/pear');
+set_include_path(get_include_path() . PATH_SEPARATOR . '/usr/local/lib/php');
+set_include_path(get_include_path() . PATH_SEPARATOR . '/usr/lib/php/pear');
+require_once "$HOME/tests/class/Common_TestCase.php";
+?>

追加: branches/version-2_12-dev/tests/ruleset.xml
===================================================================
--- branches/version-2_12-dev/tests/ruleset.xml	                        (rev 0)
+++ branches/version-2_12-dev/tests/ruleset.xml	2012-12-08 23:22:45 UTC (rev 22128)
@@ -0,0 +1,37 @@
+<?xml version="1.0"?>
+<ruleset name="Sample">
+ <description>A sample coding standard</description>
+
+ <!-- Include all sniffs in the PEAR standard -->
+ <rule ref="Zend">
+   <exclude name="Generic.Functions.OpeningFunctionBraceBsdAllman.BraceOnSameLine"/>
+   <exclude name="Zend.NamingConventions.ValidVariableName.NotCamelCaps"/>
+   <exclude name="PEAR.Classes.ClassDeclaration.OpenBraceNewLine"/>
+ </rule>
+
+ <!-- Include some specific sniffs -->
+ <rule ref="Generic.ControlStructures.InlineControlStructure"/>
+ <rule ref="Generic.Functions.FunctionCallArgumentSpacing"/>
+
+ <!-- Change the settings of the Line Length sniff -->
+ <rule ref="Generic.Files.LineLength">
+  <properties>
+   <property name="lineLimit" value="80"/>
+   <property name="absoluteLineLimit" value="200"/>
+  </properties>
+ </rule>
+
+  <!-- Change both Line Length messages -->
+ <rule ref="Generic.Files.LineLength.MaxExceeded">
+  <message>Line longer than the max of %s; has %s chars</message>
+ </rule>
+ <rule ref="Generic.Files.LineLength.TooLong">
+  <message>Line longer than %s chars; has %s chars</message>
+ </rule>
+
+ <!-- Disable internal message for missing code and short open tags -->
+ <rule ref="Internal.NoCodeFound">
+  <severity>0</severity>
+ </rule>
+</ruleset> 
+




Svn-src-all メーリングリストの案内