Answer the question
In order to leave comments, you need to log in
Laravel PHPunit AssertViewHas not seeing variables from base controller?
Here is the base controller code:
class BaseController extends Controller {
public function __construct(){
$base_config = array('base_url' => URL::to('/'));
View::share('base_config', $base_config);
}
}
class MainController extends BaseController {
public function index($id = 0){
Log::info('This is some useful information.');
$rating = Config::get('topic.index_good_topic_rating');
$topics = Topic::getSubscribedTopics(Auth::user()->id, $rating);
//echo "<pre>"; print_r($topics); echo "</pre>";exit;
return View::make('main.index', array('topics' => $topics));
}
}
public function testMainPage(){
$this->be(User::find(1));
$crawler = $this->call('GET', 'main/index');
$this->assertViewHas(['topics']);
$this->assertViewHas('base_config');
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question