Laravel 5.2:ReflectionException:类日志不存在测试供应商包内

时间:2017-06-07 09:56:09

标签: laravel laravel-5.2

我在供应商包中创建测试时遇到问题。如果我只在测试中做匹配值,那么一切正常。但如果我使用<%= image_tag item.avatar.thumb.url %> $this->post($url),那么我会获得$this->get($url)例外。我对此进行了研究,但没有得到解决方案。

以下是我的供应商包ReflectionException: Class log does not exist文件。

composer.json

以下是供应商软件包

中的TestCase.php类
{
    "name": "name",
    "description": "description.",
    "type": "library",
    "license": "license",
    "minimum-stability": "dev",
    "require": {
        "php": ">=5.5.9",
        "laravel/framework": "5.2.*",
        "elasticsearch/elasticsearch": "~5.0",
        "cyvelnet/laravel5-fractal": "^2.0",
        "spatie/laravel-fractal": "^3.5"
    },
    "require-dev": {
        "fzaninotto/faker": "~1.4",
        "phpunit/phpunit": "~4.0"
    },
    "autoload": {
        "psr-4": {
            "NAMESPACE\\": "src",
            "Test\\": "tests/"
        }
    },
    "config": {
        "preferred-install": "dist"
    }
}

当我正在运行测试时,我收到此错误

<?php

namespace Test;

use Faker\Factory as Faker;
use Illuminate\Foundation\Testing\TestCase as BaseTestCase;

class TestCase extends BaseTestCase
{

    protected $faker;

    /**
     * The base URL to use while testing the application.
     *
     * @var string
     */
    protected $baseUrl = 'http://localhost/api/v1/';

    protected $headers = [
        'Content-Type' => 'application/json',
        'Accept' => 'application/json',
    ];

    protected function setUp()
    {
        parent::setUp();

        $this->faker = Faker::create();
    }

    /**
     * Creates the application.
     *
     * @return \Illuminate\Foundation\Application
     */
    public function createApplication()
    {
        $app = require __DIR__.'/../../../../bootstrap/app.php';
        $app->singleton('NAMESPACE\Providers\PackageServiceProvider');

        $app->singleton(
            \Illuminate\Contracts\Http\Kernel::class,
            \Illuminate\Foundation\Http\Kernel::class
        );

        $app->singleton(
            \Illuminate\Contracts\Debug\ExceptionHandler::class,
            \Illuminate\Foundation\Exceptions\Handler::class
        );

        return $app;
    }
}

ListingsController root@0fd1951e0b12:/var/www/something/vendor/lucky/luckys# vendor/bin/phpunit PHPUnit 4.8.35 by Sebastian Bergmann and contributors. Warning: The Xdebug extension is not loaded No code coverage will be generated. E Time: 72 ms, Memory: 8.00MB There was 1 error: 1) Test\App\Http\Controllers\ListingControllerTest::testIndex ReflectionException: Class log does not exist /var/www/something/vendor/lucky/luckys/vendor/laravel/framework/src/Illuminate/Container/Container.php:734 /var/www/something/vendor/lucky/luckys/vendor/laravel/framework/src/Illuminate/Container/Container.php:629 /var/www/something/vendor/lucky/luckys/vendor/laravel/framework/src/Illuminate/Foundation/Application.php:697 /var/www/something/vendor/lucky/luckys/vendor/laravel/framework/src/Illuminate/Container/Container.php:849 /var/www/something/vendor/lucky/luckys/vendor/laravel/framework/src/Illuminate/Container/Container.php:804 /var/www/something/vendor/lucky/luckys/vendor/laravel/framework/src/Illuminate/Container/Container.php:773 /var/www/something/vendor/lucky/luckys/vendor/laravel/framework/src/Illuminate/Container/Container.php:629 /var/www/something/vendor/lucky/luckys/vendor/laravel/framework/src/Illuminate/Foundation/Application.php:697 /var/www/something/vendor/lucky/luckys/vendor/laravel/framework/src/Illuminate/Container/Container.php:230 /var/www/something/vendor/lucky/luckys/vendor/laravel/framework/src/Illuminate/Container/Container.php:731 /var/www/something/vendor/lucky/luckys/vendor/laravel/framework/src/Illuminate/Container/Container.php:629 /var/www/something/vendor/lucky/luckys/vendor/laravel/framework/src/Illuminate/Foundation/Application.php:697 /var/www/something/vendor/lucky/luckys/vendor/laravel/framework/src/Illuminate/Container/Container.php:1178 /var/www/something/vendor/lucky/luckys/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php:279 /var/www/something/vendor/lucky/luckys/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php:105 /var/www/something/vendor/lucky/luckys/vendor/laravel/framework/src/Illuminate/Foundation/Testing/Concerns/MakesHttpRequests.php:515 /var/www/something/vendor/lucky/luckys/vendor/laravel/framework/src/Illuminate/Foundation/Testing/Concerns/MakesHttpRequests.php:110 /var/www/something/vendor/lucky/luckys/tests/App/Http/ListingControllerTest.php:40 FAILURES! Tests: 1, Assertions: 0, Errors: 1.

testIndex()

请帮帮我。我花了太多时间在这上面......但没有弄清楚我做错了什么。

0 个答案:

没有答案