首页 > 解决方案 > Symfony 5 - 无法使用 phpunit 加载固定装置

问题描述

我正在尝试从 phpunit 加载我的装置(php 文件)。

我安装了 LiipTestFixture,并在我的 AbstractControllerTest.php 中:

<?php

namespace App\Tests\Controller;

use App\Entity\App\User;
use App\Services\App\EntrepriseServiceTest;
use Liip\TestFixturesBundle\Test\FixturesTrait;
use Symfony\Bundle\FrameworkBundle\Console\Application;
use Symfony\Bundle\FrameworkBundle\KernelBrowser;
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
use Symfony\Component\BrowserKit\Cookie;
use Symfony\Component\Console\Tester\CommandTester;
use Symfony\Component\Security\Core\Authentication\Token\UsernamePasswordToken;

abstract class AbstractControllerTest extends WebTestCase
{
    use FixturesTrait;

    protected function setUp(): void
    {
        if (!$this->client) {
            $this->client = static::createClient();
        }

        $this->loadFixtures([
                "App\DataFixtures\AppFixtures",
            ])->getReferenceRepository();
    }

我的灯具类:

class AppFixtures extends Fixture implements FixtureInterface
{
//...
}

但是当我启动测试时,我没有错误,但固定装置不收费。有人能帮助我吗 ?

PS:我使用的是MySql数据库

标签: phpsymfonyphpunitfixtures

解决方案


推荐阅读