私は次のtests/フォルダーを持っています:
テスト/ ClassOne.test.php ClassTwo.test.php ClassThree.test.php
setUp()
以下のメソッドとtearDown()
メソッドをこれらの各ファイルにコピーする必要があります。
パブリック関数setUp() {{ $ this-> dbTestData(); } パブリック関数tearDown() {{ $ this-> dbClear(); } プライベート関数dbTestData(){ //データベースにいくつかのエントリを入力します Entities \ AutocompleteValue :: create(array('field_name' =>'testing1'、'entry_value' =>'Aisforapple')); Entities \ AutocompleteValue :: create(array('field_name' =>'testing2'、'entry_value' =>'Bisforball')); Entities \ AutocompleteValue :: create(array('field_name' =>'testing3'、'entry_value' =>'Cisforcat')); Entities \ AutocompleteValue :: create(array('field_name' =>'testing4'、'entry_value' =>'Disfordog')); } プライベート関数dbClear(){ DB :: table('autocomplete_values')-> delete(); }
これらのメソッドを含む単一の個別のクラスを作成することを検討しました。require()
そのファイルは各テストファイルにあり、の代わりにそのクラスから拡張されますPHPUnit_Framework_Testcase
。これに対するより簡単な解決策はありますか?
phpunit.xml
私のコーディングフレームワークのCLIツール(Laravel、職人)がその作成を処理するため、に簡単にアクセスできません。したがって、そのファイルを含まない解決策があるとよいでしょう。