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

Popular posts from this blog

How to understand 2 main() functions after using uftrace to profile the C++ program? -

c# - Update a combobox from a presenter (MVP) -

How to put a lock and transaction on table using spring 4 or above using jdbcTemplate and annotations like @Transactional? -