Bulk load data from json file to mongoDB using php

one text

I'm using PHP with mongoDB (using Yii). For creating useful unit & acceptance tests, I like to load an fixed set of data into mongoDB test DB.
This load should run at the beginning of every test.

Question: How the export data from monogoDB to have the right format to import this data during codeception run? Or: who to use mongoDB console output for bulk import using PHP?

Background:
To be sure, that the test data has the same format like the real data, I like to use an fixed set of exported real/production data, including the "right" value types (like NumberLong instead if int32).

The testdata are (at the moment) available in two different types:

  • JSON output from mongoDB console. But this will not work as input data out of the box, because its "extended JSON", where field types are part of the output, like:

    { "_id": ObjectId("123..."), "foo": "bar", "count": NumberLong(5) }
    But this will not work with json_decode()

  • BOSN output from Mongoexport. But I have no idea, how to import this using PHP during test.

So the question is: how the export data from monogoDB to have the right format to import this data during codeception run?

Source