summaryrefslogtreecommitdiffstats
path: root/tests/codeigniter/core/Loader_test.php
blob: c7085c43925e2cac64a6dc13078fd1a1da901717 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
<?php

class Loader_test extends CI_TestCase {
	
	private $ci_obj;
	
	public function setUp()
	{
		// Instantiate a new loader
		$cls = $this->ci_core_class('load');
		$this->_loader = new $cls;
		
		// mock up a ci instance
		$this->ci_obj = new StdClass;
		
		// Fix get_instance()
		$this->ci_instance($this->ci_obj);
	}

	// --------------------------------------------------------------------
	
	public function testLibrary()
	{
		// Mock up a config object until we
		// figure out how to test the library configs
		$config = $this->getMock('CI_Config', NULL, array(), '', FALSE);
		$config->expects($this->any())
			   ->method('load')
			   ->will($this->returnValue(TRUE));
		
		// Add the mock to our stdClass
		$this->ci_instance_var('config', $config);
		
		// Test loading as an array.
		$this->assertEquals(NULL, $this->_loader->library(array('table')));
		$this->assertTrue(class_exists('CI_Table'), 'Table class exists');
		$this->assertAttributeInstanceOf('CI_Table', 'table', $this->ci_obj);
		
		// Test no lib given
		$this->assertEquals(FALSE, $this->_loader->library());
		
		// Test a string given to params
		$this->assertEquals(NULL, $this->_loader->library('table', ' '));
	}	
	
	// --------------------------------------------------------------------
	
	public function testModels()
	{
		// Test loading as an array.
		$this->assertEquals(NULL, $this->_loader->model(array('foobar')));
		
		// Test no model given
		$this->assertEquals(FALSE, $this->_loader->model(''));
		
		// Test a string given to params
		$this->assertEquals(NULL, $this->_loader->model('foobar', ' '));		
	}

	// --------------------------------------------------------------------
	
	public function testDatabase()
	{
		$this->assertEquals(NULL, $this->_loader->database());
		$this->assertEquals(NULL, $this->_loader->dbutil());		
	}

	// --------------------------------------------------------------------
	
	public function testView()
	{
		// I'm not entirely sure this is the proper way to handle this.
		// So, let's revist it, m'kay?
		try 
		{
			 $this->_loader->view('foo');
		}
		catch (Exception $expected)
		{
			return;
		}
	}

	// --------------------------------------------------------------------

	public function testFile()
	{
		// I'm not entirely sure this is the proper way to handle this.
		// So, let's revist it, m'kay?
		try 
		{
			 $this->_loader->file('foo');
		}
		catch (Exception $expected)
		{
			return;
		}		
	}

	// --------------------------------------------------------------------
	
	public function testVars()
	{
		$vars = array(
			'foo'	=> 'bar'
		);
		
		$this->assertEquals(NULL, $this->_loader->vars($vars));
		$this->assertEquals(NULL, $this->_loader->vars('foo', 'bar'));
	}

	// --------------------------------------------------------------------
	
	public function testHelper()
	{
		$this->assertEquals(NULL, $this->_loader->helper('array'));
		$this->assertEquals(NULL, $this->_loader->helper('bad'));
	}
	
	// --------------------------------------------------------------------

	public function testHelpers()
	{
		$this->assertEquals(NULL, $this->_loader->helpers(array('file', 'array', 'string')));
	}
	
	// --------------------------------------------------------------------
	
	// public function testLanguage()
	// {
	// 	$this->assertEquals(NULL, $this->_loader->language('test'));
	// }	

	// --------------------------------------------------------------------

	public function testLoadConfig()
	{
		$this->assertEquals(NULL, $this->_loader->config('config', FALSE, TRUE));
	}
	
	
	
}