Index: /branches/version-2_12-dev/tests/class/util/SC_Utils/SC_Utils_sfGetClassCatCountTest.php
===================================================================
--- /branches/version-2_12-dev/tests/class/util/SC_Utils/SC_Utils_sfGetClassCatCountTest.php	(revision 22196)
+++ /branches/version-2_12-dev/tests/class/util/SC_Utils/SC_Utils_sfGetClassCatCountTest.php	(revision 22196)
@@ -0,0 +1,131 @@
+<?php
+
+$HOME = realpath(dirname(__FILE__)) . "/../../../..";
+require_once($HOME . "/tests/class/Common_TestCase.php");
+/*
+ * This file is part of EC-CUBE
+ *
+ * Copyright(c) 2000-2012 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.
+ */
+
+/**
+ * SC_Utils::sfGetClassCatCount()のテストクラス.
+ *
+ *
+ * @author Hiroko Tamagawa
+ * @version $Id$
+ */
+class SC_Utils_sfGetClassCatCountTest extends Common_TestCase {
+
+
+  protected function setUp() {
+    parent::setUp();
+    $this->setUpClassCat();
+  }
+
+  protected function tearDown() {
+    parent::tearDown();
+  }
+
+  /////////////////////////////////////////
+  public function testSfGetClassCatCount__規格分類の件数がIDごとに取得できる() {
+    
+    $this->expected = array(
+      '1001' => '2',
+      '1002' => '1'
+    );
+    $this->actual = SC_Utils::sfGetClassCatCount();
+
+    $this->verify('規格分類の件数');
+  }
+
+  //////////////////////////////////////////
+
+  protected function setUpClassCat() {
+    $classes = array(
+      array(
+        'class_id' => '1001',
+        'name' => '味',
+        'creator_id' => '1',
+        'update_date' => 'CURRENT_TIMESTAMP',
+        'del_flg' => '0'
+      ),
+      array(
+        'class_id' => '1002',
+        'name' => '大きさ',
+        'creator_id' => '1',
+        'update_date' => 'CURRENT_TIMESTAMP',
+        'del_flg' => '0'
+      ),
+      // 削除フラグが立っているので検索されない
+      array(
+        'class_id' => '1003',
+        'name' => '匂い',
+        'creator_id' => '1',
+        'update_date' => 'CURRENT_TIMESTAMP',
+        'del_flg' => '1'
+      )
+    );
+    $this->objQuery->delete('dtb_class');
+    foreach ($classes as $item) {
+      $this->objQuery->insert('dtb_class', $item);
+    }
+
+    $class_categories = array(
+      array(
+        'classcategory_id' => '1011',
+        'class_id' => '1001',
+        'creator_id' => '1',
+        'update_date' => 'CURRENT_TIMESTAMP'
+      ),
+      // 削除フラグが立っているので検索されない
+      array(
+        'classcategory_id' => '1012',
+        'class_id' => '1001',
+        'creator_id' => '1',
+        'update_date' => 'CURRENT_TIMESTAMP',
+        'del_flg' => '1'
+      ),
+      array(
+        'classcategory_id' => '1013',
+        'class_id' => '1001',
+        'creator_id' => '1',
+        'update_date' => 'CURRENT_TIMESTAMP'
+      ),
+      array(
+        'classcategory_id' => '1021',
+        'class_id' => '1002',
+        'creator_id' => '1',
+        'update_date' => 'CURRENT_TIMESTAMP'
+      ),
+      // dtb_classでdel_flgが立っているので検索されない
+      array(
+        'classcategory_id' => '1031',
+        'class_id' => '1003',
+        'creator_id' => '1',
+        'update_date' => 'CURRENT_TIMESTAMP'
+      )
+    );
+    $this->objQuery->delete('dtb_classcategory');
+    foreach ($class_categories as $item) {
+      $this->objQuery->insert('dtb_classcategory', $item);
+    }
+  }
+}
+
Index: /branches/version-2_12-dev/tests/class/util/SC_Utils/SC_Utils_sfEncodeFileTest.php
===================================================================
--- /branches/version-2_12-dev/tests/class/util/SC_Utils/SC_Utils_sfEncodeFileTest.php	(revision 22196)
+++ /branches/version-2_12-dev/tests/class/util/SC_Utils/SC_Utils_sfEncodeFileTest.php	(revision 22196)
@@ -0,0 +1,78 @@
+<?php
+
+$HOME = realpath(dirname(__FILE__)) . "/../../../..";
+require_once($HOME . "/tests/class/Common_TestCase.php");
+/*
+ * This file is part of EC-CUBE
+ *
+ * Copyright(c) 2000-2012 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.
+ */
+
+/**
+ * SC_Utils::sfEncodeFile()のテストクラス.
+ * TODO $out_dirで最後のスラッシュまで必ず指定しなければいけないのが少し気になる
+ *
+ * @author Hiroko Tamagawa
+ * @version $Id$
+ */
+class SC_Utils_sfEncodeFileTest extends Common_TestCase {
+
+
+  protected function setUp() {
+    // parent::setUp();
+  }
+
+  protected function tearDown() {
+    // parent::tearDown();
+  }
+
+  /////////////////////////////////////////
+  public function testSfEncodeFile_ファイルが正常に開けた場合_ファイルがエンコードされ出力先のパスが取得できる() {
+    $outdir = realpath(dirname(__FILE__)) . "/../../../tmp/enc_output/";
+    SC_Helper_FileManager::deleteFile($outdir);
+    mkdir($outdir, 0777, TRUE);
+    $indir = realpath(dirname(__FILE__)) . "/../../../tmp/enc_input/";
+    SC_Helper_FileManager::deleteFile($indir);
+    mkdir($indir, 0777, TRUE);
+
+    $filepath = $indir . 'test.txt';
+    $fp_out = fopen($filepath, 'w');
+    fwrite($fp_out, 'こんにちは');
+    fclose($fp_out);
+
+    $this->expected = array(
+      'filename' => $outdir . 'enc_test.txt',
+      'content' => 'こんにちは'
+    );
+
+    $this->actual['filename'] = SC_Utils::sfEncodeFile($filepath, 'euc-jp', $outdir);
+
+    $fp_in = fopen($outdir . 'enc_test.txt', 'r');
+    $this->actual['content'] = mb_convert_encoding(fread($fp_in, 100), 'utf8', 'euc-jp');
+    fclose($fp_in);
+
+    $this->verify();
+  }
+
+  //TODO ファイルが開けなかった場合はexitするためテスト不可
+
+  //////////////////////////////////////////
+
+}
+
Index: /branches/version-2_12-dev/tests/class/util/SC_Utils/SC_Utils_sfIsSucceessTest.php
===================================================================
--- /branches/version-2_12-dev/tests/class/util/SC_Utils/SC_Utils_sfIsSucceessTest.php	(revision 22196)
+++ /branches/version-2_12-dev/tests/class/util/SC_Utils/SC_Utils_sfIsSucceessTest.php	(revision 22196)
@@ -0,0 +1,102 @@
+<?php
+
+$HOME = realpath(dirname(__FILE__)) . "/../../../..";
+require_once($HOME . "/tests/class/Common_TestCase.php");
+/*
+ * This file is part of EC-CUBE
+ *
+ * Copyright(c) 2000-2012 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.
+ */
+
+/**
+ * SC_Utils::sfIsSuccess()のテストクラス.
+ * TODO exitするケースはテスト不可
+ * TODO HTTPSのケースは未テスト(config.phpでhttpsのURLが指定されていないため)
+ * @author Hiroko Tamagawa
+ * @version $Id$
+ */
+class SC_Utils_sfIsSuccessTest extends Common_TestCase {
+
+
+  protected function setUp() {
+    // parent::setUp();
+  }
+
+  protected function tearDown() {
+    // parent::tearDown();
+  }
+
+  /////////////////////////////////////////
+  public function testSfIsSuccess_認証に失敗している場合_falseが返る() {
+    $objSess = new SC_Session_Mock();
+    $objSess->is_success = SUCCESS + 1;
+
+    $this->expected = FALSE;
+    $this->actual = SC_Utils::sfIsSuccess($objSess, FALSE);
+
+    $this->verify('認証可否');
+  }
+
+  public function testSfIsSuccess_認証成功でリファラがない場合_trueが返る() {
+    $objSess = new SC_Session_Mock();
+    $objSess->is_success = SUCCESS;
+
+    $this->expected = TRUE;
+    $this->actual = SC_Utils::sfIsSuccess($objSess);
+
+    $this->verify('認証可否');
+  }
+
+  // TODO 正規のドメインであることは確認しているが、管理画面からというのはチェックしていないのでは？
+  public function testSfIsSuccess_認証成功でリファラが正しい場合_trueが返る() {
+    $objSess = new SC_Session_Mock();
+    $objSess->is_success = SUCCESS;
+    $_SERVER['HTTP_REFERER'] = 'http://test.local/hoge/fuga';
+
+    $this->expected = TRUE;
+    $this->actual = SC_Utils::sfIsSuccess($objSess, FALSE);
+
+    $this->verify('認証可否');
+  }
+
+  public function testSfIsSuccess_認証成功でリファラが不正な場合_falseが返る() {
+    $objSess = new SC_Session_Mock();
+    $objSess->is_success = SUCCESS;
+    $_SERVER['HTTP_REFERER'] = 'http://test.jp.local/hoge/fuga';
+
+    $this->expected = FALSE;
+    $this->actual = SC_Utils::sfIsSuccess($objSess, FALSE);
+
+    $this->verify('認証可否');
+  }
+
+  //////////////////////////////////////////
+
+}
+
+class SC_Session_Mock extends SC_Session {
+
+  public $is_success;
+
+  function IsSuccess() {
+    return $this->is_success;
+  }
+
+}
+
Index: /branches/version-2_12-dev/tests/class/util/SC_Utils/SC_Utils_sfTermMonthTest.php
===================================================================
--- /branches/version-2_12-dev/tests/class/util/SC_Utils/SC_Utils_sfTermMonthTest.php	(revision 22196)
+++ /branches/version-2_12-dev/tests/class/util/SC_Utils/SC_Utils_sfTermMonthTest.php	(revision 22196)
@@ -0,0 +1,77 @@
+<?php
+
+$HOME = realpath(dirname(__FILE__)) . "/../../../..";
+require_once($HOME . "/tests/class/Common_TestCase.php");
+/*
+ * This file is part of EC-CUBE
+ *
+ * Copyright(c) 2000-2012 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.
+ */
+
+/**
+ * SC_Utils::sfTermMonth()のテストクラス.
+ *
+ *
+ * @author Hiroko Tamagawa
+ * @version $Id$
+ */
+class SC_Utils_sfTermMonthTest extends Common_TestCase {
+
+
+  protected function setUp() {
+    // parent::setUp();
+  }
+
+  protected function tearDown() {
+    // parent::tearDown();
+  }
+
+  /////////////////////////////////////////
+  public function testSfTermMonth_締め日が月末より早い場合_設定した締め日の通りになる() {
+    $this->expected = array('2012/9/16', '2012/10/15 23:59:59');
+    $this->actual = SC_Utils::sfTermMonth(2012, 10, 15);
+
+    $this->verify();
+  }
+
+  public function testSfTermMonth_該当月の末日が締め日より早い場合_末日に合わせられる() {
+    $this->expected = array('2012/9/1', '2012/9/30 23:59:59');
+    $this->actual = SC_Utils::sfTermMonth(2012, 9, 31);
+
+    $this->verify();
+  }
+
+  public function testSfTermMonth_前月の末日が締め日より早い場合_末日に合わせられる() {
+    $this->expected = array('2012/10/1', '2012/10/31 23:59:59');
+    $this->actual = SC_Utils::sfTermMonth(2012, 10, 31);
+
+    $this->verify();
+  }
+
+  public function testSfTermMonth_年をまたぐ場合_前月が前年十二月になる() {
+    $this->expected = array('2012/12/16', '2013/1/15 23:59:59');
+    $this->actual = SC_Utils::sfTermMonth(2013, 1, 15);
+
+    $this->verify();
+  }
+
+  //////////////////////////////////////////
+
+}
+
Index: /branches/version-2_12-dev/tests/class/util/SC_Utils/SC_Utils_sfGetProductClassIdTest.php
===================================================================
--- /branches/version-2_12-dev/tests/class/util/SC_Utils/SC_Utils_sfGetProductClassIdTest.php	(revision 22196)
+++ /branches/version-2_12-dev/tests/class/util/SC_Utils/SC_Utils_sfGetProductClassIdTest.php	(revision 22196)
@@ -0,0 +1,98 @@
+<?php
+
+$HOME = realpath(dirname(__FILE__)) . "/../../../..";
+require_once($HOME . "/tests/class/Common_TestCase.php");
+/*
+ * This file is part of EC-CUBE
+ *
+ * Copyright(c) 2000-2012 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.
+ */
+
+/**
+ * SC_Utils::sfGetProductClassId()のテストクラス.
+ * TODO del_flgは使わなくて良い？？
+ * TODO classcategory_id1とclasscategory_id2を使わないと一意に指定できない。
+ * @author Hiroko Tamagawa
+ * @version $Id$
+ */
+class SC_Utils_sfGetProductClassIdTest extends Common_TestCase {
+
+
+  protected function setUp() {
+    parent::setUp();
+    $this->setUpProductsClass();
+  }
+
+  protected function tearDown() {
+    parent::tearDown();
+  }
+
+  /////////////////////////////////////////
+  public function testSfGetProductClassId_存在するIDを指定した場合_対応する製品クラスが取得できる() {
+    
+    $this->expected = '1001';
+    $this->actual = SC_Utils::sfGetProductClassId('1001');
+
+    $this->verify('取得した製品クラス');
+  }
+
+  public function testSfGetProductClassId_存在しないIDを指定した場合_nullが返る() {
+    $this->expected = null;
+    $this->actual = SC_Utils::sfGetProductClassId('9999');
+
+    $this->verify('取得結果が空');
+  }
+
+  //////////////////////////////////////////
+  protected function setUpProductsClass() {
+    $products_class = array(
+      array(
+        'product_class_id' => '2001',
+        'product_id' => '2001',
+        'price02' => '1000',
+        'creator_id' => '1',
+        'update_date' => 'CURRENT_TIMESTAMP'
+      ),
+      array(
+        'product_class_id' => '1001',
+        'product_id' => '1001',
+        'price02' => '1000',
+        'classcategory_id1' => '1',
+        'creator_id' => '1',
+        'update_date' => 'CURRENT_TIMESTAMP'
+      )
+      /** 同じproduct_idが2つあるケースは現状failするのでいったんコメントアウト
+      array(
+        'product_class_id' => '1002',
+        'product_id' => '1001',
+        'price02' => '1000',
+        'classcategory_id1' => '2',
+        'creator_id' => '1',
+        'update_date' => 'CURRENT_TIMESTAMP'
+      )
+      */
+    );
+
+    $this->objQuery->delete('dtb_products_class');
+    foreach ($products_class as $item) {
+      $this->objQuery->insert('dtb_products_class', $item);
+    }
+  }
+}
+
