2 print (basename(__FILE__).": Init...\n");
8 require(dirname(dirname(__FILE__)) . '/inc/config.php');
10 // Load all include files
11 require(PATH . 'inc/includes.php');
13 // Load all game classes
14 require(PATH . 'inc/classes.php');
16 // Set default application
17 FrameworkConfiguration::getInstance()->setConfigEntry('default_application', 'ship-simu');
19 // Set testing mode (no starter.php will be loaded!)
20 define('TEST_MODE', true);
22 // Load the PHPUnit framework
23 require_once('PHPUnit/Framework.php');
25 print (basename(__FILE__).": Init completed.\n\n");
28 * A test case for the registry
30 * @author Roland Haeder <webmaster@mxchange.org>
32 * @copyright Copyright(c) 2007, 2008 Roland Haeder, this is free software
33 * @license GNU GPL 3.0 or any newer version
34 * @link http://www.ship-simu.org
35 * @see http://www.phpunit.de
37 * This program is free software: you can redistribute it and/or modify
38 * it under the terms of the GNU General Public License as published by
39 * the Free Software Foundation, either version 3 of the License, or
40 * (at your option) any later version.
42 * This program is distributed in the hope that it will be useful,
43 * but WITHOUT ANY WARRANTY; without even the implied warranty of
44 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
45 * GNU General Public License for more details.
47 * You should have received a copy of the GNU General Public License
48 * along with this program. If not, see <http://www.gnu.org/licenses/>.
50 class RegistryTest extends PHPUnit_Framework_TestCase {
52 * Tests if we can store an instance to the registry
56 public function testInstanceRegistryAdd () {
57 // Get a registry instance
58 $registryInstance = Registry::getRegistry();
60 // Create a User instance
61 $userInstance = User::createUserByEmail("webmaster@mxchange.org");
63 // Now store the instance in the registry
64 $registryInstance->addInstance('user', $userInstance);
66 // Test if the registry key is there
67 if (!$registryInstance->instanceExists('user')) {
68 $this->fail("Registry test failed: Cannot locate our user instance in registry!");
73 * Tests if we can store an instance to the registry
77 public function testInstanceRegistryCompare () {
78 // Get a registry instance
79 $registryInstance = Registry::getRegistry();
82 $userInstance = $registryInstance->getInstance('user');
84 // Compare both unique keys
85 $testPassed = ($userInstance instanceof ManageableUser);
89 $this->fail("Registry test failed: Method getInstance() returned a non-object.");