Issue with multiple tests and assertRedirectedTo()

Posted 4 years ago by tag

I have two test classes. The problem I'm having is that the test in LoginTest passes when ONLY the LoginTest class is called. As soon as I introduce any other test class to the suite, it fails.

Examples below:

class LoginTest extends TestCase
    public function test_home_redirects_to_login_if_not_logged_in()
        $this->call('GET', 'http://site.dev');


class WhatTheHellIsWrongWithThisTest extends TestCase
    public function test_one_equals_one()
        $this->assertTrue(1 == 1); // Dummy test, literally anything I test causes the other test in the other class to fail.

When I include WhatTheHellIsWrongWithThisTest in the same test suite as LoginTest, I get the following error:

Failed asserting that Illuminate\Http\Response Object (...) is an instance of class "Illuminate\Http\RedirectResponse".

When I delete WhatTheHellIsWrongWithThisTest from the test folder, the test in LoginTest passes. I cannot understand why.

Please sign in or create an account to participate in this conversation.