Skip to content

Commit

Permalink
parser->query() now returns the complete query
Browse files Browse the repository at this point in the history
  • Loading branch information
AndyWendt committed Aug 20, 2015
1 parent 6241160 commit dd770bd
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 7 deletions.
14 changes: 11 additions & 3 deletions spec/Request/ParserSpec.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,17 +52,25 @@ function it_checks_if_an_item_is_in_the_includes(Request $request, ParameterBag
$this->inIncludes($entity)->shouldReturn(true);
}

function it_gets_an_item_from_the_query(Request $request, ParameterBag $parameterBag)
function it_gets_an_item_from_the_query(Request $request)
{
$item = 'foo';
$return = 'bar';

$request->query = $parameterBag;
$parameterBag->get($item)->shouldBeCalled(1)->willReturn($return);
$request->query($item)->shouldBeCalled()->willReturn($return);

$this->query($item)->shouldReturn($return);
}

function it_returns_the_query_as_an_array(Request $request)
{
$item = null;
$return = ['foo' => 'bar', 'baz' => 'boo'];
$request->query($item)->shouldBeCalled()->willReturn($return);

$this->query()->shouldReturn($return);
}

function it_gets_an_item_from_the_header(Request $request, HeaderBag $headerBag)
{
$item = 'foo';
Expand Down
4 changes: 2 additions & 2 deletions src/Contracts/Request/Parser.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,13 @@ public function inIncludes($entity);
public function includes();

/**
* Get an item from the query
* Get an item from the query string or return the query as an array
*
* @param string $item
*
* @return string
*/
public function query($item);
public function query($item = null);

/**
* The request's content type
Expand Down
4 changes: 2 additions & 2 deletions src/Request/Parser.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,9 @@ public function includes()
/**
* @inheritdoc
*/
public function query($item)
public function query($item = null)
{
return $this->request->query->get($item);
return $this->request->query($item);
}

/**
Expand Down

0 comments on commit dd770bd

Please sign in to comment.