3 require_once 'PHPUnit/Framework.php';
10 * @copyright Copyright ©2002 - [#]year[#], Blue Static
15 class RegisterTest
extends PHPUnit_Framework_TestCase
17 public function setUp()
19 require_once 'ISSO/Register.php';
22 public function testLoadModule()
24 $this->assertTrue(BSRegister
::LoadModule('Input') instanceof BSInput
);
27 public function testLoadBadModule()
29 BSRegister
::LoadModule('nonExistentModule');
30 // TODO - use exceptions
31 // $this->assertError();
34 public function testSetGetAppPath()
36 BSRegister
::SetAppPath(getcwd());
37 $this->assertEquals(getcwd() . DIRECTORY_SEPARATOR
, BSRegister
::GetAppPath());
40 public function testSetGetAppVersion()
42 BSRegister
::SetAppVersion('1.0-test');
43 $this->assertEquals('1.0-test', BSRegister
::GetAppVersion());
46 public function testSetGetApplication()
48 BSRegister
::SetApplication('ISSO Tests');
49 $this->assertEquals('ISSO Tests', BSRegister
::GetApplication());
52 public function testSetGetWebPath()
54 $path = DIRECTORY_SEPARATOR
. 'Server' . DIRECTORY_SEPARATOR
. 'htdocs' . DIRECTORY_SEPARATOR
. 'ISSO';
55 BSRegister
::SetWebPath($path);
56 $this->assertEquals($path . DIRECTORY_SEPARATOR
, BSRegister
::GetWebPath());
59 public function testSetGetDebug()
61 BSRegister
::SetDebug(true
);
62 $this->assertSame(true
, BSRegister
::GetDebug());
65 public function testDebugList()
67 $this->assertEquals('<select><option>Debug Notices (0)</option></select>', BSRegister
::GetDebugList());
69 BSRegister
::Debug('dbg');
70 $this->assertEquals('<select><option>Debug Notices (1)</option><option>--- dbg</option></select>', BSRegister
::GetDebugList());
73 public function testRegisterValue()
75 BSRegister
::Register('someKey', 'someValue');
77 $registry = BSRegister
::GetAll();
78 $this->assertEquals($registry['someKey'], 'someValue');
81 public function testGetAll()
83 BSRegister
::Register('test', 1);
84 $this->assertType('array', BSRegister
::GetAll());
85 $this->assertEquals(sizeof(BSRegister
::GetAll()), 2);
88 public function testOverWriteRegister()
90 BSRegister
::Register('valueToOverWrite', 1);
91 BSRegister
::Register('valueToOverWrite', 2);
92 // TODO - use exceptions
93 // $this->assertError();
94 $this->assertEquals(1, BSRegister
::Get('valueToOverWrite'));
97 public function testGet()
99 BSRegister
::Register('testGet', 123);
100 $this->assertEquals(123, BSRegister
::Get('testGet'));
103 public function testUnregister()
105 BSRegister
::Register('testUnregister', 1);
106 BSRegister
::Unregister('testUnregister');
107 BSRegister
::Register('testUnregister', 2);
108 // TODO - use exceptions
109 // $this->assertNoErrors();
110 $this->assertEquals(2, BSRegister
::Get('testUnregister'));
113 /* TODO - use exceptions
114 public function testGetNoExist()
116 BSRegister::Get('doesNotExist');
117 $this->assertError();
120 public function testUnregisterNoExist()
122 BSRegister::Unregister('keyThatWontExist');
123 $this->assertError();
127 public function testGetType()
129 $input = BSRegister
::LoadModule('Input');
130 BSRegister
::Register('input', $input);
131 $this->assertSame($input, BSRegister
::GetType('Input'));
133 $this->assertEquals(null
, BSRegister
::GetType('Date'));
136 /* TODO - use exceptions
137 public function testRequiredModules()
139 BSRegister::RequiredModules(array('Input'));
140 $this->assertNoErrors();
142 BSRegister::RequiredModules(array('Input', 'Db'));
143 $this->assertError();
145 BSRegister::RequiredModules(array('Date'));
146 $this->assertError();