Laravel and Codeception - test fails on PUT forms

拈花ヽ惹草 提交于 2019-12-06 04:06:08

I found a solution but I don't think this is the right place to write it. I added a simple line of code on the Connector\Laravel5 class.

public function __construct($module)
{
    $this->module = $module;
    $this->initialize();

    $components = parse_url($this->app['config']->get('app.url', 'http://localhost'));
    $host = isset($components['host']) ? $components['host'] : 'localhost';

    parent::__construct($this->app, ['HTTP_HOST' => $host]);

    // Parent constructor defaults to not following redirects
    $this->followRedirects(true);

    // Added to solve the problem of overriding the request method
    Request::enableHttpMethodParameterOverride();
}

This solves my problem.

You can not use PUT method in HTML form tag. For that you need to use laravel's blade template format to define form tag.

e.g. {!! Form::open(['url' => 'users/{users}','method' => 'put','id' => 'form' ]) !!}

Also you can use route attribute to define route instead of url.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!