RegistryTest.php

Go to the documentation of this file.
00001 <?php
00002 print (basename(__FILE__).": Init...\n");
00003 
00004 // Change directory
00005 @chdir("..");
00006 
00007 // Load config file
00008 require(dirname(dirname(__FILE__)) . '/inc/config.php');
00009 
00010 // Load all include files
00011 require($cfg->readConfig('base_path') . 'inc/includes.php');
00012 
00013 // Load all game classes
00014 require($cfg->readConfig('base_path') . 'inc/classes.php');
00015 
00016 // Set default application
00017 FrameworkConfiguration::getInstance()->setConfigEntry('default_application', 'ship-simu');
00018 
00019 // Set testing mode (no starter.php will be loaded!)
00020 define('TEST_MODE', true);
00021 
00022 // Load the PHPUnit framework
00023 require_once('PHPUnit/Framework.php');
00024 
00025 print (basename(__FILE__).": Init completed.\n\n");
00026 
00050 class RegistryTest extends PHPUnit_Framework_TestCase {
00056         public function testInstanceRegistryAdd () {
00057                 // Get a registry instance
00058                 $registryInstance = Registry::getRegistry();
00059 
00060                 // Create a User instance
00061                 $userInstance = Member::createMemberByEmail("webmaster@ship-simu.org");
00062 
00063                 // Now store the instance in the registry
00064                 $registryInstance->addInstance('user', $userInstance);
00065 
00066                 // Test if the registry key is there
00067                 if (!$registryInstance->instanceExists('user')) {
00068                         $this->fail("Registry test failed: Cannot locate our user instance in registry!");
00069                 }
00070         }
00071 
00077         public function testInstanceRegistryCompare () {
00078                 // Get a registry instance
00079                 $registryInstance = Registry::getRegistry();
00080 
00081                 // And get it back
00082                 $userInstance = $registryInstance->getInstance('user');
00083 
00084                 // Compare both unique keys
00085                 $testPassed = ($userInstance instanceof ManageableAccount);
00086 
00087                 // Test passed?
00088                 if (!$testPassed) {
00089                         $this->fail("Registry test failed: Method getInstance() returned a non-object.");
00090                 }
00091         }
00092 }
00093 
00094 ?>

Generated on Mon Dec 8 01:06:46 2008 for Ship-Simulator by  doxygen 1.5.6