2 print (basename(__FILE__).": Init...\n");
8 require(dirname(dirname(__FILE__)) . '/framework/config.php');
10 // Load all include files
11 require($cfg->getConfigEntry('base_path') . 'framework/includes.php');
13 // Load all game classes
14 require($cfg->getConfigEntry('base_path') . 'framework/classes.php');
16 // Set default application
17 FrameworkConfiguration::getInstance()->setConfigEntry('default_application', 'shipsimu');
19 // Set testing mode (no starter.php will be loaded!)
20 define('TEST_MODE', true);
22 // Load the PHPUnit framework
23 require('PHPUnit/Framework.php');
25 print (basename(__FILE__).": Init completed.\n\n");
28 * A test case for faked HTTP requests. This is faked because we *set*
29 * $_REQUEST here. This should be made better in PHP6... :(
31 * @author Roland Haeder <webmaster@shipsimu.org>
33 * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 Core Developer Team
34 * @license GNU GPL 3.0 or any newer version
35 * @link http://www.shipsimu.org
36 * @see http://www.phpunit.de
38 * This program is free software: you can redistribute it and/or modify
39 * it under the terms of the GNU General Public License as published by
40 * the Free Software Foundation, either version 3 of the License, or
41 * (at your option) any later version.
43 * This program is distributed in the hope that it will be useful,
44 * but WITHOUT ANY WARRANTY; without even the implied warranty of
45 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
46 * GNU General Public License for more details.
48 * You should have received a copy of the GNU General Public License
49 * along with this program. If not, see <http://www.gnu.org/licenses/>.
51 class RequestTest extends PHPUnit_Framework_TestCase {
53 * A non-exist request element is being asked for. null is the expected
54 * result from the class
58 public function testMissingRequestElement () {
59 // Get a request instance
60 $requestInstance = HtmlRequest::createHtmlRequest();
63 $nonExist = $requestInstance->getRequestElement('never_there');
66 if (!is_null($nonExist)) {
68 $this->fail(sprintf("[%s:] Unexpected type %s received from request handler.",
69 $requestInstance->__toString(),
76 * Now fake a request array and try the test on it again
80 public function testFakeRequestElement () {
81 // Fake the request here
82 $_REQUEST = array('test_key' => 'test_value');
84 // Again get an instance
85 $requestInstance = HtmlRequest::createHtmlRequest();
88 $testValue = $requestInstance->getRequestElement('test_key');
91 if ($testValue !== 'test_value') {
92 // Something went wrong
93 $this->fail(sprintf('[%s] Unexpected value %s (%s) from test key received.',
94 $requestInstance->__toString(),