diff --git a/laravel/session.php b/laravel/session.php index d2253834..0c598a7b 100644 --- a/laravel/session.php +++ b/laravel/session.php @@ -1,10 +1,5 @@ data['errors'])) { - $this->data['errors'] = Session::get('errors', function() + if (Session::started() and Session::has('errors')) { - return new Messages; - }); + $this->data['errors'] = Session::get('errors'); + } + else + { + $this->data['errors'] = new Messages; + } } } diff --git a/tests/cases/laravel/view.test.php b/tests/cases/laravel/view.test.php new file mode 100644 index 00000000..caf5406b --- /dev/null +++ b/tests/cases/laravel/view.test.php @@ -0,0 +1,53 @@ +assertEquals('home.index', $view->view); + } + + /** + * Test the View class constructor. + * + * @group laravel + */ + public function testViewIsCreatedWithCorrectPath() + { + $view = new View('home.index'); + + $this->assertEquals(APP_PATH.'views/home/index.php', $view->path); + } + + /** + * Test the View class constructor. + * + * @group laravel + */ + public function testDataIsSetOnViewByConstructor() + { + $view = new View('home.index', array('name' => 'Taylor')); + + $this->assertEquals('Taylor', $view->data['name']); + } + + /** + * Test the View class constructor. + * + * @group laravel + */ + public function testEmptyMessageContainerSetOnViewWhenNoErrorsInSession() + { + $view = new View('home.index'); + + $this->assertInstanceOf('Laravel\\Messages', $view->data['errors']); + } + +} \ No newline at end of file