0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

PHP DBUnit で getDataSet() が動作しなかった件

Posted at

環境(今回の原因は環境関係ないですが)

 FuelPHP 1.8
PHP 5.6
PHPUnit 5.5.7
DBUnit 2.0.3

動かなかったソース

controller.php
class TestCase_Controller extends \PHPUnit_Extensions_Database_TestCase
{
    protected function getConnection()
    {
        //~~~割愛~~~
    }

    protected function getDataSet()
    {
      //実際に読み込む内容は各テストクラスに記載している
    }

    protected function setup()
    {
        //~~~いろいろ 処理(割愛)~~~
    }

原因

「setup()」の中で「parent::setUp()」を実行していなかった

修正後ソース

controller.php
class TestCase_Controller extends \PHPUnit_Extensions_Database_TestCase
{
    protected function getConnection()
    {
        //~~~割愛~~~
    }

    protected function getDataSet()
    {
      //実際に読み込む内容は各テストクラスに記載している
    }

    protected function setup()
    {
        parent::setUp();

        //~~~いろいろ 処理(割愛)~~~
    }

気づいてしまえば、そりゃそうだよね、、、というミスでした。orz

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?