zefy / laravel-sso

MIT License
100 stars 74 forks source link

UnitTesting always failed. Expected status code 200 but received 307. #17

Open mlopez-aeduc opened 5 years ago

mlopez-aeduc commented 5 years ago

When I run PHPUnit from a broker the system always throws the following error:

<?php

namespace Tests\Unit;

use Tests\TestCase;
use Illuminate\Foundation\Testing\RefreshDatabase;

class ExampleTest extends TestCase
{
    /**
     * A basic test example.
     *
     * @return void
     */
    public function testBasicTest()
    {
        $this->assertTrue(true);
    }
}
PHPUnit 7.5.6 by Sebastian Bergmann and contributors.

.F 2/2 (100%)

Time: 160 ms, Memory: 18.00 MB

There was 1 failure:

1) Tests \ Feature \ ExampleTest :: testBasicTest
Expected status code 200 but received 307.
Failed asserting that false is true.

I think the system tries to redirect to the server from the broker and that's why it gives error 307.

Any idea how to fix it?

mlopez-aeduc commented 5 years ago

nvm...

maybe this is the solution... edit the file tests/TestCase.php

<?php

namespace Tests;

use Illuminate\Foundation\Testing\TestCase as BaseTestCase;
use Illuminate\Foundation\Testing\WithoutMiddleware;

abstract class TestCase extends BaseTestCase
{
    use CreatesApplication, WithoutMiddleware;
}