0

I am getting following error

PHPUnit\Framework\Exception: PHP Fatal error: Uncaught Error: Class 'Route' not found in /var/www/html/checkout/routes/api.php:24

I have tried answer from Error: Class 'Route' not found in routes.php when testing standalone Laravel package using Orchestra Testbench. It is not working and giving same error.

Below is my XML code:

<filter>
        <whitelist processUncoveredFilesFromWhitelist="true">
            <directory suffix=".php">./app</directory>
            <directory suffix=".php">./routes</directory>
            <exclude>
                <directory >./routes</directory>
                 <file>./routes/api.php</file>
                 <file>./routes/web.php</file>
            </exclude>
        </whitelist>
    </filter>```
3
  • <file>./app/Http/routes/web.php</file> try like this Commented Feb 5, 2020 at 6:06
  • still getting error after changes <filter> <whitelist processUncoveredFilesFromWhitelist="true"> <directory suffix=".php">./app</directory> <exclude> <file>./app/Http/routes/api.php</file> </exclude> </whitelist> </filter> Commented Feb 5, 2020 at 6:20
  • no just check this answer carefully - stackoverflow.com/questions/49093727/… Commented Feb 5, 2020 at 6:26

3 Answers 3

0

Here is my PHPUnit File

 <filter>
    <whitelist processUncoveredFilesFromWhitelist="true">
        <directory suffix=".php">./app</directory>
        <exclude>
            <directory suffix=".php">/app/Http/Middleware</directory>
            <file>./app/Http/Middleware/RedirectIfAuthenticated.php</file>
        </exclude>
        <exclude>
            <directory suffix=".php">/app/Exceptions</directory>
            <file>./app/Exceptions/Handler.php</file>
        </exclude>
        <exclude>
            <directory suffix=".php">/app/Helpers</directory>
            <file>./app/Helpers/Helpers.php</file>
        </exclude>
        <exclude>
            <directory suffix=".php">/app/Providers</directory>
            <file>./app/Providers/BroadcastServiceProvider.php</file>
            <file>./app/Providers/HttpsProtocolProvider.php</file>
        </exclude>
    </whitelist>
</filter>
Sign up to request clarification or add additional context in comments.

Comments

0

My guess it becomes of aliases. To fix this try to import use Illuminate\Support\Facades\Route; class in the file where you are defining routes

2 Comments

inside ./routes/api.php added use Route; getting error The use statement with non-compound name 'Route' has no effect
@Roshnijoshi have your specified the full name? use Illuminate\Support\Facades\Route;
0

Partialy fixed by removing from test case

/**
  * @runInSeparateProcess
 */ 

added stderr="true" like bellow

<phpunit backupGlobals="false"
         backupStaticAttributes="false"
         bootstrap="vendor/autoload.php"
         colors="true"
         convertErrorsToExceptions="true"
         convertNoticesToExceptions="true"
         convertWarningsToExceptions="true"
         processIsolation="false"
         stopOnFailure="false"
         stderr="true">

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.