source: branches/version-2_12-dev/tests/class/Common_TestCase.php @ 22139

Revision 22139, 2.9 KB checked in by shift_hiroko.tamagawa, 11 years ago (diff)

一部単体テストを追加(SC_Utils.php/SC_Helper_Purchase.php)

Line 
1<?php
2
3$HOME = realpath(dirname(__FILE__)) . "/../..";
4require_once($HOME . "/tests/class/replace/SC_Display_Ex.php");
5require_once($HOME . "/tests/class/replace/SC_Response_Ex.php");
6require_once($HOME . "/tests/class/test/util/Test_Utils.php");
7require_once($HOME . "/tests/class/test/util/User_Utils.php");
8require_once($HOME . "/tests/require.php");
9
10require_once($HOME . "/data/class/pages/LC_Page_Index.php");
11/**
12 * 全テストケースの基底クラスです。
13 * SC_Queryのテスト以外は基本的にこのクラスを継承して作成してください。
14 *
15 */
16class Common_TestCase extends PHPUnit_Framework_TestCase {
17
18  /** SC_Query インスタンス */
19  protected $objQuery;
20
21  /** 期待値 */
22  protected $expected;
23  /** 実際の値 */
24  protected $actual;
25
26  protected function setUp() {
27    $this->objQuery = SC_Query_Ex::getSingletonInstance();
28    $this->objQuery->begin();
29  }
30
31  protected function tearDown() {
32    $this->objQuery->rollback();
33    $this->objQuery = null;
34  }
35
36  /**
37   * 各テストfunctionの末尾で呼び出し、期待値と実際の値の比較を行います。
38   * 呼び出す前に、$expectedに期待値を、$actualに実際の値を導入してください。
39   */
40  protected function verify($message = null) {
41    $this->assertEquals($this->expected, $this->actual, $message);
42  }
43
44  //////////////////////////////////////////////////////////////////
45  // 以下はテスト用のユーティリティを使うためのサンプルです。
46  // 実際に動作させる場合にはコメントアウトを外して下さい。
47
48  /**
49   * actionExit()呼び出しを書き換えてexit()させない例です。
50   */
51  /**
52  public function testExit() {
53    $resp = new SC_Response_Ex();
54    $resp->actionExit();
55
56    $this->expected = TRUE;
57    $this->actual = $resp->isExited();
58    $this->verify('exitしたかどうか');
59  }
60  */
61
62  /**
63   * 端末種別をテストケースから自由に設定する例です。
64   */
65  /**
66  public function testDeviceType() {
67    $this->expected = array(DEVICE_TYPE_MOBILE, DEVICE_TYPE_SMARTPHONE);
68    $this->actual = array();
69
70    // 端末種別を設定
71    User_Utils::setDeviceType(DEVICE_TYPE_MOBILE);
72    $this->actual[0] = SC_Display_Ex::detectDevice();
73    User_Utils::setDeviceType(DEVICE_TYPE_SMARTPHONE);
74    $this->actual[1] = SC_Display_Ex::detectDevice();
75
76    $this->verify('端末種別');
77  }
78  */
79
80  /**
81   * ログイン状態をテストケースから自由に切り替える例です。
82   */
83  /**
84  public function testLoginState() {
85    $this->expected = array(FALSE, TRUE);
86    $this->actual = array();
87
88    $objCustomer = new SC_Customer_Ex();
89    User_Utils::setLoginState(FALSE);
90    $this->actual[0] = $objCustomer->isLoginSuccess();
91    User_Utils::setLoginState(TRUE, null, $this->objQuery);
92    $this->actual[1] = $objCustomer->isLoginSuccess();
93
94    $this->verify('ログイン状態');
95  }
96  */
97}
98
Note: See TracBrowser for help on using the repository browser.