RequestTest.php
Go to the documentation of this file.00001 <?php
00002 print (basename(__FILE__).": Init...\n");
00003
00004
00005 @chdir("..");
00006
00007
00008 require(dirname(dirname(__FILE__)) . '/inc/config.php');
00009
00010
00011 require($cfg->readConfig('base_path') . 'inc/includes.php');
00012
00013
00014 require($cfg->readConfig('base_path') . 'inc/classes.php');
00015
00016
00017 FrameworkConfiguration::getInstance()->setConfigEntry('default_application', 'ship-simu');
00018
00019
00020 define('TEST_MODE', true);
00021
00022
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
00060 $requestInstance = HttpRequest::createHttpRequest();
00061
00062
00063 $nonExist = $requestInstance->getRequestElement('never_there');
00064
00065
00066 if (!is_null($nonExist)) {
00067
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
00082 $_REQUEST = array('test_key' => "test_value");
00083
00084
00085 $requestInstance = HttpRequest::createHttpRequest();
00086
00087
00088 $testValue = $requestInstance->getRequestElement('test_key');
00089
00090
00091 if ($testValue !== "test_value") {
00092
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 ?>