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()
31 BSRegister
::LoadModule('nonExistentModule');
32 $this->fail('exception expected');
38 public function testSetGetAppPath()
40 BSRegister
::SetAppPath(getcwd());
41 $this->assertEquals(getcwd() . DIRECTORY_SEPARATOR
, BSRegister
::GetAppPath());
44 public function testSetGetAppVersion()
46 BSRegister
::SetAppVersion('1.0-test');
47 $this->assertEquals('1.0-test', BSRegister
::GetAppVersion());
50 public function testSetGetApplication()
52 BSRegister
::SetApplication('ISSO Tests');
53 $this->assertEquals('ISSO Tests', BSRegister
::GetApplication());
56 public function testSetGetWebPath()
58 $path = DIRECTORY_SEPARATOR
. 'Server' . DIRECTORY_SEPARATOR
. 'htdocs' . DIRECTORY_SEPARATOR
. 'ISSO';
59 BSRegister
::SetWebPath($path);
60 $this->assertEquals($path . DIRECTORY_SEPARATOR
, BSRegister
::GetWebPath());
63 public function testSetGetDebug()
65 BSRegister
::SetDebug(true
);
66 $this->assertSame(true
, BSRegister
::GetDebug());
69 public function testDebugList()
71 $this->assertEquals('<select><option>Debug Notices (0)</option></select>', BSRegister
::GetDebugList());
73 BSRegister
::Debug('dbg');
74 $this->assertEquals('<select><option>Debug Notices (1)</option><option>--- dbg</option></select>', BSRegister
::GetDebugList());
77 public function testRegisterValue()
79 BSRegister
::Registry()->someKey
= 'someValue';
81 $registry = BSRegister
::Registry();
82 $this->assertEquals($registry->someKey
, 'someValue');
85 public function testGetAll()
87 BSRegister
::Registry()->test
= 1;
88 $this->assertType('array', BSRegister
::Registry()->allObjects());
89 $this->assertSame(sizeof(BSRegister
::Registry()->allObjects()), 2);
92 public function testOverWriteRegister()
94 BSRegister
::Registry()->valueToOverWrite
= 1;
95 BSRegister
::Registry()->valueToOverWrite
= 2;
96 $this->assertEquals(2, BSRegister
::Registry()->valueToOverWrite
);
99 public function testGet()
101 BSRegister
::Registry()->testGet
= 123;
102 $this->assertEquals(123, BSRegister
::Registry()->testGet
);
105 public function testUnregister()
107 BSRegister
::Registry()->testUnregister
= 1;
108 unset(BSRegister
::Registry()->testUnregister
);
109 $this->assertObjectNotHasAttribute('testUnregister', BSRegister
::Registry());
112 public function testGetNoExist()
116 BSRegister
::Registry()->doesNotExist
;
117 $this->fail('exception expected');
123 public function testUnregisterNoExist()
127 unset(BSRegister
::Registry()->keyThatWontExist
);
128 $this->fail('exception expected');
134 public function testGetType()
136 $input = BSRegister
::LoadModule('Input');
137 BSRegister
::Registry()->input
= $input;
138 $this->assertSame($input, BSRegister
::Registry()->getType('Input'));
140 $this->assertEquals(null
, BSRegister
::Registry()->getType('Date'));
143 public function testRequiredModules()
147 BSRegister
::RequiredModules(array('Input'));
151 $this->fail('unexpcted exception');
156 BSRegister
::RequiredModules(array('Input', 'Db'));
157 $this->fail('exception expected');
164 BSRegister
::RequiredModules(array('Date'));
165 $this->fail('exception expected');