From afaa712decbd49567738aa85846ef36ad760754c Mon Sep 17 00:00:00 2001 From: Robert Sesek Date: Tue, 15 Aug 2006 23:25:34 +0000 Subject: [PATCH] Adding the test directory --- PHPUnit/AllTests.php | 23 ++++++++++++ PHPUnit/LoaderTest.php | 84 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 107 insertions(+) create mode 100644 PHPUnit/AllTests.php create mode 100644 PHPUnit/LoaderTest.php diff --git a/PHPUnit/AllTests.php b/PHPUnit/AllTests.php new file mode 100644 index 0000000..6516eef --- /dev/null +++ b/PHPUnit/AllTests.php @@ -0,0 +1,23 @@ +addListener(new ISI_PHPUnit2_Output_HTML_Listener); +$suite = new PHPUnit2_Framework_TestSuite; + +// load tests +$suite->addTestFile('LoaderTest.php'); + +// run all the tests +$suite->run($result); + +?> \ No newline at end of file diff --git a/PHPUnit/LoaderTest.php b/PHPUnit/LoaderTest.php new file mode 100644 index 0000000..a9bec7e --- /dev/null +++ b/PHPUnit/LoaderTest.php @@ -0,0 +1,84 @@ +instance = BSLoader::NewRegister(); + + $this->assertEquals(get_class($this->instance), 'BSRegister'); + } + + // ################################################################### + /** + * Checks that the return value of GetAllRegisters() is an array + * with the right size. + */ + public function testGetAllRegisters() + { + $this->assertType(BSLoader::GetAllRegisters(), 'array', 'Register array is not an array'); + $this->assertEquals(sizeof(BSLoader::GetAllRegisters()), 1, 'Register array is wrong size'); + } + + // ################################################################### + /** + * Checks that we can set and get the main instance. + */ + public function testSetGetRegister() + { + BSLoader::SetRegister($this->instance); + + $this->assertSame(BSLoader::GetRegister(), $this->instance); + } + + // ################################################################### + /** + * Makes sure that the main instance stays the same after we add a new + * one. + */ + public function testRegisterAfterMakeNew() + { + BSLoader::NewRegister(); + + $this->assertEquals(get_class(BSLoader::GetRegister(1), 'BSRegister'), 'Failed to get arbitrary register'); + $this->assertEquals(sizeof(BSLoader::GetAllRegisters()), 2, 'Sizeof register array is wrong'); + $this->assertSame($this->instance, BSLoader::GetRegister(), 'Main register does not match instance'); + } + + // ################################################################### + /** + * Tests that we can load a module. + */ + public function testLoadModule() + { + $this->assertEquals(get_class(BSLoader::LoadModule('Input')), 'BSInput'); + } +} + +?> \ No newline at end of file -- 2.43.5