a tiny mvc framework for php using php-activerecord
at master 45 lines 1.3 kB view raw
1<?php 2 3require(__DIR__ . "/../lib/halfmoon.php"); 4 5class RequestTest extends PHPUnit_Framework_TestCase { 6 public function testNormalRequest() { 7 $req = new \HalfMoon\Request( 8 "https://www.example.com/test/blah/?whatever=hello", 9 array("whatever" => "hello"), array(), array(), time()); 10 11 $this->assertEquals("https", $req->scheme); 12 $this->assertEquals("www.example.com", $req->host); 13 $this->assertEquals(443, $req->port); 14 $this->assertEquals("test/blah", $req->path); 15 $this->assertEquals("whatever=hello", $req->query); 16 } 17 18 public function testWeakRequest() { 19 $req = new \HalfMoon\Request( 20 "http://a", 21 array(), array(), array(), time()); 22 23 $this->assertEquals("http", $req->scheme); 24 $this->assertEquals("a", $req->host); 25 $this->assertEquals(80, $req->port); 26 $this->assertEquals("", $req->path); 27 $this->assertEquals("", $req->query); 28 } 29 30 public function testMaliciousRequest() { 31 $req = new \HalfMoon\Request( 32 "http://www.example.com/test/../notreally?test=hello", 33 array("test" => "hello"), array(), array(), time()); 34 35 $this->assertEquals("notreally", $req->path); 36 37 $req = new \HalfMoon\Request( 38 "http://www.example.com/test/////asdf//", 39 array("test" => "hello"), array(), array(), time()); 40 41 $this->assertEquals("test/asdf", $req->path); 42 } 43} 44 45?>