スキップしてメイン コンテンツに移動

投稿

ラベル(Action)が付いた投稿を表示しています

PHP Symfony 1.4 Action plus View Rendering PHPUnit Test

Symfony 1.4 Action plus View Rendering PHPUnit Test I wrote test case for executing action and rendering view test. However testing action plus final rendering result is quite not easy because you need to understand how Symfony 1.4 framework handles web request and rendering model to view internally. I have investigated in the framework a bit and found a solution. Please see the test case example in the next section. Code <?php $basePath = dirname(__FILE__).'/../../../../apps/your_app_name/modules/'; $modulePaths = glob($basePath.'*', GLOB_ONLYDIR); foreach($modulePaths as $modulePath) { require_once $modulePath.'/actions/actions.class.php'; } class ActionsTest extends PHPUnit_Framework_TestCase { public function testActions() { // create stub web request $request = $this->createStubfWebRequest(); // action you would like to test. // you should pass module and action name refelctively $actions = new TargetActions($this