Removing all the package replacement tags and SVN keyword tags
[isso.git] / UnitTest / AppTest.php
1 <?php
2
3 require_once 'PHPUnit/Framework.php';
4
5
6 /**
7 * Application Test Suite
8 *
9 * @author Blue Static
10 * @copyright Copyright ©2002 - 2007, Blue Static
11 * @package ISSO Tests
12 *
13 */
14 class AppTest extends PHPUnit_Framework_TestCase
15 {
16 public function setUp()
17 {
18 require_once 'ISSO/App.php';
19 }
20
21 public function testLoadModule()
22 {
23 $this->assertTrue(BSApp::LoadModule('Input') instanceof BSInput);
24 }
25
26 public function testLoadBadModule()
27 {
28 try
29 {
30 BSApp::LoadModule('nonExistentModule');
31 $this->fail('exception expected');
32 }
33 catch (Exception $e)
34 {}
35 }
36
37 public function testSetGetAppPath()
38 {
39 BSApp::SetAppPath(getcwd());
40 $this->assertEquals(getcwd() . DIRECTORY_SEPARATOR, BSApp::GetAppPath());
41 }
42
43 public function testSetGetAppVersion()
44 {
45 BSApp::SetAppVersion('1.0-test');
46 $this->assertEquals('1.0-test', BSApp::GetAppVersion());
47 }
48
49 public function testSetGetApplication()
50 {
51 BSApp::SetApplication('ISSO Tests');
52 $this->assertEquals('ISSO Tests', BSApp::GetApplication());
53 }
54
55 public function testSetGetWebPath()
56 {
57 $path = DIRECTORY_SEPARATOR . 'Server' . DIRECTORY_SEPARATOR . 'htdocs' . DIRECTORY_SEPARATOR . 'ISSO';
58 BSApp::SetWebPath($path);
59 $this->assertEquals($path . DIRECTORY_SEPARATOR, BSApp::GetWebPath());
60 }
61
62 public function testSetGetDebug()
63 {
64 BSApp::SetDebug(true);
65 $this->assertSame(true, BSApp::GetDebug());
66 }
67
68 public function testDebugList()
69 {
70 $this->assertEquals('<select><option>Debug Notices (0)</option></select>', BSApp::GetDebugList());
71
72 BSApp::Debug('dbg');
73 $this->assertEquals('<select><option>Debug Notices (1)</option><option>--- dbg</option></select>', BSApp::GetDebugList());
74 }
75
76 public function testRegisterValue()
77 {
78 BSApp::Registry()->someKey = 'someValue';
79
80 $registry = BSApp::Registry();
81 $this->assertEquals($registry->someKey, 'someValue');
82 }
83
84 public function testGetAll()
85 {
86 BSApp::Registry()->test = 1;
87 $this->assertType('array', BSApp::Registry()->allObjects());
88 $this->assertSame(sizeof(BSApp::Registry()->allObjects()), 2);
89 }
90
91 public function testOverWriteRegister()
92 {
93 BSApp::Registry()->valueToOverWrite = 1;
94 BSApp::Registry()->valueToOverWrite = 2;
95 $this->assertEquals(2, BSApp::Registry()->valueToOverWrite);
96 }
97
98 public function testGet()
99 {
100 BSApp::Registry()->testGet = 123;
101 $this->assertEquals(123, BSApp::Registry()->testGet);
102 }
103
104 public function testUnregister()
105 {
106 BSApp::Registry()->testUnregister = 1;
107 unset(BSApp::Registry()->testUnregister);
108 $this->assertObjectNotHasAttribute('testUnregister', BSApp::Registry());
109 }
110
111 public function testGetNoExist()
112 {
113 try
114 {
115 BSApp::Registry()->doesNotExist;
116 $this->fail('exception expected');
117 }
118 catch (Exception $e)
119 {}
120 }
121
122 public function testUnregisterNoExist()
123 {
124 try
125 {
126 unset(BSApp::Registry()->keyThatWontExist);
127 $this->fail('exception expected');
128 }
129 catch (Exception $e)
130 {}
131 }
132
133 public function testGetType()
134 {
135 $input = BSApp::LoadModule('Input');
136 BSApp::Registry()->input = $input;
137 $this->assertSame($input, BSApp::Registry()->getType('Input'));
138
139 $this->assertEquals(null, BSApp::Registry()->getType('Date'));
140 }
141
142 public function testRequiredModules()
143 {
144 try
145 {
146 BSApp::RequiredModules(array('Input'));
147 }
148 catch (Exception $e)
149 {
150 $this->fail('unexpcted exception');
151 }
152
153 try
154 {
155 BSApp::RequiredModules(array('Input', 'Db'));
156 $this->fail('exception expected');
157 }
158 catch (Exception $e)
159 {}
160
161 try
162 {
163 BSApp::RequiredModules(array('Date'));
164 $this->fail('exception expected');
165 }
166 catch (Exception $e)
167 {}
168 }
169 }
170
171 ?>