Search code examples
htmlphpunitlaravel-5internal-server-error

Laravel 5 : PHPunit wont start, throws internal server error


I just wrote tests for a new controller i implemented, and wanted the run them but phpunit gives me the following error... I'm running laravel 5.2. I was wondering if any of you had an idea about where it could come from?

Thanks in advance for your help :)

Martin

$ phpunit
PHPUnit 5.6.1 by Sebastian Bergmann and contributors.

<!DOCTYPE html PUBLIC
    "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title>Internal Server Error</title>

<style type="text/css">
/*<![CDATA[*/
body {font-family:"Verdana";font-weight:normal;color:black;background-color:white;}
h1 { font-family:"Verdana";font-weight:normal;font-size:18pt;color:red }
h2 { font-family:"Verdana";font-weight:normal;font-size:14pt;color:maroon }
h3 {font-family:"Verdana";font-weight:bold;font-size:11pt}
p {font-family:"Verdana";font-weight:normal;color:black;font-size:9pt;margin-top: -5px}
.version {color: gray;font-size:8pt;border-top:1px solid #aaaaaa;}
/*]]>*/
</style>
</head>

<body>
<h1>Internal Server Error</h1>
<h2>include(DB.php): failed to open stream: No such file or directory</h2>
<p>
An internal error occurred while the Web server was processing your request.
Please contact the webmaster to report this problem.
</p>
<p>
Thank you.
</p>
<div class="version">
2016-10-13 13:27:21 </div>
</body>

Solution

  • What do your test look like and when do you get this error? Have you tried only running specific tests, for example:

    phpunit tests/someTest.php
    

    General troubleshooting:

    Try running

    composer dump-autoload
    

    And right after:

    composer install
    

    Also, unless you have it global, setup an alias for phpunit

    try the following command from project root:

    ./vendor/bin/phpunit 
    

    You can also add is as an alias:

    alias phpunit="/{pathtoproject}/vendor/bin/phpunit"
    

    Last but not least, you can do try in your .bash_profile:

    export PATH=$PATH:~/.composer/vendor/bin