JSON encode
Closed this issue · 4 comments
Is there an easy way to get a JSON representation of all the data that comes back from the server? I'd like to store it in a database for reference and manipulation at a later date.
I feel like the raw post response could just be allowed for export or implementing something like this: http://php.net/manual/en/jsonserializable.jsonserialize.php
Implementing JsonSerializable
sounds good. I commented on your commit. If you could add a test too, that'd be great.
I have never used PHPUnit, nor do I currently have the time to play around with it. I feel that this should be the test case, but have no way of checking if it's valid:
$this->assertEquals(
$array,
$score->rawResponse,
'Raw Response contains the correct data'
);
$this->assertEquals(
json_encode($array),
json_encode($score),
'Score encodes to json properly'
);
@oschwald here is the updated version: a031c6f
Like I said I have never used PHPUnit, not do I have a way to make sure the tests pass. Based on quick look I believe these would be the proper test cases. If you want me to add them to my branch before creating a PR let me know. Otherwise I will just create a PR with the code changes and you can add the tests on your own.
I can add the following test cases:
$this->assertEquals(
$array,
$score->rawResponse,
'Raw Response contains the correct data'
);
$this->assertEquals(
json_encode($array),
json_encode($score),
'Score encodes to json properly'
);
P.S. Sorry about not being able to run the test cases.
P.S.S. If you can send me the proper command to run the test cases after installing via composer I can run the test cases myself, but in a quick attempt I kept getting 'Project dependencies missing'.
That seems reasonable. Could you make a pull request for it?
To run PHPUnit, first run composer update
from the checkout and then ./vendor/bin/phpunit
. Your test cases look reasonable to me.