首页 > 解决方案 > 如何在 laravel phpunit.xml 中添加 elasticsearch 测试数据库作为第二个测试数据库?

问题描述

我将 postgres 作为主数据库,将 elasticsearch 作为第二个(侧面)数据库
也用于测试目的我有第二个 postgres 测试数据库
我想在 phpunit.xml 中添加 elasticsearch_test db
我该怎么做?
是否需要做任何其他必要的配置?
这是我当前的 phpunit.xml 文件

<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
     xsi:noNamespaceSchemaLocation="./vendor/phpunit/phpunit/phpunit.xsd"
     backupGlobals="false"
     backupStaticAttributes="false"
     bootstrap="vendor/autoload.php"
     colors="true"
     convertErrorsToExceptions="true"
     convertNoticesToExceptions="true"
     convertWarningsToExceptions="true"
     processIsolation="false"
     stopOnFailure="false">
<testsuites>
    <testsuite name="Unit">
        <directory suffix="Test.php">./tests/Unit</directory>
    </testsuite>

    <testsuite name="Feature">
        <directory suffix="Test.php">./tests/Feature</directory>
    </testsuite>

    <testsuite name="Integration">
        <directory suffix="Test.php">./tests/Integration</directory>
    </testsuite>
</testsuites>
<filter>
    <whitelist processUncoveredFilesFromWhitelist="true">
        <directory suffix=".php">./app</directory>
    </whitelist>
</filter>
<php>
    <server name="APP_ENV" value="testing"/>
    <server name="APP_URL" value="/"/>
    <server name="BCRYPT_ROUNDS" value="4"/>
    <server name="CACHE_DRIVER" value="array"/>
    <server name="MAIL_DRIVER" value="array"/>
    <server name="QUEUE_CONNECTION" value="sync"/>
    <server name="DB_CONNECTION" value="pgsql_test"/>
    <server name="SESSION_DRIVER" value="array"/>
</php>

标签: phplaravelelasticsearchphpunit

解决方案


推荐阅读