added view tests.

This commit is contained in:
Taylor Otwell 2011-07-13 23:53:14 -05:00
parent ca3c6623a2
commit f266a1c6ca
1 changed files with 43 additions and 0 deletions

43
tests/suite/ViewTest.php Normal file
View File

@ -0,0 +1,43 @@
<?php
class ViewTest extends PHPUnit_Framework_TestCase {
public function testConstructorSetsViewNameAndData()
{
$view = new System\View('view', array('name' => 'test'));
$this->assertEquals($view->view, 'view');
$this->assertEquals($view->data, array('name' => 'test'));
$view = new System\View('view');
$this->assertEquals($view->data, array());
}
public function testMakeMethodReturnsNewViewInstance()
{
$this->assertInstanceOf('System\\View', System\View::make('test'));
}
public function testBindMethodAddsItemToViewData()
{
$view = System\View::make('test')->bind('name', 'test');
$this->assertEquals($view->data, array('name' => 'test'));
}
public function testBoundViewDataCanBeRetrievedThroughMagicMethods()
{
$view = System\View::make('test')->bind('name', 'test');
$this->assertTrue(isset($view->name));
$this->assertEquals($view->name, 'test');
unset($view->name);
$this->assertFalse(isset($view->name));
}
public function testGetMethodReturnsStringContentOfView()
{
$this->assertTrue(is_string(System\View::make('home/index')->get()));
}
}