Removing BSLoader and we'll just go with a singleton instance of BSRegister
[isso.git] / UnitTest / RegisterTest.php
1 <?php
2
3 // piggy
4 require_once('./../Register.php');
5
6 /**
7 * Register 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 RegisterTest extends UnitTestCase
16 {
17 protected $fixture;
18
19 public function setUp()
20 {
21 $this->fixture = BSRegister::Instance();
22 }
23
24 public function testNewRegister()
25 {
26 $this->assertTrue($this->fixture instanceof BSRegister);
27 $this->assertReference($this->fixture, BSRegister::Instance());
28 }
29
30 public function testLoadModule()
31 {
32 $this->assertTrue(BSRegister::LoadModule('Input') instanceof BSInput);
33 }
34
35 public function testLoadBadModule()
36 {
37 BSRegister::LoadModule('nonExistentModule');
38 $this->assertError();
39 }
40
41 public function testSetGetAppPath()
42 {
43 $this->fixture->setAppPath(getcwd());
44 $this->assertEqual(getcwd() . DIRECTORY_SEPARATOR, $this->fixture->getAppPath());
45 }
46
47 public function testSetGetAppVersion()
48 {
49 $this->fixture->setAppVersion('1.0-test');
50 $this->assertEqual('1.0-test', $this->fixture->getAppVersion());
51 }
52
53 public function testSetGetApplication()
54 {
55 $this->fixture->setApplication('ISSO Tests');
56 $this->assertEqual('ISSO Tests', $this->fixture->getApplication());
57 }
58
59 public function testSetGetWebPath()
60 {
61 $path = DIRECTORY_SEPARATOR . 'Server' . DIRECTORY_SEPARATOR . 'htdocs' . DIRECTORY_SEPARATOR . 'ISSO';
62 $this->fixture->setWebPath($path);
63 $this->assertEqual($path . DIRECTORY_SEPARATOR, $this->fixture->getWebPath());
64 }
65
66 public function testSetGetDebug()
67 {
68 $this->fixture->setDebug(true);
69 $this->assertIdentical(true, $this->fixture->getDebug());
70 }
71
72 public function testRegisterValue()
73 {
74 $this->fixture->register('someKey', 'someValue');
75
76 $registry = $this->fixture->getAll();
77 $this->assertEqual($registry['someKey'], 'someValue');
78 }
79
80 public function testGetAll()
81 {
82 $this->fixture->register('test', 1);
83 $this->assertIsA($this->fixture->getAll(), 'array');
84 $this->assertEqual(sizeof($this->fixture->getAll()), 2);
85 }
86
87 public function testOverWriteRegister()
88 {
89 $this->fixture->register('valueToOverWrite', 1);
90 $this->fixture->register('valueToOverWrite', 2);
91 $this->assertError();
92 $this->assertEqual(1, $this->fixture->get('valueToOverWrite'));
93 }
94
95 public function testGet()
96 {
97 $this->fixture->register('testGet', 123);
98 $this->assertEqual(123, $this->fixture->get('testGet'));
99 }
100
101 public function testUnregister()
102 {
103 $this->fixture->register('testUnregister', 1);
104 $this->fixture->unregister('testUnregister');
105 $this->fixture->register('testUnregister', 2);
106 $this->assertNoErrors();
107 $this->assertEqual(2, $this->fixture->get('testUnregister'));
108 }
109
110 public function testGetNoExist()
111 {
112 $this->fixture->get('doesNotExist');
113 $this->assertError();
114 }
115
116 public function testUnregisterNoExist()
117 {
118 $this->fixture->unregister('keyThatWontExist');
119 $this->assertError();
120 }
121 }
122
123 ?>