laravel / framework

The Laravel Framework.
https://laravel.com
MIT License
32.55k stars 11.03k forks source link

[5.2] ViewComposer not working in testing mode #11919

Closed Loschcode closed 8 years ago

Loschcode commented 8 years ago

I've a view composer written like this

view()->composer('masterbox.partials.pipeline', function($view) {
  // Some vars and code
});

In one of my view I do as follow

@include('masterbox.partials.pipeline', ['my_var' => 1])

When i'm trying it on my browser everything is fine, but when I run a simple test everything blows up ... After some debugging I found out the closure wasn't executed at all.

$this->visit('/connect/customer/subscribe')
      ->type($faker->firstName, 'first_name')
      ->type($faker->firstName, 'first_name')
      ->type($faker->lastName, 'last_name')
      ->type($faker->email, 'email')
      ->type($faker->phoneNumber, 'phone')
      ->type($password, 'password')
      ->type($password, 'password_confirmation')
      ->press("S'inscrire");

Note : It visits a page, fills the form and subscribe, then it redirects on the page with the @include and it returns a big error, part of it is

exception 'ErrorException' with message 'Undefined variable: my_var' in /Users/Loschcode/Google Drive/projects/my_project_lo/website/storage/framework/views/7e11f284c02bc38adc60b5f8a0545df65d7cf5ec.php:7

I'm afraid it an issue, it's fresh Laravel 5.2 I downloaded a few days ago. Any guess ? Any method to debug this ? Thanks

Loschcode commented 8 years ago

The problem was using require_once in the service provider