diff --git a/php/utils.php b/php/utils.php index d2b0d129b..552bed751 100755 --- a/php/utils.php +++ b/php/utils.php @@ -432,7 +432,7 @@ function is_hermes() { **/ function result_is_multiobj( $result ) { $iter = new ArrayIterator($result); - if( is_object( $iter->current() ) OR is_array( $iter->current() ) ) { + if(is_int($iter->key()) AND (is_object( $iter->current() ) OR is_array( $iter->current()))) { return true; } unset($iter); diff --git a/tests/test-utils.php b/tests/test-utils.php index f08e39eb1..4d6ed77db 100755 --- a/tests/test-utils.php +++ b/tests/test-utils.php @@ -28,6 +28,9 @@ function testResultIsMultiObj() { $this->assertFalse( \Terminus\Utils\result_is_multiobj( $arraysimple )); $this->assertTrue( \Terminus\Utils\result_is_multiobj( $arraymultiobj )); + // real world results. + $object1 = '{"params": {"environment_id": "testlog", "deploy": {"clone_files": {"from_environment": "testlog"}, "annotation": "Create the environment.", "clone_database": {"from_environment": "testlog"}}}, "role": "owner", "site_id": "aaa313ea-d667-4cf6-b165-31a4a03abbc0", "task_ids": ["b76f4a72-bc51-11e4-b8ed-bc764e111d20", "b88cc1c8-bc51-11e4-b8ed-bc764e111d20", "b88ee85e-bc51-11e4-b8ed-bc764e111d20", "b891de74-bc51-11e4-b8ed-bc764e111d20", "b8be13cc-bc51-11e4-b8ed-bc764e111d20", "b8befdf0-bc51-11e4-b8ed-bc764e111d20", "b8bfc19a-bc51-11e4-b8ed-bc764e111d20", "b8d836f8-bc51-11e4-b8ed-bc764e111d20", "b8da08f2-bc51-11e4-b8ed-bc764e111d20", "b8dcf65c-bc51-11e4-b8ed-bc764e111d20", "b8e2c0a0-bc51-11e4-b8ed-bc764e111d20", "b8e532fe-bc51-11e4-b8ed-bc764e111d20", "b8fcfbd2-bc51-11e4-b8ed-bc764e111d20", "b8fec3ae-bc51-11e4-b8ed-bc764e111d20", "b900cf8c-bc51-11e4-b8ed-bc764e111d20", "b91e6c7c-bc51-11e4-b8ed-bc764e111d20", "b91fbeb0-bc51-11e4-b8ed-bc764e111d20", "b92315c4-bc51-11e4-b8ed-bc764e111d20", "b9267f98-bc51-11e4-b8ed-bc764e111d20"], "type": "create_cloud_development_environment", "user_id": "94212cf6-b7e1-44fc-bfc8-8a48214aa5fd", "waiting_for_task_id": "b88cc1c8-bc51-11e4-b8ed-bc764e111d20", "id": "b76f40ae-bc51-11e4-b8ed-bc764e111d20", "key": "1424800800", "environment": null, "environment_id": null, "result": null, "keep_forever": false, "final_task_id": null, "created_at": 1424801988.385195, "total_time": null, "active_description": "Creating a cloud development environment", "description": "Create a cloud development environment", "final_task": null}'; + $this->assertFalse(\Terminus\utils\result_is_multiobj(json_decode($object1))); } function testFilenameFromUrl() { @@ -52,4 +55,4 @@ function testDestinationIsValid() { $this->assertFileExists($testdir); $this->assertEquals($testdir,$destination); } - } +}