Skip to content

Commit

Permalink
Tweak macro test
Browse files Browse the repository at this point in the history
  • Loading branch information
adamwathan committed Jul 20, 2017
1 parent 8cd7188 commit fb8f379
Showing 1 changed file with 6 additions and 11 deletions.
17 changes: 6 additions & 11 deletions tests/ZttpTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -411,27 +411,22 @@ function multiple_callbacks_can_be_run_before_sending_the_request()
$this->assertEquals(json_encode(['foo' => 'bar']), $state['body']);
}

/** @test */
/** @test */
function response_can_use_macros()
{
ZttpResponse::macro('testMacro', function () {
return $this->json();
return vsprintf('%s %s', [
$this->json()['json']['foo'],
$this->json()['json']['baz'],
]);
});

$response = Zttp::post($this->url('/post'), [
'foo' => 'bar',
'baz' => 'qux',
]);

$this->assertArraySubset([
'headers' => [
'content-type' => ['application/json'],
],
'json' => [
'foo' => 'bar',
'baz' => 'qux',
]
], $response->testMacro());
$this->assertEquals('bar qux', $response->testMacro());
}
}

Expand Down

0 comments on commit fb8f379

Please sign in to comment.