January 19, 2013

FuelPHPでテストケースの雛形を作成するTaskをGitHubに置いておきました。

以下になります。
https://github.com/mp-php/fuel-myapp/blob/master/tasks/testcase.php

php oil r testcase:generateでapp/classesに対するテストケースの雛形をまとめて作成します。
既に作成されているテストケースはスキップします。
今のところ、引数は有りません。
ネーミングはMakeGoodの意識もしていますが、簡単に変えられるようにしてあります。

試しに、DLした直後のFuelPHP(1.5/develop)に対して実行してみます。
$ php oil r testcase:generate
"/xxx/fuel/app/tests/controller/welcome_Test.php" was generated.
"/xxx/fuel/app/tests/view/welcome/404_Test.php" was generated.
"/xxx/fuel/app/tests/view/welcome/hello_Test.php" was generated.
app/tests/controller/welcome_Test.phpを削除して、再度実行してみます。
$ php oil r testcase:generate
"/xxx/fuel/app/tests/controller/welcome_Test.php" was generated.
"/xxx/fuel/app/tests/view/welcome/404_Test.php" already exists, skipped generation.
"/xxx/fuel/app/tests/view/welcome/hello_Test.php" already exists, skipped generation.

作成されたソースを見てみます。

* app/tests/controller/welcome_Test.php
<?php

/**
 * Controller_Welcome class tests
 *
 * @group App
 */
class Test_Controller_Welcome extends TestCase
{

    /**
     * Tests Controller_Welcome::test_action_index()
     *
     * @test
     */
    public function test_action_index()
    {
        //TODO: test_action_index() has not been implemented yet.
        $this->markTestIncomplete(
            'test_action_index() has not been implemented yet.'
        );
    }

    /**
     * Tests Controller_Welcome::test_action_hello()
     *
     * @test
     */
    public function test_action_hello()
    {
        //TODO: test_action_hello() has not been implemented yet.
        $this->markTestIncomplete(
            'test_action_hello() has not been implemented yet.'
        );
    }

    /**
     * Tests Controller_Welcome::test_action_404()
     *
     * @test
     */
    public function test_action_404()
    {
        //TODO: test_action_404() has not been implemented yet.
        $this->markTestIncomplete(
            'test_action_404() has not been implemented yet.'
        );
    }

}
* app/tests/view/welcome/404_Test.php
<?php

/**
 * View_Welcome_404 class tests
 *
 * @group App
 */
class Test_View_Welcome_404 extends TestCase
{

    /**
     * Tests View_Welcome_404::test_view()
     *
     * @test
     */
    public function test_view()
    {
        //TODO: test_view() has not been implemented yet.
        $this->markTestIncomplete(
            'test_view() has not been implemented yet.'
        );
    }

}
* app/tests/view/welcome/hello_Test.php
<?php

/**
 * View_Welcome_Hello class tests
 *
 * @group App
 */
class Test_View_Welcome_Hello extends TestCase
{

    /**
     * Tests View_Welcome_Hello::test_view()
     *
     * @test
     */
    public function test_view()
    {
        //TODO: test_view() has not been implemented yet.
        $this->markTestIncomplete(
            'test_view() has not been implemented yet.'
        );
    }

}

No comments:

Post a Comment