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