-
Notifications
You must be signed in to change notification settings - Fork 733
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix json_decode problem #1005
Fix json_decode problem #1005
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -200,6 +200,23 @@ public function testIsNotOkBulkItemsWithStatusField() | |
$this->assertFalse($response->isOk()); | ||
} | ||
|
||
/** | ||
* @group unit | ||
*/ | ||
public function testDecodeResponseWithBigIntSetToTrue() | ||
{ | ||
$response = new Response(json_encode(array( | ||
'took' => 213, | ||
'items' => array( | ||
array('index' => array('_index' => 'rohlik', '_type' => 'grocery', '_id' => '707891', '_version' => 4, 'status' => 200)), | ||
array('index' => array('_index' => 'rohlik', '_type' => 'grocery', '_id' => '707893', '_version' => 4, 'status' => 200)), | ||
), | ||
))); | ||
$response->setJsonBigintConversion(true); | ||
|
||
$this->assertTrue(is_array($response->getData())); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This test would also pass without the setJonBigintVersion(true), right? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, this test would also pass without L215, but L215 makes the difference :) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm fine with the test. But I assume this test would also have passed without the code changes you made? It is more for me to understand if we test if the bug was actually fixed or if we test that we can use the function without any side affects? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No, it wouldn't since the return value of https://github.com/ruflin/Elastica/pull/1005/files#diff-b364251d02e70310f3c6e443372397d3L208 would be |
||
} | ||
|
||
/** | ||
* @group functional | ||
*/ | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry to bring this up again. But isn't the affect here, that if BIG_INT is enabled or not could be that the response object looks different?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
BIG_INT_* setting converts integers bigger than PHP_INT_MAX to a string, so yes, the response will be different (well some data types will be different), but it is the only way to deal with this without overflowing the integer.