RequestTest.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 
00051 class RequestTest extends PHPUnit_Framework_TestCase {
00058         public function testMissingRequestElement () {
00059                 // Get a request instance
00060                 $requestInstance = HttpRequest::createHttpRequest();
00061 
00062                 // Get the element
00063                 $nonExist = $requestInstance->getRequestElement('never_there');
00064 
00065                 // Is this null?
00066                 if (!is_null($nonExist)) {
00067                         // Is not null!
00068                         $this->fail(sprintf("[%s:] Unexpected type %s received from request handler.",
00069                                 $requestInstance->__toString(),
00070                                 gettype($nonExists)
00071                         ));
00072                 }
00073         }
00074 
00080         public function testFakeRequestElement () {
00081                 // Fake the request here
00082                 $_REQUEST = array('test_key' => "test_value");
00083 
00084                 // Again get an instance
00085                 $requestInstance = HttpRequest::createHttpRequest();
00086 
00087                 // Get the element
00088                 $testValue = $requestInstance->getRequestElement('test_key');
00089 
00090                 // Is it the same?
00091                 if ($testValue !== "test_value") {
00092                         // Something went wrong
00093                         $this->fail(sprintf("[%s] Unexpected value %s (%s) from test key received.",
00094                                 $requestInstance->__toString(),
00095                                 $testValue,
00096                                 gettype($testValue)
00097                         ));
00098                 }
00099         }
00100 }
00101 
00102 ?>

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