Fixing a bug of var not exist
[isso.git] / PHPUnit / 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 /**
18 * The new, main instance.
19 * @var object
20 */
21 protected $instance;
22
23 // ###################################################################
24 /**
25 * Creates a new instance and makes sure it's the right class.
26 */
27 public function testNewRegister()
28 {
29 $this->instance = BSLoader::NewRegister();
30
31 $this->assertEqual(get_class($this->instance), 'BSRegister');
32 }
33
34 // ###################################################################
35 /**
36 * Checks that the return value of GetAllRegisters() is an array
37 * with the right size.
38 */
39 public function testGetAllRegisters()
40 {
41 $this->assertIsA(BSLoader::GetAllRegisters(), 'array', 'Register array is not an array');
42 $this->assertEqual(sizeof(BSLoader::GetAllRegisters()), 1, 'Register array is wrong size');
43 }
44
45 // ###################################################################
46 /**
47 * Checks that we can set and get the main instance.
48 */
49 public function testSetGetRegister()
50 {
51 BSLoader::SetRegister($this->instance);
52
53 $this->assertReference(BSLoader::GetRegister(), $this->instance);
54 }
55
56 // ###################################################################
57 /**
58 * Makes sure that the main instance stays the same after we add a new
59 * one.
60 */
61 public function testRegisterAfterMakeNew()
62 {
63 BSLoader::NewRegister();
64
65 $this->assertEqual(get_class(BSLoader::GetRegister(1)), 'BSRegister', 'Failed to get arbitrary register');
66 $this->assertEqual(sizeof(BSLoader::GetAllRegisters()), 2, 'Sizeof register array is wrong');
67 $this->assertReference($this->instance, BSLoader::GetRegister(), 'Main register does not match instance');
68 }
69
70 // ###################################################################
71 /**
72 * Tests that we can load a module.
73 */
74 public function testLoadModule()
75 {
76 $this->assertEqual(get_class(BSLoader::LoadModule('Input')), 'BSInput');
77 }
78 }
79
80 ?>