Adding the functions test with some incomplete tests
[isso.git] / UnitTest / RegisterTest.php
1 <?php
2
3 // piggy
4 require_once('./../Loader.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 = BSLoader::NewRegister();
22 }
23
24 public function testSetGetAppPath()
25 {
26 $this->fixture->setAppPath(getcwd());
27 $this->assertEqual(getcwd() . DIRECTORY_SEPARATOR, $this->fixture->getAppPath());
28 }
29
30 public function testSetGetAppVersion()
31 {
32 $this->fixture->setAppVersion('1.0-test');
33 $this->assertEqual('1.0-test', $this->fixture->getAppVersion());
34 }
35
36 public function testSetGetApplication()
37 {
38 $this->fixture->setApplication('ISSO Tests');
39 $this->assertEqual('ISSO Tests', $this->fixture->getApplication());
40 }
41
42 public function testSetGetWebPath()
43 {
44 $path = DIRECTORY_SEPARATOR . 'Server' . DIRECTORY_SEPARATOR . 'htdocs' . DIRECTORY_SEPARATOR . 'ISSO';
45 $this->fixture->setWebPath($path);
46 $this->assertEqual($path . DIRECTORY_SEPARATOR, $this->fixture->getWebPath());
47 }
48
49 public function testSetGetDebug()
50 {
51 $this->fixture->setDebug(true);
52 $this->assertIdentical(true, $this->fixture->getDebug());
53 }
54
55 public function testRegisterValue()
56 {
57 $this->fixture->register('someKey', 'someValue');
58
59 $registry = $this->fixture->getAll();
60 $this->assertEqual($registry['someKey'], 'someValue');
61 }
62
63 public function testGetAll()
64 {
65 $new = BSLoader::NewRegister();
66 $new->register('test', 1);
67 $this->assertIsA($new->getAll(), 'array');
68 $this->assertEqual(sizeof($new->getAll()), 1);
69 }
70
71 public function testOverWriteRegister()
72 {
73 $this->fixture->register('valueToOverWrite', 1);
74 $this->fixture->register('valueToOverWrite', 2);
75 $this->assertError();
76 $this->assertEqual(1, $this->fixture->get('valueToOverWrite'));
77 }
78
79 public function testGet()
80 {
81 $this->fixture->register('testGet', 123);
82 $this->assertEqual(123, $this->fixture->get('testGet'));
83 }
84
85 public function testUnregister()
86 {
87 $this->fixture->register('testUnregister', 1);
88 $this->fixture->unregister('testUnregister');
89 $this->fixture->register('testUnregister', 2);
90 $this->assertNoErrors();
91 $this->assertEqual(2, $this->fixture->get('testUnregister'));
92 }
93
94 public function testGetNoExist()
95 {
96 $this->fixture->get('doesNotExist');
97 $this->assertError();
98 }
99
100 public function testUnregisterNoExist()
101 {
102 $this->fixture->unregister('keyThatWontExist');
103 $this->assertError();
104 }
105 }
106
107 ?>