Add testUnregisterNoExist()
[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 $this->assertIsA($this->fixture->getAll(), 'array');
66 $this->assertEqual(sizeof($this->fixture->getAll()), 1);
67 }
68
69 public function testOverWriteRegister()
70 {
71 $this->fixture->register('valueToOverWrite', 1);
72 $this->fixture->register('valueToOverWrite', 2);
73 $this->assertError();
74 $this->assertEqual(1, $this->fixture->get('valueToOverWrite'));
75 }
76
77 public function testGet()
78 {
79 $this->fixture->register('testGet', 123);
80 $this->assertEqual(123, $this->fixture->get('testGet'));
81 }
82
83 public function testUnregister()
84 {
85 $this->fixture->register('testUnregister', 1);
86 $this->fixture->unregister('testUnregister');
87 $this->fixture->register('testUnregister', 2);
88 $this->assertNoErrors();
89 $this->assertEqual(2, $this->fixture->get('testUnregister'));
90 }
91
92 public function testGetNoExist()
93 {
94 $this->fixture->get('doesNotExist');
95 $this->assertError();
96 }
97
98 public function testUnregisterNoExist()
99 {
100 $this->fixture->unregister('keyThatWontExist');
101 $this->assertError();
102 }
103 }
104
105 ?>