php - Making phpunit ignore include? -
have file single include one:
file.php
include(dirname(__file__)."/anotherfile.php"); class file { function myfunction() { $class = new anotherfile(); $class->functionfromanotherfile(); } function myfunctiontobetested() { // things here } } i'm using travis-ci run tests phpunit, , problem dont commit "anotherfile.php" (have logic , credentials connect database), makes not work when try include file in test script.
tests.php
class tests extends phpunit_framework_testcase { public function test_function() { include(dirname(__file__)."/file.php"); $class = new file(); } } i make file function need test , go maybe guys can come other awnser.
use kind of dependency injection:
- modify class want test accepts credentials parameters of constructor.
- in test, create fake -or real- credentials , pass them constructor of class.
Comments
Post a Comment