小编Hub*_*957的帖子

Pphunit 不断给出错误:[1049] 未知数据库 ':memory:'

我刚刚开始在 Laravel 7 中使用 phpunit。我遇到了一个无法找到解决方案的问题。我正在使用 Laravel 7 和 Xampp。

My phpunit.xml:

    <?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:noNamespaceSchemaLocation="./vendor/phpunit/phpcd ..
         cdit/phpunit.xsd"
         bootstrap="vendor/autoload.php"
         colors="true"
>
    <testsuites>
        <testsuite name="Unit">
            <directory suffix="Test.php">./tests/Unit</directory>
        </testsuite>
        <testsuite name="Feature">
            <directory suffix="Test.php">./tests/Feature</directory>
        </testsuite>
    </testsuites>
    <filter>
        <whitelist processUncoveredFilesFromWhitelist="true">
            <directory suffix=".php">./app</directory>
        </whitelist>
    </filter>
    <php>
        <server name="APP_ENV" value="testing"/>
        <server name="BCRYPT_ROUNDS" value="4"/>
        <server name="CACHE_DRIVER" value="array"/>
        <server name="DB_CONNECTION" value="mysql"/>
        <server name="DB_DATABASE" value=":memory:"/>
        <server name="MAIL_MAILER" value="array"/>
        <server name="QUEUE_CONNECTION" value="sync"/>
        <server name="SESSION_DRIVER" value="array"/>
        <server name="TELESCOPE_ENABLED" value="false"/>
    </php>
</phpunit>
Run Code Online (Sandbox Code Playgroud)

我的测试功能:

<?php

namespace Tests\Feature;


use Illuminate\Foundation\Testing\DatabaseMigrations;


use Tests\TestCase;

class …
Run Code Online (Sandbox Code Playgroud)

mysql phpunit laravel

3
推荐指数
1
解决办法
1885
查看次数

标签 统计

laravel ×1

mysql ×1

phpunit ×1