PhpStorm调试模式不起作用

时间:2017-11-13 08:17:50

标签: php symfony phpunit phpstorm xdebug

我安装了PhpStorm,目前正在尝试为我的Symfony项目配置调试模式。如果我使用Symfony功能测试用例单元并尝试在PHPUnit中进行调试,则在导入WebTestCase时会出现以下错误消息:

  

无法猜出内核目录。   供应商/ symfony中/ symfony中/ src目录/ Symfony的/包/ FrameworkBundle /测试/ KernelTestCase.php:58   供应商/ symfony的/ symfony的/ SRC / Symfony的/捆绑/ FrameworkBundle /测试/ KernelTestCase.php:128   供应商/ symfony中/ symfony中/ src目录/ Symfony的/包/ FrameworkBundle /测试/ KernelTestCase.php:157   /vendor/symfony/symfony/src/Symfony/Bundle/FrameworkBundle/Test/WebTestCase.php:33   测试/的appbundle /控制器/ BlogControllerTest.php:20

正在运行的命令:

/usr/bin/php -dxdebug.remote_enable=1 -dxdebug.remote_mode=req
-dxdebug.remote_port=9000 -dxdebug.remote_host=127.0.0.1 vendor/phpunit/phpunit/phpunit --no-configuration Tests\AppBundle\Controller\BlogControllerTest /Users/ahmetbas/PhpstormProjects/SymfonySwagger/tests/AppBundle/Controller/BlogControllerTest.php
--teamcity Testing started at 09:00 ... PHPUnit 6.4.3 by Sebastian Bergmann and contributors.

phpunit.xml.dist

<?xml version="1.0" encoding="UTF-8"?>

<!-- https://phpunit.de/manual/current/en/appendixes.configuration.html -->
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/4.8/phpunit.xsd"
         backupGlobals="false"
         colors="true"
         bootstrap="vendor/autoload.php">
    <php>
        <server name="KERNEL_DIR" value="app/" />
    </php>

    <testsuites>
        <testsuite name="Project Test Suite">
            <directory>tests</directory>
        </testsuite>
    </testsuites>

    <filter>
        <whitelist>
            <directory>src</directory>
            <exclude>
                <directory>src/*Bundle/Resources</directory>
                <directory>src/*/*Bundle/Resources</directory>
                <directory>src/*/Bundle/*Bundle/Resources</directory>
            </exclude>
        </whitelist>
    </filter>
</phpunit>

的php.ini

...
[xdebug]
zend_extension="/Applications/MAMP/bin/php/php7.1.8/lib/php/extensions/no-debug-non-zts-20160303/xdebug.so"
xdebug.remote_enable=1
xdebug.remote_host=localhost
xdebug.remote_port=9000
xdebug.profiler_enable=1
xdebug.profiler_output_dir="/Applications/MAMP/tmp/xdebug"

BlogControllerTest.php

<?php

namespace Tests\AppBundle\Controller;

use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
use PHPUnit\Framework\TestCase;

class BlogControllerTest extends WebTestCase
{

    public function testListAction(){

        $client = static::createClient();
        $crawler = $client->request('GET', '/blog/1');

        $this->assertGreaterThan(
            0,
            $crawler->filter('html:contains("test")')->count()
        );
    }

}

AppKernel.php

在我的AppKernel new Symfony\Bundle\WebServerBundle\WebServerBundle()中启用了使用客户端控制器来检查API路由。

如果我在PhpStorm IDE之外的控制台上运行PHPUnit,它的运行没有错误。出了什么问题?

0 个答案:

没有答案