Skip to content

Commit

Permalink
stubbles\input\broker\RequestBroker::procure() now returns the procur…
Browse files Browse the repository at this point in the history
…ed object
  • Loading branch information
mikey179 committed Jun 22, 2015
1 parent 3528be3 commit 21fd5ca
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
5.2.1 (2015-06-22)
------------------

* `stubbles\input\broker\RequestBroker::procure()` now returns the procured object


5.2.0 (2015-06-22)
------------------

Expand Down
3 changes: 3 additions & 0 deletions src/main/php/broker/RequestBroker.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ public function __construct(array $paramBrokers = [])
* @param \stubbles\input\Request $request
* @param object $object the object instance to fill with values
* @param string $group restrict procurement to given group
* @return object
* @throws \InvalidArgumentException
*/
public function procure(Request $request, $object, $group = null)
Expand All @@ -103,6 +104,8 @@ public function procure(Request $request, $object, $group = null)
->procure($request, $targetMethod->annotation())
);
}

return $object;
}

/**
Expand Down
6 changes: 2 additions & 4 deletions src/test/php/broker/RequestBrokerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,10 @@ public function procureNonObjectThrowsInvalidArgumentException()
*/
public function procuresOnlyThoseInGivenGroup()
{
$object = new BrokerClass();
$this->request->mapCalls(
['readParam' => ValueReader::forValue('just some string value')]
);
$this->requestBroker->procure($this->request, $object, 'main');
$object = $this->requestBroker->procure($this->request, new BrokerClass(), 'main');
assertFalse($object->isVerbose());
assertEquals('just some string value', $object->getBar());
assertNull($object->getBaz());
Expand All @@ -94,9 +93,8 @@ public function procuresAllIfNoGroupGiven()
)
]
);
$object = new BrokerClass();
$requestBroker = new RequestBroker(['Mock' => $paramBroker]);
$requestBroker->procure($this->request, $object);
$object = $requestBroker->procure($this->request, new BrokerClass());
assertTrue($object->isVerbose());
assertEquals('just some string value', $object->getBar());
assertEquals('just another string value', $object->getBaz());
Expand Down

0 comments on commit 21fd5ca

Please sign in to comment.