phpunit错误和include_path

I've a problem with require_once function and phpunit tests.

I have a file Login_test.php that calls a model, Prodotto.php, that have this function on line 2:

require_once('Oggetto.php');

Fist time, i tried to run this following command from my application/tests directory:

/opt/lampp/htdocs/my-project/application/tests$ php phpunit.phar controllers/api/Login_test.php 

Output shows me an error like this:

Fatal error: main(): Failed opening required '/opt/lampp/htdocs/my-project/application/models/Oggetto.php' (include_path='.:/opt/lampp/lib/php') in /opt/lampp/htdocs/my-project/application/models/Prodotto.php on line 2

(In Prodotto.php there is require_once('Oggetto.php') and both files are in the /opt/lampp/htdocs/my-project/application/models/ directory)

Subsequently i tried to move the Oggetto.php file in the include_path that error showed me, in /opt/lampp/lib/php and the test with phpunit ran fine!

Afterwards i tried this command: php phpunit.phar --include-path /opt/lampp/htdocs/my-project/application/model/ controller/api/Login_test.php, but output give me error again:

A PHP Error was encountered

Severity:    Compile Error
Message:     main(): Failed opening required 'Oggetto.php' (include_path='/opt/lampp/htdocs/my-project/application/models/:.:/opt/lampp/lib/php')
Filename:    /opt/lampp/htdocs/my-project/application/models/Prodotto.php
Line Number: 2

I hope that someone has already encountered and solved this error. Thank you in advance!

It may be useful to post the entire output:

Warning: Uncaught exception 'LogicException' with message 'Replacement data still remain' in /opt/lampp/htdocs/my-project/application/tests/_ci_phpunit_test/patcher/Patcher/MethodPatcher.php:75
Stack trace:
#0 /opt/lampp/htdocs/my-project/application/tests/_ci_phpunit_test/patcher/Patcher/AbstractPatcher.php(45): Kenjis\MonkeyPatch\Patcher\MethodPatcher::generateNewSource('<?php

/**
 * T...')
#1 /opt/lampp/htdocs/my-project/application/tests/_ci_phpunit_test/patcher/MonkeyPatchManager.php(313): Kenjis\MonkeyPatch\Patcher\AbstractPatcher->patch('<?php

/**
 * T...')
#2 /opt/lampp/htdocs/my-project/application/tests/_ci_phpunit_test/patcher/MonkeyPatchManager.php(276): Kenjis\MonkeyPatch\MonkeyPatchManager::execPatchers('<?php

/**
 * T...')
#3 /opt/lampp/htdocs/my-project/application/tests/_ci_phpunit_test/patcher/IncludeStream.php(57): Kenjis\MonkeyPatch\MonkeyPatchManager::patch('/opt/lampp/htdo...')
#4 /opt/lampp/htdocs/my-project/application/tests/_ci_phpunit_test in /opt/lampp/htdocs/my-project/application/tests/_ci_phpunit_test/patcher/Patcher/MethodPatcher.php on line 75

Call Stack:
    0.0149     694848   1. {main}() /opt/lampp/htdocs/my-project/application/tests/phpunit.phar:0
    0.1474   13330248   2. PHPUnit_TextUI_Command::main() /opt/lampp/htdocs/my-project/application/tests/phpunit.phar:569
    0.1475   13330872   3. PHPUnit_TextUI_Command->run() phar:///opt/lampp/htdocs/my-project/application/tests/phpunit.phar/phpunit/TextUI/Command.php:113
    0.2428   18638128   4. PHPUnit_TextUI_TestRunner->doRun() phar:///opt/lampp/htdocs/my-project/application/tests/phpunit.phar/phpunit/TextUI/Command.php:162
    0.2826   18798536   5. PHPUnit_Framework_TestSuite->run() phar:///opt/lampp/htdocs/my-project/application/tests/phpunit.phar/phpunit/TextUI/TestRunner.php:465
    0.3158   19502704   6. PHPUnit_Framework_TestCase->run() phar:///opt/lampp/htdocs/my-project/application/tests/phpunit.phar/phpunit/Framework/TestSuite.php:753
    0.3158   19504672   7. PHPUnit_Framework_TestResult->run() phar:///opt/lampp/htdocs/my-project/application/tests/phpunit.phar/phpunit/Framework/TestCase.php:888
    0.3784   19508752   8. PHPUnit_Framework_TestCase->runBare() phar:///opt/lampp/htdocs/my-project/application/tests/phpunit.phar/phpunit/Framework/TestResult.php:701
    0.3996   19710432   9. PHPUnit_Framework_TestCase->runTest() phar:///opt/lampp/htdocs/my-project/application/tests/phpunit.phar/phpunit/Framework/TestCase.php:932
    0.4001   19711328  10. ReflectionMethod->invokeArgs() phar:///opt/lampp/htdocs/my-project/application/tests/phpunit.phar/phpunit/Framework/TestCase.php:1081
    0.4001   19711496  11. Login_test->test_prodotto_post_ok() phar:///opt/lampp/htdocs/my-project/application/tests/phpunit.phar/phpunit/Framework/TestCase.php:1081
    0.4169   19877616  12. CIPHPUnitTestCase->request() /opt/lampp/htdocs/my-project/application/tests/controllers/api/Login_test.php:39
    0.4171   19877976  13. CIPHPUnitTestRequest->request() /opt/lampp/htdocs/my-project/application/tests/_ci_phpunit_test/CIPHPUnitTestCase.php:114
    0.4183   19878520  14. CIPHPUnitTestRequest->requestUri() /opt/lampp/htdocs/my-project/application/tests/_ci_phpunit_test/CIPHPUnitTestRequest.php:141
    0.7082   20513064  15. CIPHPUnitTestRequest->createAndCallController() /opt/lampp/htdocs/my-project/application/tests/_ci_phpunit_test/CIPHPUnitTestRequest.php:265
    1.0317   20935488  16. call_user_func_array:{/opt/lampp/htdocs/my-project/application/tests/_ci_phpunit_test/CIPHPUnitTestRequest.php:331}() /opt/lampp/htdocs/my-project/application/tests/_ci_phpunit_test/CIPHPUnitTestRequest.php:331
    1.0317   20937424  17. REST_Controller->_remap() /opt/lampp/htdocs/my-project/application/tests/_ci_phpunit_test/CIPHPUnitTestRequest.php:331
    1.0389   20941408  18. call_user_func_array:{/opt/lampp/htdocs/my-project/application/libraries/REST_Controller.php:654}() /opt/lampp/htdocs/my-project/application/libraries/REST_Controller.php:654
    1.0389   20942360  19. Login->prodotto_post() /opt/lampp/htdocs/my-project/application/libraries/REST_Controller.php:654
    1.4195   23147264  20. CI_Loader->model() /opt/lampp/htdocs/my-project/application/controllers/api/Login.php:88
    1.4399   23591064  21. MY_Model->__construct() /opt/lampp/htdocs/my-project/application/tests/_ci_phpunit_test/replacing/core/Loader.php:355
    1.4535   23599144  22. Pagamento->__after_construct() /opt/lampp/htdocs/my-project/application/core/MY_Model.php:98
    1.4596   23602568  23. CI_Loader->model() /opt/lampp/htdocs/my-project/application/models/Pagamento.php:63
   50.0535   29854528  24. require_once('/opt/lampp/htdocs/my-project/application/models/Prodotto.php') /opt/lampp/htdocs/my-project/application/tests/_ci_phpunit_test/replacing/core/Loader.php:335


Fatal error: main(): Failed opening required 'Oggetto.php' (include_path='.:/opt/lampp/lib/php') in /opt/lampp/htdocs/my-project/application/models/Prodotto.php on line 2

Call Stack:
    0.0149     694848   1. {main}() /opt/lampp/htdocs/my-project/application/tests/phpunit.phar:0
    0.1474   13330248   2. PHPUnit_TextUI_Command::main() /opt/lampp/htdocs/my-project/application/tests/phpunit.phar:569
    0.1475   13330872   3. PHPUnit_TextUI_Command->run() phar:///opt/lampp/htdocs/my-project/application/tests/phpunit.phar/phpunit/TextUI/Command.php:113
    0.2428   18638128   4. PHPUnit_TextUI_TestRunner->doRun() phar:///opt/lampp/htdocs/my-project/application/tests/phpunit.phar/phpunit/TextUI/Command.php:162
    0.2826   18798536   5. PHPUnit_Framework_TestSuite->run() phar:///opt/lampp/htdocs/my-project/application/tests/phpunit.phar/phpunit/TextUI/TestRunner.php:465
    0.3158   19502704   6. PHPUnit_Framework_TestCase->run() phar:///opt/lampp/htdocs/my-project/application/tests/phpunit.phar/phpunit/Framework/TestSuite.php:753
    0.3158   19504672   7. PHPUnit_Framework_TestResult->run() phar:///opt/lampp/htdocs/my-project/application/tests/phpunit.phar/phpunit/Framework/TestCase.php:888
    0.3784   19508752   8. PHPUnit_Framework_TestCase->runBare() phar:///opt/lampp/htdocs/my-project/application/tests/phpunit.phar/phpunit/Framework/TestResult.php:701
    0.3996   19710432   9. PHPUnit_Framework_TestCase->runTest() phar:///opt/lampp/htdocs/my-project/application/tests/phpunit.phar/phpunit/Framework/TestCase.php:932
    0.4001   19711328  10. ReflectionMethod->invokeArgs() phar:///opt/lampp/htdocs/my-project/application/tests/phpunit.phar/phpunit/Framework/TestCase.php:1081
    0.4001   19711496  11. Login_test->test_prodotto_post_ok() phar:///opt/lampp/htdocs/my-project/application/tests/phpunit.phar/phpunit/Framework/TestCase.php:1081
    0.4169   19877616  12. CIPHPUnitTestCase->request() /opt/lampp/htdocs/my-project/application/tests/controllers/api/Login_test.php:39
    0.4171   19877976  13. CIPHPUnitTestRequest->request() /opt/lampp/htdocs/my-project/application/tests/_ci_phpunit_test/CIPHPUnitTestCase.php:114
    0.4183   19878520  14. CIPHPUnitTestRequest->requestUri() /opt/lampp/htdocs/my-project/application/tests/_ci_phpunit_test/CIPHPUnitTestRequest.php:141
    0.7082   20513064  15. CIPHPUnitTestRequest->createAndCallController() /opt/lampp/htdocs/my-project/application/tests/_ci_phpunit_test/CIPHPUnitTestRequest.php:265
    1.0317   20935488  16. call_user_func_array:{/opt/lampp/htdocs/my-project/application/tests/_ci_phpunit_test/CIPHPUnitTestRequest.php:331}() /opt/lampp/htdocs/my-project/application/tests/_ci_phpunit_test/CIPHPUnitTestRequest.php:331
    1.0317   20937424  17. REST_Controller->_remap() /opt/lampp/htdocs/my-project/application/tests/_ci_phpunit_test/CIPHPUnitTestRequest.php:331
    1.0389   20941408  18. call_user_func_array:{/opt/lampp/htdocs/my-project/application/libraries/REST_Controller.php:654}() /opt/lampp/htdocs/my-project/application/libraries/REST_Controller.php:654
    1.0389   20942360  19. Login->prodotto_post() /opt/lampp/htdocs/my-project/application/libraries/REST_Controller.php:654
    1.4195   23147264  20. CI_Loader->model() /opt/lampp/htdocs/my-project/application/controllers/api/Login.php:88
    1.4399   23591064  21. MY_Model->__construct() /opt/lampp/htdocs/my-project/application/tests/_ci_phpunit_test/replacing/core/Loader.php:355
    1.4535   23599144  22. Pagamento->__after_construct() /opt/lampp/htdocs/my-project/application/core/MY_Model.php:98
    1.4596   23602568  23. CI_Loader->model() /opt/lampp/htdocs/my-project/application/models/Pagamento.php:63
   50.0535   29854528  24. require_once('/opt/lampp/htdocs/my-project/application/models/Prodotto.php') /opt/lampp/htdocs/my-project/application/tests/_ci_phpunit_test/replacing/core/Loader.php:335


A PHP Error was encountered

Severity:    Compile Error
Message:     main(): Failed opening required 'Oggetto.php' (include_path='.:/opt/lampp/lib/php')
Filename:    /opt/lampp/htdocs/my-project/application/models/Prodotto.php
Line Number: 2

Backtrace:


Fatal error: Uncaught exception 'CIPHPUnitTestExitException' with message 'exit() called in _error_handler() function' in /opt/lampp/htdocs/my-project/system/core/Common.php on line 635

Call Stack:
    0.0149     694848   1. {main}() /opt/lampp/htdocs/my-project/application/tests/phpunit.phar:0
    0.1474   13330248   2. PHPUnit_TextUI_Command::main() /opt/lampp/htdocs/my-project/application/tests/phpunit.phar:569
    0.1475   13330872   3. PHPUnit_TextUI_Command->run() phar:///opt/lampp/htdocs/my-project/application/tests/phpunit.phar/phpunit/TextUI/Command.php:113
    0.2428   18638128   4. PHPUnit_TextUI_TestRunner->doRun() phar:///opt/lampp/htdocs/my-project/application/tests/phpunit.phar/phpunit/TextUI/Command.php:162
    0.2826   18798536   5. PHPUnit_Framework_TestSuite->run() phar:///opt/lampp/htdocs/my-project/application/tests/phpunit.phar/phpunit/TextUI/TestRunner.php:465
    0.3158   19502704   6. PHPUnit_Framework_TestCase->run() phar:///opt/lampp/htdocs/my-project/application/tests/phpunit.phar/phpunit/Framework/TestSuite.php:753
    0.3158   19504672   7. PHPUnit_Framework_TestResult->run() phar:///opt/lampp/htdocs/my-project/application/tests/phpunit.phar/phpunit/Framework/TestCase.php:888
    0.3784   19508752   8. PHPUnit_Framework_TestCase->runBare() phar:///opt/lampp/htdocs/my-project/application/tests/phpunit.phar/phpunit/Framework/TestResult.php:701
    0.3996   19710432   9. PHPUnit_Framework_TestCase->runTest() phar:///opt/lampp/htdocs/my-project/application/tests/phpunit.phar/phpunit/Framework/TestCase.php:932
    0.4001   19711328  10. ReflectionMethod->invokeArgs() phar:///opt/lampp/htdocs/my-project/application/tests/phpunit.phar/phpunit/Framework/TestCase.php:1081
    0.4001   19711496  11. Login_test->test_prodotto_post_ok() phar:///opt/lampp/htdocs/my-project/application/tests/phpunit.phar/phpunit/Framework/TestCase.php:1081
    0.4169   19877616  12. CIPHPUnitTestCase->request() /opt/lampp/htdocs/my-project/application/tests/controllers/api/Login_test.php:39
    0.4171   19877976  13. CIPHPUnitTestRequest->request() /opt/lampp/htdocs/my-project/application/tests/_ci_phpunit_test/CIPHPUnitTestCase.php:114
    0.4183   19878520  14. CIPHPUnitTestRequest->requestUri() /opt/lampp/htdocs/my-project/application/tests/_ci_phpunit_test/CIPHPUnitTestRequest.php:141
    0.7082   20513064  15. CIPHPUnitTestRequest->createAndCallController() /opt/lampp/htdocs/my-project/application/tests/_ci_phpunit_test/CIPHPUnitTestRequest.php:265
    1.0317   20935488  16. call_user_func_array:{/opt/lampp/htdocs/my-project/application/tests/_ci_phpunit_test/CIPHPUnitTestRequest.php:331}() /opt/lampp/htdocs/my-project/application/tests/_ci_phpunit_test/CIPHPUnitTestRequest.php:331
    1.0317   20937424  17. REST_Controller->_remap() /opt/lampp/htdocs/my-project/application/tests/_ci_phpunit_test/CIPHPUnitTestRequest.php:331
    1.0389   20941408  18. call_user_func_array:{/opt/lampp/htdocs/my-project/application/libraries/REST_Controller.php:654}() /opt/lampp/htdocs/my-project/application/libraries/REST_Controller.php:654
    1.0389   20942360  19. Login->prodotto_post() /opt/lampp/htdocs/my-project/application/libraries/REST_Controller.php:654
    1.4195   23147264  20. CI_Loader->model() /opt/lampp/htdocs/my-project/application/controllers/api/Login.php:88
    1.4399   23591064  21. MY_Model->__construct() /opt/lampp/htdocs/my-project/application/tests/_ci_phpunit_test/replacing/core/Loader.php:355
    1.4535   23599144  22. Pagamento->__after_construct() /opt/lampp/htdocs/my-project/application/core/MY_Model.php:98
    1.4596   23602568  23. CI_Loader->model() /opt/lampp/htdocs/my-project/application/models/Pagamento.php:63
   50.0535   29854528  24. require_once('/opt/lampp/htdocs/my-project/application/models/Prodotto.php') /opt/lampp/htdocs/my-project/application/tests/_ci_phpunit_test/replacing/core/Loader.php:335

CIPHPUnitTestExitException: exit() called in _error_handler() function in /opt/lampp/htdocs/my-project/system/core/Common.php on line 635

Call Stack:
    0.0149     694848   1. {main}() /opt/lampp/htdocs/my-project/application/tests/phpunit.phar:0
    0.1474   13330248   2. PHPUnit_TextUI_Command::main() /opt/lampp/htdocs/my-project/application/tests/phpunit.phar:569
    0.1475   13330872   3. PHPUnit_TextUI_Command->run() phar:///opt/lampp/htdocs/my-project/application/tests/phpunit.phar/phpunit/TextUI/Command.php:113
    0.2428   18638128   4. PHPUnit_TextUI_TestRunner->doRun() phar:///opt/lampp/htdocs/my-project/application/tests/phpunit.phar/phpunit/TextUI/Command.php:162
    0.2826   18798536   5. PHPUnit_Framework_TestSuite->run() phar:///opt/lampp/htdocs/my-project/application/tests/phpunit.phar/phpunit/TextUI/TestRunner.php:465
    0.3158   19502704   6. PHPUnit_Framework_TestCase->run() phar:///opt/lampp/htdocs/my-project/application/tests/phpunit.phar/phpunit/Framework/TestSuite.php:753
    0.3158   19504672   7. PHPUnit_Framework_TestResult->run() phar:///opt/lampp/htdocs/my-project/application/tests/phpunit.phar/phpunit/Framework/TestCase.php:888
    0.3784   19508752   8. PHPUnit_Framework_TestCase->runBare() phar:///opt/lampp/htdocs/my-project/application/tests/phpunit.phar/phpunit/Framework/TestResult.php:701
    0.3996   19710432   9. PHPUnit_Framework_TestCase->runTest() phar:///opt/lampp/htdocs/my-project/application/tests/phpunit.phar/phpunit/Framework/TestCase.php:932
    0.4001   19711328  10. ReflectionMethod->invokeArgs() phar:///opt/lampp/htdocs/my-project/application/tests/phpunit.phar/phpunit/Framework/TestCase.php:1081
    0.4001   19711496  11. Login_test->test_prodotto_post_ok() phar:///opt/lampp/htdocs/my-project/application/tests/phpunit.phar/phpunit/Framework/TestCase.php:1081
    0.4169   19877616  12. CIPHPUnitTestCase->request() /opt/lampp/htdocs/my-project/application/tests/controllers/api/Login_test.php:39
    0.4171   19877976  13. CIPHPUnitTestRequest->request() /opt/lampp/htdocs/my-project/application/tests/_ci_phpunit_test/CIPHPUnitTestCase.php:114
    0.4183   19878520  14. CIPHPUnitTestRequest->requestUri() /opt/lampp/htdocs/my-project/application/tests/_ci_phpunit_test/CIPHPUnitTestRequest.php:141
    0.7082   20513064  15. CIPHPUnitTestRequest->createAndCallController() /opt/lampp/htdocs/my-project/application/tests/_ci_phpunit_test/CIPHPUnitTestRequest.php:265
    1.0317   20935488  16. call_user_func_array:{/opt/lampp/htdocs/my-project/application/tests/_ci_phpunit_test/CIPHPUnitTestRequest.php:331}() /opt/lampp/htdocs/my-project/application/tests/_ci_phpunit_test/CIPHPUnitTestRequest.php:331
    1.0317   20937424  17. REST_Controller->_remap() /opt/lampp/htdocs/my-project/application/tests/_ci_phpunit_test/CIPHPUnitTestRequest.php:331
    1.0389   20941408  18. call_user_func_array:{/opt/lampp/htdocs/my-project/application/libraries/REST_Controller.php:654}() /opt/lampp/htdocs/my-project/application/libraries/REST_Controller.php:654
    1.0389   20942360  19. Login->prodotto_post() /opt/lampp/htdocs/my-project/application/libraries/REST_Controller.php:654
    1.4195   23147264  20. CI_Loader->model() /opt/lampp/htdocs/my-project/application/controllers/api/Login.php:88
    1.4399   23591064  21. MY_Model->__construct() /opt/lampp/htdocs/my-project/application/tests/_ci_phpunit_test/replacing/core/Loader.php:355
    1.4535   23599144  22. Pagamento->__after_construct() /opt/lampp/htdocs/my-project/application/core/MY_Model.php:98
    1.4596   23602568  23. CI_Loader->model() /opt/lampp/htdocs/my-project/application/models/Pagamento.php:63
   50.0535   29854528  24. require_once('/opt/lampp/htdocs/my-project/application/models/Prodotto.php') /opt/lampp/htdocs/my-project/application/tests/_ci_phpunit_test/replacing/core/Loader.php:335
   55.7306   29946560  25. _shutdown_handler() /opt/lampp/htdocs/my-project/system/core/Common.php:0
   55.7377   29947544  26. _error_handler() /opt/lampp/htdocs/my-project/system/core/Common.php:692
   55.7654   29990544  27. exit__() /opt/lampp/htdocs/my-project/system/core/Common.php:635