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