コード例 #1
0
ファイル: Enlighten.php プロジェクト: roydejong/Enlighten
 /**
  * Bootstraps the application state as necessary.
  */
 protected function beforeStart()
 {
     // If no explicit request was given (via Enlighten::setRequest), create one based on the current PHP globals
     if (empty($this->request)) {
         $this->setRequest(Request::extractFromEnvironment());
     }
     $this->bootstrapRouter();
 }
コード例 #2
0
ファイル: RequestTest.php プロジェクト: roydejong/Enlighten
 /**
  * @depends testSetGetRequestUri
  * @depends testRequestMethodPatch
  * @runInSeparateProcess
  */
 public function testExtractFromEnvironment()
 {
     $_GET = ['test' => 'abc'];
     $_POST = ['abc' => 'test'];
     $_SERVER = ['REQUEST_URI' => '/pots?test=abc', 'REQUEST_METHOD' => RequestMethod::PATCH];
     $_COOKIE = ['Session' => uniqid()];
     $_FILES = ['badKey' => ['name' => 'missingSomeData'], 'goodKey' => ['name' => 'bookmarks.html', 'type' => 'text/html', 'tmp_name' => '/tmp/php3D.tmp', 'error' => UPLOAD_ERR_OK, 'size' => 644563]];
     $request = Request::extractFromEnvironment();
     $this->assertTrue($request->isPatch());
     $this->assertEquals('/pots', $request->getRequestUri());
     $this->assertEquals('test', $request->getPost('abc', 'POST_DEF'));
     $this->assertEquals('abc', $request->getQueryParam('test', 'QUERY_DEF'));
     $this->assertEquals('PATCH', $request->getEnvironment('REQUEST_METHOD'));
     $this->assertEquals($_COOKIE['Session'], $request->getCookie('Session'));
     $this->assertCount(1, $request->getFileUploads());
     $files = $request->getFileUploads();
     $file = array_shift($files);
     $this->assertEquals('text/html', $file->getType());
 }