首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Liip\FunctionalTestBundle\Test\WebTestCase‘在C:\wamp\www\test\src\TestTask\PhotosBundle\Tests\Controller\ApiControllerTest.php中找不到

Liip\FunctionalTestBundle\Test\WebTestCase‘在C:\wamp\www\test\src\TestTask\PhotosBundle\Tests\Controller\ApiControllerTest.php中找不到
EN

Stack Overflow用户
提问于 2016-04-14 07:30:49
回答 1查看 2K关注 0票数 2

当我运行命令php ApiControllerTest.php时,它将显示以下错误:

Liip\FunctionalTestBundle\Test\WebTestCase‘在第12行的C:\wamp\www\test\src\TestTask\PhotosBundle\Tests\Controller\ApiControllerTest.php中找不到

我的作曲家如下:

代码语言:javascript
复制
"require-dev": {
    "sensio/generator-bundle": "~2.3",
    "symfony/phpunit-bridge": "~2.7",
    "hautelook/alice-bundle": "^1.1",
    "doctrine/doctrine-fixtures-bundle": "^2.3",
    "liip/functional-test-bundle": "^1.4",
    "phpunit/phpunit": "^4.8",
    "helmich/phpunit-json-assert": "^1.0

我的文件应用程序如下;

代码语言:javascript
复制
if (in_array($this->getEnvironment(), array('dev', 'test'))) {
    $bundles[] = new Acme\DemoBundle\AcmeDemoBundle();
    $bundles[] = new Symfony\Bundle\WebProfilerBundle\WebProfilerBundle();
    $bundles[] = new Symfony\Bundle\DebugBundle\DebugBundle();
    $bundles[] = new Sensio\Bundle\DistributionBundle\SensioDistributionBundle();
    $bundles[] = new Sensio\Bundle\GeneratorBundle\SensioGeneratorBundle();
    $bundles[] = new Doctrine\Bundle\FixturesBundle\DoctrineFixturesBundle();
    $bundles[] = new Hautelook\AliceBundle\HautelookAliceBundle();
    $bundles[] = new Liip\FunctionalTestBundle\LiipFunctionalTestBundle();

我的测试控制器如下所示;我不知道问题出在哪里;所有的东西都包括在这里,

代码语言:javascript
复制
<?php

namespace TestTask\PhotosBundle\Tests\Controller;

use Helmich\JsonAssert\JsonAssertions;
use Liip\FunctionalTestBundle\Test\WebTestCase;
use Symfony\Component\BrowserKit\Client;
use Symfony\Component\HttpFoundation\File\UploadedFile;
use Symfony\Component\HttpFoundation\Response;

class ApiControllerTest extends WebTestCase
{
    use JsonAssertions;

    public function testPostInvalidPhoto()
    {
        $client = static::createClient();
        $client->request(
            'POST',
            '/photos',
            array(
                'tags' => array(
                    'ololo',
                    'trololo',
                )
            ),
            array('image' => $this->getFile(__FILE__)),
            array('HTTP_Accept' => 'application/json')
        );

当我使用命令运行它时: phpunit -c app/phminit.xml.dist,或者php供应商/bin/ phpunit -c app/phminit.xml.dist,它显示出phpunit是不被识别的。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2016-04-18 15:08:32

当我运行命令重新启动php ApiControllerTest.php

这会失败,因为您必须引导PHPUnit,而不是直接执行测试类。

您必须使用phpunit命令运行测试,就像正式文件中建议的那样。

这应该可以使用以下命令之一(当前目录必须是Symfony项目的根目录):

代码语言:javascript
复制
phpunit -c app/phpunit.xml.dist src/TestTask/PhotosBundle/Tests/Controller/ApiControllerTest.php
# or
php vendor/bin/phpunit -c app/phpunit.xml.dist src/TestTask/PhotosBundle/Tests/Controller/ApiControllerTest.php

如果您想启动所有测试而不是这个特定的文件,您可以删除最后一个参数。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/36616479

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档