Changes between Version 4 and Version 5 of EC-CUBE標準規約/単体テストガイドライン
- Timestamp:
- 2012/12/07 19:22:50 (10 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
EC-CUBE標準規約/単体テストガイドライン
v4 v5 15 15 16 16 ||build.xml||テストやインスペクションを行うための設定ファイルです。|| 17 ||tests|| 17 ||tests|| || 18 18 ||├phpunit.xml||PHPUnitで使う各種設定を記載したファイルです。|| 19 19 ||├ruleset.xml||PHP_CodeSniffer(インスペクションツール)用の設定ファイルです。|| … … 50 50 51 51 {{{ 52 #!php 53 <?php 52 54 SampleTest extends Common_TestCase { 53 55 … … 80 82 81 83 {{{ 84 #!php 85 <?php 82 86 protected function verify($msg = null) { 83 87 $this->assertEquals($this->expected, $this->actual, $msg); … … 87 91 $this->expected = array(1, “山田”, “太郎”); 88 92 // テスト対象を実行して$actualに結果を格納 89 93 $this->verify(); 90 94 } 91 95 }}} … … 96 100 * 良い例 97 101 {{{ 102 #!php 103 <?php 98 104 function testAbs_正の値の場合() { 99 105 $expected = 1; … … 115 121 116 122 {{{ 123 #!php 124 <?php 117 125 function testAbs() { 118 126 $expected[0] = 1; … … 182 190 183 191 {{{ 192 #!php 193 <?php 184 194 /** 185 195 * actionExit()呼び出しを書き換えてexit()させない例です。 … … 203 213 * ソースコード 204 214 {{{ 215 #!php 216 <?php 205 217 class Sample { 206 218 function hoge() { … … 220 232 * テストコード 221 233 {{{ 234 #!php 235 <?php 222 236 class SampleTest extends PHPUnit_Framcework_TestCase { 223 237 function testHoge_fugaがtrueの場合() { … … 242 256 そのため、EC-CUBEのユーティリティであるSC_Queryクラスを使ってsetUp()の中でデータの準備を行い、tearDown()でロールバックを行います。 243 257 {{{ 258 #!php 259 <?php 244 260 class SampleTest extends PHPUnit_Framework_TestCase { 245 261 // データ準備 … … 277 293 テスト専用のユーティリティを使用して擬似的に端末の種別を設定します。ユーティリティはtests/class/test/util/User_Utils.phpに定義されています。 278 294 {{{ 295 #!php 296 <?php 279 297 /** 280 298 * 端末種別をテストケースから自由に設定する例です。 … … 298 316 情報を書き換えるfunctionは、端末種別設定と同じくtests/class/test/util/User_Utils.php内で定義されています。 299 317 {{{ 318 #!php 319 <?php 300 320 /** 301 321 * ログイン状態をテストケースから自由に切り替える例です。