Merging r695 from the 2.1.x branch to the trunk
[isso.git] / UnitTest / LoaderTest.php
1 <?php
2
3 // load piggy
4 require_once('./../Loader.php');
5
6 /**
7 * Loader Test Suite
8 *
9 * @author Blue Static
10 * @copyright Copyright ©2002 - [#]year[#], Blue Static
11 * @version $Revision$
12 * @package ISSO Tests
13 *
14 */
15 class LoaderTest extends UnitTestCase
16 {
17 protected $instance;
18
19 public function testNewRegister()
20 {
21 $this->instance = BSLoader::NewRegister();
22
23 $this->assertEqual(get_class($this->instance), 'BSRegister');
24 }
25
26 public function testGetAllRegisters()
27 {
28 $this->assertIsA(BSLoader::GetAllRegisters(), 'array', 'Register array is not an array');
29 $this->assertEqual(sizeof(BSLoader::GetAllRegisters()), 1, 'Register array is wrong size');
30 }
31
32 public function testSetGetRegister()
33 {
34 BSLoader::SetRegister($this->instance);
35
36 $this->assertReference(BSLoader::GetRegister(), $this->instance);
37 }
38
39 public function testRegisterAfterMakeNew()
40 {
41 BSLoader::NewRegister();
42
43 $this->assertEqual(get_class(BSLoader::GetRegister(1)), 'BSRegister', 'Failed to get arbitrary register');
44 $this->assertEqual(sizeof(BSLoader::GetAllRegisters()), 2, 'Sizeof register array is wrong');
45 $this->assertReference($this->instance, BSLoader::GetRegister(), 'Main register does not match instance');
46 }
47
48 public function testLoadModule()
49 {
50 $this->assertEqual(get_class(BSLoader::LoadModule('Input')), 'BSInput');
51 }
52
53 public function testLoadBadModule()
54 {
55 BSLoader::LoadModule('nonExistentModule');
56 $this->assertError();
57 }
58 }
59
60 ?>