zachleigh's avatar

Cant test post routes

I have an app that I upgraded from 5.0 to 5.1. Testing get routes works fine, but post routes always return 500, even though they work fine in the browser. Heres a simple test class with one method that is failing:

<?php

use Illuminate\Foundation\Testing\WithoutMiddleware;

class SearchApiTest extends TestCase {

    use WithoutMiddleware;

    protected $route = 'api/search';

    public function test_empty_search_returns_error()
    {
        $this->post($this->route, ['input' => ''])
             ->seeStatusCode(200);
    }
}

Ive tested the route with Postman, and it works fine. What could be causing the problem?

0 likes
1 reply
zachleigh's avatar

Figured it out. Had an error in and event handler that had never raised its head until I tried testing it. Weird how it never got triggered outside of the test suite...

Please or to participate in this conversation.