Commits

Greg Aker  committed 4129c32

load->file() tests.

  • Participants
  • Parent commits df82dfe
  • Branches unit_tests

Comments (0)

Files changed (1)

File tests/codeigniter/core/Loader_test.php

 
 	// --------------------------------------------------------------------
 
-	
 	public function testNonExistentModel()
 	{
 		$this->setExpectedException(
 
 	public function testFile()
 	{
-		// I'm not entirely sure this is the proper way to handle this.
-		// $this->load->file('foo');
+		$content = 'Here is a test file, which we will load now.';
+		$file = vfsStream::newFile('ci_test_mock_file.php')->withContent($content)
+														   ->at($this->load->views_dir);
+		
+		// Just like load->view(), take the output class out of the mix here.
+		$load = $this->load->file(vfsStream::url('application').'/views/ci_test_mock_file.php', 
+								TRUE);
+		
+		$this->assertEquals($content, $load);
+		
+		$this->setExpectedException(
+			'Exception',
+			'CI Error: Unable to load the requested file: ci_test_file_not_exists'
+			);
+		
+		$this->load->file('ci_test_file_not_exists', TRUE);
 		
 	}
 
 			'CI Error: Unable to load the requested file: helpers/bad_helper.php'
 			);
 		
-		
 		$this->load->helper('bad');
 	}