Laravel 5.1 PHPUnit 503错误

时间:2015-07-15 17:30:34

标签: laravel phpunit

目前难以接受无缘无故返回503错误的测试。运行Laravel 5.1和最新的PHPUnit。

测试:

$this->call('GET', '/about');
$this->assertResponseStatus(200);

失败,因为它返回503错误,其他测试(类似的GET调用)通过。

如果我dd($this->call())我可以看到返回整个html响应,但仍然附加了503错误。日志中也没有错误。页面在浏览器中加载正常,没有503错误。

修改

Route::group(array('after' => 'cache:1440'), function() {
    Route::get('about', 'HomeController@showAbout');
}

EDIT2:

dd($this->call('GET', '/about'));

产生完整的html +

version: "1.1"
statusCode: 503
statusText: "Service Unavailable"
charset: null

composer.json

{
"name": "laravel/laravel",
"description": "The Laravel Framework.",
"keywords": ["framework", "laravel"],
"license": "MIT",
"type": "project",
"require": {
    "php": ">=5.5.9",
    "laravel/framework": "5.1.*",
    "laravelcollective/html": "~5.0",
    "intervention/image": "dev-master",
    "watson/sitemap": "2.0.*",
    "rap2hpoutre/laravel-log-viewer": "dev-master",
    "barryvdh/laravel-httpcache": "0.2.x@dev",
    "guzzlehttp/guzzle": "~5.3|~6.0"
},
"require-dev": {
    "fzaninotto/faker": "~1.4",
    "mockery/mockery": "0.9.*",
    "phpunit/phpunit": "~4.0",
    "phpspec/phpspec": "~2.1"
},
"autoload": {
    "classmap": [
        "database",
        "app/Http/Controllers",
        "app/Models",
        "app/Helpers"
    ],
    "psr-4": {
        "App\\": "app/"
    }
},
"autoload-dev": {
    "classmap": [
        "tests/TestCase.php"
    ]
},
"scripts": {
    "post-install-cmd": [
        "php artisan clear-compiled",
        "php artisan optimize"
    ],
    "post-update-cmd": [
        "php artisan clear-compiled",
        "php artisan optimize"
    ],
    "post-root-package-install": [
        "php -r \"copy('.env.example', '.env');\""
    ],
    "post-create-project-cmd": [
        "php artisan key:generate"
    ]
},
"config": {
    "preferred-install": "dist"
},
"minimum-stability": "dev",
"prefer-stable": true
}

1 个答案:

答案 0 :(得分:0)

好吧我发现问题出于某种原因,刷新和清除缓存对barryvdh\laravel-httpcache库不起作用,我不得不手动删除storage/httpcache下的所有内容