more view tests.
This commit is contained in:
parent
b812f2f08a
commit
37b5f614ba
|
@ -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 @@ public function testNestMethodSetsViewInstanceInData()
|
|||
$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 @@ public function testDataIsPassedToViewCorrectly()
|
|||
$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);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1 @@
|
|||
Taylor
|
Loading…
Reference in New Issue