开发者

PHPUnit error while creating unit test cases

开发者 https://www.devze.com 2023-01-28 21:08 出处:网络
i have controller class \"UserController\"(in controller folder) which extends BaseController (present in app folder),

i have controller class "UserController"(in controller folder) which extends BaseController (present in app folder),

when i right click and select option "Create PHPUnitTests" it gives me following error:

php开发者_开发知识库unit Fatal error: Class 'Base Controller' not found 

can ayone tell me why i get this error and what i have to configure for the same.

I using custom php framework


Your Include Path is likely not configured correctly for your IDE. For Netbeans, follow the instructions given in the Netbeans User Manual:

  • http://netbeans.org/kb/docs/php/project-setup.html#phpIncludePath

If you are not using include statements to include the files to be tested in the UnitTests, you also have to bootstrap the environment. Executing the UnitTests from the IDE will likely not run your regular bootstrap file. Consider adding a phpunit.xml file to your tests:

<phpunit backupGlobals="true"
     backupStaticAttributes="false"
     <!--bootstrap="/path/to/bootstrap.php"-->
     colors="false"
     …
<php>
    <includePath>.</includePath>

See the Appendix in the PHPUnit Manual for more information:

  • https://phpunit.de/manual/current/en/appendixes.configuration.html

Follow the instructions given in the Netbeans User Manual to make the IDE consider the file automatically when tests are run:

  • http://blogs.oracle.com/netbeansphp/entry/recent_improvements_in_phpunit_support
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号