相关疑难解决方法(0)

Symfony 3.4 - "尝试在类中运行控制台命令时,"doctrine:schema"命名空间"中没有定义命令

我正在跟随这个博客创建使用我的数据夹具作为基础的单元测试.相关代码:

namespace Tests\AppBundle\Repository;

use Symfony\Component\Console\Application;
use Symfony\Component\Console\Input\StringInput;
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;

class DataFixtureTestCase extends WebTestCase
{
    protected $client, $container, $em;
    protected static $application;

    /**
     * {@inheritdoc}
     */
    protected function setUp()
    {
        self::runCommand('doctrine:schema:drop --force');
        self::runCommand('doctrine:schema:create');
        self::runCommand('doctrine:fixtures:load --append --no-interaction --force');

        $this->client = static::createClient();
        $this->container = $this->client->getContainer();
        $this->em = $this->container->get('doctrine')->getManager();
    }

    protected static function runCommand($command)
    {
        $command = sprintf('%s --quiet', $command);

        try {
            return self::getApplication()->run(new StringInput($command));
        } catch(\Exception $e) {
            echo $e->getMessage();
        }
    }

    protected static function getApplication()
    {
        if (null === self::$application) …
Run Code Online (Sandbox Code Playgroud)

php unit-testing fixtures symfony-3.4

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

标签 统计

fixtures ×1

php ×1

symfony-3.4 ×1

unit-testing ×1