Adding Loader module
[isso.git] / PHPUnit / LoaderTest.php
1 <?php
2
3 // load test harness
4 require_once('PHPUnit2/Framework/IncompleteTestError.php');
5 require_once('PHPUnit2/Framework/TestCase.php');
6
7 // load piggy
8 require_once('./../Loader.php');
9
10 /**
11 * Loader Test Suite
12 *
13 * @author Blue Static
14 * @copyright Copyright ©2002 - [#]year[#], Blue Static
15 * @version $Revision$
16 * @package ISSO Tests
17 *
18 */
19 class LoaderTest extends PHPUnit2_Framework_TestCase
20 {
21 /**
22 * The new, main instance.
23 * @var object
24 */
25 protected $instance;
26
27 // ###################################################################
28 /**
29 * Creates a new instance and makes sure it's the right class.
30 */
31 public function testNewRegister()
32 {
33 $this->instance = BSLoader::NewRegister();
34
35 $this->assertEquals(get_class($this->instance), 'BSRegister');
36 }
37
38 // ###################################################################
39 /**
40 * Checks that the return value of GetAllRegisters() is an array
41 * with the right size.
42 */
43 public function testGetAllRegisters()
44 {
45 $this->assertType(BSLoader::GetAllRegisters(), 'array', 'Register array is not an array');
46 $this->assertEquals(sizeof(BSLoader::GetAllRegisters()), 1, 'Register array is wrong size');
47 }
48
49 // ###################################################################
50 /**
51 * Checks that we can set and get the main instance.
52 */
53 public function testSetGetRegister()
54 {
55 BSLoader::SetRegister($this->instance);
56
57 $this->assertSame(BSLoader::GetRegister(), $this->instance);
58 }
59
60 // ###################################################################
61 /**
62 * Makes sure that the main instance stays the same after we add a new
63 * one.
64 */
65 public function testRegisterAfterMakeNew()
66 {
67 BSLoader::NewRegister();
68
69 $this->assertEquals(get_class(BSLoader::GetRegister(1), 'BSRegister'), 'Failed to get arbitrary register');
70 $this->assertEquals(sizeof(BSLoader::GetAllRegisters()), 2, 'Sizeof register array is wrong');
71 $this->assertSame($this->instance, BSLoader::GetRegister(), 'Main register does not match instance');
72 }
73
74 // ###################################################################
75 /**
76 * Tests that we can load a module.
77 */
78 public function testLoadModule()
79 {
80 $this->assertEquals(get_class(BSLoader::LoadModule('Input')), 'BSInput');
81 }
82 }
83
84 ?>