Generating a single unit test for a function inside of a controller Symfony2/PHP -
i have function exists within controller. want logic sound writing small unit test assertions match correctly output of function.
i've created new unit folder house little unit tests controller. correct term may functional test?
this current set have house of assertions function. question is, out of functions exist in external controller, how can bring function in , perform test on logic within it?
<?php namespace acme\simplewanbundle\tests\unit; use doctrine\orm\tools\schematool; class configcontrollerunittest extends \phpunit_framework_testcase { public function testvalidiprange() { } }
first, method should moved service independent controller. in case, without doing change, can test controller class other php class:
namespace acme\simplewanbundle\tests\unit; use doctrine\orm\tools\schematool; class configcontrollerunittest extends \phpunit_framework_testcase { public function testvalidiprange() { $controller = new \appbundle\controller\configcontroller(); $this->asserttrue($controller->isvalidiprange(...)); } }
Comments
Post a Comment