機能テスト

moduleのテストをする際、毎回moduleのURLを叩いてブラウザ確認をするのは大変。
そこでtestフレームワークです。

個別に実行

$ php test/functional/[app名]/[module名]ActionsTest.php

もしくは

$ ./symfony test:functional [app名] [module名]Actions

実行後、結果が返ります

# get /hoge/index
ok 1 - request parameter module is hoge
ok 2 - request parameter action is index
ok 3 - status code is 200
ok 4 - response selector body does not match regex /This is a temporary page/
1..5
# Looks like everything went fine.

include(dirname(__FILE__).'/../../bootstrap/functional.php');

$browser = new sfTestFunctional(new sfBrowser());

$browser->
  get('/hoge/index')->

  with('request')->begin()->
    isParameter('module', 'hoge')->
    isParameter('action', 'index')->
  end()->

  with('response')->begin()->
    isStatusCode(200)->
    checkElement('body', '!/This is a temporary page/')->
  end()
;

suffixを付けている場合は、合わせて付与する必要があります。
例)suffixが「.html」の場合

//  get('/hoge/index')->
  get('/hoge/index.html')->