コード例 #1
0
ファイル: RequestTest.php プロジェクト: nicksagona/PopPHP
 public function testRequest()
 {
     $r = new Request();
     $r->setRequestUri('/test', '/admin');
     $this->assertEquals('/admin', $r->getBasePath());
     $this->assertEquals('/test', $r->getRequestUri());
     $this->assertEquals('/admin/test', $r->getFullUri());
     $this->assertFalse($r->isFile());
     $this->assertFalse($r->isSecure());
     $this->assertEquals('', $r->getDocRoot());
     $this->assertEquals('/admin', $r->getFullPath());
     $this->assertNull($r->getFilename());
     $this->assertEquals('http', $r->getScheme());
     $this->assertTrue(is_array($r->getQuery()));
     $this->assertNull($r->getQuery('test'));
     $this->assertTrue(is_array($r->getPost()));
     $this->assertNull($r->getPost('test'));
     $this->assertTrue(is_array($r->getPut()));
     $this->assertNull($r->getPut('test'));
     $this->assertTrue(is_array($r->getPatch()));
     $this->assertNull($r->getPatch('test'));
     $this->assertTrue(is_array($r->getDelete()));
     $this->assertNull($r->getDelete('test'));
     $this->assertTrue(is_array($r->getCookie()));
     $this->assertNull($r->getCookie('test'));
     $this->assertTrue(is_array($r->getServer()));
     $this->assertNull($r->getServer('test'));
     $this->assertTrue(is_array($r->getEnv()));
     $this->assertNull($r->getEnv('test'));
 }
コード例 #2
0
ファイル: http.php プロジェクト: nicksagona/PopPHP
<?php

require_once '../../bootstrap.php';
use Pop\Http\Request;
try {
    $request = new Request();
    switch ($request->getMethod()) {
        case 'GET':
            print_r($request->getQuery());
            break;
        case 'POST':
            print_r($request->getPost());
            break;
        case 'PUT':
            print_r($request->getPut());
            break;
        case 'PATCH':
            print_r($request->getPatch());
            break;
        case 'DELETE':
            print_r($request->getDelete());
            break;
    }
} catch (\Exception $e) {
    echo $e->getMessage();
}