Skip to content

Commit

Permalink
parse console command arguments w/o filename into super global (#17)
Browse files Browse the repository at this point in the history
  • Loading branch information
nimmneun authored Mar 8, 2018
1 parent 03502e1 commit 92db465
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/Nono/Request.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@ class Request
public function __construct()
{
$_SERVER;
if (!in_array($this->method(), ['GET', 'POST'])) {
if (PHP_SAPI == 'cli') {
parse_str(implode('&', array_slice($this->server('argv'), 1)), $GLOBALS['_QUERY']);
} elseif (!in_array($this->method(), ['GET', 'POST'])) {
parse_str($this->content(), $GLOBALS['_QUERY']);
}
}
Expand Down
6 changes: 6 additions & 0 deletions tests/RequestTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,12 @@ public function testMethod()
self::assertEquals('GET', $this->request->method());
}

public function testContentProducesNoError()
{
self::assertNotFalse($this->request->content());
self::assertNull(error_get_last());
}

public function testRequestTimeFloat()
{
self::assertTrue(is_numeric($this->request->requestTimeFloat()));
Expand Down

0 comments on commit 92db465

Please sign in to comment.