I have a Laravel 5 app in which one controller action finishes by redirecting to a page outside the Laravel app but on the same domain. Interacting manually with the page works fine, but automating the test with PHPunit doesn't. It keeps trying to load the route and fails with 'headers already sent'.
Route
Route::post('/trials', [
'middleware' => ['web'],
'uses' => 'TrialsController@create'
]);
Controller
public function create(Request $request)
{
...
setcookie( 'etc', $value, time() + 60, '/', "domain.com", true, true) ;
return Saml2::login('http://ift.tt/1pbc3uW');
}
Test
public function testSuccessfulSignup(){
$this->visit('/signup')
->type('test@mail.com', 'mail')
->type('Philip', 'first_name')
->type('Fry', 'last_name')
->press('Signup !') ;
// ->seePageIs('http://ift.tt/1pbc3uW'); doesn't work
// ->assertRedirectedTo('http://ift.tt/1pbc3uW'); doesn't work
}
Error
1) TrialsTest::testSuccessfulSignup
A request to [http://ift.tt/1V4P9ll] failed. Received status code [500].
/private/var/identity/vendor/laravel/framework/src/Illuminate/Foundation/Testing/Concerns/InteractsWithPages.php:196
/private/var/identity/vendor/laravel/framework/src/Illuminate/Foundation/Testing/Concerns/InteractsWithPages.php:80
/private/var/identity/vendor/laravel/framework/src/Illuminate/Foundation/Testing/Concerns/InteractsWithPages.php:114
/private/var/identity/vendor/laravel/framework/src/Illuminate/Foundation/Testing/Concerns/InteractsWithPages.php:554
/private/var/identity/vendor/laravel/framework/src/Illuminate/Foundation/Testing/Concerns/InteractsWithPages.php:541
/private/var/identity/tests/TrialsTest.php:154
Caused by
exception 'ErrorException' with message 'Cannot modify header information - headers already sent by (output started at phar:///usr/local/bin/phpunit/phpunit/Util/Printer.php:134)' in /private/var/identity/app/Http/Controllers/TrialsController.php:84
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire