Browse Source

added view tests.

Taylor Otwell 13 years ago
parent
commit
f266a1c6ca
1 changed files with 43 additions and 0 deletions
  1. 43 0
      tests/suite/ViewTest.php

+ 43 - 0
tests/suite/ViewTest.php

@@ -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()));
+	}
+
+}