Example #1
0
 public function testRequestParsingFromGlobals()
 {
     /*//
     	testing all the primary features of the router in a method similiar to a
     	web request from apache.
     	//*/
     $_SERVER['HTTP_HOST'] = static::$RequestData['TestQuery']['Domain'];
     $_SERVER['REQUEST_URI'] = static::$RequestData['TestQuery']['Path'];
     $_GET['omg'] = 'true';
     $_GET['bbq'] = 'yum';
     $router = new Nether\Avenue\Router();
     (new Verify('check GetFullDomain() returns full original HTTP_HOST', $router->GetFullDomain()))->equals('www.nether.io');
     (new Verify('check GetDomain() returns relevent domain.tld only from HTTP_HOST', $router->GetDomain()))->equals('nether.io');
     (new Verify('check GetPath() returns REQUEST_URI string without query.', $router->GetPath()))->equals('/test');
     (new Verify('check that GetPathArray() returns the path array that contains one element.', is_array($router->GetPathArray()) && count($router->GetPathArray()) === 1))->true();
     (new Verify('check that GetPathArray() had good data.', $router->GetPathArray()[0]))->equals('test');
     (new Verify('check that GetPathSlot() returns proper path chunk.', $router->GetPathSlot(1)))->equals('test');
     (new Verify('check that GetQuery() returns the input data array that contains two element.', is_array($router->GetQuery()) && count($router->GetQuery()) === 2))->true();
     (new Verify('check that GetQueryVar() returns an existing var.', $router->GetQueryVar('omg')))->equals('true');
     (new Verify('check that GetQueryVar() returns an null for nonexisting var.', $router->GetQueryVar('nope')))->null();
     unset($_SERVER['HTTP_HOST'], $_SERVER['REQUEST_URI'], $_GET['omg'], $_GET['bbq']);
     return;
 }