Commit 37b5f614 authored by Taylor Otwell's avatar Taylor Otwell

more view tests.

parent b812f2f0
......@@ -2,6 +2,15 @@
class ViewTest extends PHPUnit_Framework_TestCase {
/**
* Tear down the testing environment.
*/
public function tearDown()
{
View::$shared = array();
Event::$events = array();
}
/**
* Test the View::make method.
*
......@@ -162,6 +171,7 @@ class ViewTest extends PHPUnit_Framework_TestCase {
$view = View::make('home.index')->nest('partial', 'tests.basic');
$this->assertEquals('tests.basic', $view->data['partial']->view);
$this->assertInstanceOf('Laravel\\View', $view->data['partial']);
}
......@@ -179,4 +189,49 @@ class ViewTest extends PHPUnit_Framework_TestCase {
$this->assertEquals('Taylor is 25', $view);
}
/**
* Test that the View class renders nested views.
*
* @group laravel
*/
public function testNestedViewsAreRendered()
{
$view = View::make('tests.basic')
->with('age', 25)
->nest('name', 'tests.nested');
$this->assertEquals('Taylor is 25', $view->render());
}
/**
* Test that the View class renders nested responses.
*
* @group laravel
*/
public function testNestedResponsesAreRendered()
{
$view = View::make('tests.basic')
->with('age', 25)
->with('name', Response::view('tests.nested'));
$this->assertEquals('Taylor is 25', $view->render());
}
/**
* Test the View class raises a composer event.
*
* @group laravel
*/
public function testComposerEventIsCalledWhenViewIsRendering()
{
View::composer('tests.basic', function($view)
{
$view->data = array('name' => 'Taylor', 'age' => 25);
});
$view = View::make('tests.basic')->render();
$this->assertEquals('Taylor is 25', $view);
}
}
\ No newline at end of file
Taylor
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment