3 require_once 'PHPUnit/Framework.php';
7 * Application Test Suite
10 * @copyright Copyright (c)2002 - 2007, Blue Static
14 class AppTest
extends PHPUnit_Framework_TestCase
16 public function setUp()
18 require_once ISSO
. '/App.php';
21 public function testLoadModule()
23 $this->assertTrue(BSApp
::LoadModule('Input') instanceof BSInput
);
26 public function testLoadBadModule()
30 BSApp
::LoadModule('nonExistentModule');
31 $this->fail('exception expected');
37 public function testSetGetAppPath()
39 BSApp
::SetAppPath(getcwd());
40 $this->assertEquals(getcwd() . DIRECTORY_SEPARATOR
, BSApp
::GetAppPath());
43 public function testSetGetAppVersion()
45 BSApp
::SetAppVersion('1.0-test');
46 $this->assertEquals('1.0-test', BSApp
::GetAppVersion());
49 public function testSetGetApplication()
51 BSApp
::SetApplication('ISSO Tests');
52 $this->assertEquals('ISSO Tests', BSApp
::GetApplication());
55 public function testSetGetWebPath()
57 $path = DIRECTORY_SEPARATOR
. 'Server' . DIRECTORY_SEPARATOR
. 'htdocs' . DIRECTORY_SEPARATOR
. 'ISSO';
58 BSApp
::SetWebPath($path);
59 $this->assertEquals($path . DIRECTORY_SEPARATOR
, BSApp
::GetWebPath());
62 public function testSetGetDebug()
64 BSApp
::SetDebug(true);
65 $this->assertSame(true, BSApp
::GetDebug());
68 public function testDebugList()
70 $this->assertEquals('<select><option>Debug Notices (0)</option></select>', BSApp
::GetDebugList());
73 $this->assertEquals('<select><option>Debug Notices (1)</option><option>--- dbg</option></select>', BSApp
::GetDebugList());
76 public function testRegisterValue()
78 BSApp
::Registry()->someKey
= 'someValue';
80 $registry = BSApp
::Registry();
81 $this->assertEquals($registry->someKey
, 'someValue');
84 public function testGetAll()
86 BSApp
::Registry()->test
= 1;
87 $this->assertType('array', BSApp
::Registry()->allObjects());
88 $this->assertSame(sizeof(BSApp
::Registry()->allObjects()), 3);
91 public function testOverWriteRegister()
93 BSApp
::Registry()->valueToOverWrite
= 1;
94 BSApp
::Registry()->valueToOverWrite
= 2;
95 $this->assertEquals(2, BSApp
::Registry()->valueToOverWrite
);
98 public function testGet()
100 BSApp
::Registry()->testGet
= 123;
101 $this->assertEquals(123, BSApp
::Registry()->testGet
);
104 public function testUnregister()
106 BSApp
::Registry()->testUnregister
= 1;
107 unset(BSApp
::Registry()->testUnregister
);
108 $this->assertObjectNotHasAttribute('testUnregister', BSApp
::Registry());
111 public function testGetNoExist()
115 BSApp
::Registry()->doesNotExist
;
116 $this->fail('exception expected');
122 public function testUnregisterNoExist()
126 unset(BSApp
::Registry()->keyThatWontExist
);
127 $this->fail('exception expected');
133 public function testGetType()
135 $input = BSApp
::LoadModule('Input');
136 BSApp
::Registry()->input
= $input;
137 $this->assertSame($input, BSApp
::Registry()->getType('Input'));
139 $this->assertEquals(null, BSApp
::Registry()->getType('Date'));
142 public function testRequiredModules()
146 BSApp
::RequiredModules(array('Input'));
150 $this->fail('unexpcted exception');
155 BSApp
::RequiredModules(array('Input', 'Db'));
156 $this->fail('exception expected');
163 BSApp
::RequiredModules(array('Date'));
164 $this->fail('exception expected');