emabusi's avatar

PHPUnit test with XAMPP localhost instead of laravel artisan serve

I have unit tests (not dusk browser test) setup on laravel 5.4, I have configured the baseUrl in phpunit.xml to 'http://localhost/TestApp/public' but when I run a vendor\bin\phpunit to assert the status is 200 I get the failed test saying the status returned is 404 while on the browser I can access the URL.

0 likes
7 replies
emabusi's avatar

@zachleigh I see my phpunit.xml below

<?xml version="1.0" encoding="UTF-8"?>
<phpunit backupGlobals="false"
         backupStaticAttributes="false"
         bootstrap="bootstrap/autoload.php"
         colors="true"
         convertErrorsToExceptions="true"
         convertNoticesToExceptions="true"
         convertWarningsToExceptions="true"
         processIsolation="false"
         stopOnFailure="false"
         baseUrl = "http://localhost/TestApp/public">
    <testsuites>
        <testsuite name="Feature Tests">
            <directory suffix="Test.php">./tests/Feature</directory>
        </testsuite>

        <testsuite name="Unit Tests">
            <directory suffix="Test.php">./tests/Unit</directory>
        </testsuite>
    </testsuites>
    <filter>
        <whitelist processUncoveredFilesFromWhitelist="true">
            <directory suffix=".php">./app</directory>
        </whitelist>
    </filter>
    <php>
        <env name="APP_ENV" value="testing"/>
        <env name="CACHE_DRIVER" value="array"/>
        <env name="SESSION_DRIVER" value="array"/>
        <env name="QUEUE_DRIVER" value="sync"/>
        <env name="DB_DATABASE" value="TestApp_test"/>
    </php>
</phpunit>

The .env also has the same url configured

Please or to participate in this conversation.