1

我复制了.envlaravel 的文件并将其命名到我拥有.env.testing 的文件中.env.testing

DB_CONNECTION=sqlite
DB_DATABASE="C:/wamp64/wwww/myApp/test.sqlite"

然后在phpunit.xml我有这个

<php>
    <server name="APP_ENV" value="testing"/>
    <server name="BCRYPT_ROUNDS" value="4"/>
    <server name="CACHE_DRIVER" value="array"/>
    <server name="DB_CONNECTION" value="sqlite"/>
    <server name="DB_DATABASE" value="C:/wamp64/www/myApp/test.sqlite"/>
    <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>

我的设置正确吗?

在我的测试课中,我有这个代码

namespace Tests\Unit;

use Illuminate\Foundation\Testing\DatabaseMigrations;
use PHPUnit\Framework\TestCase;
class CodeTest extends TestCase
{

    use DatabaseMigrations;

    public function test_can_push_data() {

           $this->assertTrue(true);
    }

}

当我试图跑

./vendor/bin/phpunit

1) Tests\Unit\CodeTest::test_can_push_data
Error: Call to a member function connection() on null

任何想法为什么?

4

0 回答 0