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>```
4

3 回答 3

0

我猜它变成了别名。要解决此问题,请尝试use Illuminate\Support\Facades\Route;在定义路由的文件中导入类

于 2020-02-05T06:35:40.810 回答
0

这是我的 PHPUnit 文件

 <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>
于 2020-02-05T06:38:33.807 回答
0

通过从测试用例中删除部分修复

/**
  * @runInSeparateProcess
 */ 

添加 stderr="true" 如下所示

<phpunit backupGlobals="false"
         backupStaticAttributes="false"
         bootstrap="vendor/autoload.php"
         colors="true"
         convertErrorsToExceptions="true"
         convertNoticesToExceptions="true"
         convertWarningsToExceptions="true"
         processIsolation="false"
         stopOnFailure="false"
         stderr="true">
于 2020-02-05T10:13:08.677 回答