Skip to content

Commit

Permalink
Added support for regular rpc calls with body.
Browse files Browse the repository at this point in the history
  • Loading branch information
noggan committed Apr 13, 2017
1 parent a0871ae commit c807cdd
Showing 1 changed file with 40 additions and 1 deletion.
41 changes: 40 additions & 1 deletion src/Context/ApiContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -565,7 +565,46 @@ public function iRemoveATypeWithIdFromRelationParentTypeWithId($type, $typeId, $
*/
public function iSendAActionWithMethod($action, $method)
{
$this->sendRpcAction('/' . $action, $method);
$this->iSendAActionWithMethodAndValues($action, $method, new TableNode([]));
}

/**
* @When I send a :action action with method :method and values:
*
* @param $action
* @param $method
* @param TableNode $values
*/
public function iSendAActionWithMethodAndValues($action, $method, TableNode $values)
{
$body = [];

foreach ($values->getRows() as list ($key, $values)) {
$body[$key] = $this->convertValueToAlias($values);
}

$this->sendRpcAction(sprintf('/%s', $action), $method, $body);
}

/**
* @When I send a :action action with method :method and body:
*
* @param $action
* @param $method
* @param PyStringNode $string
*/
public function iSendAActionWithMethodAndBody($action, $method, PyStringNode $string)
{
// Make sure the developer provided valid json
Assertions::assertJson($string->getRaw());

$data = json_decode($string, true);

foreach ($data as $key => $value) {
$body[$key] = $this->convertValueToAlias($value);
}

$this->sendRpcAction(sprintf('/%s', $action), $method, $body);
}

/**
Expand Down

0 comments on commit c807cdd

Please sign in to comment.