├── .gitignore ├── .travis.scripts ├── compile.sh └── script.gdb ├── .travis.yml ├── CONTRIBUTING.md ├── LICENSE.md ├── Makefile.frag ├── Makefile.servers ├── README.md ├── api ├── batch.c ├── batch.h ├── wire_version.c ├── wire_version.h ├── write.c └── write.h ├── batch ├── delete.c ├── delete.h ├── insert.c ├── insert.h ├── update.c ├── update.h ├── write.c ├── write.h └── write_private.h ├── bson.c ├── bson.h ├── cleantests.sh ├── collection.c ├── collection.h ├── command_cursor.c ├── command_cursor.h ├── config.m4 ├── config.w32 ├── contrib ├── crypto.c ├── crypto.h ├── php-json.c ├── php-json.h ├── php-ssl.c └── php-ssl.h ├── cursor.c ├── cursor.h ├── cursor_shared.c ├── cursor_shared.h ├── db.c ├── db.h ├── docs ├── book.mongo.html ├── changelog.mongo.html ├── class.mongo.html ├── class.mongobindata.html ├── class.mongoclient.html ├── class.mongocode.html ├── class.mongocollection.html ├── class.mongocommandcursor.html ├── class.mongoconnectionexception.html ├── class.mongocursor.html ├── class.mongocursorexception.html ├── class.mongocursorinterface.html ├── class.mongocursortimeoutexception.html ├── class.mongodate.html ├── class.mongodb.html ├── class.mongodbref.html ├── class.mongodeletebatch.html ├── class.mongoduplicatekeyexception.html ├── class.mongoexception.html ├── class.mongoexecutiontimeoutexception.html ├── class.mongogridfs.html ├── class.mongogridfscursor.html ├── class.mongogridfsexception.html ├── class.mongogridfsfile.html ├── class.mongoid.html ├── class.mongoinsertbatch.html ├── class.mongoint32.html ├── class.mongoint64.html ├── class.mongolog.html ├── class.mongomaxkey.html ├── class.mongominkey.html ├── class.mongopool.html ├── class.mongoprotocolexception.html ├── class.mongoregex.html ├── class.mongoresultexception.html ├── class.mongotimestamp.html ├── class.mongoupdatebatch.html ├── class.mongowritebatch.html ├── class.mongowriteconcernexception.html ├── function.bson-decode.html ├── function.bson-encode.html ├── function.log-cmd-delete.html ├── function.log-cmd-insert.html ├── function.log-cmd-update.html ├── function.log-getmore.html ├── function.log-killcursor.html ├── function.log-reply.html ├── function.log-write-batch.html ├── index.html ├── mongo.batch.html ├── mongo.configuration.html ├── mongo.connecting.auth.html ├── mongo.connecting.html ├── mongo.connecting.mongos.html ├── mongo.connecting.persistent.html ├── mongo.connecting.persistent.manual.html ├── mongo.connecting.pools.html ├── mongo.connecting.rs.html ├── mongo.connecting.ssl.html ├── mongo.connecting.uds.html ├── mongo.connectutil.html ├── mongo.constants.html ├── mongo.construct.html ├── mongo.context.html ├── mongo.core.html ├── mongo.exceptions.html ├── mongo.getpoolsize.html ├── mongo.getslave.html ├── mongo.getslaveokay.html ├── mongo.gridfs.html ├── mongo.installation.html ├── mongo.manual.html ├── mongo.miscellaneous.html ├── mongo.pooldebug.html ├── mongo.queries.html ├── mongo.readpreferences.html ├── mongo.requirements.html ├── mongo.security.html ├── mongo.setpoolsize.html ├── mongo.setslaveokay.html ├── mongo.setup.html ├── mongo.sqltomongo.html ├── mongo.testing.html ├── mongo.trouble.html ├── mongo.tutorial.collection.html ├── mongo.tutorial.connecting.html ├── mongo.tutorial.counting.html ├── mongo.tutorial.criteria.html ├── mongo.tutorial.cursor.html ├── mongo.tutorial.findone.html ├── mongo.tutorial.html ├── mongo.tutorial.indexes.html ├── mongo.tutorial.insert.html ├── mongo.tutorial.insert.multiple.html ├── mongo.tutorial.multi.query.html ├── mongo.tutorial.selectdb.html ├── mongo.types.html ├── mongo.updates.html ├── mongo.writeconcerns.html ├── mongo.writes.html ├── mongobindata.construct.html ├── mongobindata.tostring.html ├── mongoclient.close.html ├── mongoclient.connect.html ├── mongoclient.construct.html ├── mongoclient.dropdb.html ├── mongoclient.get.html ├── mongoclient.getconnections.html ├── mongoclient.gethosts.html ├── mongoclient.getreadpreference.html ├── mongoclient.getwriteconcern.html ├── mongoclient.killcursor.html ├── mongoclient.listdbs.html ├── mongoclient.selectcollection.html ├── mongoclient.selectdb.html ├── mongoclient.setreadpreference.html ├── mongoclient.setwriteconcern.html ├── mongoclient.tostring.html ├── mongocode.construct.html ├── mongocode.tostring.html ├── mongocollection.--tostring.html ├── mongocollection.aggregate.html ├── mongocollection.aggregatecursor.html ├── mongocollection.batchinsert.html ├── mongocollection.construct.html ├── mongocollection.count.html ├── mongocollection.createdbref.html ├── mongocollection.createindex.html ├── mongocollection.deleteindex.html ├── mongocollection.deleteindexes.html ├── mongocollection.distinct.html ├── mongocollection.drop.html ├── mongocollection.ensureindex.html ├── mongocollection.find.html ├── mongocollection.findandmodify.html ├── mongocollection.findone.html ├── mongocollection.get.html ├── mongocollection.getdbref.html ├── mongocollection.getindexinfo.html ├── mongocollection.getname.html ├── mongocollection.getreadpreference.html ├── mongocollection.getslaveokay.html ├── mongocollection.getwriteconcern.html ├── mongocollection.group.html ├── mongocollection.insert.html ├── mongocollection.parallelcollectionscan.html ├── mongocollection.remove.html ├── mongocollection.save.html ├── mongocollection.setreadpreference.html ├── mongocollection.setslaveokay.html ├── mongocollection.setwriteconcern.html ├── mongocollection.toindexstring.html ├── mongocollection.update.html ├── mongocollection.validate.html ├── mongocommandcursor.batchsize.html ├── mongocommandcursor.construct.html ├── mongocommandcursor.createfromdocument.html ├── mongocommandcursor.current.html ├── mongocommandcursor.dead.html ├── mongocommandcursor.getreadpreference.html ├── mongocommandcursor.info.html ├── mongocommandcursor.key.html ├── mongocommandcursor.next.html ├── mongocommandcursor.rewind.html ├── mongocommandcursor.setreadpreference.html ├── mongocommandcursor.timeout.html ├── mongocommandcursor.valid.html ├── mongocursor.addoption.html ├── mongocursor.awaitdata.html ├── mongocursor.batchsize.html ├── mongocursor.construct.html ├── mongocursor.count.html ├── mongocursor.current.html ├── mongocursor.dead.html ├── mongocursor.doquery.html ├── mongocursor.explain.html ├── mongocursor.fields.html ├── mongocursor.getnext.html ├── mongocursor.getreadpreference.html ├── mongocursor.hasnext.html ├── mongocursor.hint.html ├── mongocursor.immortal.html ├── mongocursor.info.html ├── mongocursor.key.html ├── mongocursor.limit.html ├── mongocursor.maxtimems.html ├── mongocursor.next.html ├── mongocursor.partial.html ├── mongocursor.reset.html ├── mongocursor.rewind.html ├── mongocursor.setflag.html ├── mongocursor.setreadpreference.html ├── mongocursor.skip.html ├── mongocursor.slaveokay.html ├── mongocursor.snapshot.html ├── mongocursor.sort.html ├── mongocursor.tailable.html ├── mongocursor.timeout.html ├── mongocursor.valid.html ├── mongocursorexception.gethost.html ├── mongocursorinterface.batchsize.html ├── mongocursorinterface.dead.html ├── mongocursorinterface.getreadpreference.html ├── mongocursorinterface.info.html ├── mongocursorinterface.setreadpreference.html ├── mongocursorinterface.timeout.html ├── mongodate.construct.html ├── mongodate.todatetime.html ├── mongodate.tostring.html ├── mongodb.--tostring.html ├── mongodb.authenticate.html ├── mongodb.command.html ├── mongodb.construct.html ├── mongodb.createcollection.html ├── mongodb.createdbref.html ├── mongodb.drop.html ├── mongodb.dropcollection.html ├── mongodb.execute.html ├── mongodb.forceerror.html ├── mongodb.get.html ├── mongodb.getcollectioninfo.html ├── mongodb.getcollectionnames.html ├── mongodb.getdbref.html ├── mongodb.getgridfs.html ├── mongodb.getprofilinglevel.html ├── mongodb.getreadpreference.html ├── mongodb.getslaveokay.html ├── mongodb.getwriteconcern.html ├── mongodb.lasterror.html ├── mongodb.listcollections.html ├── mongodb.preverror.html ├── mongodb.repair.html ├── mongodb.reseterror.html ├── mongodb.selectcollection.html ├── mongodb.setprofilinglevel.html ├── mongodb.setreadpreference.html ├── mongodb.setslaveokay.html ├── mongodb.setwriteconcern.html ├── mongodbref.create.html ├── mongodbref.get.html ├── mongodbref.isref.html ├── mongodeletebatch.construct.html ├── mongogridfs.construct.html ├── mongogridfs.delete.html ├── mongogridfs.drop.html ├── mongogridfs.find.html ├── mongogridfs.findone.html ├── mongogridfs.get.html ├── mongogridfs.put.html ├── mongogridfs.remove.html ├── mongogridfs.storebytes.html ├── mongogridfs.storefile.html ├── mongogridfs.storeupload.html ├── mongogridfscursor.construct.html ├── mongogridfscursor.current.html ├── mongogridfscursor.getnext.html ├── mongogridfscursor.key.html ├── mongogridfsfile.construct.html ├── mongogridfsfile.getbytes.html ├── mongogridfsfile.getfilename.html ├── mongogridfsfile.getresource.html ├── mongogridfsfile.getsize.html ├── mongogridfsfile.write.html ├── mongoid.construct.html ├── mongoid.gethostname.html ├── mongoid.getinc.html ├── mongoid.getpid.html ├── mongoid.gettimestamp.html ├── mongoid.isvalid.html ├── mongoid.set-state.html ├── mongoid.tostring.html ├── mongoinsertbatch.construct.html ├── mongoint32.construct.html ├── mongoint32.tostring.html ├── mongoint64.construct.html ├── mongoint64.tostring.html ├── mongolog.getcallback.html ├── mongolog.getlevel.html ├── mongolog.getmodule.html ├── mongolog.setcallback.html ├── mongolog.setlevel.html ├── mongolog.setmodule.html ├── mongopool.getsize.html ├── mongopool.info.html ├── mongopool.setsize.html ├── mongoregex.construct.html ├── mongoregex.tostring.html ├── mongoresultexception.getdocument.html ├── mongotimestamp.construct.html ├── mongotimestamp.tostring.html ├── mongoupdatebatch.construct.html ├── mongowritebatch.add.html ├── mongowritebatch.construct.html ├── mongowritebatch.execute.html ├── mongowriteconcernexception.getdocument.html ├── ref.mongo.html ├── search-description.json ├── search-index.json └── styles │ ├── 03e73060321a0a848018724a6c83de7f-theme-base.css │ └── 03e73060321a0a848018724a6c83de7f-theme-medium.css ├── exceptions ├── connection_exception.c ├── connection_exception.h ├── cursor_exception.c ├── cursor_exception.h ├── cursor_timeout_exception.c ├── cursor_timeout_exception.h ├── duplicate_key_exception.c ├── duplicate_key_exception.h ├── exception.c ├── exception.h ├── execution_timeout_exception.c ├── execution_timeout_exception.h ├── gridfs_exception.c ├── gridfs_exception.h ├── protocol_exception.c ├── protocol_exception.h ├── result_exception.c ├── result_exception.h ├── write_concern_exception.c └── write_concern_exception.h ├── gridfs ├── gridfs.c ├── gridfs.h ├── gridfs_cursor.c ├── gridfs_cursor.h ├── gridfs_file.c ├── gridfs_file.h ├── gridfs_stream.c └── gridfs_stream.h ├── io_stream.c ├── io_stream.h ├── log_stream.c ├── log_stream.h ├── mcon ├── bson_helpers.c ├── bson_helpers.h ├── collection.c ├── collection.h ├── connections.c ├── connections.h ├── contrib │ ├── md5.c │ ├── md5.h │ ├── strndup.c │ └── strndup.h ├── manager.c ├── manager.h ├── mini_bson.c ├── mini_bson.h ├── parse.c ├── parse.h ├── read_preference.c ├── read_preference.h ├── str.c ├── str.h ├── tests │ ├── authcon-test.c │ ├── compile.sh │ ├── parse-test.c │ ├── parse-test2.c │ ├── replicacon-test.c │ ├── rp-test-complex1.c │ ├── rp-test-complex2.c │ ├── rp-test-simple1.c │ ├── shardcon-test.c │ ├── simplecon-test.c │ └── test-hash-split.c ├── types.h ├── utils.c └── utils.h ├── mongo.c ├── mongo.h ├── mongoclient.c ├── mongoclient.h ├── package.xml ├── php_mongo.c ├── php_mongo.h ├── rebuild.sh ├── tests ├── auth-replicaset │ ├── bug00779.phpt │ ├── bug00829.phpt │ └── legacy │ │ ├── bug00397.phpt │ │ ├── bug00426.phpt │ │ ├── bug00629.phpt │ │ ├── bug00631.phpt │ │ ├── manual-aborted-connections.phpt │ │ └── mongocursor-tailable.phpt ├── auth-standalone │ ├── bug00827.phpt │ ├── bug01107-1-28.phpt │ ├── bug01107-1.phpt │ ├── bug01107-2-28.phpt │ ├── bug01107-2.phpt │ ├── invalid-memcpy.phpt │ └── legacy │ │ └── bug00574.phpt ├── bridge │ ├── legacy │ │ ├── bug00339-001.phpt │ │ └── bug00798-001.phpt │ └── mongoclient-connecttimeoutms-001.phpt ├── data-files │ ├── bug00485-data.txt │ ├── empty │ ├── gridfs-fseek2-data.txt │ └── mongogridfs-storefile-003.pdf ├── generic │ ├── bug00273.phpt │ ├── bug00300-execute-segfault.phpt │ ├── bug00320-2.phpt │ ├── bug00320.phpt │ ├── bug00333-without-id.phpt │ ├── bug00333.phpt │ ├── bug00343-1.phpt │ ├── bug00343-2.phpt │ ├── bug00353.phpt │ ├── bug00361.phpt │ ├── bug00369.phpt │ ├── bug00372.phpt │ ├── bug00375.phpt │ ├── bug00384_32bit.phpt │ ├── bug00384_64bit.phpt │ ├── bug00389.phpt │ ├── bug00394-2.phpt │ ├── bug00394.phpt │ ├── bug00402.phpt │ ├── bug00408.phpt │ ├── bug00413.phpt │ ├── bug00429-2.phpt │ ├── bug00429.phpt │ ├── bug00436.phpt │ ├── bug00466.phpt │ ├── bug00468.phpt │ ├── bug00473.phpt │ ├── bug00486.phpt │ ├── bug00490.phpt │ ├── bug00507.phpt │ ├── bug00508.phpt │ ├── bug00522_error.phpt │ ├── bug00537.phpt │ ├── bug00543.phpt │ ├── bug00554.phpt │ ├── bug00559-002.phpt │ ├── bug00559-003.phpt │ ├── bug00559-004.phpt │ ├── bug00559-005.phpt │ ├── bug00559-006.phpt │ ├── bug00559-007.phpt │ ├── bug00559.phpt │ ├── bug00561.phpt │ ├── bug00585.phpt │ ├── bug00586.phpt │ ├── bug00602-32bit.phpt │ ├── bug00602-64bit.phpt │ ├── bug00609.phpt │ ├── bug00616.phpt │ ├── bug00617.phpt │ ├── bug00619.phpt │ ├── bug00627.phpt │ ├── bug00635.phpt │ ├── bug00667.phpt │ ├── bug00680.phpt │ ├── bug00683.phpt │ ├── bug00684.phpt │ ├── bug00687.phpt │ ├── bug00690.phpt │ ├── bug00737.phpt │ ├── bug00744.phpt │ ├── bug00746.phpt │ ├── bug00776.phpt │ ├── bug00792.phpt │ ├── bug00795.phpt │ ├── bug00797.phpt │ ├── bug00801.phpt │ ├── bug00802.phpt │ ├── bug00804.phpt │ ├── bug00805.phpt │ ├── bug00816.phpt │ ├── bug00963.phpt │ ├── bug00977.phpt │ ├── bug01059.phpt │ ├── bug01091.phpt │ ├── bug01149-001.phpt │ ├── bug01149-002.phpt │ ├── bug01229.phpt │ ├── bug01231.phpt │ ├── bug01247.phpt │ ├── bug01355.phpt │ ├── bug01357.phpt │ ├── bug01358.phpt │ ├── bug01382-001.phpt │ ├── bug01382-002.phpt │ ├── bug01382-003.phpt │ ├── bug01382-004.phpt │ ├── bug01382-005.phpt │ ├── bug01382-006.phpt │ ├── bug01382-007.phpt │ ├── bug01382-008.phpt │ ├── bug01382-009.phpt │ ├── bug01382-010.phpt │ ├── bug01382-011.phpt │ ├── bug01390-001.phpt │ ├── bug01390-002.phpt │ ├── bug01394-001.phpt │ ├── bug01394-002.phpt │ ├── bug01395-001.phpt │ ├── bug01395-002.phpt │ ├── bug01395-003.phpt │ ├── bug01395-004.phpt │ ├── bug01395-005.phpt │ ├── bug01400.phpt │ ├── bug01402-001.phpt │ ├── bug01402-002.phpt │ ├── bug01402-003.phpt │ ├── bug01425.phpt │ ├── bug01460-001.phpt │ ├── bug01460-002.phpt │ ├── bug01464.phpt │ ├── bug01500-001.phpt │ ├── bug01500-002.phpt │ ├── bug01505-001.phpt │ ├── bug01505-002.phpt │ ├── collection-index-sparse.phpt │ ├── connection-fork-001.phpt │ ├── connection-fork-002.phpt │ ├── connection-multiple.phpt │ ├── connection-multiple_error-001.phpt │ ├── connection-multiple_error-002.phpt │ ├── connection-single.phpt │ ├── connection-single_error-001.phpt │ ├── connection-single_error-002.phpt │ ├── connection-single_error-003.phpt │ ├── connection-with-auth-failure.phpt │ ├── connection-with-auth-successfull.phpt │ ├── connection-with-database-name-and-port.phpt │ ├── connection-with-database-name.phpt │ ├── database-createcollection-with-options.phpt │ ├── database-createcollection-with-size-and-max-old.phpt │ ├── database-createcollection-with-size-and-max.phpt │ ├── database-createcollection-with-size-old.phpt │ ├── database-createcollection-with-size.phpt │ ├── database-createcollection.phpt │ ├── database-createcollection_error.phpt │ ├── database-dropcollection-memory-test.phpt │ ├── database-dropcollection-object.phpt │ ├── database-dropcollection.phpt │ ├── database-profiling-collection-drop.phpt │ ├── database-profiling-level.phpt │ ├── database-tostring.phpt │ ├── database-valid-name.phpt │ ├── gridfs-chunks-1.phpt │ ├── gridfs-fseek.phpt │ ├── gridfs-fseek2.phpt │ ├── gridfs-get.phpt │ ├── gridfs-memory-leak-1.phpt │ ├── gridfs-memory-leak-2.phpt │ ├── gridfs-memory-usage-2.phpt │ ├── gridfs-memory-usage.phpt │ ├── gridfs-storeupload.phpt │ ├── gridfs-stream-check-validity.phpt │ ├── gridfs-streaming.phpt │ ├── gridfs-wrapper.phpt │ ├── ini-mongo_allow_empty_keys.phpt │ ├── ini-mongo_cmd-001.phpt │ ├── ini-mongo_cmd-002.phpt │ ├── ini-mongo_cmd-003.phpt │ ├── ini-mongo_native_long_64bit-001.phpt │ ├── ini-mongo_native_long_64bit-002.phpt │ ├── ini-mongo_native_long_64bit-003.phpt │ ├── ini-mongo_native_long_64bit-004.phpt │ ├── long_int_32bit-001.phpt │ ├── long_int_64bit-001.phpt │ ├── mongid-serialize.phpt │ ├── mongo-forceerror-001.phpt │ ├── mongo-lasterror-001.phpt │ ├── mongo-preverror-001.phpt │ ├── mongo-reseterror-001.phpt │ ├── mongo_batch_insert.phpt │ ├── mongo_batch_insert_old.phpt │ ├── mongobindata-002.phpt │ ├── mongobindata-003.phpt │ ├── mongobindata-004.phpt │ ├── mongobindata-006.phpt │ ├── mongoclient-ctor-001.phpt │ ├── mongoclient-ctor-readPref-001.phpt │ ├── mongoclient-dropdb-001.phpt │ ├── mongoclient-dropdb-002.phpt │ ├── mongoclient-dropdb-003.phpt │ ├── mongoclient-getreadpreference-001.phpt │ ├── mongoclient-listdbs-001.phpt │ ├── mongoclient-selectcollection-001.phpt │ ├── mongoclient-selectcollection_error-001.phpt │ ├── mongoclient-selectcollection_error-002.phpt │ ├── mongoclient-selectdb-001.phpt │ ├── mongoclient-selectdb_error-001.phpt │ ├── mongoclient-setreadpreference-001.phpt │ ├── mongoclient-setreadpreference-002.phpt │ ├── mongoclient-setreadpreference-003.phpt │ ├── mongoclient-setreadpreference-004.phpt │ ├── mongoclient-setreadpreference_error-001.phpt │ ├── mongoclient-setreadpreference_error-002.phpt │ ├── mongoclient-setreadpreference_error-003.phpt │ ├── mongoclient-setreadpreference_error-004.phpt │ ├── mongocode-001.phpt │ ├── mongocode-002.phpt │ ├── mongocollection-aggregate-001.phpt │ ├── mongocollection-aggregate-002.phpt │ ├── mongocollection-aggregate-003.phpt │ ├── mongocollection-aggregatecursor-001.phpt │ ├── mongocollection-aggregatecursor-002.phpt │ ├── mongocollection-aggregatecursor-003.phpt │ ├── mongocollection-aggregatecursor-004.phpt │ ├── mongocollection-aggregatecursor-005.phpt │ ├── mongocollection-aggregatecursor-006.phpt │ ├── mongocollection-aggregatecursor-007.phpt │ ├── mongocollection-aggregatecursor-008.phpt │ ├── mongocollection-aggregatecursor-009.phpt │ ├── mongocollection-aggregatecursor_error-001.phpt │ ├── mongocollection-aggregatecursor_error-002.phpt │ ├── mongocollection-aggregatecursor_error-003.phpt │ ├── mongocollection-aggregatecursor_error-004.phpt │ ├── mongocollection-batchinsert-001.phpt │ ├── mongocollection-count-001.phpt │ ├── mongocollection-count-002.phpt │ ├── mongocollection-count-003.phpt │ ├── mongocollection-count-004.phpt │ ├── mongocollection-count_error-001.phpt │ ├── mongocollection-count_error-002.phpt │ ├── mongocollection-createdbref-001.phpt │ ├── mongocollection-createdbref-002.phpt │ ├── mongocollection-createindex-empty.phpt │ ├── mongocollection-createindex-options-28.phpt │ ├── mongocollection-createindex-options.phpt │ ├── mongocollection-createindex-scalar.phpt │ ├── mongocollection-createindex-timeout-001.phpt │ ├── mongocollection-createindex_error-001.phpt │ ├── mongocollection-createindex_error-002.phpt │ ├── mongocollection-deleteindex-001.phpt │ ├── mongocollection-deleteindex-002.phpt │ ├── mongocollection-deleteindex_error.phpt │ ├── mongocollection-deleteindexes-001.phpt │ ├── mongocollection-deleteindexes-002.phpt │ ├── mongocollection-distinct-001.phpt │ ├── mongocollection-distinct_error-001.phpt │ ├── mongocollection-ensureindex-object.phpt │ ├── mongocollection-ensureindex_error-001.phpt │ ├── mongocollection-findandmodify-001.phpt │ ├── mongocollection-findandmodify-002.phpt │ ├── mongocollection-findandmodify_error-001.phpt │ ├── mongocollection-findone-001.phpt │ ├── mongocollection-getdbref-001.phpt │ ├── mongocollection-getdbref_error-001.phpt │ ├── mongocollection-getdbref_error-002.phpt │ ├── mongocollection-getindexinfo-001.phpt │ ├── mongocollection-getindexinfo-002.phpt │ ├── mongocollection-getname.phpt │ ├── mongocollection-getname_error.phpt │ ├── mongocollection-getreadpreference-001.phpt │ ├── mongocollection-getreadpreference-002.phpt │ ├── mongocollection-getserver_error.phpt │ ├── mongocollection-getslaveokay.phpt │ ├── mongocollection-group-001.phpt │ ├── mongocollection-group-002.phpt │ ├── mongocollection-insert-001.phpt │ ├── mongocollection-insert-002.phpt │ ├── mongocollection-insert_error-002.phpt │ ├── mongocollection-insert_error-003.phpt │ ├── mongocollection-insert_error-004.phpt │ ├── mongocollection-insert_error-005.phpt │ ├── mongocollection-insert_error.phpt │ ├── mongocollection-parallelcollectionscan-001.phpt │ ├── mongocollection-parallelcollectionscan-002.phpt │ ├── mongocollection-remove-001.phpt │ ├── mongocollection-remove_error-001.phpt │ ├── mongocollection-save-001.phpt │ ├── mongocollection-setreadpreference-001.phpt │ ├── mongocollection-setreadpreference-002.phpt │ ├── mongocollection-setreadpreference-003.phpt │ ├── mongocollection-setreadpreference_error-001.phpt │ ├── mongocollection-setreadpreference_error-002.phpt │ ├── mongocollection-setreadpreference_error-003.phpt │ ├── mongocollection-setreadpreference_error-004.phpt │ ├── mongocollection-setslaveokay_error.phpt │ ├── mongocollection-tostring.phpt │ ├── mongocollection-update-001.phpt │ ├── mongocollection-update_error-001.phpt │ ├── mongocommandcursor-001.phpt │ ├── mongocommandcursor-002.phpt │ ├── mongocommandcursor-003.phpt │ ├── mongocommandcursor-004.phpt │ ├── mongocommandcursor-005-32bit.phpt │ ├── mongocommandcursor-005-64bit.phpt │ ├── mongocommandcursor-createfromdocument-001.phpt │ ├── mongocommandcursor-createfromdocument-002.phpt │ ├── mongocommandcursor-createfromdocument_error-001.phpt │ ├── mongocommandcursor-dead.phpt │ ├── mongocommandcursor-info.phpt │ ├── mongocommandcursor-timeout-001.phpt │ ├── mongocommandcursor-timeout-002.phpt │ ├── mongocommandcursor_error-001.phpt │ ├── mongocursor-batchsize-001.phpt │ ├── mongocursor-batchsize-002.phpt │ ├── mongocursor-batchsize-003.phpt │ ├── mongocursor-batchsize-004.phpt │ ├── mongocursor-batchsize-005.phpt │ ├── mongocursor-batchsize-006.phpt │ ├── mongocursor-batchsize-007.phpt │ ├── mongocursor-batchsize-008.phpt │ ├── mongocursor-count-001.phpt │ ├── mongocursor-count-002.phpt │ ├── mongocursor-count-003.phpt │ ├── mongocursor-count-004.phpt │ ├── mongocursor-count-005.phpt │ ├── mongocursor-dead-001.phpt │ ├── mongocursor-dead-002.phpt │ ├── mongocursor-getreadpreference-001.phpt │ ├── mongocursor-getreadpreference-002.phpt │ ├── mongocursor-kill-cursors.phpt │ ├── mongocursor-kill-cursors_error.phpt │ ├── mongocursor-maxtimems-001.phpt │ ├── mongocursor-maxtimems-002.phpt │ ├── mongocursor-maxtimems-003.phpt │ ├── mongocursor-maxtimems_error.phpt │ ├── mongocursor-next-001.phpt │ ├── mongocursor-setreadpreference-001.phpt │ ├── mongocursor-setreadpreference-002.phpt │ ├── mongocursor-setreadpreference-003.phpt │ ├── mongocursor-setreadpreference_error-001.phpt │ ├── mongocursor-setreadpreference_error-002.phpt │ ├── mongocursor-setreadpreference_error-003.phpt │ ├── mongocursor-setreadpreference_error-004.phpt │ ├── mongocursor-tailable-001.phpt │ ├── mongocursor-tailable-002.phpt │ ├── mongocursor-tailable-003.phpt │ ├── mongocursor-tailable-004.phpt │ ├── mongocursor-tailable-005.phpt │ ├── mongocursor-tailable-006.phpt │ ├── mongocursor-tailable-007.phpt │ ├── mongodate-006.phpt │ ├── mongodate-008.phpt │ ├── mongodb-authenticate.phpt │ ├── mongodb-command-001.phpt │ ├── mongodb-command-002.phpt │ ├── mongodb-command-003.phpt │ ├── mongodb-command_error-001.phpt │ ├── mongodb-command_error-002.phpt │ ├── mongodb-createcollection.phpt │ ├── mongodb-createdbref-001.phpt │ ├── mongodb-createdbref-002.phpt │ ├── mongodb-drop.phpt │ ├── mongodb-dropcollection.phpt │ ├── mongodb-get.phpt │ ├── mongodb-getcollectioninfo-001.phpt │ ├── mongodb-getcollectioninfo-002.phpt │ ├── mongodb-getcollectionnames.phpt │ ├── mongodb-getdbref-001.phpt │ ├── mongodb-getdbref_error-001.phpt │ ├── mongodb-getdbref_error-002.phpt │ ├── mongodb-getgridfs-001.phpt │ ├── mongodb-getgridfs-002.phpt │ ├── mongodb-getgridfs_error-001.phpt │ ├── mongodb-getreadpreference-001.phpt │ ├── mongodb-getreadpreference-002.phpt │ ├── mongodb-listcollections-001.phpt │ ├── mongodb-listcollections-002.phpt │ ├── mongodb-listcollections-003.phpt │ ├── mongodb-listcollections-004.phpt │ ├── mongodb-listcollections-005.phpt │ ├── mongodb-listcollections-006.phpt │ ├── mongodb-listcollections_error-001.phpt │ ├── mongodb-listcollections_error-002.phpt │ ├── mongodb-repair.phpt │ ├── mongodb-selectcollection.phpt │ ├── mongodb-setreadpreference-001.phpt │ ├── mongodb-setreadpreference-002.phpt │ ├── mongodb-setreadpreference-003.phpt │ ├── mongodb-setreadpreference_error-001.phpt │ ├── mongodb-setreadpreference_error-002.phpt │ ├── mongodb-setreadpreference_error-003.phpt │ ├── mongodb-setreadpreference_error-004.phpt │ ├── mongodbref-get-001.phpt │ ├── mongodbref-get_error-001.phpt │ ├── mongodbref-get_error-002.phpt │ ├── mongogridfs-001.phpt │ ├── mongogridfs-002.phpt │ ├── mongogridfs-delete-001.phpt │ ├── mongogridfs-drop-001.phpt │ ├── mongogridfs-find-001.phpt │ ├── mongogridfs-findone-001.phpt │ ├── mongogridfs-findone-002.phpt │ ├── mongogridfs-findone-003.phpt │ ├── mongogridfs-findone-004.phpt │ ├── mongogridfs-findone-005.phpt │ ├── mongogridfs-findone-006.phpt │ ├── mongogridfs-get-001.phpt │ ├── mongogridfs-put-001.phpt │ ├── mongogridfs-put-002.phpt │ ├── mongogridfs-put-003.phpt │ ├── mongogridfs-put_error-001.phpt │ ├── mongogridfs-remove-001.phpt │ ├── mongogridfs-remove-002.phpt │ ├── mongogridfs-remove-003.phpt │ ├── mongogridfs-remove-004.phpt │ ├── mongogridfs-storebytes-001.phpt │ ├── mongogridfs-storebytes-002.phpt │ ├── mongogridfs-storebytes-003.phpt │ ├── mongogridfs-storebytes-004.phpt │ ├── mongogridfs-storefile-001.phpt │ ├── mongogridfs-storefile-002.phpt │ ├── mongogridfs-storefile-003.phpt │ ├── mongogridfs-storefile-004.phpt │ ├── mongogridfs-storefile-005.phpt │ ├── mongogridfs-storefile-006.phpt │ ├── mongogridfs-storefile_error-001.phpt │ ├── mongogridfs-storefile_error-002.phpt │ ├── mongogridfs-storefile_error-003.phpt │ ├── mongogridfs_error-001.phpt │ ├── mongogridfscursor-current-001.phpt │ ├── mongogridfscursor-getnext-001.phpt │ ├── mongogridfscursor-key-001.phpt │ ├── mongogridfsfile-001.phpt │ ├── mongogridfsfile-getbytes-001.phpt │ ├── mongogridfsfile-getbytes-002.phpt │ ├── mongogridfsfile-getfilename-001.phpt │ ├── mongogridfsfile-getsize-001.phpt │ ├── mongogridfsfile-write-001.phpt │ ├── mongoid-gettimestamp.phpt │ ├── mongoint32.phpt │ ├── mongoint32_32bit-001.phpt │ ├── mongoint32_32bit-002.phpt │ ├── mongoint32_64bit-001.phpt │ ├── mongoint32_64bit-002.phpt │ ├── mongoint64.phpt │ ├── mongoint64_32bit-001.phpt │ ├── mongoint64_32bit-002.phpt │ ├── mongoint64_32bit-003.phpt │ ├── mongoint64_32bit-004.phpt │ ├── mongoint64_64bit-001.phpt │ ├── mongoint64_64bit-002.phpt │ ├── mongoint64_64bit-003.phpt │ ├── mongoint64_64bit-004.phpt │ ├── mongolog-001.phpt │ ├── mongolog-002.phpt │ ├── mongomaxkey.phpt │ ├── mongominkey.phpt │ ├── mongoregex-003.phpt │ ├── mongotimestamp-005.phpt │ ├── mongowritebatch-construct_error-001.phpt │ ├── mongowriteconcernexception-001.phpt │ ├── php00613.phpt │ ├── public-props-read-only.phpt │ ├── stream-logger-batchinsert-001.phpt │ ├── stream-logger-getmore-001.phpt │ └── stream-logger-killcursor-001.phpt ├── master-slave │ └── bug01111.phpt ├── mongos │ ├── bug00698.phpt │ ├── bug00735.phpt │ ├── bug00755-001.phpt │ ├── bug00755-002.phpt │ ├── bug00756.phpt │ ├── legacy │ │ └── bug00638.phpt │ ├── mongoclient-connection-options-fsync.phpt │ ├── mongoclient-connection-options-journal.phpt │ ├── mongoclient-construct-001.phpt │ ├── mongoclient-construct-002.phpt │ ├── mongocursor-maxtimems-001.phpt │ ├── read-preferences-001.phpt │ └── stream-logger-001.phpt ├── no-servers │ ├── bson_decode_error-001.phpt │ ├── bson_decode_error-002.phpt │ ├── bson_decode_error-003.phpt │ ├── bson_encode-001.phpt │ ├── bson_encode-002.phpt │ ├── bson_encode-003.phpt │ ├── bson_encode-004.phpt │ ├── bson_encode-005.phpt │ ├── bson_encode-006.phpt │ ├── bson_encode-007.phpt │ ├── bson_encode-008.phpt │ ├── bson_encode-009.phpt │ ├── bson_encode-010.phpt │ ├── bson_encode-011.phpt │ ├── bson_encode-012.phpt │ ├── bson_encode-013.phpt │ ├── bson_encode-014.phpt │ ├── bson_encode-array.phpt │ ├── bson_encode-object.phpt │ ├── bson_encode_error-001.phpt │ ├── bug00270-arginfo.phpt │ ├── bug00306.phpt │ ├── bug00359.phpt │ ├── bug00394-2.phpt │ ├── bug00417.phpt │ ├── bug00434.phpt │ ├── bug00747.phpt │ ├── bug00814.phpt │ ├── bug00815.phpt │ ├── bug00833_error.phpt │ ├── bug00850.phpt │ ├── bug00858.phpt │ ├── bug00894.phpt │ ├── bug00896-binary.phpt │ ├── bug00896-code_ws.phpt │ ├── bug00896-dbpointer.phpt │ ├── bug00896-regex.phpt │ ├── bug00896-simple.phpt │ ├── bug00896-strings.phpt │ ├── bug00907.phpt │ ├── bug00949-001.phpt │ ├── bug01060.phpt │ ├── bug01218-php53.phpt │ ├── bug01218.phpt │ ├── bug01426-001.phpt │ ├── bug01426-002.phpt │ ├── bug01449-001.phpt │ ├── bug01449-002.phpt │ ├── bug01450-001.phpt │ ├── bug01450-002.phpt │ ├── bug01450-003.phpt │ ├── bug01453-001.phpt │ ├── mongobindata-001.phpt │ ├── mongobindata-002.phpt │ ├── mongobindata-005.phpt │ ├── mongobindata_error-001.phpt │ ├── mongoclient-authmechanismproperties-001.phpt │ ├── mongoclient-authmechanismproperties-002.phpt │ ├── mongoclient-authmechanismproperties_error-001.phpt │ ├── mongoclient-authmechanismproperties_error-002.phpt │ ├── mongoclient-authmechanismproperties_error-003.phpt │ ├── mongoclient-close.phpt │ ├── mongoclient-connection-string.phpt │ ├── mongoclient-default-auth-db.phpt │ ├── mongoclient-invalid-host.phpt │ ├── mongoclient-ssl-001.phpt │ ├── mongoclient-ssl_error-001.phpt │ ├── mongocollection-toindexstring-broken.phpt │ ├── mongocollection-toindexstring.phpt │ ├── mongocommandcursor-getreadpreference-001.phpt │ ├── mongocommandcursor-getreadpreference-002.phpt │ ├── mongocommandcursor-setreadpreference-001.phpt │ ├── mongocommandcursor-setreadpreference-002.phpt │ ├── mongocommandcursor-setreadpreference-003.phpt │ ├── mongocursor-doquery.phpt │ ├── mongodate-001.phpt │ ├── mongodate-002.phpt │ ├── mongodate-003.phpt │ ├── mongodate-004.phpt │ ├── mongodate-005.phpt │ ├── mongodate-007.phpt │ ├── mongodate-008.phpt │ ├── mongodate_error.phpt │ ├── mongodbref-create-001.phpt │ ├── mongodbref-create-002.phpt │ ├── mongodbref-isref-001.phpt │ ├── mongoid-001.phpt │ ├── mongoint32-001.phpt │ ├── mongoint32-002.phpt │ ├── mongoint64-001.phpt │ ├── mongoint64-002.phpt │ ├── mongolog-001.phpt │ ├── mongopool.phpt │ ├── mongoregex-001.phpt │ ├── mongoregex-002.phpt │ ├── mongoregex-tostring.phpt │ ├── mongoregex_error.phpt │ ├── mongotimestamp-001.phpt │ ├── mongotimestamp-002.phpt │ ├── mongotimestamp-003.phpt │ ├── mongotimestamp-004.phpt │ ├── mongotimestamp-tostring.phpt │ ├── mongotimestamp_error.phpt │ └── skipif.inc ├── replicaset-failover │ ├── bug01220.phpt │ ├── mongoclient-construct-001.phpt │ ├── mongoclient-construct-002.phpt │ ├── mongoclient-construct-003.phpt │ ├── mongocollection-find_error-001.phpt │ ├── mongocollection-insert-001.phpt │ ├── mongod-recovery-mode-001.phpt │ ├── mongoinsertbatch-execute-001.phpt │ └── mongoinsertbatch-execute-002.phpt ├── replicaset │ ├── bug00294-2.6.phpt │ ├── bug00294.phpt │ ├── bug00535.phpt │ ├── bug00698.phpt │ ├── bug00736.phpt │ ├── bug00741.phpt │ ├── bug00759.phpt │ ├── bug00779.phpt │ ├── bug00869.phpt │ ├── bug00925.phpt │ ├── bug00978-001.phpt │ ├── bug00978-002.phpt │ ├── bug00978-003.phpt │ ├── bug00999.phpt │ ├── bug01012-001.phpt │ ├── bug01367.phpt │ ├── bug01369.phpt │ ├── bug01371.phpt │ ├── bug01504.phpt │ ├── bug1102-1.phpt │ ├── bug1102-2.phpt │ ├── ini-is_master_interval-001.phpt │ ├── legacy │ │ ├── bug00207.phpt │ │ ├── bug00266.phpt │ │ ├── bug00307.phpt │ │ ├── bug00485.phpt │ │ ├── bug00487.phpt │ │ ├── bug00500.phpt │ │ ├── bug00511-001.phpt │ │ ├── bug00511.phpt │ │ ├── bug00522-001-2.6.phpt │ │ ├── bug00522-001.phpt │ │ ├── bug00569-001.phpt │ │ ├── bug00569-002.phpt │ │ ├── bug00569-003.phpt │ │ ├── bug00569-004.phpt │ │ ├── bug00586-replicaset.phpt │ │ ├── bug00605.phpt │ │ ├── bug00611.phpt │ │ ├── bug00612.phpt │ │ ├── bug00639-001.phpt │ │ ├── bug00639-002.phpt │ │ ├── bug00639-003.phpt │ │ ├── bug00639-004.phpt │ │ ├── bug00639-005.phpt │ │ ├── bug00639-006.phpt │ │ ├── bug00639-007.phpt │ │ ├── bug00647.phpt │ │ ├── bug00676.phpt │ │ ├── bug00685.phpt │ │ ├── bug00790.phpt │ │ ├── connection-tostring.phpt │ │ ├── log-1.phpt │ │ ├── log-1_alternative.phpt │ │ ├── log-2.phpt │ │ ├── log-3.phpt │ │ ├── log-4.phpt │ │ ├── mongoclient-ctor-002.phpt │ │ ├── mongocollection-findandmodify-001-errors.phpt │ │ ├── mongocollection-findone.phpt │ │ ├── mongocursor-setreadpreference-001.phpt │ │ ├── mongocursor-setreadpreference-002.phpt │ │ └── mongocursor-setreadpreference-003.phpt │ ├── mongoclient-construct-001.phpt │ ├── mongoclient-construct-002.phpt │ ├── mongoclient-construct-003.phpt │ ├── mongocollection-aggregate-004.phpt │ ├── mongocollection-aggregate-005.phpt │ ├── mongocollection-aggregatecursor-010.phpt │ ├── mongocollection-aggregatecursor-011.phpt │ ├── mongocollection-find_error-002.phpt │ ├── mongocollection-getindexinfo-001.phpt │ ├── mongocollection-getindexinfo-002.phpt │ ├── mongocollection-getindexinfo-003.phpt │ ├── mongocollection-getindexinfo-004.phpt │ ├── mongocollection-getindexinfo-005.phpt │ ├── mongocollection-getindexinfo-006.phpt │ ├── mongocommandcursor-008.phpt │ ├── mongocommandcursor-setreadpreference-004.phpt │ ├── mongocommandcursor-setreadpreference-005.phpt │ ├── mongodb-listcollections-001.phpt │ ├── mongodb-listcollections-002.phpt │ ├── mongodb-listcollections-003.phpt │ ├── mongodb-listcollections-004.phpt │ ├── mongodb-listcollections-005.phpt │ ├── mongodb-listcollections-006.phpt │ └── mongoresultexception-001.phpt ├── standalone │ ├── bug00296-1.phpt │ ├── bug00296-2.phpt │ ├── bug00296-3.phpt │ ├── bug00506.phpt │ ├── bug00698.phpt │ ├── bug00712.phpt │ ├── bug00723.phpt │ ├── bug00755-001.phpt │ ├── bug00755-002.phpt │ ├── bug00756.phpt │ ├── bug00778.phpt │ ├── bug00848.phpt │ ├── bug00853.phpt │ ├── bug00859.phpt │ ├── bug00872-001.phpt │ ├── bug00872-002.phpt │ ├── bug00872-003.phpt │ ├── bug00906.phpt │ ├── bug00928-001.phpt │ ├── bug00928-002.phpt │ ├── bug00928-003.phpt │ ├── bug00949-002.phpt │ ├── bug00949-003.phpt │ ├── bug00981.phpt │ ├── bug01011-001.phpt │ ├── bug01011-002.phpt │ ├── bug01012-001.phpt │ ├── bug01019.phpt │ ├── bug01036-001.phpt │ ├── bug01044.phpt │ ├── bug01065.phpt │ ├── bug01075.phpt │ ├── bug01077.phpt │ ├── bug01080.phpt │ ├── bug01082.phpt │ ├── bug01084.phpt │ ├── bug01085-001.phpt │ ├── bug01085-002.phpt │ ├── bug01099-1.phpt │ ├── bug01099-2.phpt │ ├── bug01099-3.phpt │ ├── bug01105-001-32bit.phpt │ ├── bug01105-001-64bit.phpt │ ├── bug01105-002.phpt │ ├── bug01109.phpt │ ├── bug01118.phpt │ ├── bug01155-1.phpt │ ├── bug01155-2.phpt │ ├── bug01155-3.phpt │ ├── bug01156-1.phpt │ ├── bug01156-2.phpt │ ├── bug01156-3.phpt │ ├── bug01158.phpt │ ├── bug01280.phpt │ ├── bug01435.phpt │ ├── insert-duplicate-key.phpt │ ├── legacy │ │ ├── bug00464.phpt │ │ ├── bug00485.phpt │ │ ├── bug00489.phpt │ │ ├── bug00500.phpt │ │ ├── bug00522_error.phpt │ │ ├── bug00569-001.phpt │ │ ├── bug00569-002.phpt │ │ ├── bug00569-003.phpt │ │ ├── bug00569-004.phpt │ │ ├── bug00605.phpt │ │ ├── bug00644-001.phpt │ │ ├── bug00644-002.phpt │ │ ├── bug00672.phpt │ │ ├── connect-mongodb-prefix.phpt │ │ ├── connection-tostring.phpt │ │ ├── log-1.phpt │ │ ├── log-2.phpt │ │ ├── log-3.phpt │ │ ├── log-4.phpt │ │ ├── mongo-ping-interval.phpt │ │ ├── mongoclient-getconnections.phpt │ │ ├── mongocollection-find-001.phpt │ │ ├── mongocollection-findandmodify-001-errors.phpt │ │ └── mongocollection-insert-001.phpt │ ├── mongoclient-connection-options-fsync-2.6.phpt │ ├── mongoclient-connection-options-fsync.phpt │ ├── mongoclient-connection-options-journal-2.6.phpt │ ├── mongoclient-connection-options-journal.phpt │ ├── mongoclient-construct-001.phpt │ ├── mongoclient-setwriteconcern-001.phpt │ ├── mongoclient-setwriteconcern_error-001.phpt │ ├── mongocollection-setwriteconcern-001.phpt │ ├── mongocollection-setwriteconcern_error-001.phpt │ ├── mongocursor-construct-001.phpt │ ├── mongocursor-construct-002.phpt │ ├── mongocursor-construct_error-001.phpt │ ├── mongocursor-construct_error-002.phpt │ ├── mongocursor-explain.phpt │ ├── mongocursor-hint-001.phpt │ ├── mongocursor-info-003.phpt │ ├── mongocursor-info-005.phpt │ ├── mongocursor-info-006.phpt │ ├── mongocursor-info-007.phpt │ ├── mongocursor-info-008.phpt │ ├── mongodb-setwriteconcern-001.phpt │ ├── mongodb-setwriteconcern_error-001.phpt │ ├── mongodeletebatch-add-001.phpt │ ├── mongodeletebatch-execute-001.phpt │ ├── mongodeletebatch-execute-002.phpt │ ├── mongoinsertbatch-001.phpt │ ├── mongoinsertbatch-002.phpt │ ├── mongoinsertbatch-003_32bit.phpt │ ├── mongoinsertbatch-003_64bit.phpt │ ├── mongoinsertbatch-004.phpt │ ├── mongoinsertbatch-005.phpt │ ├── mongoinsertbatch-006.phpt │ ├── mongoinsertbatch-007.phpt │ ├── mongoinsertbatch-008.phpt │ ├── mongoinsertbatch-009.phpt │ ├── mongoinsertbatch-010.phpt │ ├── mongoinsertbatch-011.phpt │ ├── mongoinsertbatch-add-001.phpt │ ├── mongoinsertbatch-execute-001.phpt │ ├── mongoupdatebatch-add-001.phpt │ ├── mongoupdatebatch-execute-001.phpt │ └── mongoupdatebatch-execute-002.phpt ├── templates │ ├── auth-replicaset.phpt │ ├── auth-standalone.phpt │ ├── bridge.phpt │ ├── failover-replicaset.phpt │ ├── mongos.phpt │ ├── replicaset.phpt │ ├── standalone.phpt │ └── unix.phpt ├── unix-standalone │ └── bug00846.phpt ├── utils │ ├── auth-replicaset.inc │ ├── auth-standalone.inc │ ├── bridge.inc │ ├── cfg.inc.template │ ├── collection-info.inc │ ├── daemon.php │ ├── fix-master.inc │ ├── fix-secondaries.inc │ ├── keyFile │ ├── make-servers.php │ ├── masterslave.inc │ ├── mongos.inc │ ├── myconfig.js │ ├── replicaset-failover.inc │ ├── replicaset.inc │ ├── server.inc │ ├── standalone.inc │ ├── stream-notifications.inc │ ├── teardown-servers.php │ └── unix-standalone.inc └── write │ ├── insert-duplicate-key.phpt │ └── mongocollection-insert-001.phpt ├── types ├── bin_data.c ├── bin_data.h ├── code.c ├── code.h ├── date.c ├── date.h ├── db_ref.c ├── db_ref.h ├── id.c ├── id.h ├── int32.c ├── int32.h ├── int64.c ├── int64.h ├── regex.c ├── regex.h ├── timestamp.c └── timestamp.h └── util ├── log.c ├── log.h ├── pool.c └── pool.h /.travis.scripts/compile.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | sudo apt-get install gdb 3 | phpize 4 | ./configure --quiet 5 | make all install 6 | echo "extension=mongo.so" >> `php --ini | grep "Loaded Configuration" | sed -e "s|.*:\s*||"` 7 | 8 | MONGO=`which mongo` 9 | mongod --version 10 | ls $MONGO* 11 | pwd 12 | cp tests/utils/cfg.inc.template tests/utils/cfg.inc 13 | MONGO_SERVER_STANDALONE=yes MONGO_SERVER_STANDALONE_AUTH=yes MONGO_SERVER_REPLICASET=yes MONGO_SERVER_REPLICASET_AUTH=yes make servers 14 | if [ $? -ne 0 ]; then 15 | cat /tmp/MONGO-PHP-TESTS* 16 | cat /tmp/NODE.* 17 | ps aux | grep mongo 18 | hostname 19 | exit 42 20 | fi 21 | 22 | -------------------------------------------------------------------------------- /.travis.scripts/script.gdb: -------------------------------------------------------------------------------- 1 | set env MALLOC_CHECK_=3 2 | set env ZEND_DONT_UNLOAD_MODULES=1 3 | set env USE_ZEND_ALLOC=0 4 | run 5 | backtrace full 6 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: php 2 | 3 | php: 4 | - 5.6 5 | - 5.5 6 | - 5.4 7 | - 5.3 8 | 9 | services: 10 | - mongodb 11 | 12 | env: 13 | - REPORT_EXIT_STATUS=1 14 | 15 | before_script: 16 | - sudo mkdir -p /data/db 17 | - sudo chown -R travis /data/ 18 | - ./.travis.scripts/compile.sh 19 | 20 | notifications: 21 | email: 22 | - driver-php@10gen.com 23 | 24 | # - cat ./.travis.scripts/script.gdb | gdb --args $MYPHP `find ...core` 25 | # Run PHPs run-tests.php 26 | script: 27 | - MYPHP=`make findphp` 28 | - MODULES=`pwd`/modules/ 29 | - SHOW_ONLY_GROUPS="FAIL,XFAIL,BORK,WARN,LEAK,SKIP" REPORT_EXIT_STATUS=1 TEST_PHP_EXECUTABLE=$MYPHP $MYPHP run-tests.php -n -d extension_dir=$MODULES -d extension=mongo.so -q -x --show-diff 30 | 31 | -------------------------------------------------------------------------------- /Makefile.frag: -------------------------------------------------------------------------------- 1 | clean-coverage: 2 | @rm -rf .coverage coverage 3 | 4 | coverage: test clean-coverage 5 | @echo "Generating $@" 6 | @$(LCOV) --directory . --capture --base-directory=. --output-file .coverage 7 | @$(GENHTML) --legend --output-directory coverage/ --title "pecl/mongo code coverage" .coverage 8 | 9 | -------------------------------------------------------------------------------- /Makefile.servers: -------------------------------------------------------------------------------- 1 | servers: daemon 2 | $(PHP_EXECUTABLE) tests/utils/make-servers.php 3 | 4 | stop-servers: 5 | $(PHP_EXECUTABLE) tests/utils/teardown-servers.php 6 | 7 | daemon: 8 | $(PHP_EXECUTABLE) tests/utils/daemon.php & 9 | sleep 3 10 | 11 | findphp: 12 | @echo $(PHP_EXECUTABLE) 13 | -------------------------------------------------------------------------------- /cleantests.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | for group in auth-replicaset auth-standalone bridge generic mongos no-servers replicaset replicaset-failover standalone 4 | do 5 | for extension in diff exp log out mem php sh 6 | do 7 | rm -f tests/$group/*.$extension 8 | rm -f tests/$group/legacy/*.$extension 9 | done 10 | done 11 | -------------------------------------------------------------------------------- /mcon/tests/compile.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | FLAGS="-Wall -ggdb3 -O0 -I.." 4 | FILES="../bson_helpers.c ../collection.c ../connections.c ../manager.c ../mini_bson.c ../parse.c ../read_preference.c ../str.c ../utils.c ../io.c" 5 | 6 | gcc $FLAGS -o sc-test1 simplecon-test.c $FILES 7 | gcc $FLAGS -o rc-test1 replicacon-test.c $FILES 8 | gcc $FLAGS -o rp-test1 rp-test-simple1.c $FILES 9 | gcc $FLAGS -o rp-test2 rp-test-complex1.c $FILES 10 | gcc $FLAGS -o hash-test1 test-hash-split.c $FILES 11 | gcc $FLAGS -o parse-test1 parse-test.c $FILES 12 | gcc $FLAGS -o parse-test2 parse-test2.c $FILES 13 | gcc $FLAGS -o shc-test1 shardcon-test.c $FILES 14 | gcc $FLAGS -o auth-test1 authcon-test.c $FILES 15 | -------------------------------------------------------------------------------- /mcon/tests/replicacon-test.c: -------------------------------------------------------------------------------- 1 | #include "parse.h" 2 | #include "manager.h" 3 | #include 4 | 5 | int main(void) 6 | { 7 | mongo_servers *servers; 8 | mongo_con_manager *manager; 9 | char *error_message; 10 | 11 | manager = mongo_init(); 12 | manager->log_function = mongo_log_printf; 13 | 14 | servers = mongo_parse_init(); 15 | mongo_parse_server_spec(manager, servers, "mongodb://whisky:13002,whisky:13000,whisky:13001/demo?replicaSet=seta", (char **) &error_message); 16 | mongo_servers_dump(manager, servers); 17 | servers->read_pref.type = MONGO_RP_PRIMARY_PREFERRED; 18 | mongo_get_read_write_connection(manager, servers, MONGO_CON_FLAG_READ, (char**) &error_message); 19 | if (error_message) { 20 | printf("ERROR: %s\n", error_message); 21 | } 22 | mongo_servers_dtor(servers); 23 | 24 | mongo_deinit(manager); 25 | 26 | return 0; 27 | } 28 | -------------------------------------------------------------------------------- /mcon/tests/shardcon-test.c: -------------------------------------------------------------------------------- 1 | #include "parse.h" 2 | #include "manager.h" 3 | #include 4 | #include 5 | 6 | int main(void) 7 | { 8 | mongo_servers *servers; 9 | mongo_con_manager *manager; 10 | char *error_message = NULL; 11 | 12 | manager = mongo_init(); 13 | manager->log_function = mongo_log_printf; 14 | 15 | servers = mongo_parse_init(); 16 | mongo_parse_server_spec(manager, servers, "mongodb://whisky:13200,whisky:13201/phpunit", (char **) &error_message); 17 | mongo_servers_dump(manager, servers); 18 | servers->read_pref.type = MONGO_RP_PRIMARY_PREFERRED; 19 | mongo_get_read_write_connection(manager, servers, MONGO_CON_FLAG_READ, (char**) &error_message); 20 | if (error_message) { 21 | printf("ERROR: %s\n", error_message); 22 | free(error_message); 23 | } 24 | mongo_servers_dtor(servers); 25 | 26 | mongo_deinit(manager); 27 | 28 | return 0; 29 | } 30 | -------------------------------------------------------------------------------- /rebuild.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | export CFLAGS="-Wall -Wextra -Wdeclaration-after-statement -Wmissing-field-initializers -Wshadow -Wno-unused-parameter -ggdb3" 4 | phpize > /dev/null && \ 5 | ./configure --with-mongo-sasl > /dev/null && \ 6 | make clean && make all > /dev/null && make install 7 | -------------------------------------------------------------------------------- /tests/auth-replicaset/bug00829.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Test for PHP-829: Segfault when a Replicaset doesn't have a passive server 3 | --SKIPIF-- 4 | 5 | --FILE-- 6 | getReplicaSetConfig(true); 11 | $creds = $s->getCredentials(); 12 | 13 | $options = array( 14 | 'db' => 'admin', 15 | 'username' => $creds['admin']->username, 16 | 'password' => $creds['admin']->password, 17 | ); 18 | 19 | 20 | try { 21 | $mc = new MongoClient($rs['dsn'], $options + array('replicaSet' => $rs['rsname'])); 22 | echo "ok\n"; 23 | } catch(Exception $e) { 24 | var_dump(get_class($e), $e->getMessage()); 25 | } 26 | 27 | ?> 28 | --EXPECTF-- 29 | ok 30 | 31 | -------------------------------------------------------------------------------- /tests/auth-standalone/bug00827.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Test for PHP-827: Segfault on connect when database name starts with an X 3 | --SKIPIF-- 4 | 5 | --FILE-- 6 | getStandaloneConfig(true); 11 | $creds = $s->getCredentials(); 12 | 13 | $opts = array( 14 | "db" => "Xanadu", 15 | "username" => $creds["user"]->username, 16 | "password" => $creds["user"]->password, 17 | ); 18 | try { 19 | $m = new MongoClient($host, $opts); 20 | } catch (MongoConnectionException $e) { 21 | echo $e->getCode(), "\n"; 22 | echo $e->getMessage(), "\n"; 23 | } 24 | echo "DONE\n"; 25 | ?> 26 | --EXPECTF-- 27 | 71 28 | Failed to connect to: %s:%d:%sAuthentication failed%s 29 | DONE 30 | -------------------------------------------------------------------------------- /tests/bridge/legacy/bug00798-001.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Test for PHP-798: socketTimeoutMS (streams) 3 | --SKIPIF-- 4 | 5 | --FILE-- 6 | selectDB(dbname())->selectCollection("php-798"); 12 | 13 | try { 14 | $retval = $c->insert( array( 'test' => 1 ), array( 'fsync' => true, 'w' => true, 'socketTimeoutMS' => 100 ) ); 15 | var_dump($retval["ok"]); 16 | } catch ( Exception $e ) { 17 | echo $e->getCode(), "\n"; 18 | echo $e->getMessage(), "\n"; 19 | } 20 | ?> 21 | --EXPECTF-- 22 | 80 23 | %s:%d: Read timed out after reading %d bytes, waited for 0.100000 seconds 24 | -------------------------------------------------------------------------------- /tests/bridge/mongoclient-connecttimeoutms-001.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Test for PHP-1350: Functional test for MongoClient connectTimeoutMS option 3 | --SKIPIF-- 4 | 5 | --FILE-- 6 | 500)); 13 | } catch (MongoConnectionException $e) { 14 | echo $e->getCode(), ': ', $e->getMessage(), "\n"; 15 | } 16 | 17 | ?> 18 | ===DONE=== 19 | --EXPECTF-- 20 | 71: Failed to connect to: %s:%d: Read timed out after reading 0 bytes, waited for 0.500000 seconds 21 | ===DONE=== 22 | -------------------------------------------------------------------------------- /tests/data-files/empty: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mongodb/mongo-php-driver-legacy/ce796fef410487eeec220e0562adf33fb9ecae09/tests/data-files/empty -------------------------------------------------------------------------------- /tests/data-files/mongogridfs-storefile-003.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mongodb/mongo-php-driver-legacy/ce796fef410487eeec220e0562adf33fb9ecae09/tests/data-files/mongogridfs-storefile-003.pdf -------------------------------------------------------------------------------- /tests/generic/bug00300-execute-segfault.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Test for PHP-300: execute crashes with array() as argument. 3 | --SKIPIF-- 4 | 5 | --FILE-- 6 | phpunit; 10 | $db->execute(array()); 11 | ?> 12 | --EXPECTF-- 13 | Deprecated: Function MongoDB::execute() is deprecated in %s on line %d 14 | 15 | Fatal error: MongoDB::execute(): The argument is neither an object of MongoCode or a string in %s on line %d 16 | -------------------------------------------------------------------------------- /tests/generic/bug00361.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Test for PHP-361: Mongo::getHosts() segfaults when not connecting to a replica set. 3 | --SKIPIF-- 4 | 5 | --FILE-- 6 | getHosts(); 11 | if ($hosts && is_array($hosts)) { 12 | echo "ok\n"; 13 | } 14 | 15 | $host = current($hosts); 16 | echo $host["host"], ":", $host["port"], "\n"; 17 | ?> 18 | --EXPECTF-- 19 | ok 20 | %s:%d 21 | -------------------------------------------------------------------------------- /tests/generic/bug00394-2.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Test for PHP-394: Crashes and mem leaks. (2) 3 | --SKIPIF-- 4 | 5 | --FILE-- 6 | __construct(NULL); 9 | $x->getInc(NULL); 10 | var_dump($x->__toString()); 11 | ?> 12 | ===DONE=== 13 | --EXPECTF-- 14 | string(24) "%s" 15 | ===DONE=== 16 | 17 | -------------------------------------------------------------------------------- /tests/generic/bug00468.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Test for PHP-468: Undefined behavior calling MongoGridFSFile::write() without a filename. 3 | --SKIPIF-- 4 | 5 | --FILE-- 6 | selectDB(dbname())->getGridFS(); 12 | $id = $grid->storeBytes('foo'); 13 | $file = $grid->get($id); 14 | try { 15 | $file->write(); 16 | } catch(MongoGridFSException $e) { 17 | var_dump($e->getMessage(), $e->getCode()); 18 | } 19 | ?> 20 | --EXPECTF-- 21 | string(20) "Cannot find filename" 22 | int(15) 23 | 24 | -------------------------------------------------------------------------------- /tests/generic/bug00543.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Test for PHP-543: Mongo::connect() should return a bool value. 3 | --SKIPIF-- 4 | 5 | --FILE-- 6 | false ) ); 10 | var_dump($m->connect()); 11 | 12 | try 13 | { 14 | $m = new MongoClient("mongodb://totallynonsense/", array( 'connect' => false ) ); 15 | var_dump(@$m->connect()); 16 | } 17 | catch ( Exception $e ) 18 | { 19 | echo $e->getMessage(), "\n"; 20 | } 21 | ?> 22 | --EXPECTF-- 23 | bool(true) 24 | Failed to connect to: %s:%d: %s 25 | -------------------------------------------------------------------------------- /tests/generic/bug00559-002.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Test for PHP-559: The wrong connection is sometimes picked when there are two connections open (authenticated). 3 | --SKIPIF-- 4 | skip Manual test 5 | --FILE-- 6 | phpunit->test->insert( array( 'foo' => 'bar' ) ); 16 | echo "\nINSERTING 2\n"; 17 | $b->phpunit->test->insert( array( 'foo' => 'bar' ) ); 18 | ?> 19 | --EXPECT-- 20 | -------------------------------------------------------------------------------- /tests/generic/bug00559-004.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Test for PHP-559: The wrong connection is sometimes picked when there are two connections open (replicasets). 3 | --SKIPIF-- 4 | skip Manual test 5 | --FILE-- 6 | phpunit->test->insert( array( 'foo' => 'bar' ) ); 16 | echo "\nINSERTING 2\n"; 17 | $b->phpunit->test->insert( array( 'foo' => 'bar' ) ); 18 | ?> 19 | --EXPECTF-- 20 | -------------------------------------------------------------------------------- /tests/generic/bug00559-005.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Test for PHP-559: The wrong connection is sometimes picked when there are two connections open (replicasets). 3 | --SKIPIF-- 4 | skip Manual test 5 | --FILE-- 6 | phpunit->test->insert( array( 'foo' => 'bar' ) ); 16 | echo "\nINSERTING 2\n"; 17 | $b->phpunit->test->insert( array( 'foo' => 'bar' ) ); 18 | 19 | var_dump( $a->getConnections() ); 20 | ?> 21 | --EXPECTF-- 22 | -------------------------------------------------------------------------------- /tests/generic/bug00559.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Test for PHP-559: The wrong connection is sometimes picked when there are two connections open. 3 | --SKIPIF-- 4 | skip Manual test 5 | --FILE-- 6 | phpunit->test->insert( array( 'foo' => 'bar' ) ); 16 | echo "\nINSERTING 2\n"; 17 | $b->phpunit->test->insert( array( 'foo' => 'bar' ) ); 18 | ?> 19 | --EXPECTF-- 20 | -------------------------------------------------------------------------------- /tests/generic/bug00586.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Test for PHP-586: GridFS should only do one GLE 3 | --SKIPIF-- 4 | 5 | --FILE-- 6 | selectDB(dbname()); 10 | 11 | $gridfs = $db->getGridFS(); 12 | $gridfs->drop(); 13 | $gridfs->storeFile(__FILE__, array('x' => 1), array("w" => 1)); 14 | 15 | $file = $gridfs->findOne(array(), array('x' => 1)); 16 | 17 | try { 18 | $file->getBytes(); 19 | var_dump(false); 20 | } catch (MongoGridFSException $e) { 21 | var_dump(true); 22 | } 23 | --EXPECT-- 24 | bool(true) 25 | -------------------------------------------------------------------------------- /tests/generic/bug00609.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Test for PHP-609: MongoGridFS::put not returning MongoId despite inserting file 3 | --SKIPIF-- 4 | 5 | --FILE-- 6 | selectDb(dbname())->getGridFS(); 11 | $retval = $gridfs->put(__FILE__, array("meta" => "data")); 12 | $gridfs->drop(); 13 | var_dump($retval); 14 | ?> 15 | --EXPECTF-- 16 | object(MongoId)#%d (1) { 17 | ["$id"]=> 18 | string(24) "%s" 19 | } 20 | 21 | -------------------------------------------------------------------------------- /tests/generic/bug00619.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Test for PHP-619: Connection failure 3 | --SKIPIF-- 4 | 5 | --FILE-- 6 | dbname())); 11 | ?> 12 | I'm Alive 13 | ==DONE== 14 | --EXPECTF-- 15 | I'm Alive 16 | ==DONE== 17 | -------------------------------------------------------------------------------- /tests/generic/bug00635.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Test for PHP-635: The second argument to MongoCursor::__construct() always gets converted to a string. 3 | --SKIPIF-- 4 | 5 | --FILE-- 6 | selectDb(dbname())->bug635; 11 | var_dump($collection); 12 | 13 | $cursor = new MongoCursor($m, $collection); 14 | var_dump($collection); 15 | var_dump(is_object($collection)); 16 | ?> 17 | --EXPECTF-- 18 | object(MongoCollection)#%d (%d) { 19 | ["w"]=> 20 | int(1) 21 | ["wtimeout"]=> 22 | int(10000) 23 | } 24 | object(MongoCollection)#%d (%d) { 25 | ["w"]=> 26 | int(1) 27 | ["wtimeout"]=> 28 | int(10000) 29 | } 30 | bool(true) 31 | -------------------------------------------------------------------------------- /tests/generic/bug00667.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Test for PHP-667: Off-by-one error in BSON deserialization of pre-epoch dates 3 | --SKIPIF-- 4 | 5 | 6 | --INI-- 7 | date.timezone=UTC 8 | --FILE-- 9 | selectCollection(dbname(), 'bug667'); 14 | $c->drop(); 15 | 16 | $mongoDate = new MongoDate(strtotime('1900-01-01 UTC')); 17 | $c->insert(array('date' => $mongoDate)); 18 | 19 | $document = $c->findOne(); 20 | 21 | printf("%s\n", $mongoDate); 22 | printf("%s\n", $document['date']); 23 | 24 | --EXPECT-- 25 | 0.00000000 -2208988800 26 | 0.00000000 -2208988800 27 | -------------------------------------------------------------------------------- /tests/generic/bug00680.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Test for PHP-680: mongo_read_preference_dtor() will segfault if invoked twice 3 | --SKIPIF-- 4 | 5 | --FILE-- 6 | 7 | setReadPreference(Mongo::RP_PRIMARY_PREFERRED, array(array('dc' => 'east')))); 11 | var_dump($m->setReadPreference(Mongo::RP_PRIMARY_PREFERRED, array('not_an_array'))); 12 | 13 | ?> 14 | --EXPECTF-- 15 | bool(true) 16 | 17 | Warning: MongoClient::setReadPreference(): Tagset 1 needs to contain an array of 0 or more tags in %s on line %d 18 | bool(false) 19 | -------------------------------------------------------------------------------- /tests/generic/bug00687.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Test for PHP-687: MongoDate usec not decoded correctly on 32-bit platform 3 | --SKIPIF-- 4 | 5 | --FILE-- 6 | selectCollection(dbname(), 'bug687'); 11 | $c->drop(); 12 | 13 | $date = new MongoDate(); 14 | $c->insert(array('d' => $date)); 15 | $doc = $c->findOne(); 16 | 17 | var_dump($date == $doc['d']); 18 | 19 | ?> 20 | --EXPECT-- 21 | bool(true) 22 | -------------------------------------------------------------------------------- /tests/generic/bug00690.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Test for PHP-690: Percentage symbol is not escaped in error messages 3 | --SKIPIF-- 4 | 5 | --FILE-- 6 | selectCollection(dbname(), 'bug690'); 10 | $c->drop(); 11 | 12 | $c->insert(array('_id'=>'hello%20London', 'added'=>time())); 13 | try 14 | { 15 | $c->insert(array('_id'=>'hello%20London', 'added'=>time())); 16 | } 17 | catch ( Exception $e ) 18 | { 19 | echo $e->getMessage(), "\n"; 20 | } 21 | 22 | ?> 23 | --EXPECTF-- 24 | %s:%d:%s { : "hello%20London" } 25 | -------------------------------------------------------------------------------- /tests/generic/bug00776.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Test for PHP-776: MongoCollection::batchInsert() with empty options array segfaults 3 | --SKIPIF-- 4 | 5 | --FILE-- 6 | 1), 11 | array('_id' => 2), 12 | ); 13 | 14 | $m = mongo_standalone(); 15 | $c = $m->selectCollection(dbname(), 'bug00776'); 16 | $c->drop(); 17 | 18 | $c->batchInsert($documents, array()); 19 | 20 | var_dump($c->count()); 21 | ?> 22 | --EXPECT-- 23 | int(2) 24 | -------------------------------------------------------------------------------- /tests/generic/bug00795.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Test for PHP-795: MongoCode segfaults when internal 'code' property is modified 3 | --FILE-- 4 | code = new stdclass; 14 | var_dump((string)$m); 15 | ?> 16 | --EXPECTF-- 17 | %s: The 'code' property is read-only in %s on line %d 18 | string(4) "bacd" 19 | -------------------------------------------------------------------------------- /tests/generic/bug00801.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Test for PHP-801: Deprecate boolean options to MongoCollection::insert(). 3 | --SKIPIF-- 4 | 5 | --FILE-- 6 | selectDB(dbname()); 12 | $c = $d->bug801; 13 | $c->drop(); 14 | 15 | $c->insert(array('foo' => 1), true); 16 | ?> 17 | --EXPECTF-- 18 | %s: Argument 2 passed to MongoCollection::insert() must be %s array, boolean given in %sbug00801.php on line %d 19 | -------------------------------------------------------------------------------- /tests/generic/bug00802.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Test for PHP-802: Deprecate boolean options to MongoCollection::ensureIndex(). 3 | --SKIPIF-- 4 | 5 | --FILE-- 6 | selectDB(dbname()); 12 | $c = $d->bug802; 13 | 14 | $c->ensureIndex(array('foo' => 1), true); 15 | ?> 16 | --EXPECTF-- 17 | %s: Argument 2 passed to MongoCollection::ensureIndex() must be %s array, boolean given in %sbug00802.php on line %d 18 | -------------------------------------------------------------------------------- /tests/generic/bug00804.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Test for PHP-804: Deprecate Mongo::connectUtil. 3 | --SKIPIF-- 4 | 5 | --FILE-- 6 | connectUtil(); 21 | ?> 22 | --EXPECTF-- 23 | %s: Function Mongo::connectUtil() is deprecated in %sbug00804.php on line %d 24 | -------------------------------------------------------------------------------- /tests/generic/bug00805.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Test for PHP-805: Deprecate the "chunks" option in MongoGridFS::__construct. 3 | --SKIPIF-- 4 | 5 | --FILE-- 6 | selectDB(dbname()); 10 | 11 | $gridfs = new MongoGridFS($db, "foo", "bar"); 12 | $gridfs = $db->getGridFS("foo", "bar"); 13 | ?> 14 | --EXPECTF-- 15 | %s: MongoGridFS::__construct(): The 'chunks' argument is deprecated and ignored in %sbug00805.php on line %d 16 | 17 | %s: MongoDB::getGridFS(): The 'chunks' argument is deprecated and ignored in %sbug00805.php on line %d 18 | -------------------------------------------------------------------------------- /tests/generic/bug01231.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Test for PHP-1231: PHP crashed when using selectCollection inside a Generator 3 | --SKIPIF-- 4 | 5 | =')) echo "skip >= PHP 5.5 needed\n"; ?> 6 | --INI-- 7 | mongo.long_as_object=0 8 | --FILE-- 9 | selectCollection(dbname(), collname(__FILE__)); 17 | yield 1; 18 | }; 19 | 20 | foreach(a($host) as $file) { 21 | var_dump($file); 22 | } 23 | 24 | echo "ALIVE\n"; 25 | ?> 26 | --EXPECT-- 27 | int(1) 28 | ALIVE 29 | -------------------------------------------------------------------------------- /tests/generic/bug01390-001.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Test for PHP-1390: hasNext() should return true before advancing to a single result 3 | --SKIPIF-- 4 | 5 | --FILE-- 6 | selectDb(dbname()); 13 | $c = $m->selectCollection(dbname(), collname(__FILE__)); 14 | $c->drop(); 15 | 16 | $c->save(array('_id' => 'test1')); 17 | 18 | $cursor = $c->find(); 19 | 20 | var_dump($cursor->hasNext()); 21 | var_dump($cursor->getNext()); 22 | var_dump($cursor->hasNext()); 23 | 24 | ?> 25 | --EXPECT-- 26 | bool(true) 27 | array(1) { 28 | ["_id"]=> 29 | string(5) "test1" 30 | } 31 | bool(false) 32 | -------------------------------------------------------------------------------- /tests/generic/bug01390-002.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Test for PHP-1390: hasNext() should return false when there is an empty result 3 | --SKIPIF-- 4 | 5 | --FILE-- 6 | selectDb(dbname()); 13 | $c = $m->selectCollection(dbname(), collname(__FILE__)); 14 | $c->drop(); 15 | 16 | $cursor = $c->find(); 17 | 18 | var_dump($cursor->hasNext()); 19 | var_dump($cursor->getNext()); 20 | var_dump($cursor->hasNext()); 21 | 22 | ?> 23 | --EXPECT-- 24 | bool(false) 25 | NULL 26 | bool(false) 27 | -------------------------------------------------------------------------------- /tests/generic/bug01402-001.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Test for PHP-1402: Fix for PHP-1394 caused hasNext() regression error from PHP-1382 when limiting to 1 3 | --SKIPIF-- 4 | 5 | --FILE-- 6 | selectCollection(dbname(), collname(__FILE__)); 13 | $coll->remove(); 14 | $coll->save(array('_id' => 'test1')); 15 | $cur = $coll->find(array('_id' => new MongoRegex('/^test.*$/')), array('_id' => 1))->limit(1); 16 | 17 | while ($cur->hasNext()) { 18 | $arr = $cur->getNext(); 19 | var_dump($arr['_id']); 20 | } 21 | ?> 22 | ===DONE=== 23 | --EXPECTF-- 24 | string(5) "test1" 25 | ===DONE=== 26 | -------------------------------------------------------------------------------- /tests/generic/collection-index-sparse.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Indexes: Sparse 3 | --SKIPIF-- 4 | 5 | --FILE-- 6 | phpunit; 10 | 11 | $db->people->drop(); 12 | $db->people->ensureIndex(array('title' => true), array('sparse' => true)); 13 | $db->people->insert(array('name' => 'Jim')); 14 | $db->people->insert(array('name' => 'Bones', 'title' => 'Doctor')); 15 | 16 | $indexes = $db->people->getIndexInfo(); 17 | // Index 0 is _id 18 | var_dump($indexes[1]["name"], $indexes[1]["sparse"]); 19 | 20 | $db->people->drop(); 21 | ?> 22 | --EXPECT-- 23 | string(7) "title_1" 24 | bool(true) 25 | -------------------------------------------------------------------------------- /tests/generic/connection-fork-001.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Test for forking and connection management (1) 3 | --SKIPIF-- 4 | 5 | 6 | --FILE-- 7 | selectDb("phpunit")->fork; 13 | 14 | $col->drop(); 15 | $col->insert(array("parent" => time()), array("w" => 1)); 16 | 17 | $pid = pcntl_fork(); 18 | if ($pid == 0) { 19 | $col->count(); 20 | exit; 21 | } 22 | 23 | $n = 0; 24 | while($n++ < 1000) { 25 | $col->insert(array("parent" => time()), array("w" => 1)); 26 | } 27 | 28 | echo $col->count(), "\n"; 29 | ?> 30 | --EXPECT-- 31 | 1001 32 | -------------------------------------------------------------------------------- /tests/generic/connection-fork-002.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Test for forking and connection management (2) 3 | --SKIPIF-- 4 | 5 | 6 | --FILE-- 7 | selectDb("phpunit")->fork; 14 | 15 | $col->drop(); 16 | $col->insert(array("parent" => time()), array("w" => 1)); 17 | 18 | $pid = pcntl_fork(); 19 | if ($pid == 0) { 20 | $n = 0; 21 | while($n++ < 1000) { 22 | $col->insert(array("parent" => time()), array("w" => 1)); 23 | } 24 | 25 | echo $col->count(), "\n"; 26 | } else { 27 | echo $col->count(), "\n"; 28 | } 29 | ?> 30 | --EXPECT-- 31 | 1 32 | 1001 33 | -------------------------------------------------------------------------------- /tests/generic/connection-multiple.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Connection strings: Test multiple host names with/without port 3 | --SKIPIF-- 4 | 13 | --FILE-- 14 | connected); 23 | $b = new Mongo("$hostname:$port,$ip:$port"); 24 | var_dump($b->connected); 25 | ?> 26 | --EXPECT-- 27 | bool(true) 28 | bool(true) 29 | -------------------------------------------------------------------------------- /tests/generic/connection-single.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Connection strings: Test single host name with/without port 3 | --SKIPIF-- 4 | 12 | --FILE-- 13 | 24 | --EXPECT-- 25 | bool(true) 26 | bool(true) 27 | -------------------------------------------------------------------------------- /tests/generic/connection-single_error-001.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Connection strings: Incorrect connection string (1) 3 | --SKIPIF-- 4 | 13 | --FILE-- 14 | connected); 19 | ?> 20 | --EXPECTF-- 21 | Fatal error: Uncaught exception 'MongoConnectionException' with message 'Failed to connect to: http:0: %s' in %sconnection-single_error-001.php:%d 22 | Stack trace: 23 | #0 %sconnection-single_error-001.php(4): Mongo->__construct('http://foofas:5...') 24 | #1 {main} 25 | thrown in %sconnection-single_error-001.php on line %d 26 | -------------------------------------------------------------------------------- /tests/generic/connection-single_error-002.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Connection strings: Incorrect connection string (2) 3 | --SKIPIF-- 4 | 13 | --FILE-- 14 | connected); 19 | ?> 20 | --EXPECTF-- 21 | Fatal error: Uncaught exception 'MongoConnectionException' with message 'Failed to connect to: foofas:5345: %s' in %sconnection-single_error-002.php:%d 22 | Stack trace: 23 | #0 %sconnection-single_error-002.php(%d): Mongo->__construct('foofas:5345') 24 | #1 {main} 25 | thrown in %sconnection-single_error-002.php on line %d 26 | -------------------------------------------------------------------------------- /tests/generic/connection-single_error-003.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Connection strings: Unconnectable host/port (3) 3 | --SKIPIF-- 4 | 13 | --FILE-- 14 | connected); 19 | ?> 20 | --EXPECTF-- 21 | Fatal error: Uncaught exception 'MongoConnectionException' with message '%s' in %sconnection-single_error-003.php:%d 22 | Stack trace: 23 | #0 %sconnection-single_error-003.php(%d): Mongo->__construct('mongodb://foofa...') 24 | #1 {main} 25 | thrown in %sconnection-single_error-003.php on line %d 26 | -------------------------------------------------------------------------------- /tests/generic/connection-with-auth-failure.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Connection strings: unsuccesfull authentication 3 | --SKIPIF-- 4 | 5 | --FILE-- 6 | $db->collection->findOne(); 18 | } catch (Exception $e) { 19 | echo $e->getMessage(), "\n"; 20 | } 21 | ?> 22 | --EXPECTF-- 23 | Failed to connect to: %s:%d:%sAuthentication failed on database '%s'%s 24 | -------------------------------------------------------------------------------- /tests/generic/connection-with-auth-successfull.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Connection strings: succesfull authentication 3 | --SKIPIF-- 4 | 5 | --FILE-- 6 | 7 | connected); 10 | echo $a, "\n"; 11 | ?> 12 | --EXPECTF-- 13 | bool(true) 14 | %s 15 | -------------------------------------------------------------------------------- /tests/generic/connection-with-database-name-and-port.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Connection strings: with database name and port 3 | --SKIPIF-- 4 | 5 | --FILE-- 6 | 18 | --EXPECT-- 19 | -------------------------------------------------------------------------------- /tests/generic/connection-with-database-name.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Connection strings: with database name 3 | --SKIPIF-- 4 | 5 | --FILE-- 6 | 12 | --EXPECTF-- 13 | -------------------------------------------------------------------------------- /tests/generic/database-createcollection.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Database: Create collection 3 | --SKIPIF-- 4 | 5 | --FILE-- 6 | selectDb(dbname()); 12 | 13 | // cleanup 14 | $d->dropCollection('create-col1'); 15 | var_dump(findCollection($d, 'create-col1')); 16 | 17 | // create 18 | $d->createCollection('create-col1'); 19 | $retval = findCollection($d, 'create-col1'); 20 | var_dump($retval['name']); 21 | 22 | ?> 23 | --EXPECT-- 24 | NULL 25 | string(11) "create-col1" 26 | -------------------------------------------------------------------------------- /tests/generic/database-dropcollection-memory-test.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Database: Dropping collections (memory test) 3 | --SKIPIF-- 4 | 5 | --FILE-- 6 | selectDb("phpunit"); 10 | $ns = $d->selectCollection('system.namespaces'); 11 | 12 | // drop the collection 100 times 13 | $u = memory_get_usage(true); 14 | for ($i = 0; $i < 100; $i++) { 15 | $d->dropCollection($d->dropcoltest); 16 | } 17 | var_dump($u - memory_get_usage(true)); 18 | 19 | // drop the collection 100 times 20 | $u = memory_get_usage(true); 21 | for ($i = 0; $i < 100; $i++) { 22 | $d->dropCollection('dropcoltest'); 23 | } 24 | var_dump($u - memory_get_usage(true)); 25 | 26 | ?> 27 | --EXPECT-- 28 | int(0) 29 | int(0) 30 | -------------------------------------------------------------------------------- /tests/generic/database-tostring.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Database: toString. 3 | --SKIPIF-- 4 | 5 | --FILE-- 6 | selectDb("phpunit"); 10 | echo $d, "\n"; 11 | echo $d->__toString(), "\n"; 12 | ?> 13 | --EXPECT-- 14 | phpunit 15 | phpunit 16 | -------------------------------------------------------------------------------- /tests/generic/database-valid-name.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Database: valid name checks 3 | --SKIPIF-- 4 | 5 | --FILE-- 6 | getMessage(), "\n"; 16 | } 17 | } 18 | ?> 19 | --EXPECT-- 20 | \: Database name contains invalid characters: \ 21 | $: Database name contains invalid characters: $ 22 | /: Database name contains invalid characters: / 23 | foo.bar: Database name contains invalid characters: foo.bar 24 | $external: OK 25 | run$fores: Database name contains invalid characters: run$fores 26 | -------------------------------------------------------------------------------- /tests/generic/gridfs-memory-leak-1.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | GridFS: Testing minor memory issue 3 | --SKIPIF-- 4 | 5 | --FILE-- 6 | phpunit; 10 | 11 | $grid = $db->getGridFS(); 12 | 13 | $grid->storeBytes('some thing', array('filename' => '1.txt'), array('w' => true)); 14 | 15 | echo "No memory leak"; 16 | --EXPECT-- 17 | No memory leak 18 | -------------------------------------------------------------------------------- /tests/generic/gridfs-memory-leak-2.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | GridFS: Testing minor memory issue 3 | --SKIPIF-- 4 | 5 | --FILE-- 6 | phpunit; 10 | 11 | $grid = $db->getGridFS(); 12 | 13 | $grid->storeBytes('some thing', array('filename' => '1.txt')); 14 | 15 | echo "No memory leak"; 16 | --EXPECT-- 17 | No memory leak 18 | -------------------------------------------------------------------------------- /tests/generic/ini-mongo_allow_empty_keys.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | "mongo.allow_empty_keys" INI option 3 | --SKIPIF-- 4 | 5 | --FILE-- 6 | selectCollection(dbname(), 'allow_empty_keys'); 10 | $coll->drop(); 11 | 12 | ini_set('mongo.allow_empty_keys', true); 13 | 14 | $coll->insert(array('_id' => 1, '' => 'foo')); 15 | $result = $coll->findOne(array('_id' => 1)); 16 | var_dump($result['']); 17 | ?> 18 | --EXPECT-- 19 | string(3) "foo" 20 | -------------------------------------------------------------------------------- /tests/generic/ini-mongo_cmd-001.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Custom "mongo.cmd" INI option with modifier operations 3 | --SKIPIF-- 4 | 5 | --FILE-- 6 | selectCollection(dbname(), 'bar'); 10 | $coll->drop(); 11 | 12 | ini_set('mongo.cmd', '!'); 13 | $coll->insert(array('_id' => 1, 'name' => 'example.com')); 14 | 15 | $coll->update(array('_id' => 1), array('!set' => array('name' => 'google.com'))); 16 | $result = $coll->findOne(); 17 | echo $result['name'] . "\n"; 18 | 19 | ini_set('mongo.cmd', '#'); 20 | $coll->update(array('_id' => 1), array('#set' => array('name' => 'yahoo.com'))); 21 | $result = $coll->findOne(); 22 | echo $result['name'] . "\n"; 23 | ?> 24 | --EXPECT-- 25 | google.com 26 | yahoo.com 27 | -------------------------------------------------------------------------------- /tests/generic/ini-mongo_cmd-002.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Custom "mongo.cmd" INI option with namespaces 3 | --SKIPIF-- 4 | 5 | --FILE-- 6 | selectDB('admin'); 10 | 11 | ini_set('mongo.cmd', '@'); 12 | 13 | $cmd = $db->selectCollection('@cmd'); 14 | 15 | $info = $cmd->findOne(array('buildinfo' => 1)); 16 | var_dump(array_key_exists('version', $info)); 17 | var_dump(array_key_exists('gitVersion', $info)); 18 | var_dump(array_key_exists('sysInfo', $info)); 19 | ?> 20 | --EXPECT-- 21 | bool(true) 22 | bool(true) 23 | bool(true) 24 | -------------------------------------------------------------------------------- /tests/generic/ini-mongo_cmd-003.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Custom "mongo.cmd" INI option with references 3 | --SKIPIF-- 4 | 5 | --FILE-- 6 | selectCollection(dbname(), 'bar'); 10 | $coll->drop(); 11 | 12 | ini_set('mongo.cmd', ':'); 13 | 14 | $coll->insert(array('_id' => 123, 'hello' => 'world')); 15 | $coll->insert(array('_id' => 456, 'ref' => array(':ref' => 'bar', ':id' => 123))); 16 | 17 | $referrer = $coll->findOne(array('_id' => 456)); 18 | $referee = MongoDBRef::get($coll->db, $referrer['ref']); 19 | echo $referee['hello'] . "\n"; 20 | ?> 21 | --EXPECT-- 22 | world 23 | -------------------------------------------------------------------------------- /tests/generic/ini-mongo_native_long_64bit-001.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Enabled "mongo.native_long" INI option allows reading and writing of 64-bit integers 3 | --SKIPIF-- 4 | 5 | 6 | --FILE-- 7 | selectCollection(dbname(), 'mongo_native_long'); 11 | $coll->drop(); 12 | 13 | ini_set('mongo.native_long', true); 14 | 15 | $coll->insert(array('int64' => 9223372036854775807)); 16 | $result = $coll->findOne(); 17 | var_dump($result['int64']); 18 | ?> 19 | --EXPECT-- 20 | int(9223372036854775807) 21 | -------------------------------------------------------------------------------- /tests/generic/ini-mongo_native_long_64bit-002.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Disabled "mongo.native_long" INI option stores 32-bits of 64-bit integers 3 | --SKIPIF-- 4 | 5 | 6 | --FILE-- 7 | selectCollection(dbname(), 'mongo_native_long'); 11 | $coll->drop(); 12 | 13 | ini_set('mongo.native_long', false); 14 | 15 | $coll->insert(array('int64' => 9223372036854775807)); 16 | $result = $coll->findOne(); 17 | var_dump($result['int64']); 18 | ?> 19 | --EXPECT-- 20 | int(-1) 21 | -------------------------------------------------------------------------------- /tests/generic/ini-mongo_native_long_64bit-003.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Disabled "mongo.native_long" INI option reads 64-bit integers as floats 3 | --SKIPIF-- 4 | 5 | 6 | --FILE-- 7 | selectCollection(dbname(), 'mongo_native_long'); 11 | $coll->drop(); 12 | 13 | ini_set('mongo.native_long', true); 14 | 15 | $coll->insert(array('int64' => 9223372036854775807)); 16 | 17 | ini_set('mongo.native_long', false); 18 | 19 | $result = $coll->findOne(); 20 | var_dump($result['int64']); 21 | ?> 22 | --EXPECT-- 23 | float(9.2233720368548E+18) 24 | -------------------------------------------------------------------------------- /tests/generic/mongid-serialize.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | MongoID: serialize() and unserialize() 3 | --FILE-- 4 | 10 | --EXPECTF-- 11 | bool(true) 12 | -------------------------------------------------------------------------------- /tests/generic/mongo-forceerror-001.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Mongo::forceError() 3 | --SKIPIF-- 4 | 5 | --INI-- 6 | error_reporting=E_ALL & ~E_DEPRECATED 7 | --FILE-- 8 | array('log_query' => 'log_query'), 17 | )); 18 | 19 | $host = MongoShellServer::getStandaloneInfo(); 20 | $m = new Mongo($host, array(), array('context' => $ctx)); 21 | 22 | $m->forceError(); 23 | 24 | ?> 25 | ===DONE=== 26 | 27 | --EXPECT-- 28 | Issuing forceerror command on namespace: admin.$cmd 29 | ===DONE=== 30 | -------------------------------------------------------------------------------- /tests/generic/mongo-lasterror-001.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Mongo::lastError() 3 | --SKIPIF-- 4 | 5 | --INI-- 6 | error_reporting=E_ALL & ~E_DEPRECATED 7 | --FILE-- 8 | array('log_query' => 'log_query'), 17 | )); 18 | 19 | $host = MongoShellServer::getStandaloneInfo(); 20 | $m = new Mongo($host, array(), array('context' => $ctx)); 21 | 22 | $m->lastError(); 23 | 24 | ?> 25 | ===DONE=== 26 | 27 | --EXPECT-- 28 | Issuing getlasterror command on namespace: admin.$cmd 29 | ===DONE=== 30 | -------------------------------------------------------------------------------- /tests/generic/mongo-preverror-001.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Mongo::prevError() 3 | --SKIPIF-- 4 | 5 | --INI-- 6 | error_reporting=E_ALL & ~E_DEPRECATED 7 | --FILE-- 8 | array('log_query' => 'log_query'), 17 | )); 18 | 19 | $host = MongoShellServer::getStandaloneInfo(); 20 | $m = new Mongo($host, array(), array('context' => $ctx)); 21 | 22 | $m->prevError(); 23 | 24 | ?> 25 | ===DONE=== 26 | 27 | --EXPECT-- 28 | Issuing getpreverror command on namespace: admin.$cmd 29 | ===DONE=== 30 | -------------------------------------------------------------------------------- /tests/generic/mongo-reseterror-001.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Mongo::resetError() 3 | --SKIPIF-- 4 | 5 | --INI-- 6 | error_reporting=E_ALL & ~E_DEPRECATED 7 | --FILE-- 8 | array('log_query' => 'log_query'), 17 | )); 18 | 19 | $host = MongoShellServer::getStandaloneInfo(); 20 | $m = new Mongo($host, array(), array('context' => $ctx)); 21 | 22 | $m->resetError(); 23 | 24 | ?> 25 | ===DONE=== 26 | 27 | --EXPECT-- 28 | Issuing reseterror command on namespace: admin.$cmd 29 | ===DONE=== 30 | -------------------------------------------------------------------------------- /tests/generic/mongobindata-002.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | MongoBinData insertion with default type 3 | --SKIPIF-- 4 | 5 | --FILE-- 6 | selectCollection(dbname(), 'mongobindata'); 12 | $coll->drop(); 13 | 14 | $coll->insert(array('_id' => 1, 'bin' => new MongoBinData('abcdefg'))); 15 | 16 | $result = $coll->findOne(array('_id' => 1)); 17 | 18 | echo get_class($result['bin']) . "\n"; 19 | var_dump($result['bin']->bin); 20 | var_dump($result['bin']->type); 21 | ?> 22 | --EXPECTF-- 23 | MongoBinData 24 | string(7) "abcdefg" 25 | int(0) 26 | -------------------------------------------------------------------------------- /tests/generic/mongobindata-006.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | MongoBinData insertion with 4MB of binary data 3 | --SKIPIF-- 4 | 5 | --FILE-- 6 | selectCollection(dbname(), 'mongobindata'); 10 | $coll->drop(); 11 | 12 | $data = ''; 13 | 14 | for ($i = 0; $i < 1024; ++$i) { 15 | $data .= chr($i % 256); 16 | } 17 | 18 | $data = str_repeat($data, 4 * 1024); 19 | 20 | $coll->insert(array('_id' => 1, 'bin' => new MongoBinData($data, 0))); 21 | 22 | $result = $coll->findOne(array('_id' => 1)); 23 | 24 | var_dump($data === $result['bin']->bin); 25 | ?> 26 | --EXPECTF-- 27 | bool(true) 28 | -------------------------------------------------------------------------------- /tests/generic/mongoclient-dropdb-001.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | MongoClient::dropDB() with MongoDB argument 3 | --SKIPIF-- 4 | 5 | --FILE-- 6 | array('log_query' => 'log_query'), 15 | )); 16 | 17 | $host = MongoShellServer::getStandaloneInfo(); 18 | $mc = new MongoClient($host, array(), array('context' => $ctx)); 19 | $db = $mc->selectDB('test_mongoclient_dropdb'); 20 | 21 | $mc->dropDB($db); 22 | 23 | ?> 24 | ===DONE=== 25 | 26 | --EXPECT-- 27 | Issuing dropDatabase command on namespace: test_mongoclient_dropdb.$cmd 28 | ===DONE=== 29 | -------------------------------------------------------------------------------- /tests/generic/mongoclient-dropdb-002.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | MongoClient::dropDB() with string argument 3 | --SKIPIF-- 4 | 5 | --FILE-- 6 | array('log_query' => 'log_query'), 15 | )); 16 | 17 | $host = MongoShellServer::getStandaloneInfo(); 18 | $mc = new MongoClient($host, array(), array('context' => $ctx)); 19 | 20 | $mc->dropDB('test_mongoclient_dropdb'); 21 | 22 | ?> 23 | ===DONE=== 24 | 25 | --EXPECT-- 26 | Issuing dropDatabase command on namespace: test_mongoclient_dropdb.$cmd 27 | ===DONE=== 28 | -------------------------------------------------------------------------------- /tests/generic/mongoclient-listdbs-001.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Mongo::listDBs() 3 | --SKIPIF-- 4 | 5 | --FILE-- 6 | listDBs(); 11 | var_dump($dbs['ok']); 12 | var_dump(isset($dbs['totalSize'])); 13 | var_dump(isset($dbs['databases']) && is_array($dbs['databases'])); 14 | ?> 15 | --EXPECTF-- 16 | float(1) 17 | bool(true) 18 | bool(true) 19 | -------------------------------------------------------------------------------- /tests/generic/mongoclient-selectcollection-001.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Mongo::selectCollection() 3 | --SKIPIF-- 4 | 5 | --FILE-- 6 | selectCollection('db', 'collection'); 13 | 14 | echo get_class($collection), "\n"; 15 | echo (string) $collection, "\n"; 16 | ?> 17 | --EXPECT-- 18 | MongoCollection 19 | db.collection 20 | -------------------------------------------------------------------------------- /tests/generic/mongoclient-selectdb-001.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Mongo::selectDB() 3 | --SKIPIF-- 4 | 5 | --FILE-- 6 | selectDB('db'); 13 | 14 | echo get_class($db), "\n"; 15 | echo (string) $db, "\n"; 16 | ?> 17 | --EXPECT-- 18 | MongoDB 19 | db 20 | -------------------------------------------------------------------------------- /tests/generic/mongoclient-setreadpreference-003.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | MongoClient::setReadPreference() should allow empty tags parameter for primary mode 3 | --SKIPIF-- 4 | 5 | --FILE-- 6 | 7 | setReadPreference(Mongo::RP_PRIMARY, array())); 11 | var_dump($m->getReadPreference()); 12 | ?> 13 | --EXPECT-- 14 | bool(true) 15 | array(1) { 16 | ["type"]=> 17 | string(7) "primary" 18 | } 19 | -------------------------------------------------------------------------------- /tests/generic/mongoclient-setreadpreference_error-003.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | MongoClient::setReadPreference() error setting tag sets for primary read preference mode 3 | --SKIPIF-- 4 | 5 | --FILE-- 6 | 7 | setReadPreference(MongoClient::RP_PRIMARY, array( array( 'foo' => 'bar' ) ) ); 11 | $rp = $m->getReadPreference(); 12 | var_dump($rp); 13 | ?> 14 | --EXPECTF-- 15 | Warning: MongoClient::setReadPreference(): You can't use read preference tags with a read preference of PRIMARY in %s on line %d 16 | array(1) { 17 | ["type"]=> 18 | string(7) "primary" 19 | } 20 | -------------------------------------------------------------------------------- /tests/generic/mongocode-002.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | MongoCode insertion with atypical code strings 3 | --SKIPIF-- 4 | 5 | --FILE-- 6 | selectCollection(dbname(), 'mongocode'); 10 | $coll->drop(); 11 | 12 | $coll->insert(array('_id' => 1, 'code' => new MongoCode(3))); 13 | $result = $coll->findOne(array('_id' => 1)); 14 | var_dump($result['code']->code); 15 | 16 | $coll->insert(array('_id' => 2, 'code' => new MongoCode(null))); 17 | $result = $coll->findOne(array('_id' => 2)); 18 | var_dump($result['code']->code); 19 | ?> 20 | --EXPECT-- 21 | string(1) "3" 22 | string(0) "" 23 | -------------------------------------------------------------------------------- /tests/generic/mongocollection-count_error-001.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | MongoCollection::count() requires query to be a hash 3 | --SKIPIF-- 4 | 5 | --FILE-- 6 | 7 | selectCollection(dbname(), collname(__FILE__)); 12 | $c->drop(); 13 | 14 | $c->insert(array('x' => 1)); 15 | $c->insert(array('x' => 2)); 16 | $c->insert(array('x' => 3)); 17 | $c->insert(array('x' => 4)); 18 | 19 | var_dump($c->count(array())); 20 | var_dump($c->count(new stdClass())); 21 | var_dump($c->count(0)); 22 | 23 | ?> 24 | ===DONE=== 25 | --EXPECTF-- 26 | int(4) 27 | int(4) 28 | 29 | Warning: MongoCollection::count() expects parameter 1 to be array, integer given in %s on line %d 30 | NULL 31 | ===DONE=== 32 | -------------------------------------------------------------------------------- /tests/generic/mongocollection-createdbref-002.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | MongoCollection::createDBRef() with missing _id field in array/object 3 | --SKIPIF-- 4 | 5 | --FILE-- 6 | 7 | database->collection->createDBRef(array())); 13 | var_dump($mongo->database->collection->createDBRef((object) array())); 14 | 15 | ?> 16 | --EXPECTF-- 17 | NULL 18 | array(2) { 19 | ["$ref"]=> 20 | string(10) "collection" 21 | ["$id"]=> 22 | object(stdClass)#%d (0) { 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /tests/generic/mongocollection-createindex_error-002.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | MongoCollection::createIndex() error if namespace exceeds 127 bytes (legacy) 3 | --SKIPIF-- 4 | 5 | 6 | --FILE-- 7 | selectCollection(dbname(), collname(__FILE__)); 14 | 15 | try { 16 | $c->ensureIndex( 17 | array('x' => 1), 18 | array('name' => str_repeat('a', 200)) 19 | ); 20 | } catch (MongoException $e) { 21 | printf("error message: %s\n", $e->getMessage()); 22 | } 23 | 24 | ?> 25 | ===DONE=== 26 | --EXPECTF-- 27 | error message: %sname too long%s 28 | ===DONE=== 29 | -------------------------------------------------------------------------------- /tests/generic/mongocollection-deleteindex_error.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | MongoCollection::deleteIndex() error with invalid params 3 | --SKIPIF-- 4 | 5 | --FILE-- 6 | $name; 11 | $c = $d->deleteIndex; 12 | $ns = $d->selectCollection('system.indexes'); 13 | $c->drop(); 14 | 15 | $c->ensureIndex( array( 'surname' => 1, 'name' => 1 ) ); 16 | var_dump( count( $c->getIndexInfo() ) ); 17 | 18 | echo "Wrong argument\n"; 19 | $c->deleteIndex( 42 ); 20 | var_dump( count( $c->getIndexInfo() ) ); 21 | ?> 22 | --EXPECTF-- 23 | int(2) 24 | Wrong argument 25 | 26 | Warning: MongoCollection::deleteIndex(): The key needs to be either a string or an array in %smongocollection-deleteindex_error.php on line %d 27 | int(2) 28 | -------------------------------------------------------------------------------- /tests/generic/mongocollection-deleteindexes-002.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | MongoCollection::deleteIndexes() uses dropIndexes command 3 | --SKIPIF-- 4 | 5 | --FILE-- 6 | array('log_query' => 'log_query'), 15 | )); 16 | 17 | $host = MongoShellServer::getStandaloneInfo(); 18 | $mc = new MongoClient($host, array(), array('context' => $ctx)); 19 | 20 | $collection = $mc->selectCollection(dbname(), collname(__FILE__)); 21 | $collection->deleteIndexes(); 22 | 23 | ?> 24 | ===DONE=== 25 | --EXPECTF-- 26 | array(2) { 27 | ["dropIndexes"]=> 28 | string(%d) "%s" 29 | ["index"]=> 30 | string(1) "*" 31 | } 32 | ===DONE=== 33 | -------------------------------------------------------------------------------- /tests/generic/mongocollection-distinct-001.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | MongoCollection::distinct() 3 | --SKIPIF-- 4 | 5 | --FILE-- 6 | 7 | selectCollection(dbname(), collname(__FILE__)); 12 | $c->drop(); 13 | 14 | $c->insert(array('x' => 1)); 15 | $c->insert(array('x' => 2)); 16 | $c->insert(array('x' => 2)); 17 | $c->insert(array('x' => 3)); 18 | 19 | printf("Distinct x values: %s\n", json_encode($c->distinct('x'))); 20 | printf("Distinct x values where x >= 2: %s\n", json_encode($c->distinct('x', array('x' => array('$gte' => 2))))); 21 | 22 | ?> 23 | ===DONE=== 24 | --EXPECT-- 25 | Distinct x values: [1,2,3] 26 | Distinct x values where x >= 2: [2,3] 27 | ===DONE=== 28 | -------------------------------------------------------------------------------- /tests/generic/mongocollection-ensureindex_error-001.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | MongoCollection::ensureIndex() error if namespace exceeds 127 bytes (legacy) 3 | --SKIPIF-- 4 | 5 | 6 | --FILE-- 7 | selectCollection(dbname(), collname(__FILE__)); 14 | 15 | try { 16 | $c->ensureIndex( 17 | array('x' => 1), 18 | array('name' => str_repeat('a', 200)) 19 | ); 20 | } catch (MongoException $e) { 21 | printf("error message: %s\n", $e->getMessage()); 22 | } 23 | 24 | ?> 25 | ===DONE=== 26 | --EXPECTF-- 27 | error message: %sname too long%s 28 | ===DONE=== 29 | -------------------------------------------------------------------------------- /tests/generic/mongocollection-getdbref-001.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | MongoCollection::getDBRef() 3 | --SKIPIF-- 4 | 5 | 6 | --FILE-- 7 | selectCollection(dbname(), 'dbref'); 12 | $coll1->drop(); 13 | $coll1->insert(array('_id' => 123, 'x' => 'foo')); 14 | 15 | $coll2 = $mongo->selectCollection('test2', 'dbref2'); 16 | $coll2->drop(); 17 | $coll2->insert(array('_id' => 456, 'x' => 'bar')); 18 | 19 | $result = $coll1->getDBRef(MongoDBRef::create('dbref', 123)); 20 | echo $result['x'] . "\n"; 21 | 22 | $result = $coll1->getDBRef(MongoDBRef::create('dbref2', 456, 'test2')); 23 | echo $result['x'] . "\n"; 24 | ?> 25 | --EXPECT-- 26 | foo 27 | bar 28 | -------------------------------------------------------------------------------- /tests/generic/mongocollection-getdbref_error-001.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | MongoCollection::getDBRef() returns null if reference parameter is invalid 3 | --SKIPIF-- 4 | 5 | --FILE-- 6 | selectCollection(dbname(), 'dbref'); 10 | 11 | var_dump($coll->getDBRef(array())); 12 | var_dump($coll->getDBRef(array('$ref' => 'dbref'))); 13 | var_dump($coll->getDBRef(array('$id' => 123))); 14 | ?> 15 | --EXPECT-- 16 | NULL 17 | NULL 18 | NULL 19 | -------------------------------------------------------------------------------- /tests/generic/mongocollection-getdbref_error-002.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | MongoCollection::getDBRef() throws exception if $ref or $db fields are not strings 3 | --SKIPIF-- 4 | 5 | --FILE-- 6 | selectCollection(dbname(), 'dbref'); 10 | 11 | try { 12 | $coll->getDBRef(array('$ref' => 1, '$id' => 2)); 13 | } catch (Exception $e) { 14 | printf("%s: %s\n", get_class($e), $e->getCode()); 15 | } 16 | 17 | try { 18 | $coll->getDBRef(array('$ref' => 'dbref', '$id' => 2, '$db' => 3)); 19 | } catch (Exception $e) { 20 | printf("%s: %d\n", get_class($e), $e->getCode()); 21 | } 22 | ?> 23 | --EXPECT-- 24 | MongoException: 10 25 | MongoException: 11 26 | -------------------------------------------------------------------------------- /tests/generic/mongocollection-getindexinfo-002.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | MongoCollection::getIndexInfo() with non-existent collection 3 | --SKIPIF-- 4 | 5 | --FILE-- 6 | selectCollection(dbname(), collname(__FILE__)); 12 | 13 | $c->drop(); 14 | 15 | var_dump($c->getIndexInfo()); 16 | 17 | ?> 18 | ===DONE=== 19 | --EXPECT-- 20 | array(0) { 21 | } 22 | ===DONE=== 23 | -------------------------------------------------------------------------------- /tests/generic/mongocollection-getname.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | MongoCollection::getName() 3 | --SKIPIF-- 4 | 5 | --FILE-- 6 | phpunit->col; 11 | echo "Working with collection " . $c->getName() . ".\n"; 12 | $c = $m->phpunit->col->foo; 13 | echo "Working with collection " . $c->getName() . ".\n"; 14 | $c = $m->phpunit->col->foo->bar; 15 | echo "Working with collection " . $c->getName() . ".\n"; 16 | ?> 17 | --EXPECT-- 18 | Working with collection col. 19 | Working with collection col.foo. 20 | Working with collection col.foo.bar. 21 | -------------------------------------------------------------------------------- /tests/generic/mongocollection-getname_error.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | MongoCollection::getName() 3 | --SKIPIF-- 4 | 5 | --FILE-- 6 | phpunit->col; 11 | // testing an unneeded parameter 12 | echo "Working with collection " . $c->getName('test') . ".\n"; 13 | ?> 14 | --EXPECT-- 15 | Working with collection col. 16 | -------------------------------------------------------------------------------- /tests/generic/mongocollection-getserver_error.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | MongoCollection::getServer() 3 | --DESCRIPTION-- 4 | Test for error when trying to insert something in a collection when 5 | no server is attached to it. 6 | --SKIPIF-- 7 | 8 | --FILE-- 9 | insert(array('hello' => 'Hello, world!', 0 => 'Joehoe')); 15 | } 16 | } 17 | catch (Exception $e) 18 | { 19 | echo $e->getMessage(); 20 | } 21 | ?> 22 | --EXPECTF-- 23 | Warning: MongoCollection::__construct() expects exactly 2 parameters, 0 given in %smongocollection-getserver_error.php on line %d 24 | -------------------------------------------------------------------------------- /tests/generic/mongocollection-getslaveokay.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | MongoCollection::getSlaveOkay() 3 | --DESCRIPTION-- 4 | Test both true and false for slave_okay attribute 5 | --SKIPIF-- 6 | 7 | --FILE-- 8 | phpunit->col; 13 | $c->setSlaveOkay((bool) array('foo')); 14 | var_dump($c->getSlaveOkay()); 15 | $c->setSlaveOkay((bool) null); 16 | var_dump($c->getSlaveOkay()); 17 | ?> 18 | --EXPECTF-- 19 | %s: Function MongoCollection::setSlaveOkay() is deprecated in %s on line %d 20 | 21 | %s: Function MongoCollection::getSlaveOkay() is deprecated in %s on line %d 22 | bool(true) 23 | 24 | %s: Function MongoCollection::setSlaveOkay() is deprecated in %s on line %d 25 | 26 | %s: Function MongoCollection::getSlaveOkay() is deprecated in %s on line %d 27 | bool(false) 28 | 29 | -------------------------------------------------------------------------------- /tests/generic/mongocollection-insert-001.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | MongoCollection::insert() encodes arrays as objects 3 | --SKIPIF-- 4 | 5 | --FILE-- 6 | selectCollection(dbname(), 'insert'); 10 | $coll->drop(); 11 | 12 | $coll->insert(array('foo', 'bar')); 13 | $result = $coll->findOne(); 14 | var_dump($result['0']); 15 | var_dump($result['1']); 16 | 17 | $coll->drop(); 18 | 19 | $coll->insert(array(-2147483647 => 'xyz')); 20 | $result = $coll->findOne(); 21 | var_dump($result['-2147483647']); 22 | ?> 23 | --EXPECT-- 24 | string(3) "foo" 25 | string(3) "bar" 26 | string(3) "xyz" 27 | -------------------------------------------------------------------------------- /tests/generic/mongocollection-insert_error-003.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | MongoCollection::insert() error with excessive document size 3 | --SKIPIF-- 4 | 5 | --FILE-- 6 | selectCollection(dbname(), 'insert'); 10 | $coll->drop(); 11 | 12 | try { 13 | $coll->insert(array('str' => str_repeat('a', 16 * 1024 * 1024))); 14 | } catch (Exception $e) { 15 | printf("%s: %d\n", get_class($e), $e->getCode()); 16 | } 17 | ?> 18 | --EXPECT-- 19 | MongoException: 3 20 | -------------------------------------------------------------------------------- /tests/generic/mongocollection-insert_error-004.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | MongoCollection::insert() error with zero-length keys 3 | --SKIPIF-- 4 | 5 | --FILE-- 6 | selectCollection(dbname(), 'insert'); 10 | $coll->drop(); 11 | 12 | $documents = array( 13 | array('' => 'foo'), 14 | array('x' => array('' => 'foo')), 15 | array('x' => array('' => 'foo'), 'y' => 'z'), 16 | ); 17 | 18 | foreach ($documents as $document) { 19 | try { 20 | $coll->insert($document); 21 | } catch (Exception $e) { 22 | printf("%s: %d\n", get_class($e), $e->getCode()); 23 | } 24 | } 25 | ?> 26 | --EXPECT-- 27 | MongoException: 1 28 | MongoException: 1 29 | MongoException: 1 30 | -------------------------------------------------------------------------------- /tests/generic/mongocollection-insert_error-005.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | MongoCollection::insert() error with dot characters in keys 3 | --SKIPIF-- 4 | 5 | --FILE-- 6 | selectCollection(dbname(), 'insert'); 10 | $coll->drop(); 11 | 12 | try { 13 | $coll->insert(array('x.y' => 'z')); 14 | } catch (Exception $e) { 15 | printf("%s: %d\n", get_class($e), $e->getCode()); 16 | } 17 | ?> 18 | --EXPECT-- 19 | MongoException: 2 20 | -------------------------------------------------------------------------------- /tests/generic/mongocollection-remove_error-001.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | MongoCollection::remove() error with non-UTF8 strings 3 | --SKIPIF-- 4 | 5 | --FILE-- 6 | selectCollection(dbname(), 'remove'); 10 | $coll->drop(); 11 | 12 | try { 13 | $coll->remove(array('foo' => "\xFE\xF0")); 14 | } catch (Exception $e) { 15 | printf("%s: %d\n", get_class($e), $e->getCode()); 16 | } 17 | ?> 18 | --EXPECT-- 19 | MongoException: 12 20 | -------------------------------------------------------------------------------- /tests/generic/mongocollection-setreadpreference-003.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | MongoCollection::setReadPreference() should allow empty tags parameter for primary mode 3 | --SKIPIF-- 4 | 5 | --FILE-- 6 | 7 | phpunit->test; 11 | var_dump($c->setReadPreference(Mongo::RP_PRIMARY, array())); 12 | var_dump($c->getReadPreference()); 13 | ?> 14 | --EXPECT-- 15 | bool(true) 16 | array(1) { 17 | ["type"]=> 18 | string(7) "primary" 19 | } 20 | -------------------------------------------------------------------------------- /tests/generic/mongocollection-setreadpreference_error-003.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | MongoCollection::setReadPreference() error setting tag sets for primary read preference mode 3 | --SKIPIF-- 4 | 5 | --FILE-- 6 | 7 | phpunit->test; 11 | $c->setReadPreference(Mongo::RP_PRIMARY, array( array( 'foo' => 'bar' ) ) ); 12 | $rp = $c->getReadPreference(); 13 | var_dump($rp); 14 | ?> 15 | --EXPECTF-- 16 | Warning: MongoCollection::setReadPreference(): You can't use read preference tags with a read preference of PRIMARY in %s on line %d 17 | array(1) { 18 | ["type"]=> 19 | string(7) "primary" 20 | } 21 | -------------------------------------------------------------------------------- /tests/generic/mongocollection-setslaveokay_error.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | MongoCollection::setSlaveOkay() 3 | --DESCRIPTION-- 4 | Test for a value that cannot convert to boolean 5 | --SKIPIF-- 6 | 7 | --FILE-- 8 | phpunit->col; 12 | var_dump($c->setSlaveOkay(array('error'))); 13 | ?> 14 | --EXPECTF-- 15 | %s: Function MongoCollection::setSlaveOkay() is deprecated in %s on line %d 16 | 17 | Warning: MongoCollection::setSlaveOkay() expects parameter 1 to be boolean, array given in %smongocollection-setslaveokay_error.php on line %d 18 | NULL 19 | -------------------------------------------------------------------------------- /tests/generic/mongocollection-tostring.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | MongoCollection::__toString() 3 | --DESCRIPTION-- 4 | Test implicit and explicit __toString 5 | --SKIPIF-- 6 | 7 | --FILE-- 8 | phpunit->col; 12 | echo "This is collection $c\n"; 13 | echo "This is collection ".$c->__toString()."\n"; 14 | $c = $m->selectCollection('phpunit', 'col2'); 15 | echo "This is collection $c\n"; 16 | echo "This is collection ".$c->__toString()."\n"; 17 | ?> 18 | --EXPECT-- 19 | This is collection phpunit.col 20 | This is collection phpunit.col 21 | This is collection phpunit.col2 22 | This is collection phpunit.col2 23 | -------------------------------------------------------------------------------- /tests/generic/mongocollection-update_error-001.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | MongoCollection::update() error with non-UTF8 strings 3 | --SKIPIF-- 4 | 5 | --FILE-- 6 | selectCollection(dbname(), 'update'); 10 | $coll->drop(); 11 | 12 | $coll->insert(array('_id' => 1, 'foo' => 'bar')); 13 | 14 | try { 15 | $coll->update(array('_id' => 1), array('$set' => array('foo' => "\xFE\xF0"))); 16 | } catch (Exception $e) { 17 | printf("%s: %d\n", get_class($e), $e->getCode()); 18 | } 19 | 20 | try { 21 | $coll->update(array('foo' => "\xFE\xF0"), array('$set' => array('foo' => 'bar'))); 22 | } catch (Exception $e) { 23 | printf("%s: %d\n", get_class($e), $e->getCode()); 24 | } 25 | ?> 26 | --EXPECT-- 27 | MongoException: 12 28 | MongoException: 12 29 | -------------------------------------------------------------------------------- /tests/generic/mongocursor-dead-001.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | MongoCursor::dead() with collection size equal to limit 3 | --SKIPIF-- 4 | 5 | --INI-- 6 | mongo.long_as_object=1 7 | --FILE-- 8 | selectCollection(dbname(), collname(__FILE__)); 12 | $c->drop(); 13 | 14 | $c->insert(array('test' => 1)); 15 | $c->insert(array('test' => 2)); 16 | 17 | $txlogs = $c->find()->limit(2); 18 | 19 | foreach($txlogs as $txlog) { 20 | echo ($txlogs->dead() ? "Dead" : "Not Dead") . "\n"; 21 | } 22 | echo ($txlogs->dead() ? "Dead" : "Not Dead") . "\n"; 23 | 24 | $info = $txlogs->info(); 25 | var_dump((string) $info['id']); 26 | ?> 27 | --EXPECTF-- 28 | Dead 29 | Dead 30 | Dead 31 | %s(1) "0" 32 | -------------------------------------------------------------------------------- /tests/generic/mongocursor-dead-002.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | MongoCursor::dead() with collection size greater than limit 3 | --SKIPIF-- 4 | 5 | --INI-- 6 | mongo.long_as_object=1 7 | --FILE-- 8 | selectCollection(dbname(), collname(__FILE__)); 12 | $c->drop(); 13 | 14 | $c->insert(array('test' => 1)); 15 | $c->insert(array('test' => 2)); 16 | $c->insert(array('test' => 3)); 17 | 18 | $txlogs = $c->find()->limit(2); 19 | 20 | foreach($txlogs as $txlog) { 21 | echo ($txlogs->dead() ? "Dead" : "Not Dead") . "\n"; 22 | } 23 | echo ($txlogs->dead() ? "Dead" : "Not Dead") . "\n"; 24 | 25 | $info = $txlogs->info(); 26 | var_dump((string) $info['id']); 27 | ?> 28 | --EXPECTF-- 29 | Not Dead 30 | Not Dead 31 | Dead 32 | %s(1) "0" 33 | -------------------------------------------------------------------------------- /tests/generic/mongocursor-kill-cursors_error.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | MongoCursor::killCursor() Testing faulty arguments 3 | --SKIPIF-- 4 | 5 | --FILE-- 6 | 13 | --EXPECTF-- 14 | Warning: MongoClient::killCursor(): A connection with hash 'This is a non existing hash' does not exist in %s on line %d 15 | bool(false) 16 | -------------------------------------------------------------------------------- /tests/generic/mongocursor-maxtimems_error.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | MongoCursor::maxTimeMS() (error) 3 | --SKIPIF-- 4 | 5 | --FILE-- 6 | selectDB(dbname()); 12 | $c = $d->maxtimems; 13 | $c->drop(); 14 | 15 | for ( $i = 0; $i < 2; $i++ ) 16 | { 17 | $c->insert(array('foo' => $i)); 18 | } 19 | 20 | $cursor = $c->find()->maxTimeMS(-1); 21 | try { 22 | foreach ($cursor as $foo) { 23 | } 24 | } catch (MongoCursorException $e) { 25 | echo get_class($e), "\n"; 26 | echo $e->getCode(), "\n"; 27 | echo $e->getMessage(), "\n"; 28 | } 29 | ?> 30 | --EXPECTF-- 31 | MongoCursorException 32 | 17287 33 | %s:%d:%sBadValue%smaxTimeMS%s 34 | -------------------------------------------------------------------------------- /tests/generic/mongocursor-next-001.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | MongoCollection::next() should not throw exceptions for "err" document fields 3 | --SKIPIF-- 4 | 5 | --FILE-- 6 | selectCollection(dbname(), 'mongocollection-next-001'); 13 | $c->drop(); 14 | 15 | $c->insert(array('_id' => 1, 'err' => 'foo')); 16 | var_dump($c->findOne(array('_id' => 1))); 17 | ?> 18 | --EXPECTF-- 19 | array(2) { 20 | ["_id"]=> 21 | int(1) 22 | ["err"]=> 23 | string(3) "foo" 24 | } 25 | -------------------------------------------------------------------------------- /tests/generic/mongocursor-setreadpreference-003.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | MongoCursor::setReadPreference() should allow empty tags parameter for primary mode 3 | --SKIPIF-- 4 | 5 | --FILE-- 6 | 7 | phpunit->test->find(); 11 | var_dump($c === $c->setReadPreference(Mongo::RP_PRIMARY, array())); 12 | var_dump($c->getReadPreference()); 13 | ?> 14 | --EXPECT-- 15 | bool(true) 16 | array(1) { 17 | ["type"]=> 18 | string(7) "primary" 19 | } 20 | -------------------------------------------------------------------------------- /tests/generic/mongocursor-setreadpreference_error-003.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | MongoCursor::setReadPreference() error setting tag sets for primary read preference mode 3 | --SKIPIF-- 4 | 5 | --FILE-- 6 | 7 | phpunit->test->find(); 11 | $c->setReadPreference(MongoClient::RP_PRIMARY, array( array( 'foo' => 'bar' ) ) ); 12 | $rp = $c->getReadPreference(); 13 | var_dump($rp); 14 | ?> 15 | --EXPECTF-- 16 | Warning: MongoCursor::setReadPreference(): You can't use read preference tags with a read preference of PRIMARY in %s on line %d 17 | array(1) { 18 | ["type"]=> 19 | string(7) "primary" 20 | } 21 | -------------------------------------------------------------------------------- /tests/generic/mongodate-006.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | MongoDate insertion 3 | --SKIPIF-- 4 | 5 | --FILE-- 6 | selectCollection(dbname(), 'mongodate'); 10 | $coll->drop(); 11 | 12 | $date = new MongoDate(); 13 | 14 | $coll->insert(array('_id' => 1, 'date' => $date)); 15 | $result = $coll->findOne(array('_id' => 1)); 16 | echo get_class($result['date']) . "\n"; 17 | var_dump($result['date']->sec === $date->sec); 18 | var_dump($result['date']->usec === $date->usec); 19 | ?> 20 | --EXPECT-- 21 | MongoDate 22 | bool(true) 23 | bool(true) 24 | -------------------------------------------------------------------------------- /tests/generic/mongodb-command_error-001.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | MongoDB::command() with unsupported database command 3 | --SKIPIF-- 4 | 5 | --FILE-- 6 | selectDb('phpunit'); 11 | $retval = $db->command(array()); 12 | var_dump($retval["errmsg"], $retval["ok"]); 13 | ?> 14 | --EXPECTF-- 15 | string(%d) "no such c%s" 16 | float(0) 17 | -------------------------------------------------------------------------------- /tests/generic/mongodb-command_error-002.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | MongoDB::command() requires hash argument to be passed by reference 3 | --SKIPIF-- 4 | 5 | --FILE-- 6 | selectDB(dbname()); 13 | $db->command(array('buildInfo' => 1), array(), 'foo'); 14 | ?> 15 | ===DONE=== 16 | --EXPECTF-- 17 | Fatal error: Cannot pass parameter 3 by reference in %s on line %d 18 | -------------------------------------------------------------------------------- /tests/generic/mongodb-createcollection.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | MongoDB::selectCollection() 3 | --SKIPIF-- 4 | 5 | --FILE-- 6 | selectDb(dbname()); 13 | $col = $db->createCollection("createcollection"); 14 | 15 | var_dump($col); 16 | ?> 17 | ===DONE=== 18 | --EXPECT-- 19 | object(MongoCollection)#3 (2) { 20 | ["w"]=> 21 | int(1) 22 | ["wtimeout"]=> 23 | int(10000) 24 | } 25 | ===DONE=== 26 | -------------------------------------------------------------------------------- /tests/generic/mongodb-createdbref-002.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | MongoDB::createDBRef() with missing _id field in array/object 3 | --SKIPIF-- 4 | 5 | --FILE-- 6 | 7 | database->createDBRef('collection', array())); 13 | var_dump($mongo->database->createDBRef('collection', (object) array())); 14 | 15 | ?> 16 | --EXPECTF-- 17 | NULL 18 | array(2) { 19 | ["$ref"]=> 20 | string(10) "collection" 21 | ["$id"]=> 22 | object(stdClass)#%d (0) { 23 | } 24 | } 25 | 26 | -------------------------------------------------------------------------------- /tests/generic/mongodb-drop.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | MongoDB::drop() Drop a database 3 | --SKIPIF-- 4 | 5 | --FILE-- 6 | 7 | selectDb(dbname()); 15 | $db->drop(); 16 | 17 | $db->collection->insert(array('_id' => 1)); 18 | var_dump($db->collection->count()); 19 | 20 | $db->drop(); 21 | 22 | $list = $m->listDBs(); 23 | 24 | foreach($list['databases'] as $database) { 25 | if ($database['name'] == (string) $db) { 26 | printf("FAILED to drop databse: %s\n", $db); 27 | } 28 | } 29 | ?> 30 | ===DONE=== 31 | --EXPECT-- 32 | int(1) 33 | ===DONE=== 34 | -------------------------------------------------------------------------------- /tests/generic/mongodb-dropcollection.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | MongoDB::selectCollection() 3 | --SKIPIF-- 4 | 5 | --FILE-- 6 | selectDb(dbname()); 13 | $col = $db->createCollection("dropcollection"); 14 | $col->insert(array('boo' => 'bar')); 15 | 16 | var_dump($db->dropCollection(0)); 17 | 18 | dump_these_keys($db->dropCollection('dropcollection'), array("nIndexesWas", "ns", "ok")); 19 | ?> 20 | --EXPECTF-- 21 | Warning: MongoDB::dropCollection(): expects parameter 1 to be an string or MongoCollection in %smongodb-dropcollection.php on line %d 22 | NULL 23 | array(3) { 24 | ["nIndexesWas"]=> 25 | %s(1) 26 | ["ns"]=> 27 | string(19) "test.dropcollection" 28 | ["ok"]=> 29 | float(1) 30 | } 31 | -------------------------------------------------------------------------------- /tests/generic/mongodb-get.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | MongoDB::selectCollection() 3 | --SKIPIF-- 4 | 5 | --FILE-- 6 | selectDb(dbname()); 13 | $col = $db->selectCollection; 14 | 15 | var_dump($col); 16 | ?> 17 | ===DONE=== 18 | --EXPECT-- 19 | object(MongoCollection)#3 (2) { 20 | ["w"]=> 21 | int(1) 22 | ["wtimeout"]=> 23 | int(10000) 24 | } 25 | ===DONE=== 26 | -------------------------------------------------------------------------------- /tests/generic/mongodb-getcollectioninfo-002.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Test for PHP-1378: MongoDB::getCollectionInfo() returns a numerically indexed array 3 | --SKIPIF-- 4 | 5 | --FILE-- 6 | selectDB(dbname()); 13 | 14 | $db->selectCollection(collname(__FILE__))->drop(); 15 | $db->createCollection(collname(__FILE__)); 16 | 17 | $collections = $db->getCollectionInfo(array('filter' => array('name' => collname(__FILE__)))); 18 | 19 | var_dump($collections[0]['name'] == collname(__FILE__)); 20 | 21 | ?> 22 | ===DONE=== 23 | --EXPECT-- 24 | bool(true) 25 | ===DONE=== 26 | -------------------------------------------------------------------------------- /tests/generic/mongodb-getdbref_error-001.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | MongoDB::getDBRef() returns null if reference parameter is invalid 3 | --SKIPIF-- 4 | 5 | --FILE-- 6 | selectDB('test'); 10 | 11 | var_dump($db->getDBRef(array())); 12 | var_dump($db->getDBRef(array('$ref' => 'dbref'))); 13 | var_dump($db->getDBRef(array('$id' => 123))); 14 | ?> 15 | --EXPECT-- 16 | NULL 17 | NULL 18 | NULL 19 | -------------------------------------------------------------------------------- /tests/generic/mongodb-getdbref_error-002.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | MongoDB::getDBRef() throws exception if $ref or $db fields are not strings 3 | --SKIPIF-- 4 | 5 | --FILE-- 6 | selectDB('test'); 10 | 11 | try { 12 | $db->getDBRef(array('$ref' => 1, '$id' => 2)); 13 | } catch (Exception $e) { 14 | printf("%s: %s\n", get_class($e), $e->getCode()); 15 | } 16 | 17 | try { 18 | $db->getDBRef(array('$ref' => 'dbref', '$id' => 2, '$db' => 3)); 19 | } catch (Exception $e) { 20 | printf("%s: %d\n", get_class($e), $e->getCode()); 21 | } 22 | ?> 23 | --EXPECT-- 24 | MongoException: 10 25 | MongoException: 11 26 | -------------------------------------------------------------------------------- /tests/generic/mongodb-getgridfs-001.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | MongoDB::getGridFS() with default prefix 3 | --SKIPIF-- 4 | 5 | --FILE-- 6 | selectDB(dbname()); 10 | 11 | $gridfs = $db->getGridFS(); 12 | printf("%s\n", $gridfs); 13 | printf("%s\n", $gridfs->chunks); 14 | --EXPECTF-- 15 | %s.fs.files 16 | %s.fs.chunks 17 | -------------------------------------------------------------------------------- /tests/generic/mongodb-getgridfs-002.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | MongoDB::getGridFS() with custom prefix 3 | --SKIPIF-- 4 | 5 | --FILE-- 6 | selectDB(dbname()); 10 | 11 | $gridfs = $db->getGridFS('foo'); 12 | printf("%s\n", $gridfs); 13 | printf("%s\n", $gridfs->chunks); 14 | --EXPECTF-- 15 | %s.foo.files 16 | %s.foo.chunks 17 | -------------------------------------------------------------------------------- /tests/generic/mongodb-getgridfs_error-001.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | MongoDB::getGridFS() with invalid prefix 3 | --SKIPIF-- 4 | 5 | --FILE-- 6 | selectDB(dbname()); 10 | 11 | try { 12 | $db->getGridFS(null); 13 | var_dump(false); 14 | } catch (Exception $e) { 15 | var_dump($e->getMessage(), $e->getCode()); 16 | } 17 | --EXPECT-- 18 | string(42) "MongoGridFS::__construct(): invalid prefix" 19 | int(2) 20 | -------------------------------------------------------------------------------- /tests/generic/mongodb-listcollections-006.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | MongoDB::listCollections() with non-existent database 3 | --SKIPIF-- 4 | 5 | --FILE-- 6 | selectDB(dbname() . '_non-existent'); 13 | $db->drop(); 14 | 15 | var_dump($db->listCollections()); 16 | 17 | ?> 18 | ===DONE=== 19 | --EXPECT-- 20 | array(0) { 21 | } 22 | ===DONE=== 23 | -------------------------------------------------------------------------------- /tests/generic/mongodb-listcollections_error-001.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | MongoDB::listCollections() requires "filter" option to be a document (legacy mode) 3 | --SKIPIF-- 4 | 5 | 6 | --FILE-- 7 | selectDB(dbname()); 14 | 15 | try { 16 | $db->listCollections(array( 17 | 'filter' => 0, 18 | )); 19 | } catch (MongoException $e) { 20 | printf("error message: %s\n", $e->getMessage()); 21 | printf("error code: %d\n", $e->getCode()); 22 | } 23 | 24 | ?> 25 | ===DONE=== 26 | --EXPECT-- 27 | error message: Expected filter to be array or object, integer given 28 | error code: 26 29 | ===DONE=== 30 | -------------------------------------------------------------------------------- /tests/generic/mongodb-repair.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | MongoDB::repair() Repair a database 3 | --SKIPIF-- 4 | 5 | --FILE-- 6 | 7 | selectDb(dbname()); 15 | var_dump($db->repair()); 16 | ?> 17 | ===DONE=== 18 | --EXPECTF-- 19 | array(1) { 20 | ["ok"]=> 21 | float(1) 22 | } 23 | ===DONE=== 24 | -------------------------------------------------------------------------------- /tests/generic/mongodb-selectcollection.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | MongoDB::selectCollection() 3 | --SKIPIF-- 4 | 5 | --FILE-- 6 | selectDb(dbname()); 13 | $col = $db->selectCollection('selectCollection'); 14 | 15 | var_dump($col); 16 | ?> 17 | ===DONE=== 18 | --EXPECT-- 19 | object(MongoCollection)#3 (2) { 20 | ["w"]=> 21 | int(1) 22 | ["wtimeout"]=> 23 | int(10000) 24 | } 25 | ===DONE=== 26 | -------------------------------------------------------------------------------- /tests/generic/mongodb-setreadpreference-003.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | MongoDB::setReadPreference() should allow empty tags parameter for primary mode 3 | --SKIPIF-- 4 | 5 | --FILE-- 6 | 7 | phpunit; 11 | var_dump($db->setReadPreference(Mongo::RP_PRIMARY, array())); 12 | var_dump($db->getReadPreference()); 13 | ?> 14 | --EXPECT-- 15 | bool(true) 16 | array(1) { 17 | ["type"]=> 18 | string(7) "primary" 19 | } 20 | -------------------------------------------------------------------------------- /tests/generic/mongodb-setreadpreference_error-003.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | MongoDB::setReadPreference() error setting tag sets for primary read preference mode 3 | --SKIPIF-- 4 | 5 | --FILE-- 6 | 7 | phpunit; 11 | $db->setReadPreference(MongoClient::RP_PRIMARY, array( array( 'foo' => 'bar' ) ) ); 12 | $rp = $db->getReadPreference(); 13 | var_dump($rp); 14 | ?> 15 | --EXPECTF-- 16 | Warning: MongoDB::setReadPreference(): You can't use read preference tags with a read preference of PRIMARY in %s on line %d 17 | array(1) { 18 | ["type"]=> 19 | string(7) "primary" 20 | } 21 | -------------------------------------------------------------------------------- /tests/generic/mongodbref-get_error-001.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | MongoDBRef::get() returns null if reference parameter is invalid 3 | --SKIPIF-- 4 | 5 | --FILE-- 6 | selectDB('test'); 10 | 11 | var_dump(MongoDBRef::get($db, null)); 12 | var_dump(MongoDBRef::get($db, array())); 13 | var_dump(MongoDBRef::get($db, array('$ref' => 'dbref'))); 14 | var_dump(MongoDBRef::get($db, array('$id' => 123))); 15 | ?> 16 | --EXPECT-- 17 | NULL 18 | NULL 19 | NULL 20 | NULL 21 | -------------------------------------------------------------------------------- /tests/generic/mongodbref-get_error-002.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | MongoDBRef::get() throws exception if $ref or $db fields are not strings 3 | --SKIPIF-- 4 | 5 | --FILE-- 6 | selectDB('test'); 10 | 11 | try { 12 | MongoDBRef::get($db, array('$ref' => 1, '$id' => 2)); 13 | } catch (Exception $e) { 14 | printf("%s: %s\n", get_class($e), $e->getCode()); 15 | } 16 | 17 | try { 18 | MongoDBRef::get($db, array('$ref' => 'dbref', '$id' => 2, '$db' => 3)); 19 | } catch (Exception $e) { 20 | printf("%s: %d\n", get_class($e), $e->getCode()); 21 | } 22 | ?> 23 | --EXPECT-- 24 | MongoException: 10 25 | MongoException: 11 26 | -------------------------------------------------------------------------------- /tests/generic/mongogridfs-001.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | MongoGridFS constructor with default prefix 3 | --SKIPIF-- 4 | 5 | --FILE-- 6 | selectDB(dbname()); 10 | 11 | $gridfs = new MongoGridFS($db); 12 | printf("%s\n", $gridfs); 13 | printf("%s\n", $gridfs->chunks); 14 | --EXPECTF-- 15 | %s.fs.files 16 | %s.fs.chunks 17 | -------------------------------------------------------------------------------- /tests/generic/mongogridfs-002.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | MongoGridFS constructor with custom prefix 3 | --SKIPIF-- 4 | 5 | --FILE-- 6 | selectDB(dbname()); 10 | 11 | $gridfs = new MongoGridFS($db, 'foo'); 12 | printf("%s\n", $gridfs); 13 | printf("%s\n", $gridfs->chunks); 14 | --EXPECTF-- 15 | %s.foo.files 16 | %s.foo.chunks 17 | -------------------------------------------------------------------------------- /tests/generic/mongogridfs-delete-001.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | MongoGridFS::delete() 3 | --SKIPIF-- 4 | 5 | --FILE-- 6 | selectDB(dbname()); 10 | 11 | $gridfs = $db->getGridFS(); 12 | $gridfs->drop(); 13 | $id = $gridfs->storeFile(__FILE__); 14 | 15 | var_dump(0 < $gridfs->chunks->count()); 16 | var_dump(1 === $gridfs->count()); 17 | 18 | $gridfs->delete($id); 19 | 20 | var_dump(0 === $gridfs->chunks->count()); 21 | var_dump(0 === $gridfs->count()); 22 | --EXPECT-- 23 | bool(true) 24 | bool(true) 25 | bool(true) 26 | bool(true) 27 | -------------------------------------------------------------------------------- /tests/generic/mongogridfs-drop-001.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | MongoGridFS::drop() 3 | --SKIPIF-- 4 | 5 | --FILE-- 6 | selectDB(dbname()); 10 | 11 | $gridfs = $db->getGridFS(); 12 | $gridfs->drop(); 13 | $gridfs->storeFile(__FILE__); 14 | 15 | var_dump(0 < $gridfs->chunks->count()); 16 | var_dump(1 === $gridfs->count()); 17 | 18 | $gridfs->drop(); 19 | 20 | var_dump(0 === $gridfs->chunks->count()); 21 | var_dump(0 === $gridfs->count()); 22 | --EXPECT-- 23 | bool(true) 24 | bool(true) 25 | bool(true) 26 | bool(true) 27 | -------------------------------------------------------------------------------- /tests/generic/mongogridfs-find-001.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | MongoGridFS::find() 3 | --SKIPIF-- 4 | 5 | --FILE-- 6 | selectDB(dbname()); 10 | 11 | $gridfs = $db->getGridFS(); 12 | $gridfs->drop(); 13 | $gridfs->storeFile(__FILE__); 14 | 15 | $cursor = $gridfs->find(); 16 | var_dump($cursor instanceof MongoGridFSCursor); 17 | var_dump($cursor->getNext() instanceof MongoGridFSFile); 18 | var_dump(null === $cursor->getNext()); 19 | --EXPECT-- 20 | bool(true) 21 | bool(true) 22 | bool(true) 23 | -------------------------------------------------------------------------------- /tests/generic/mongogridfs-findone-001.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | MongoGridFS::findOne() with no arguments 3 | --SKIPIF-- 4 | 5 | --FILE-- 6 | selectDB(dbname()); 10 | 11 | $gridfs = $db->getGridFS(); 12 | $gridfs->drop(); 13 | 14 | var_dump(null === $gridfs->findOne()); 15 | 16 | $gridfs->storeFile(__FILE__); 17 | 18 | var_dump($gridfs->findOne() instanceof MongoGridFSFile); 19 | --EXPECT-- 20 | bool(true) 21 | bool(true) 22 | -------------------------------------------------------------------------------- /tests/generic/mongogridfs-findone-002.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | MongoGridFS::findOne() with filename argument 3 | --SKIPIF-- 4 | 5 | --FILE-- 6 | selectDB(dbname()); 10 | 11 | $gridfs = $db->getGridFS(); 12 | $gridfs->drop(); 13 | 14 | var_dump(null === $gridfs->findOne(__FILE__)); 15 | 16 | $gridfs->storeFile(__FILE__); 17 | 18 | var_dump($gridfs->findOne(__FILE__) instanceof MongoGridFSFile); 19 | var_dump(null === $gridfs->findOne('/does/not/exist')); 20 | --EXPECT-- 21 | bool(true) 22 | bool(true) 23 | bool(true) 24 | -------------------------------------------------------------------------------- /tests/generic/mongogridfs-findone-003.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | MongoGridFS::findOne() with criteria argument 3 | --SKIPIF-- 4 | 5 | --FILE-- 6 | selectDB(dbname()); 10 | 11 | $gridfs = $db->getGridFS(); 12 | $gridfs->drop(); 13 | 14 | var_dump(null === $gridfs->findOne(array('filename' => __FILE__))); 15 | 16 | $gridfs->storeFile(__FILE__); 17 | 18 | var_dump($gridfs->findOne(array('filename' => __FILE__)) instanceof MongoGridFSFile); 19 | var_dump(null === $gridfs->findOne(array('filename' => '/does/not/exist'))); 20 | --EXPECT-- 21 | bool(true) 22 | bool(true) 23 | bool(true) 24 | -------------------------------------------------------------------------------- /tests/generic/mongogridfs-findone-004.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | MongoGridFS::findOne() with selected fields 3 | --SKIPIF-- 4 | 5 | --FILE-- 6 | selectDB(dbname()); 10 | 11 | $gridfs = $db->getGridFS(); 12 | $gridfs->drop(); 13 | $gridfs->storeFile(__FILE__, array('x' => 1, 'y' => 'foo', 'z' => 'bar')); 14 | 15 | $file = $gridfs->findOne(array(), array('x' => 1, 'y' => 1)); 16 | 17 | var_dump(1 === $file->file['x']); 18 | var_dump('foo' === $file->file['y']); 19 | var_dump(array_key_exists('z', $file->file)); 20 | --EXPECT-- 21 | bool(true) 22 | bool(true) 23 | bool(false) 24 | -------------------------------------------------------------------------------- /tests/generic/mongogridfs-findone-005.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | MongoGridFS::findOne() with selected fields may omit file contents 3 | --SKIPIF-- 4 | 5 | --FILE-- 6 | selectDB(dbname()); 10 | 11 | $gridfs = $db->getGridFS(); 12 | $gridfs->drop(); 13 | $gridfs->storeFile(__FILE__, array('x' => 1)); 14 | 15 | $file = $gridfs->findOne(array(), array('x' => 1)); 16 | 17 | try { 18 | $file->getBytes(); 19 | var_dump(false); 20 | } catch (MongoGridFSException $e) { 21 | var_dump($e->getMessage(), $e->getCode()); 22 | } 23 | --EXPECT-- 24 | string(23) "couldn't find file size" 25 | int(14) 26 | -------------------------------------------------------------------------------- /tests/generic/mongogridfs-get-001.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | MongoGridFS::get() 3 | --SKIPIF-- 4 | 5 | --FILE-- 6 | selectDB(dbname()); 10 | 11 | $gridfs = $db->getGridFS(); 12 | $gridfs->drop(); 13 | $id = $gridfs->storeFile(__FILE__); 14 | 15 | $file = $gridfs->get($id); 16 | 17 | var_dump($id == $file->file['_id']); 18 | var_dump(__FILE__ === $file->file['filename']); 19 | --EXPECT-- 20 | bool(true) 21 | bool(true) 22 | -------------------------------------------------------------------------------- /tests/generic/mongogridfs-put-001.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | MongoGridFS::put() 3 | --SKIPIF-- 4 | 5 | --FILE-- 6 | selectDB(dbname()); 10 | 11 | $gridfs = $db->getGridFS(); 12 | $gridfs->drop(); 13 | $id = $gridfs->put(__FILE__); 14 | 15 | $file = $gridfs->get($id); 16 | 17 | var_dump($id == $file->file['_id']); 18 | var_dump(__FILE__ === $file->file['filename']); 19 | --EXPECT-- 20 | bool(true) 21 | bool(true) 22 | -------------------------------------------------------------------------------- /tests/generic/mongogridfs-put-002.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | MongoGridFS::put() with metadata argument 3 | --SKIPIF-- 4 | 5 | --FILE-- 6 | selectDB(dbname()); 10 | 11 | $gridfs = $db->getGridFS(); 12 | $gridfs->drop(); 13 | $id = $gridfs->put(__FILE__, array('x' => 1)); 14 | 15 | $file = $gridfs->get($id); 16 | 17 | var_dump(1 === $file->file['x']); 18 | --EXPECT-- 19 | bool(true) 20 | -------------------------------------------------------------------------------- /tests/generic/mongogridfs-put-003.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | MongoGridFS::put() with empty file 3 | --SKIPIF-- 4 | 5 | --FILE-- 6 | selectDB(dbname()); 10 | 11 | $gridfs = $db->getGridFS(); 12 | $gridfs->drop(); 13 | 14 | $gridfs->put('tests/data-files/empty'); 15 | 16 | $file = $gridfs->findOne(); 17 | 18 | var_dump(0 === $file->file['length']); 19 | --EXPECT-- 20 | bool(true) 21 | -------------------------------------------------------------------------------- /tests/generic/mongogridfs-put_error-001.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | MongoGridFS::put() throws exception for nonexistent file 3 | --SKIPIF-- 4 | 5 | --FILE-- 6 | selectDB(dbname()); 10 | 11 | $gridfs = $db->getGridFS(); 12 | 13 | try { 14 | $gridfs->put('/does/not/exist'); 15 | var_dump(false); 16 | } catch (MongoGridFSException $e) { 17 | var_dump($e->getMessage(), $e->getCode()); 18 | } 19 | --EXPECT-- 20 | string(38) "error setting up file: /does/not/exist" 21 | int(7) 22 | -------------------------------------------------------------------------------- /tests/generic/mongogridfs-remove-001.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | MongoGridFS::remove() with no arguments 3 | --SKIPIF-- 4 | 5 | --FILE-- 6 | selectDB(dbname()); 10 | 11 | $gridfs = $db->getGridFS(); 12 | $gridfs->drop(); 13 | $gridfs->storeFile(__FILE__); 14 | 15 | var_dump(0 < $gridfs->chunks->count()); 16 | var_dump(1 === $gridfs->count()); 17 | 18 | $gridfs->remove(); 19 | 20 | var_dump(0 === $gridfs->chunks->count()); 21 | var_dump(0 === $gridfs->count()); 22 | --EXPECT-- 23 | bool(true) 24 | bool(true) 25 | bool(true) 26 | bool(true) 27 | -------------------------------------------------------------------------------- /tests/generic/mongogridfs-remove-002.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | MongoGridFS::remove() with filename argument 3 | --SKIPIF-- 4 | 5 | --FILE-- 6 | selectDB(dbname()); 10 | 11 | $gridfs = $db->getGridFS(); 12 | $gridfs->drop(); 13 | $gridfs->storeFile(__FILE__); 14 | 15 | var_dump(0 < $gridfs->chunks->count()); 16 | var_dump(1 === $gridfs->count()); 17 | 18 | $gridfs->remove('/does/not/exist'); 19 | 20 | var_dump(0 < $gridfs->chunks->count()); 21 | var_dump(1 === $gridfs->count()); 22 | 23 | $gridfs->remove(__FILE__); 24 | 25 | var_dump(0 === $gridfs->chunks->count()); 26 | var_dump(0 === $gridfs->count()); 27 | --EXPECT-- 28 | bool(true) 29 | bool(true) 30 | bool(true) 31 | bool(true) 32 | bool(true) 33 | bool(true) 34 | -------------------------------------------------------------------------------- /tests/generic/mongogridfs-remove-003.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | MongoGridFS::remove() with criteria argument 3 | --SKIPIF-- 4 | 5 | --FILE-- 6 | selectDB(dbname()); 10 | 11 | $gridfs = $db->getGridFS(); 12 | $gridfs->drop(); 13 | $gridfs->storeFile(__FILE__); 14 | 15 | var_dump(0 < $gridfs->chunks->count()); 16 | var_dump(1 === $gridfs->count()); 17 | 18 | $gridfs->remove(array('filename' => '/does/not/exist')); 19 | 20 | var_dump(0 < $gridfs->chunks->count()); 21 | var_dump(1 === $gridfs->count()); 22 | 23 | $gridfs->remove(array('filename' => __FILE__)); 24 | 25 | var_dump(0 === $gridfs->chunks->count()); 26 | var_dump(0 === $gridfs->count()); 27 | --EXPECT-- 28 | bool(true) 29 | bool(true) 30 | bool(true) 31 | bool(true) 32 | bool(true) 33 | bool(true) 34 | -------------------------------------------------------------------------------- /tests/generic/mongogridfs-remove-004.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | MongoGridFS::remove() with safe option 3 | --SKIPIF-- 4 | 5 | --FILE-- 6 | selectDB(dbname()); 10 | 11 | $gridfs = $db->getGridFS(); 12 | $gridfs->drop(); 13 | $id = $gridfs->storeFile(__FILE__); 14 | 15 | $result = $gridfs->remove(array('_id' => $id), array('w' => true)); 16 | var_dump((bool) $result['ok']); 17 | var_dump(1 === $result['n']); 18 | var_dump(null === $result['err']); 19 | --EXPECT-- 20 | bool(true) 21 | bool(true) 22 | bool(true) 23 | -------------------------------------------------------------------------------- /tests/generic/mongogridfs-storebytes-001.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | MongoGridFS::storeBytes() returns a generated ID 3 | --SKIPIF-- 4 | 5 | --FILE-- 6 | selectDB(dbname()); 10 | 11 | $gridfs = $db->getGridFS(); 12 | $gridfs->drop(); 13 | $id = $gridfs->storeBytes('foobar'); 14 | 15 | var_dump($id instanceof MongoId); 16 | 17 | $file = $gridfs->findOne(); 18 | var_dump($id == $file->file['_id']); 19 | --EXPECT-- 20 | bool(true) 21 | bool(true) 22 | -------------------------------------------------------------------------------- /tests/generic/mongogridfs-storebytes-002.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | MongoGridFS::storeBytes() returns a custom ID 3 | --SKIPIF-- 4 | 5 | --FILE-- 6 | selectDB(dbname()); 10 | 11 | $gridfs = $db->getGridFS(); 12 | $gridfs->drop(); 13 | $id = $gridfs->storeBytes('foobar', array('_id' => 1)); 14 | 15 | var_dump(1 === $id); 16 | 17 | $file = $gridfs->findOne(); 18 | var_dump($id == $file->file['_id']); 19 | --EXPECT-- 20 | bool(true) 21 | bool(true) 22 | -------------------------------------------------------------------------------- /tests/generic/mongogridfs-storebytes-003.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | MongoGridFS::storeBytes() with arbitrary values 3 | --SKIPIF-- 4 | 5 | --FILE-- 6 | selectDB(dbname()); 10 | 11 | $bytes = chr(0) . '4g7' . chr(255) . chr(127) . chr(128) . chr(0); 12 | 13 | $gridfs = $db->getGridFS(); 14 | $gridfs->drop(); 15 | $gridfs->storeBytes($bytes, array('myopt' => new MongoBinData($bytes, MongoBinData::BYTE_ARRAY))); 16 | 17 | $file = $gridfs->findOne(); 18 | 19 | var_dump($bytes === $file->getBytes()); 20 | var_dump($bytes === $file->file['myopt']->bin); 21 | --EXPECT-- 22 | bool(true) 23 | bool(true) 24 | -------------------------------------------------------------------------------- /tests/generic/mongogridfs-storebytes-004.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | MongoGridFS::storeBytes() with metadata argument 3 | --SKIPIF-- 4 | 5 | --FILE-- 6 | selectDB(dbname()); 10 | 11 | $gridfs = $db->getGridFS(); 12 | $gridfs->drop(); 13 | 14 | $gridfs->storeBytes('foobar', array('x' => 1)); 15 | 16 | $file = $gridfs->findOne(); 17 | 18 | var_dump(1 === $file->file['x']); 19 | --EXPECT-- 20 | bool(true) 21 | -------------------------------------------------------------------------------- /tests/generic/mongogridfs-storefile-001.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | MongoGridFS::storeFile() returns a generated ID 3 | --SKIPIF-- 4 | 5 | --FILE-- 6 | selectDB(dbname()); 10 | 11 | $gridfs = $db->getGridFS(); 12 | $gridfs->drop(); 13 | $id = $gridfs->storeFile(__FILE__); 14 | 15 | var_dump($id instanceof MongoId); 16 | 17 | $file = $gridfs->findOne(); 18 | var_dump($id == $file->file['_id']); 19 | --EXPECT-- 20 | bool(true) 21 | bool(true) 22 | -------------------------------------------------------------------------------- /tests/generic/mongogridfs-storefile-002.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | MongoGridFS::storeFile() returns a custom ID 3 | --SKIPIF-- 4 | 5 | --FILE-- 6 | selectDB(dbname()); 10 | 11 | $gridfs = $db->getGridFS(); 12 | $gridfs->drop(); 13 | $id = $gridfs->storeFile(__FILE__, array('_id' => 1)); 14 | 15 | var_dump(1 === $id); 16 | 17 | $file = $gridfs->findOne(); 18 | var_dump($id == $file->file['_id']); 19 | --EXPECT-- 20 | bool(true) 21 | bool(true) 22 | -------------------------------------------------------------------------------- /tests/generic/mongogridfs-storefile-003.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | MongoGridFS::storeFile() with large file 3 | --SKIPIF-- 4 | 5 | --FILE-- 6 | selectDB(dbname()); 10 | 11 | $gridfs = $db->getGridFS(); 12 | $gridfs->drop(); 13 | 14 | $gridfs->storeFile('tests/data-files/mongogridfs-storefile-003.pdf'); 15 | 16 | $file = $gridfs->findOne(); 17 | 18 | var_dump(file_get_contents('tests/data-files/mongogridfs-storefile-003.pdf') === $file->getBytes()); 19 | --EXPECT-- 20 | bool(true) 21 | -------------------------------------------------------------------------------- /tests/generic/mongogridfs-storefile-004.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | MongoGridFS::storeFile() with metadata argument 3 | --SKIPIF-- 4 | 5 | --FILE-- 6 | selectDB(dbname()); 10 | 11 | $gridfs = $db->getGridFS(); 12 | $gridfs->drop(); 13 | 14 | $gridfs->storeFile(__FILE__, array('x' => 1)); 15 | 16 | $file = $gridfs->findOne(); 17 | 18 | var_dump(1 === $file->file['x']); 19 | --EXPECT-- 20 | bool(true) 21 | -------------------------------------------------------------------------------- /tests/generic/mongogridfs-storefile-005.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | MongoGridFS::storeFile() with empty file 3 | --SKIPIF-- 4 | 5 | --FILE-- 6 | selectDB(dbname()); 10 | 11 | $gridfs = $db->getGridFS(); 12 | $gridfs->drop(); 13 | 14 | $gridfs->storeFile('tests/data-files/empty'); 15 | 16 | $file = $gridfs->findOne(); 17 | 18 | var_dump(0 === $file->file['length']); 19 | --EXPECT-- 20 | bool(true) 21 | -------------------------------------------------------------------------------- /tests/generic/mongogridfs-storefile-006.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | MongoGridFS::storeFile() insertion error without safe option 3 | --SKIPIF-- 4 | 5 | --FILE-- 6 | selectDB(dbname()); 10 | 11 | $gridfs = $db->getGridFS(); 12 | $gridfs->drop(); 13 | $gridfs->storeFile(__FILE__, array('_id' => 1), array('w' => false)); 14 | var_dump(true); 15 | --EXPECT-- 16 | bool(true) 17 | -------------------------------------------------------------------------------- /tests/generic/mongogridfs-storefile_error-001.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | MongoGridFS::storeFile() throws exception if insert fails with safe option 3 | --SKIPIF-- 4 | 5 | --FILE-- 6 | selectDB(dbname()); 10 | 11 | $gridfs = $db->getGridFS(); 12 | $gridfs->drop(); 13 | $gridfs->storeFile(__FILE__, array('_id' => 1), array('w' => true)); 14 | 15 | try { 16 | $gridfs->storeFile(__FILE__, array('_id' => 1), array('w' => true)); 17 | var_dump(false); 18 | } catch (MongoGridFSException $e) { 19 | var_dump($e->getMessage(), $e->getCode()); 20 | } 21 | ?> 22 | --EXPECTF-- 23 | string(%d) "Could not store file:%s { : 1, : 0 }" 24 | int(11000) 25 | -------------------------------------------------------------------------------- /tests/generic/mongogridfs-storefile_error-002.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | MongoGridFS::storeFile() throws exception when overwriting files 3 | --SKIPIF-- 4 | 5 | --FILE-- 6 | selectDB(dbname()); 10 | 11 | $gridfs = $db->getGridFS(); 12 | $gridfs->drop(); 13 | 14 | $gridfs->storeFile(__FILE__, array('_id' => 1)); 15 | 16 | try { 17 | $gridfs->storeFile(__FILE__, array('_id' => 1)); 18 | } catch (MongoGridFSException $e) { 19 | echo $e->getMessage(), "\n"; 20 | } 21 | ?> 22 | --EXPECTF-- 23 | Could not store file:%s { : 1, : 0 } 24 | -------------------------------------------------------------------------------- /tests/generic/mongogridfs-storefile_error-003.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | MongoGridFS::storeFile() throws exception for nonexistent file 3 | --SKIPIF-- 4 | 5 | --FILE-- 6 | selectDB(dbname()); 10 | 11 | $gridfs = $db->getGridFS(); 12 | 13 | try { 14 | $gridfs->storeFile('/does/not/exist'); 15 | var_dump(false); 16 | } catch (MongoGridFSException $e) { 17 | var_dump(true); 18 | } 19 | --EXPECT-- 20 | bool(true) 21 | -------------------------------------------------------------------------------- /tests/generic/mongogridfs_error-001.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | MongoGridFS constructor with invalid prefix 3 | --SKIPIF-- 4 | 5 | --FILE-- 6 | selectDB(dbname()); 10 | 11 | try { 12 | $gridfs = new MongoGridFS($db, null); 13 | var_dump(false); 14 | } catch (Exception $e) { 15 | var_dump($e->getMessage(), $e->getCode()); 16 | } 17 | --EXPECT-- 18 | string(42) "MongoGridFS::__construct(): invalid prefix" 19 | int(2) 20 | -------------------------------------------------------------------------------- /tests/generic/mongogridfscursor-getnext-001.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | MongoGridFSCursor::getNext() 3 | --SKIPIF-- 4 | 5 | --FILE-- 6 | selectDB(dbname()); 10 | 11 | $gridfs = $db->getGridFS(); 12 | $gridfs->drop(); 13 | 14 | $gridfs->storeFile(__FILE__); 15 | 16 | $cursor = $gridfs->find(); 17 | 18 | var_dump($cursor instanceof MongoGridFSCursor); 19 | var_dump($cursor->getNext() instanceof MongoGridFSFile); 20 | var_dump(null === $cursor->getNext()); 21 | --EXPECT-- 22 | bool(true) 23 | bool(true) 24 | bool(true) 25 | -------------------------------------------------------------------------------- /tests/generic/mongogridfscursor-key-001.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | MongoGridFSCursor::key() returns the current element's filename 3 | --SKIPIF-- 4 | 5 | --FILE-- 6 | selectDB(dbname()); 10 | 11 | $gridfs = $db->getGridFS(); 12 | $gridfs->drop(); 13 | 14 | $gridfs->storeFile(__FILE__); 15 | 16 | $cursor = $gridfs->find(); 17 | 18 | var_dump($cursor instanceof MongoGridFSCursor); 19 | var_dump(null === $cursor->key()); 20 | 21 | $next = $cursor->getNext(); 22 | 23 | var_dump($next instanceof MongoGridFSFile); 24 | var_dump($cursor->key()); 25 | --EXPECTF-- 26 | bool(true) 27 | bool(true) 28 | bool(true) 29 | string(24) "%s" 30 | 31 | -------------------------------------------------------------------------------- /tests/generic/mongogridfsfile-getbytes-001.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | MongoGridFSFile::getBytes() 3 | --SKIPIF-- 4 | 5 | --FILE-- 6 | selectDB(dbname()); 10 | 11 | $gridfs = $db->getGridFS(); 12 | $gridfs->drop(); 13 | 14 | $gridfs->storeFile(__FILE__); 15 | 16 | $file = $gridfs->findOne(); 17 | 18 | var_dump(file_get_contents(__FILE__) === $file->getBytes()); 19 | --EXPECT-- 20 | bool(true) 21 | -------------------------------------------------------------------------------- /tests/generic/mongogridfsfile-getbytes-002.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | MongoGridFSFile::getBytes() returns all file data from all chunks 3 | --SKIPIF-- 4 | 5 | --FILE-- 6 | selectDB(dbname()); 10 | 11 | $gridfs = $db->getGridFS(); 12 | $gridfs->drop(); 13 | 14 | $id = $gridfs->storeFile(__FILE__); 15 | 16 | $chunks = $db->selectCollection('fs.chunks')->find(array('files_id' => $id)); 17 | 18 | $chunksData = ''; 19 | 20 | foreach ($chunks as $chunk) { 21 | $chunksData .= $chunk['data']->bin; 22 | } 23 | 24 | $contents = file_get_contents(__FILE__); 25 | 26 | var_dump($contents === $gridfs->findOne()->getBytes()); 27 | var_dump($contents === $chunksData); 28 | --EXPECT-- 29 | bool(true) 30 | bool(true) 31 | -------------------------------------------------------------------------------- /tests/generic/mongogridfsfile-getfilename-001.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | MongoGridFSFile::getFilename() 3 | --SKIPIF-- 4 | 5 | --FILE-- 6 | selectDB(dbname()); 10 | 11 | $gridfs = $db->getGridFS(); 12 | $gridfs->drop(); 13 | 14 | $gridfs->storeFile(__FILE__); 15 | 16 | $file = $gridfs->findOne(); 17 | var_dump(__FILE__ === $file->getFilename()); 18 | var_dump($file->file['filename'] === $file->getFilename()); 19 | --EXPECT-- 20 | bool(true) 21 | bool(true) 22 | -------------------------------------------------------------------------------- /tests/generic/mongogridfsfile-getsize-001.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | MongoGridFSFile::getSize() 3 | --SKIPIF-- 4 | 5 | --FILE-- 6 | selectDB(dbname()); 10 | 11 | $gridfs = $db->getGridFS(); 12 | $gridfs->drop(); 13 | 14 | $gridfs->storeFile(__FILE__); 15 | 16 | $file = $gridfs->findOne(); 17 | var_dump(filesize(__FILE__) === $file->getSize()); 18 | var_dump($file->file['length'] === $file->getSize()); 19 | --EXPECT-- 20 | bool(true) 21 | bool(true) 22 | -------------------------------------------------------------------------------- /tests/generic/mongoid-gettimestamp.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | MongoID: Test getting the getTimestamp. 3 | --SKIPIF-- 4 | 5 | --FILE-- 6 | phpunit; 12 | // Select a collection 13 | $collection = $db->test; 14 | 15 | $collection->drop(); 16 | 17 | // Add a record 18 | $obj = array("title" => "test1"); 19 | 20 | $time = time(); 21 | $collection->insert($obj); 22 | 23 | $cursor = $collection->find(); 24 | 25 | $a = $cursor->getNext(); 26 | 27 | var_dump($time === $a['_id']->getTimestamp()); 28 | ?> 29 | --EXPECTF-- 30 | bool(true) 31 | -------------------------------------------------------------------------------- /tests/generic/mongoint32.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | MongoInt32 value property read-only 3 | --SKIPIF-- 4 | 5 | --FILE-- 6 | value = 3.1415; 10 | var_dump($int); 11 | ?> 12 | --EXPECTF-- 13 | object(MongoInt32)#%d (1) { 14 | ["value"]=> 15 | string(17) "85876234523452345" 16 | } 17 | 18 | Deprecated: main(): The 'value' property is read-only in %smongoint32.php on line %d 19 | object(MongoInt32)#%d (1) { 20 | ["value"]=> 21 | string(17) "85876234523452345" 22 | } 23 | -------------------------------------------------------------------------------- /tests/generic/mongoint32_32bit-001.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | MongoInt32 constructed with 32-bit integer 3 | --SKIPIF-- 4 | 5 | 6 | --FILE-- 7 | selectCollection('phpunit', 'mongoint32'); 11 | $coll->drop(); 12 | 13 | $coll->insert(array('int32' => new MongoInt32(1234567890))); 14 | 15 | ini_set('mongo.native_long', false); 16 | ini_set('mongo.long_as_object', false); 17 | $result = $coll->findOne(); 18 | var_dump($result['int32']); 19 | 20 | ini_set('mongo.native_long', false); 21 | ini_set('mongo.long_as_object', true); 22 | $result = $coll->findOne(); 23 | var_dump($result['int32']); 24 | ?> 25 | --EXPECT-- 26 | int(1234567890) 27 | int(1234567890) 28 | -------------------------------------------------------------------------------- /tests/generic/mongoint32_32bit-002.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | MongoInt32 constructed with 64-bit integer 3 | --SKIPIF-- 4 | 5 | 6 | --FILE-- 7 | selectCollection('phpunit', 'mongoint32'); 11 | $coll->drop(); 12 | 13 | $coll->insert(array('int32' => new MongoInt32(123456789012345))); 14 | 15 | ini_set('mongo.native_long', false); 16 | ini_set('mongo.long_as_object', false); 17 | $result = $coll->findOne(); 18 | var_dump($result['int32']); 19 | 20 | ini_set('mongo.native_long', false); 21 | ini_set('mongo.long_as_object', true); 22 | $result = $coll->findOne(); 23 | var_dump($result['int32']); 24 | ?> 25 | --EXPECT-- 26 | int(1) 27 | int(1) 28 | -------------------------------------------------------------------------------- /tests/generic/mongoint64.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | MongoInt64 value property read-only 3 | --SKIPIF-- 4 | 5 | --FILE-- 6 | value = 3.1415; 10 | var_dump($int); 11 | ?> 12 | --EXPECTF-- 13 | object(MongoInt64)#%d (1) { 14 | ["value"]=> 15 | string(17) "85876234523452345" 16 | } 17 | 18 | Deprecated: main(): The 'value' property is read-only in %smongoint64.php on line %d 19 | object(MongoInt64)#%d (1) { 20 | ["value"]=> 21 | string(17) "85876234523452345" 22 | } 23 | -------------------------------------------------------------------------------- /tests/generic/mongoint64_32bit-002.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | MongoInt64 constructed with 64-bit integer 3 | --SKIPIF-- 4 | 5 | 6 | --FILE-- 7 | selectCollection('phpunit', 'mongoint64'); 11 | $coll->drop(); 12 | 13 | $coll->insert(array('int64' => new MongoInt64(123456789012345))); 14 | 15 | ini_set('mongo.native_long', false); 16 | ini_set('mongo.long_as_object', false); 17 | $result = $coll->findOne(); 18 | printf("%s\n", $result['int64']); 19 | 20 | ini_set('mongo.native_long', false); 21 | ini_set('mongo.long_as_object', true); 22 | $result = $coll->findOne(); 23 | printf("%s(%s)\n", get_class($result['int64']), $result['int64']); 24 | ?> 25 | --EXPECT-- 26 | 1 27 | MongoInt64(1) 28 | -------------------------------------------------------------------------------- /tests/generic/mongolog-001.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | MongoLog generates E_NOTICE messages 3 | --SKIPIF-- 4 | 5 | --INI-- 6 | display_errors=1 7 | --FILE-- 8 | selectCollection(dbname(), 'mongolog'); 26 | $coll->drop(); 27 | 28 | $coll->insert(array('x' => 1)); 29 | 30 | var_dump(0 < $numNotices); 31 | --EXPECT-- 32 | bool(true) 33 | -------------------------------------------------------------------------------- /tests/generic/mongoregex-003.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | MongoRegex insertion 3 | --SKIPIF-- 4 | 5 | --FILE-- 6 | selectCollection(dbname(), 'mongoregex'); 10 | $coll->drop(); 11 | 12 | $regex = new MongoRegex('/foo[bar]{3}/imx'); 13 | 14 | $coll->insert(array('_id' => 1, 'regex' => $regex)); 15 | $result = $coll->findOne(array('_id' => 1)); 16 | echo get_class($result['regex']) . "\n"; 17 | var_dump($result['regex']->regex === $regex->regex); 18 | var_dump($result['regex']->flags === $regex->flags); 19 | ?> 20 | --EXPECT-- 21 | MongoRegex 22 | bool(true) 23 | bool(true) 24 | -------------------------------------------------------------------------------- /tests/generic/mongotimestamp-005.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | MongoTimestamp insertion 3 | --SKIPIF-- 4 | 5 | --FILE-- 6 | selectCollection('phpunit', 'mongotimestamp'); 10 | $coll->drop(); 11 | 12 | $ts = new MongoTimestamp(); 13 | 14 | $coll->insert(array('_id' => 1, 'ts' => $ts)); 15 | $result = $coll->findOne(array('_id' => 1)); 16 | echo get_class($result['ts']) . "\n"; 17 | var_dump($result['ts']->sec === $ts->sec); 18 | var_dump($result['ts']->inc === $ts->inc); 19 | ?> 20 | --EXPECT-- 21 | MongoTimestamp 22 | bool(true) 23 | bool(true) 24 | -------------------------------------------------------------------------------- /tests/mongos/bug00756.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Test for PHP-756: Support QueryFailure query flag 3 | --SKIPIF-- 4 | 5 | --FILE-- 6 | selectCollection(dbname(), 'php756'); 12 | $c->drop(); 13 | $c->insert(array('test'=>42)); 14 | 15 | $r = $c->find( array( 'foo' => array( '$near' => array( 5, 5 ) ) ) ); 16 | 17 | try { 18 | foreach( $r as $f) 19 | { 20 | var_dump($f); 21 | } 22 | } catch (MongoCursorException $e) { 23 | echo "got exception\n"; 24 | } 25 | ?> 26 | --EXPECTF-- 27 | got exception 28 | -------------------------------------------------------------------------------- /tests/mongos/mongoclient-construct-001.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | MongoClient::__construct(): Connecting to one mongos (1) 3 | --SKIPIF-- 4 | 5 | --FILE-- 6 | getMessage()); 15 | } 16 | 17 | ?> 18 | --EXPECTF-- 19 | ok 20 | 21 | -------------------------------------------------------------------------------- /tests/mongos/mongoclient-construct-002.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | MongoClient::__construct(): Connecting to multiple mongos (2) 3 | --SKIPIF-- 4 | 5 | --FILE-- 6 | getMessage()); 15 | } 16 | 17 | ?> 18 | --EXPECTF-- 19 | ok 20 | 21 | -------------------------------------------------------------------------------- /tests/no-servers/bson_encode-001.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | bson_encode() null 3 | --SKIPIF-- 4 | 5 | --FILE-- 6 | 9 | --EXPECT-- 10 | bool(true) 11 | -------------------------------------------------------------------------------- /tests/no-servers/bson_encode-002.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | bson_encode() integer 3 | --SKIPIF-- 4 | 5 | --FILE-- 6 | 10 | --EXPECT-- 11 | bool(true) 12 | -------------------------------------------------------------------------------- /tests/no-servers/bson_encode-003.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | bson_encode() double 3 | --SKIPIF-- 4 | 5 | --FILE-- 6 | 10 | --EXPECT-- 11 | bool(true) 12 | -------------------------------------------------------------------------------- /tests/no-servers/bson_encode-004.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | bson_encode() boolean 3 | --SKIPIF-- 4 | 5 | --FILE-- 6 | 10 | --EXPECT-- 11 | bool(true) 12 | bool(true) 13 | -------------------------------------------------------------------------------- /tests/no-servers/bson_encode-005.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | bson_encode() string 3 | --SKIPIF-- 4 | 5 | --FILE-- 6 | 9 | --EXPECT-- 10 | bool(true) 11 | -------------------------------------------------------------------------------- /tests/no-servers/bson_encode-006.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | bson_encode() array 3 | --SKIPIF-- 4 | 5 | --FILE-- 6 | 21 | --EXPECT-- 22 | bool(true) 23 | -------------------------------------------------------------------------------- /tests/no-servers/bson_encode-007.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | bson_encode() MongoId 3 | --SKIPIF-- 4 | 5 | --FILE-- 6 | 11 | --EXPECT-- 12 | bool(true) 13 | -------------------------------------------------------------------------------- /tests/no-servers/bson_encode-008.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | bson_encode() object 3 | --SKIPIF-- 4 | 5 | --FILE-- 6 | 23 | ===DONE=== 24 | --EXPECT-- 25 | bool(true) 26 | ===DONE=== 27 | -------------------------------------------------------------------------------- /tests/no-servers/bson_encode-010.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | bson_encode() MongoTimestamp 3 | --SKIPIF-- 4 | 5 | --FILE-- 6 | 14 | ===DONE=== 15 | --EXPECT-- 16 | bool(true) 17 | ===DONE=== 18 | -------------------------------------------------------------------------------- /tests/no-servers/bson_encode-011.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | bson_encode() MongoRegex 3 | --SKIPIF-- 4 | 5 | --FILE-- 6 | 14 | ===DONE=== 15 | --EXPECT-- 16 | bool(true) 17 | ===DONE=== 18 | -------------------------------------------------------------------------------- /tests/no-servers/bson_encode-012.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | bson_encode() MongoBinData 3 | --SKIPIF-- 4 | 5 | --FILE-- 6 | 21 | ===DONE=== 22 | --EXPECT-- 23 | bool(true) 24 | bool(true) 25 | ===DONE=== 26 | -------------------------------------------------------------------------------- /tests/no-servers/bson_encode-014.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | bson_encode() MongoMaxKey and ongoMinKey 3 | --SKIPIF-- 4 | 5 | --FILE-- 6 | 10 | --EXPECT-- 11 | bool(true) 12 | bool(true) 13 | -------------------------------------------------------------------------------- /tests/no-servers/bug00306.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Test for PHP-306: MongoID::__set_state does not work. 3 | --SKIPIF-- 4 | 5 | --FILE-- 6 | '4f06e55e44670ab92b000000', 13 | )); 14 | var_dump($a); 15 | ?> 16 | --EXPECT-- 17 | MongoId::__set_state(array( 18 | '$id' => '4f06e55e44670ab92b000000', 19 | )) 20 | object(MongoId)#2 (1) { 21 | ["$id"]=> 22 | string(24) "4f06e55e44670ab92b000000" 23 | } 24 | -------------------------------------------------------------------------------- /tests/no-servers/bug00434.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Test for PHP-434: Mongo::connect() doesn't validate the object. 3 | --FILE-- 4 | connect(); 9 | } catch(Exception $e) { 10 | var_dump($e->getMessage()); 11 | } 12 | ?> 13 | ===DONE=== 14 | --EXPECT-- 15 | string(70) "The Mongo object has not been correctly initialized by its constructor" 16 | ===DONE=== 17 | 18 | 19 | -------------------------------------------------------------------------------- /tests/no-servers/bug00814.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Test for bug PHP-814: Passing in invalid MongoDB to MongoDBRef::get() segfaults 3 | --FILE-- 4 | "", '$id' => 1)); 14 | } catch (MongoException $e) { 15 | var_dump($e->getCode()); 16 | var_dump($e->getMessage()); 17 | } 18 | ?> 19 | --EXPECT-- 20 | int(0) 21 | string(72) "The MongoDB object has not been correctly initialized by its constructor" 22 | -------------------------------------------------------------------------------- /tests/no-servers/bug00815.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Test for PHP-815: MongoCursor ctor doesn't validate the MongoClient object. 3 | --FILE-- 4 | getCode()); 19 | var_dump($e->getMessage()); 20 | } 21 | ?> 22 | ==DONE== 23 | --EXPECT-- 24 | int(0) 25 | string(76) "The MongoClient object has not been correctly initialized by its constructor" 26 | ==DONE== 27 | -------------------------------------------------------------------------------- /tests/no-servers/bug00833_error.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Test for PHP-833: Killcursor with wrong hash. 3 | --FILE-- 4 | 8 | --EXPECTF-- 9 | Warning: MongoClient::killCursor(): A connection with hash 'abacadabra!' does not exist in %sbug00833_error.php on line %d 10 | DONE 11 | -------------------------------------------------------------------------------- /tests/no-servers/bug00850.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Test for PHP-850: Conditional jump on empty server name to MongoClient 3 | --SKIPIF-- 4 | 5 | --FILE-- 6 | false)); 8 | var_dump($mc->__toString()); 9 | ?> 10 | --EXPECTF-- 11 | string(15) "localhost:27017" 12 | -------------------------------------------------------------------------------- /tests/no-servers/bug01060.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Test for PHP-1060: The '$id' property is read-only 3 | --SKIPIF-- 4 | 5 | --FILE-- 6 | 13 | --EXPECTF-- 14 | object(MyId)#%d (%d) { 15 | ["$id"]=> 16 | string(24) "%s" 17 | } 18 | -------------------------------------------------------------------------------- /tests/no-servers/bug01426-001.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Test for PHP-1426: bson_decode() buffer overflow via string length 3 | --SKIPIF-- 4 | 5 | --FILE-- 6 | getMessage()); 12 | } 13 | 14 | 15 | try { 16 | var_dump(bson_decode("\xff\xff\xff\x10\x02\x30\x00\xff\xff\x10\x00XXXXX\x00\x00")); 17 | } catch (MongoException $e) { 18 | printf("%s: %s\n", get_class($e), $e->getMessage()); 19 | } 20 | 21 | ?> 22 | ===DONE=== 23 | 24 | --EXPECT-- 25 | MongoCursorException: Document length (285212671 bytes) exceeds buffer (18 bytes) 26 | MongoCursorException: Document length (285212671 bytes) exceeds buffer (18 bytes) 27 | ===DONE=== 28 | -------------------------------------------------------------------------------- /tests/no-servers/mongobindata-001.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | MongoBinData construction with default type 3 | --SKIPIF-- 4 | 5 | --INI-- 6 | display_errors=1 7 | --FILE-- 8 | bin); 13 | var_dump($bin->type); 14 | --EXPECT-- 15 | string(7) "abcdefg" 16 | int(0) 17 | -------------------------------------------------------------------------------- /tests/no-servers/mongobindata-002.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | MongoBinData construction with valid RFC4122 UUID 3 | --SKIPIF-- 4 | 5 | --FILE-- 6 | bin); 10 | var_dump($bin->type); 11 | 12 | ?> 13 | ===DONE=== 14 | --EXPECT-- 15 | string(16) "abcdefghijklmnop" 16 | int(4) 17 | ===DONE=== 18 | -------------------------------------------------------------------------------- /tests/no-servers/mongobindata-005.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | MongoBinData type constants 3 | --SKIPIF-- 4 | 5 | --FILE-- 6 | 15 | --EXPECT-- 16 | int(0) 17 | int(1) 18 | int(2) 19 | int(3) 20 | int(4) 21 | int(5) 22 | int(128) 23 | -------------------------------------------------------------------------------- /tests/no-servers/mongoclient-invalid-host.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | MongoClient should throw exception on unresolvable hostname 3 | --SKIPIF-- 4 | 5 | --FILE-- 6 | getMessage()); 12 | } 13 | ?> 14 | ===DONE=== 15 | 16 | --EXPECTF-- 17 | string(%d) "Failed to connect to: invalid-host-name:27017: %s" 18 | ===DONE=== 19 | -------------------------------------------------------------------------------- /tests/no-servers/mongocollection-toindexstring-broken.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | MongoCollection::toIndexString (broken) 3 | --FILE-- 4 | 14 | --EXPECTF-- 15 | %s: Function MongoCollection::toIndexString() is deprecated in %smongocollection-toindexstring-broken.php on line 6 16 | 17 | %s: MongoCollection::toIndexString(): The key needs to be either a string or an array in %smongocollection-toindexstring-broken.php on line 6 18 | NULL 19 | -------------------------------------------------------------------------------- /tests/no-servers/mongocommandcursor-setreadpreference-003.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | MongoCommandCursor::setReadPreference() should allow empty tags parameter for primary mode 3 | --SKIPIF-- 4 | 5 | --FILE-- 6 | false)); 9 | $cc = new MongoCommandCursor($mc, 'test.foo', array()); 10 | var_dump($cc === $cc->setReadPreference(MongoClient::RP_PRIMARY, array())); 11 | var_dump($cc->getReadPreference()); 12 | 13 | ?> 14 | ===DONE=== 15 | --EXPECT-- 16 | bool(true) 17 | array(1) { 18 | ["type"]=> 19 | string(7) "primary" 20 | } 21 | ===DONE=== 22 | -------------------------------------------------------------------------------- /tests/no-servers/mongocursor-doquery.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | MongoCursor::doQuery() 3 | --FILE-- 4 | 13 | --EXPECTF-- 14 | Fatal error: Cannot override final method MongoCursor::doQuery() in %smongocursor-doquery.php on line %d 15 | -------------------------------------------------------------------------------- /tests/no-servers/mongodate-001.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | MongoDate constructor uses current time 3 | --DESCRIPTION-- 4 | This test purposesly allows for one second of variation between MongoDate and 5 | the asserted timestamp, since we cannot guarantee that the clock will not 6 | advance to the next second during test execution. 7 | --SKIPIF-- 8 | 9 | --FILE-- 10 | sec <= 1); 13 | var_dump($date->usec); 14 | ?> 15 | --EXPECTF-- 16 | bool(true) 17 | int(%d) 18 | -------------------------------------------------------------------------------- /tests/no-servers/mongodate-002.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | MongoDate constructor has millisecond precision 3 | --SKIPIF-- 4 | 5 | --FILE-- 6 | usec === ($date->usec / 1000) * 1000); 9 | ?> 10 | --EXPECT-- 11 | bool(true) 12 | -------------------------------------------------------------------------------- /tests/no-servers/mongodate-003.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | MongoDate constructor with custom arguments 3 | --SKIPIF-- 4 | 5 | --FILE-- 6 | sec, $date->usec); 9 | 10 | $date = new MongoDate(12345, 67890); 11 | printf("%d.%06d\n", $date->sec, $date->usec); 12 | 13 | $date = new MongoDate(12345); 14 | printf("%d.%06d\n", $date->sec, $date->usec); 15 | ?> 16 | --EXPECT-- 17 | 0.000000 18 | 12345.067000 19 | 12345.000000 20 | -------------------------------------------------------------------------------- /tests/no-servers/mongodate-004.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | MongoDate constructor casts arguments to integers 3 | --SKIPIF-- 4 | 5 | --FILE-- 6 | sec, $date->usec); 9 | 10 | $date = new MongoDate('12345', '67890'); 11 | printf("%d.%06d\n", $date->sec, $date->usec); 12 | ?> 13 | --EXPECT-- 14 | 0.000000 15 | 12345.067000 16 | -------------------------------------------------------------------------------- /tests/no-servers/mongodate-005.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | MongoDate comparison 3 | --SKIPIF-- 4 | 5 | --FILE-- 6 | 12 | --EXPECT-- 13 | bool(true) 14 | bool(false) 15 | -------------------------------------------------------------------------------- /tests/no-servers/mongodate-008.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | MongoDate works with var_export() 3 | --SKIPIF-- 4 | 5 | --FILE-- 6 | '12345', 13 | 'usec' => '67000', 14 | )); 15 | var_dump($exported); 16 | ?> 17 | --EXPECT-- 18 | MongoDate::__set_state(array( 19 | 'sec' => 12345, 20 | 'usec' => 67000, 21 | )) 22 | object(MongoDate)#2 (2) { 23 | ["sec"]=> 24 | int(12345) 25 | ["usec"]=> 26 | int(67000) 27 | } 28 | -------------------------------------------------------------------------------- /tests/no-servers/mongodate_error.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | MongoDate constructor given invalid arguments 3 | --SKIPIF-- 4 | 5 | --FILE-- 6 | sec); 9 | var_dump($ts->usec); 10 | 11 | $ts = new MongoDate(1, 'foo'); 12 | var_dump($ts->sec); 13 | var_dump($ts->usec); 14 | ?> 15 | --EXPECTF-- 16 | Warning: MongoDate::__construct() expects parameter 1 to be long, string given in %s 17 | int(0) 18 | int(0) 19 | 20 | Warning: MongoDate::__construct() expects parameter 2 to be long, string given in %s 21 | int(0) 22 | int(0) 23 | -------------------------------------------------------------------------------- /tests/no-servers/mongodbref-create-002.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | MongoDBRef::create() casts reference and database parameters to strings 3 | --SKIPIF-- 4 | 5 | --FILE-- 6 | 9 | --EXPECT-- 10 | array(3) { 11 | ["$ref"]=> 12 | string(3) "123" 13 | ["$id"]=> 14 | int(456) 15 | ["$db"]=> 16 | string(3) "789" 17 | } 18 | -------------------------------------------------------------------------------- /tests/no-servers/mongoint32-001.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | MongoInt32 constructed with integers 3 | --SKIPIF-- 4 | 5 | --FILE-- 6 | 10 | --EXPECT-- 11 | bool(true) 12 | bool(true) 13 | -------------------------------------------------------------------------------- /tests/no-servers/mongoint32-002.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | MongoInt32 constructed with strings 3 | --SKIPIF-- 4 | 5 | --FILE-- 6 | 11 | --EXPECT-- 12 | bool(true) 13 | bool(true) 14 | bool(true) 15 | -------------------------------------------------------------------------------- /tests/no-servers/mongoint64-001.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | MongoInt64 constructed with integers 3 | --SKIPIF-- 4 | 5 | --FILE-- 6 | 10 | --EXPECT-- 11 | bool(true) 12 | bool(true) 13 | -------------------------------------------------------------------------------- /tests/no-servers/mongoint64-002.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | MongoInt64 constructed with strings 3 | --SKIPIF-- 4 | 5 | --FILE-- 6 | 11 | --EXPECT-- 12 | bool(true) 13 | bool(true) 14 | bool(true) 15 | -------------------------------------------------------------------------------- /tests/no-servers/mongolog-001.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | MongoLog constants 3 | --SKIPIF-- 4 | 5 | --FILE-- 6 | 23 | --EXPECTF-- 24 | bool(true) 25 | bool(true) 26 | bool(true) 27 | bool(true) 28 | bool(true) 29 | bool(true) 30 | bool(true) 31 | bool(true) 32 | bool(true) 33 | bool(true) 34 | -------------------------------------------------------------------------------- /tests/no-servers/mongoregex-001.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | MongoRegex constructor 3 | --SKIPIF-- 4 | 5 | --FILE-- 6 | regex); 9 | var_dump($regex->flags); 10 | 11 | $regex = new MongoRegex('/\w+/im'); 12 | var_dump($regex->regex); 13 | var_dump($regex->flags); 14 | 15 | $regex = new MongoRegex('/foo[bar]{3}/i'); 16 | var_dump($regex->regex); 17 | var_dump($regex->flags); 18 | ?> 19 | --EXPECT-- 20 | string(0) "" 21 | string(0) "" 22 | string(3) "\w+" 23 | string(2) "im" 24 | string(11) "foo[bar]{3}" 25 | string(1) "i" 26 | -------------------------------------------------------------------------------- /tests/no-servers/mongoregex-002.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | MongoRegex constructor with unsupported or redundant flags 3 | --SKIPIF-- 4 | 5 | --FILE-- 6 | regex); 9 | var_dump($regex->flags); 10 | 11 | $regex = new MongoRegex('//iii'); 12 | var_dump($regex->regex); 13 | var_dump($regex->flags); 14 | 15 | $regex = new MongoRegex('//nopenope'); 16 | var_dump($regex->regex); 17 | var_dump($regex->flags); 18 | ?> 19 | --EXPECT-- 20 | string(0) "" 21 | string(4) "nope" 22 | string(0) "" 23 | string(3) "iii" 24 | string(0) "" 25 | string(8) "nopenope" 26 | -------------------------------------------------------------------------------- /tests/no-servers/mongoregex-tostring.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | MongoRegex::__toString() 3 | --SKIPIF-- 4 | 5 | --FILE-- 6 | 10 | --EXPECT-- 11 | /foo[bar]{3}/imx 12 | -------------------------------------------------------------------------------- /tests/no-servers/mongoregex_error.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | MongoRegex constructor given invalid arguments 3 | --SKIPIF-- 4 | 5 | --FILE-- 6 | getCode()); 14 | } 15 | } 16 | ?> 17 | --EXPECT-- 18 | MongoException: 9 19 | MongoException: 9 20 | MongoException: 9 21 | MongoException: 9 22 | -------------------------------------------------------------------------------- /tests/no-servers/mongotimestamp-001.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | MongoTimestamp constructor uses automatic increment 3 | --SKIPIF-- 4 | 5 | --FILE-- 6 | sec, $ts->inc); 9 | 10 | $ts = new MongoTimestamp(); 11 | printf("Timestamp(%d, %d)\n", $ts->sec, $ts->inc); 12 | 13 | $ts = new MongoTimestamp(12345, 67890); 14 | printf("Timestamp(%d, %d)\n", $ts->sec, $ts->inc); 15 | 16 | $ts = new MongoTimestamp(100); 17 | printf("Timestamp(%d, %d)\n", $ts->sec, $ts->inc); 18 | 19 | $ts = new MongoTimestamp(); 20 | printf("Timestamp(%d, %d)\n", $ts->sec, $ts->inc); 21 | ?> 22 | --EXPECTF-- 23 | Timestamp(0, 0) 24 | Timestamp(%d, 0) 25 | Timestamp(12345, 67890) 26 | Timestamp(100, 1) 27 | Timestamp(%d, 2) 28 | -------------------------------------------------------------------------------- /tests/no-servers/mongotimestamp-002.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | MongoTimestamp constructor uses current time 3 | --DESCRIPTION-- 4 | This test purposesly allows for one second of variation between MongoTimestamp 5 | and the asserted timestamp, since we cannot guarantee that the clock will not 6 | advance to the next second during test execution. 7 | --SKIPIF-- 8 | 9 | --FILE-- 10 | sec <= 1); 13 | ?> 14 | --EXPECT-- 15 | bool(true) 16 | -------------------------------------------------------------------------------- /tests/no-servers/mongotimestamp-003.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | MongoTimestamp constructor casts arguments to integers 3 | --SKIPIF-- 4 | 5 | --FILE-- 6 | sec); 9 | var_dump($ts->inc); 10 | 11 | $ts = new MongoTimestamp(60.123, 3e1); 12 | var_dump($ts->sec); 13 | var_dump($ts->inc); 14 | ?> 15 | --EXPECT-- 16 | int(60) 17 | int(30) 18 | int(60) 19 | int(30) 20 | -------------------------------------------------------------------------------- /tests/no-servers/mongotimestamp-004.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | MongoTimestamp comparison 3 | --SKIPIF-- 4 | 5 | --FILE-- 6 | 12 | --EXPECT-- 13 | bool(true) 14 | bool(false) 15 | -------------------------------------------------------------------------------- /tests/no-servers/mongotimestamp-tostring.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | MongoTimestamp::__toString() 3 | --SKIPIF-- 4 | 5 | --FILE-- 6 | 10 | --EXPECT-- 11 | 12345 12 | -------------------------------------------------------------------------------- /tests/no-servers/mongotimestamp_error.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | MongoTimestamp constructor given invalid arguments 3 | --SKIPIF-- 4 | 5 | --FILE-- 6 | sec); 9 | var_dump($ts->inc); 10 | 11 | $ts = new MongoTimestamp(1, 'foo'); 12 | var_dump($ts->sec); 13 | var_dump($ts->inc); 14 | ?> 15 | --EXPECTF-- 16 | Warning: MongoTimestamp::__construct() expects parameter 1 to be long, string given in %s 17 | int(0) 18 | int(0) 19 | 20 | Warning: MongoTimestamp::__construct() expects parameter 2 to be long, string given in %s 21 | int(0) 22 | int(0) 23 | -------------------------------------------------------------------------------- /tests/no-servers/skipif.inc: -------------------------------------------------------------------------------- 1 | 5 | --FILE-- 6 | $rs['rsname'])); 12 | 13 | ?> 14 | ===DONE=== 15 | 16 | --EXPECTF-- 17 | ===DONE=== 18 | -------------------------------------------------------------------------------- /tests/replicaset/legacy/bug00266.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Test for PHP-266: segfault when connection string refers to unknown replica set member. 3 | --SKIPIF-- 4 | 5 | 6 | --FILE-- 7 | true)); 19 | $coll = $m->selectCollection("phpunit","bug00266"); 20 | try { 21 | $coll->getIndexInfo(); 22 | echo "I'm alive\n"; 23 | } catch(MongoCursorException $e) { 24 | var_dump($e->getMessage()); 25 | } 26 | ?> 27 | --EXPECT-- 28 | I'm alive 29 | 30 | -------------------------------------------------------------------------------- /tests/replicaset/legacy/bug00307.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Test for PHP-307: getHosts() turns wrong results. 3 | --SKIPIF-- 4 | 5 | --FILE-- 6 | phpunit->bug307; 12 | var_dump($d->findOne()); 13 | 14 | $hosts = $m->getHosts(); 15 | $host = current($hosts); 16 | var_dump($host); 17 | ?> 18 | --EXPECTF-- 19 | NULL 20 | array(6) { 21 | ["host"]=> 22 | string(%d) "%s" 23 | ["port"]=> 24 | int(%d) 25 | ["health"]=> 26 | int(%d) 27 | ["state"]=> 28 | int(%d) 29 | ["ping"]=> 30 | int(%d) 31 | ["lastPing"]=> 32 | int(%d) 33 | } 34 | -------------------------------------------------------------------------------- /tests/replicaset/legacy/bug00611.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Test for PHP-611: Segfault when no candidate servers found. 3 | --SKIPIF-- 4 | 5 | 6 | --FILE-- 7 | MongoClient::RP_PRIMARY_PREFERRED, 13 | "readPreferenceTags" => "dc:no;dc:eu;", 14 | "replicaSet" => rsname(), 15 | ); 16 | try { 17 | $m = new MongoClient($hostname, $opts); 18 | } catch(MongoConnectionException $e) { 19 | echo $e->getMessage(), "\n"; 20 | } 21 | echo "I'm alive\n"; 22 | ?> 23 | --EXPECT-- 24 | No candidate servers found 25 | I'm alive 26 | -------------------------------------------------------------------------------- /tests/replicaset/legacy/bug00676.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Test for PHP-676: Collection level write concern overwritten by deprecated "safe" option 3 | --SKIPIF-- 4 | 5 | 6 | --INI-- 7 | error_reporting=0 8 | --FILE-- 9 | selectDb(dbname())->semafor; 14 | $oSemafor->drop(); 15 | $oSemafor->w = 42; 16 | $oSemafor->wtimeout = 3; 17 | 18 | try{ 19 | $time = microtime(true); 20 | $x = $oSemafor->insert(array('createts' => microtime(true)), array('safe' => true)); 21 | var_dump($x); 22 | } catch(MongoCursorException $e){ 23 | var_dump($e->getMessage(), $e->getCode()); 24 | } 25 | ?> 26 | --EXPECTF-- 27 | string(%d) "%s:%d:%stime%S" 28 | int(%d) 29 | -------------------------------------------------------------------------------- /tests/replicaset/legacy/bug00685.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Test for PHP-685: wtimeout option is not supported per-query 3 | --SKIPIF-- 4 | 5 | 6 | --FILE-- 7 | selectDb(dbname())->test->insert(array("random" => "data"), array("wtimeout" => 1, "w" => 7)); 16 | } catch(MongoCursorException $e) { 17 | var_dump($e->getMessage(), $e->getCode()); 18 | } 19 | 20 | if ((time() - $start) > 2) { 21 | echo "timeout longer than it should have been\n"; 22 | } 23 | ?> 24 | --EXPECTF-- 25 | %s: MongoCollection::insert(): The 'wtimeout' option is deprecated, please use 'wTimeoutMS' instead in %sbug00685.php on line %d 26 | string(%d) "%s:%d:%stime%S" 27 | int(%d) 28 | -------------------------------------------------------------------------------- /tests/replicaset/legacy/bug00790.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Test for PHP-790: MongoCollection write operation wtimeout option inconsistent with connection string wTimeoutMS option 3 | --SKIPIF-- 4 | 5 | 6 | --FILE-- 7 | selectDb(dbname())->test->insert(array("random" => "data"), array("wTimeoutMS" => 1, "w" => 7)); 16 | } catch(MongoCursorException $e) { 17 | var_dump($e->getMessage(), $e->getCode()); 18 | } 19 | 20 | if ((time() - $start) > 2) { 21 | echo "timeout longer than it should have been\n"; 22 | } 23 | ?> 24 | --EXPECTF-- 25 | string(%d) "%s:%d:%stime%S" 26 | int(%d) 27 | -------------------------------------------------------------------------------- /tests/replicaset/legacy/connection-tostring.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Connection strings: toString. 3 | --SKIPIF-- 4 | 5 | 6 | --FILE-- 7 | __toString()); 14 | 15 | ?> 16 | --EXPECTF-- 17 | string(%d) "[%s:%d],%s:%d"" 18 | -------------------------------------------------------------------------------- /tests/replicaset/legacy/log-3.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Test for MongoLog (PARSE only) 3 | --SKIPIF-- 4 | 5 | --FILE-- 6 | $config["rsname"])); 19 | ?> 20 | --EXPECTF-- 21 | PARSE INFO: Parsing mongodb://%s:%d 22 | PARSE INFO: - Found node: %s:%d 23 | PARSE INFO: - Connection type: STANDALONE 24 | PARSE INFO: - Found option 'replicaSet': '%s' 25 | PARSE INFO: - Switching connection type: REPLSET 26 | -------------------------------------------------------------------------------- /tests/replicaset/mongoclient-construct-001.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | MongoClient::__construct(): Connecting to replicaset (1) 3 | --SKIPIF-- 4 | 5 | --FILE-- 6 | $rs["rsname"])); 12 | echo "ok\n"; 13 | } catch(Exception $e) { 14 | var_dump(get_class($e), $e->getMessage()); 15 | } 16 | 17 | ?> 18 | --EXPECTF-- 19 | ok 20 | 21 | -------------------------------------------------------------------------------- /tests/replicaset/mongoclient-construct-002.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | MongoClient::__construct(): Connecting to replicaset using only one node (2) 3 | --SKIPIF-- 4 | 5 | --FILE-- 6 | $rs["rsname"])); 12 | echo "ok\n"; 13 | } catch(Exception $e) { 14 | var_dump(get_class($e), $e->getMessage()); 15 | } 16 | 17 | ?> 18 | --EXPECTF-- 19 | ok 20 | 21 | -------------------------------------------------------------------------------- /tests/replicaset/mongoclient-construct-003.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | MongoClient::__construct(): Connecting to replicaset member in a standalone mode (3) 3 | --SKIPIF-- 4 | 5 | --FILE-- 6 | MongoClient::RP_PRIMARY_PREFERRED)); 12 | echo "ok\n"; 13 | } catch(Exception $e) { 14 | var_dump(get_class($e), $e->getMessage()); 15 | } 16 | 17 | ?> 18 | --EXPECTF-- 19 | ok 20 | 21 | -------------------------------------------------------------------------------- /tests/replicaset/mongocollection-getindexinfo-002.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | MongoCollection::getIndexInfo() Run against secondary directly (legacy mode) 3 | --SKIPIF-- 4 | 5 | 6 | --FILE-- 7 | selectCollection(dbname(), collname(__FILE__)); 14 | 15 | try { 16 | $l = $c->getIndexInfo(); 17 | } catch(MongoCursorException $e) { 18 | echo $e->getCode(), "\n"; 19 | echo $e->getMessage(), "\n"; 20 | } 21 | ?> 22 | DONE 23 | --EXPECTF-- 24 | 13435 25 | %s:%d: not master and slaveOk=false 26 | DONE 27 | -------------------------------------------------------------------------------- /tests/replicaset/mongocollection-getindexinfo-003.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | MongoCollection::getIndexInfo() Run against primary 3 | --SKIPIF-- 4 | 5 | 6 | --FILE-- 7 | $rs['rsname'])); 13 | $c = $m->selectCollection(dbname(), collname(__FILE__)); 14 | 15 | MongoLog::setModule( MongoLog::ALL ); 16 | MongoLog::setLevel( MongoLog::ALL ); 17 | MongoLog::setCallback( function($a, $b, $c) { if (preg_match('/forcing/', $c)) { echo $c, "\n"; } } ); 18 | 19 | $l = $c->getIndexInfo(); 20 | ?> 21 | DONE 22 | --EXPECTF-- 23 | forcing primary for command 24 | DONE 25 | -------------------------------------------------------------------------------- /tests/replicaset/mongocollection-getindexinfo-004.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | MongoCollection::getIndexInfo() Run against secondary directly 3 | --SKIPIF-- 4 | 5 | 6 | --FILE-- 7 | MongoClient::RP_SECONDARY)); 13 | $c = $m->selectCollection(dbname(), collname(__FILE__)); 14 | 15 | MongoLog::setModule( MongoLog::ALL ); 16 | MongoLog::setLevel( MongoLog::ALL ); 17 | MongoLog::setCallback( function($a, $b, $c) { if (preg_match('/forcing/', $c)) { echo $c, "\n"; } } ); 18 | 19 | $l = $c->getIndexInfo(); 20 | ?> 21 | DONE 22 | --EXPECTF-- 23 | DONE 24 | -------------------------------------------------------------------------------- /tests/replicaset/mongodb-listcollections-002.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | MongoDB::listCollections() Run against secondary directly (legacy mode) 3 | --SKIPIF-- 4 | 5 | 6 | --FILE-- 7 | selectDB(dbname()); 14 | 15 | try { 16 | $l = $d->listCollections(); 17 | } catch(MongoCursorException $e) { 18 | echo $e->getCode(), "\n"; 19 | echo $e->getMessage(), "\n"; 20 | } 21 | ?> 22 | DONE 23 | --EXPECTF-- 24 | 13435 25 | %s:%d: not master and slaveOk=false 26 | DONE 27 | -------------------------------------------------------------------------------- /tests/replicaset/mongodb-listcollections-003.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | MongoDB::listCollections() Run against primary 3 | --SKIPIF-- 4 | 5 | 6 | --FILE-- 7 | $rs['rsname'])); 13 | $d = $m->selectDB(dbname()); 14 | 15 | MongoLog::setModule( MongoLog::ALL ); 16 | MongoLog::setLevel( MongoLog::ALL ); 17 | MongoLog::setCallback( function($a, $b, $c) { if (preg_match('/forcing/', $c)) { echo $c, "\n"; } } ); 18 | 19 | $l = $d->listCollections(); 20 | ?> 21 | DONE 22 | --EXPECTF-- 23 | forcing primary for command 24 | DONE 25 | -------------------------------------------------------------------------------- /tests/replicaset/mongodb-listcollections-004.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | MongoDB::listCollections() Run against secondary directly 3 | --SKIPIF-- 4 | 5 | 6 | --FILE-- 7 | MongoClient::RP_SECONDARY)); 13 | $d = $m->selectDB(dbname()); 14 | 15 | MongoLog::setModule( MongoLog::ALL ); 16 | MongoLog::setLevel( MongoLog::ALL ); 17 | MongoLog::setCallback( function($a, $b, $c) { if (preg_match('/forcing/', $c)) { echo $c, "\n"; } } ); 18 | 19 | $l = $d->listCollections(); 20 | ?> 21 | DONE 22 | --EXPECTF-- 23 | DONE 24 | -------------------------------------------------------------------------------- /tests/standalone/bug00712.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | PHP-712: findAndModify returns empty array when nothing is found. 3 | --SKIPIF-- 4 | 5 | --FILE-- 6 | selectDb(dbname())->bug712; 12 | $c->drop(); 13 | 14 | $c->insert( array( 'x' => 1 ) ); 15 | 16 | $a = $c->findAndModify( 17 | array( 'x' => 1 ), 18 | array( '$set' => array( 'x' => 1 ) ), 19 | array( '_id' => 0, 'x' => 0 ) 20 | ); 21 | 22 | $b = $c->findAndModify( 23 | array( 'x' => 2 ), 24 | array( '$set' => array( 'x' => 1 ) ), 25 | array( '_id' => 0, 'x' => 0 ) 26 | ); 27 | 28 | var_dump( $a, $b ); 29 | ?> 30 | --EXPECTF-- 31 | array(0) { 32 | } 33 | NULL 34 | 35 | -------------------------------------------------------------------------------- /tests/standalone/bug00723.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Test for PHP-723: Possibly invalid read in MongoCollection getter 3 | --SKIPIF-- 4 | 5 | --FILE-- 6 | test; 12 | 13 | $collection = $db->part1->part2; 14 | var_dump($collection->getName()); 15 | 16 | ?> 17 | --EXPECTF-- 18 | string(11) "part1.part2" 19 | -------------------------------------------------------------------------------- /tests/standalone/bug00756.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Test for PHP-756: Support QueryFailure query flag 3 | --SKIPIF-- 4 | 5 | --FILE-- 6 | selectCollection(dbname(), 'php756'); 12 | $c->drop(); 13 | $c->insert(array('test'=>42)); 14 | 15 | $r = $c->find( array( 'foo' => array( '$near' => array( 5, 5 ) ) ) ); 16 | 17 | try { 18 | foreach( $r as $f) 19 | { 20 | var_dump($f); 21 | } 22 | } catch (MongoCursorException $e) { 23 | echo "got exception\n"; 24 | } 25 | ?> 26 | --EXPECTF-- 27 | got exception 28 | -------------------------------------------------------------------------------- /tests/standalone/bug00848.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Invalid read in $cursor->count() 3 | --SKIPIF-- 4 | 5 | --FILE-- 6 | selectDB(dbname()) 14 | ->selectCollection("bug848") 15 | ->find() 16 | ->sort(array("_id" => 1)); 17 | $cursor->count(); 18 | foreach($cursor as $doc); 19 | echo "ok\n"; 20 | ?> 21 | --EXPECTF-- 22 | ok 23 | 24 | -------------------------------------------------------------------------------- /tests/standalone/bug00859.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Test for PHP-859: MongoCollection::save() crashes when giving options. 3 | --SKIPIF-- 4 | 5 | --FILE-- 6 | selectDb(dbname())->bug859; 12 | $c->drop(); 13 | 14 | $document = array('data' => 'test'); 15 | $writeConcern = array('w' => 1, 'j' => true); 16 | $c->save($document, $writeConcern); 17 | echo "DONE\n"; 18 | ?> 19 | --EXPECTF-- 20 | DONE 21 | -------------------------------------------------------------------------------- /tests/standalone/bug00872-001.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Test for PHP-872: Driver needs to prevent \0 in key names. 3 | --SKIPIF-- 4 | 5 | --FILE-- 6 | selectDb(dbname())->bug872; 13 | $c->drop(); 14 | 15 | $document = array( 16 | 'fo' . chr(0) . 'o' => 42, 17 | ); 18 | 19 | try { 20 | $c->insert( $document ); 21 | } catch( MongoException $e ) { 22 | var_dump($e->getCode()); 23 | var_dump($e->getMessage()); 24 | } 25 | ?> 26 | --EXPECTF-- 27 | int(2) 28 | string(32) "'\0' not allowed in key: fo\0..." 29 | -------------------------------------------------------------------------------- /tests/standalone/bug00872-003.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Test for PHP-872: Driver needs to prevent \0 in database names. 3 | --SKIPIF-- 4 | 5 | --FILE-- 6 | $faulty; 16 | } catch( MongoException $e ) { 17 | var_dump($e->getCode()); 18 | var_dump($e->getMessage()); 19 | } 20 | 21 | try { 22 | $c = $m->selectDb($faulty); 23 | } catch( MongoException $e ) { 24 | var_dump($e->getCode()); 25 | var_dump($e->getMessage()); 26 | } 27 | ?> 28 | --EXPECT-- 29 | int(2) 30 | string(48) "Database name cannot contain null bytes: fo\0..." 31 | int(2) 32 | string(48) "Database name cannot contain null bytes: fo\0..." 33 | -------------------------------------------------------------------------------- /tests/standalone/bug00928-001.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Test for PHP-928: The 'w' property is read-only (parent::__construct) 3 | --SKIPIF-- 4 | 5 | --FILE-- 6 | 22 | --EXPECTF-- 23 | MyDb 24 | -------------------------------------------------------------------------------- /tests/standalone/bug00928-002.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Test for PHP-928: The 'w' property is read-only (inherited method) 3 | --SKIPIF-- 4 | 5 | --FILE-- 6 | w = $w; 18 | } 19 | } 20 | 21 | $dsn = MongoShellServer::getStandaloneInfo(); 22 | $m = new MongoClient($dsn); 23 | 24 | $db = new MyDB($m, dbname()); 25 | echo get_class($db); 26 | ?> 27 | --EXPECTF-- 28 | MyDb 29 | -------------------------------------------------------------------------------- /tests/standalone/bug00928-003.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Test for PHP-928: The 'w' property is read-only (out-of-scope) 3 | --SKIPIF-- 4 | 5 | --FILE-- 6 | w = 42; 21 | echo get_class($db); 22 | ?> 23 | --EXPECTF-- 24 | %s: main(): The 'w' property is read-only in %sbug00928-003.php on line %d 25 | MyDb 26 | -------------------------------------------------------------------------------- /tests/standalone/bug01011-001.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Test for PHP-1011: MongoDB does not inherit write concern string mode option 3 | --SKIPIF-- 4 | 5 | --FILE-- 6 | 'majority')); 11 | 12 | $db = $mc->selectDB(dbname()); 13 | 14 | dump_these_keys($db->getWriteConcern(), array('w')); 15 | 16 | ?> 17 | ===DONE=== 18 | --EXPECTF-- 19 | array(1) { 20 | ["w"]=> 21 | string(8) "majority" 22 | } 23 | ===DONE=== 24 | -------------------------------------------------------------------------------- /tests/standalone/bug01019.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | PHP-1019: Empty Batch Insert should throw exception 3 | --SKIPIF-- 4 | 5 | --FILE-- 6 | selectCollection(dbname(), collname(__FILE__)); 14 | $collection->drop(); 15 | 16 | 17 | try { 18 | $retval = $collection->batchInsert(array()); 19 | var_dump($retval); 20 | echo "FAILED\n!"; 21 | } catch(MongoException $e) { 22 | echo $e->getMessage(), "\n"; 23 | } 24 | 25 | ?> 26 | ===DONE=== 27 | 28 | --EXPECTF-- 29 | No write ops were included in the batch 30 | ===DONE=== 31 | 32 | -------------------------------------------------------------------------------- /tests/standalone/bug01044.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Test for PHP-906: Segmentation Fault - in mongo_deregister_callback_from_connection 3 | --SKIPIF-- 4 | 5 | 6 | --FILE-- 7 | 19 | --EXPECT-- 20 | I should still be alive! 21 | 22 | -------------------------------------------------------------------------------- /tests/standalone/bug01080.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Test for PHP-1080: MongoCursor::$timeout=-1 doesn't work anymore 3 | --SKIPIF-- 4 | 5 | --FILE-- 6 | -1)); 11 | $db = $mc->selectDb(dbname()); 12 | 13 | $collection = $mc->selectCollection(dbname(), collname(__FILE__)); 14 | $collection->drop(); 15 | 16 | MongoCursor::$timeout = -1; 17 | $collection->findOne(); 18 | ?> 19 | ===DONE=== 20 | 21 | --EXPECTF-- 22 | %s: MongoCollection::findOne(): The 'MongoCursor::$timeout' static property is deprecated, please call MongoCursor->timeout() instead in %s on line %d 23 | ===DONE=== 24 | 25 | -------------------------------------------------------------------------------- /tests/standalone/bug01084.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Test for PHP-1084: collection->update($query, $document) crashes if $document is an object 3 | --SKIPIF-- 4 | 5 | --FILE-- 6 | selectDb(dbname()); 12 | $collection = $mc->selectCollection(dbname(), collname(__FILE__)); 13 | $collection->drop(); 14 | 15 | 16 | $document = array("some" => "document"); 17 | $collection->insert($document); 18 | $collection->update($document["_id"], array("data")); 19 | $collection->remove($document["_id"]); 20 | echo "I am alive\n"; 21 | ?> 22 | ===DONE=== 23 | 24 | --EXPECTF-- 25 | I am alive 26 | ===DONE=== 27 | 28 | -------------------------------------------------------------------------------- /tests/standalone/bug01109.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Test for PHP-1109: upsert returns an array of ids rather then the _id 3 | --SKIPIF-- 4 | 5 | --FILE-- 6 | selectDb(dbname()); 12 | $collection = $mc->selectCollection(dbname(), collname(__FILE__)); 13 | $collection->drop(); 14 | 15 | $mid = new MongoID(); 16 | $ret = $collection->update(array("_id" => $mid), array('$set' => array("x" => "y")), array("upsert" => true)); 17 | var_dump($ret["upserted"] == $mid, (string)$ret["upserted"]); 18 | ?> 19 | ===DONE=== 20 | 21 | --EXPECTF-- 22 | bool(true) 23 | string(24) "%s" 24 | ===DONE=== 25 | 26 | -------------------------------------------------------------------------------- /tests/standalone/bug01118.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Test for PHP-1118: Aggregate cursor on non-existing collection throws weird error. 3 | --SKIPIF-- 4 | 5 | --FILE-- 6 | demo->foobar; 13 | $c->drop(); 14 | 15 | $query = array(array('$match' => array( 'foo' => 'telephone' ))); 16 | 17 | $results = $c->aggregateCursor($query); 18 | 19 | foreach ( $results as $r ) 20 | { 21 | } 22 | ?> 23 | ===DONE=== 24 | --EXPECT-- 25 | ===DONE=== 26 | -------------------------------------------------------------------------------- /tests/standalone/bug01280.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Test for PHP-1280: segfault without auth credentials 3 | --SKIPIF-- 4 | 5 | --FILE-- 6 | rewind(); 14 | } catch (Exception $e) { 15 | echo $e->getMessage(), "\n"; 16 | } 17 | ?> 18 | ==DONE== 19 | --EXPECTF-- 20 | %s:%d: no such c%s 21 | ==DONE== 22 | -------------------------------------------------------------------------------- /tests/standalone/bug01435.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Test for PHP-1435: MongoCollection::getIndexInfo on non-existing collection segfaults 3 | --SKIPIF-- 4 | 5 | --FILE-- 6 | selectCollection('doesnotexist', 'doesnotexist'); 12 | $i = $c->getIndexInfo(); 13 | $m->close(); 14 | var_dump($i); 15 | ?> 16 | ==DONE== 17 | --EXPECTF-- 18 | array(0) { 19 | } 20 | ==DONE== 21 | -------------------------------------------------------------------------------- /tests/standalone/legacy/bug00522_error.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Test for PHP-522: Checking error conditions in insert options 3 | --SKIPIF-- 4 | 5 | --FILE-- 6 | selectCollection( dbname(), "php-522_error" ); 11 | 12 | $c->w = "3"; 13 | 14 | try { 15 | $c->insert( array( 'test' => 1 ), array( 'w' => 3 ) ); 16 | } catch ( Exception $e ) { 17 | echo $e->getMessage(), "\n"; 18 | } 19 | ?> 20 | --EXPECTF-- 21 | %s:%d:%s 22 | -------------------------------------------------------------------------------- /tests/standalone/legacy/bug00644-001.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Test for PHP-644: mongo.ping_interval and mongo.is_master_interval is unused (1) 3 | --SKIPIF-- 4 | 5 | --INI-- 6 | mongo.ping_interval=103 7 | mongo.is_master_interval=823 8 | --FILE-- 9 | 13 | --EXPECTF-- 14 | 103 15 | 823 16 | -------------------------------------------------------------------------------- /tests/standalone/legacy/bug00644-002.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Test for PHP-644: mongo.ping_interval and mongo.is_master_interval is unused (2) 3 | --SKIPIF-- 4 | 5 | --INI-- 6 | mongo.ping_interval=victory 7 | mongo.is_master_interval=-5 8 | --FILE-- 9 | 13 | --EXPECTF-- 14 | 5 15 | 15 16 | -------------------------------------------------------------------------------- /tests/standalone/legacy/connect-mongodb-prefix.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Connection strings: Prefixed with mongodb:// 3 | --SKIPIF-- 4 | 5 | 11 | --FILE-- 12 | false)); 18 | var_dump($c->connected); 19 | $a = new Mongo("mongodb://$STANDALONE_HOSTNAME"); 20 | var_dump($a->connected); 21 | $b = new Mongo("mongodb://$STANDALONE_HOSTNAME:$STANDALONE_PORT"); 22 | var_dump($b->connected); 23 | --EXPECTF-- 24 | bool(false) 25 | bool(true) 26 | bool(true) 27 | -------------------------------------------------------------------------------- /tests/standalone/legacy/log-3.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Test for MongoLog (PARSE only) 3 | --SKIPIF-- 4 | 5 | --FILE-- 6 | 20 | --EXPECTF-- 21 | PARSE INFO: Parsing mongodb://%s:%d 22 | PARSE INFO: - Found node: %s:%d 23 | PARSE INFO: - Connection type: STANDALONE 24 | -------------------------------------------------------------------------------- /tests/standalone/mongoclient-construct-001.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | MongoClient::__construct()#001 Connecting to standalone server 3 | --SKIPIF-- 4 | 5 | --FILE-- 6 | getMessage()); 15 | } 16 | 17 | ?> 18 | --EXPECTF-- 19 | ok 20 | 21 | -------------------------------------------------------------------------------- /tests/standalone/mongocursor-explain.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | MongoCursor::explain() 3 | --SKIPIF-- 4 | 5 | --FILE-- 6 | selectCollection(dbname(), collname(__FILE__)); 11 | $c->drop(); 12 | $c->insert( array( 'test' => 42 ) ); 13 | 14 | $result = $c->find( array( 'test' => array( '$gte' => 40 ) ) )->explain(); 15 | echo gettype( $result ), "\n"; 16 | ?> 17 | --EXPECTF-- 18 | array 19 | -------------------------------------------------------------------------------- /tests/standalone/mongocursor-hint-001.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | MongoCursor::hint() 3 | --SKIPIF-- 4 | 5 | --FILE-- 6 | array('log_query' => 'log_query'))); 14 | $host = MongoShellServer::getStandaloneInfo(); 15 | $mc = new MongoClient($host, array(), array("context" => $ctx)); 16 | 17 | $c = $mc->selectCollection(dbname(), 'mongocursor-hint-001'); 18 | $c->find()->hint('x_1')->next(); 19 | $c->find()->hint(array('x' => 1))->next(); 20 | $c->find()->hint(new stdClass())->next(); 21 | 22 | ?> 23 | --EXPECTF-- 24 | string(3) "x_1" 25 | array(1) { 26 | ["x"]=> 27 | int(1) 28 | } 29 | object(stdClass)#%d (0) { 30 | } 31 | -------------------------------------------------------------------------------- /tests/standalone/mongocursor-info-005.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | MongoCursor::info() (64bit, native_long=0, long_as_object=0) 3 | --SKIPIF-- 4 | 5 | 6 | --FILE-- 7 | selectCollection(dbname(), 'info'); 15 | $c->drop(); 16 | 17 | for ($i = 0; $i < 105; $i++) { 18 | $c->insert(array('test' => $i)); 19 | } 20 | 21 | $r = $c->find(); 22 | $foo = $r->next(); 23 | $info = $r->info(); 24 | echo gettype($info['id']), "\n"; 25 | var_dump($info['id']); 26 | ?> 27 | --EXPECTF-- 28 | double 29 | float(%f) 30 | -------------------------------------------------------------------------------- /tests/standalone/mongocursor-info-006.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | MongoCursor::info() (64bit, native_long=1, long_as_object=0) 3 | --SKIPIF-- 4 | 5 | 6 | --FILE-- 7 | selectCollection(dbname(), 'info'); 15 | $c->drop(); 16 | 17 | for ($i = 0; $i < 105; $i++) { 18 | $c->insert(array('test' => $i)); 19 | } 20 | 21 | $r = $c->find(); 22 | $foo = $r->next(); 23 | $info = $r->info(); 24 | echo gettype($info['id']), "\n"; 25 | var_dump($info['id']); 26 | ?> 27 | --EXPECTF-- 28 | integer 29 | int(%d) 30 | -------------------------------------------------------------------------------- /tests/standalone/mongoinsertbatch-008.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | MongoWriteBatch: Throw exception on invalid wire version 3 | --SKIPIF-- 4 | 5 | 6 | 7 | --FILE-- 8 | selectCollection(dbname(), collname(__FILE__)); 16 | $collection->drop(); 17 | 18 | 19 | try { 20 | $batch = new MongoInsertBatch($collection); 21 | } catch(MongoProtocolException $e) { 22 | echo $e->getMessage(), "\n"; 23 | } 24 | 25 | ?> 26 | ===DONE=== 27 | 28 | --EXPECTF-- 29 | Current primary does not have a Write API support 30 | ===DONE=== 31 | -------------------------------------------------------------------------------- /tests/templates/bridge.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Test for PHP-xxx: Description 3 | --SKIPIF-- 4 | ="; ?> 5 | 6 | 7 | --FILE-- 8 | selectDb(dbname()); 14 | $collection = $mc->selectCollection(dbname(), collname(__FILE__)); 15 | $collection->drop(); 16 | 17 | echo "My test here\n"; 18 | ?> 19 | ===DONE=== 20 | 21 | --EXPECTF-- 22 | My test here 23 | ===DONE=== 24 | 25 | -------------------------------------------------------------------------------- /tests/templates/failover-replicaset.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Test for PHP-xxx: Description 3 | --SKIPIF-- 4 | ="; ?> 5 | 6 | --FILE-- 7 | getReplicaSetConfig(); 12 | $opts = array('replicaSet' => $cfg['rsname']); 13 | $mc = new MongoClient($cfg["dsn"], $opts); 14 | $db = $mc->selectDb(dbname()); 15 | $collection = $mc->selectCollection(dbname(), collname(__FILE__)); 16 | $collection->drop(); 17 | 18 | echo "My test here\n"; 19 | $s->killMaster(); 20 | 21 | ?> 22 | ===DONE=== 23 | 24 | --CLEAN-- 25 | 26 | --EXPECTF-- 27 | My test here 28 | ===DONE=== 29 | 30 | -------------------------------------------------------------------------------- /tests/templates/mongos.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Test for PHP-xxx: Description 3 | --SKIPIF-- 4 | ="; ?> 5 | 6 | --FILE-- 7 | selectDb(dbname()); 13 | $collection = $mc->selectCollection(dbname(), collname(__FILE__)); 14 | $collection->drop(); 15 | 16 | echo "My test here\n"; 17 | ?> 18 | ===DONE=== 19 | 20 | --EXPECTF-- 21 | My test here 22 | ===DONE=== 23 | 24 | -------------------------------------------------------------------------------- /tests/templates/replicaset.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Test for PHP-xxx: Description 3 | --SKIPIF-- 4 | ="; ?> 5 | 6 | --FILE-- 7 | $cfg['rsname']); 12 | $mc = new MongoClient($cfg["dsn"], $opts); 13 | $db = $mc->selectDb(dbname()); 14 | $collection = $mc->selectCollection(dbname(), collname(__FILE__)); 15 | $collection->drop(); 16 | 17 | echo "My test here\n"; 18 | ?> 19 | ===DONE=== 20 | 21 | --EXPECTF-- 22 | My test here 23 | ===DONE=== 24 | 25 | -------------------------------------------------------------------------------- /tests/templates/standalone.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Test for PHP-xxx: Description 3 | --SKIPIF-- 4 | ="; ?> 5 | 6 | --FILE-- 7 | selectDb(dbname()); 13 | $collection = $mc->selectCollection(dbname(), collname(__FILE__)); 14 | $collection->drop(); 15 | 16 | echo "My test here\n"; 17 | ?> 18 | ===DONE=== 19 | 20 | --EXPECTF-- 21 | My test here 22 | ===DONE=== 23 | 24 | -------------------------------------------------------------------------------- /tests/templates/unix.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Test for PHP-xxx: Description 3 | --SKIPIF-- 4 | ="; ?> 5 | 6 | --FILE-- 7 | selectDb(dbname()); 13 | $collection = $mc->selectCollection(dbname(), collname(__FILE__)); 14 | $collection->drop(); 15 | 16 | echo "My test here\n"; 17 | ?> 18 | ===DONE=== 19 | 20 | --EXPECTF-- 21 | My test here 22 | ===DONE=== 23 | 24 | -------------------------------------------------------------------------------- /tests/unix-standalone/bug00846.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Test for PHP-846: Connecting to standalone server over Unix Domain sockets 3 | --SKIPIF-- 4 | 5 | --FILE-- 6 | getMessage()); 17 | } 18 | 19 | ?> 20 | --EXPECTF-- 21 | Notice: PARSE INFO: Parsing /tmp/mongodb-%d.sock in %s on line %d 22 | 23 | Notice: PARSE INFO: - Found node: /tmp/mongodb-%d.sock:0 in %s on line %d 24 | 25 | Notice: PARSE INFO: - Connection type: STANDALONE in %s on line %d 26 | ok 27 | 28 | -------------------------------------------------------------------------------- /tests/utils/auth-replicaset.inc: -------------------------------------------------------------------------------- 1 | getReplicaSetConfig(true); 7 | $server->close(); 8 | } catch(Exception $e) { 9 | exit("skip " . $e->getMessage()); 10 | } 11 | 12 | -------------------------------------------------------------------------------- /tests/utils/bridge.inc: -------------------------------------------------------------------------------- 1 | getBridgeConfig(); 7 | $server->close(); 8 | if (!$cfg) { 9 | throw new Exception("No bridge configured"); 10 | } 11 | } catch(Exception $e) { 12 | die("skip " . $e->getMessage()); 13 | } 14 | 15 | 16 | -------------------------------------------------------------------------------- /tests/utils/collection-info.inc: -------------------------------------------------------------------------------- 1 | getCollectionInfo(array( 6 | 'includeSystemCollections' => true, 7 | 'filter' => array('name' => $name), 8 | )); 9 | 10 | return reset($collections) !== false ? current($collections) : null; 11 | } 12 | -------------------------------------------------------------------------------- /tests/utils/fix-master.inc: -------------------------------------------------------------------------------- 1 | restartMaster(); 6 | $server->close(); 7 | 8 | -------------------------------------------------------------------------------- /tests/utils/fix-secondaries.inc: -------------------------------------------------------------------------------- 1 | setMaintenanceForSecondaries(false); 6 | $server->close(); 7 | 8 | -------------------------------------------------------------------------------- /tests/utils/keyFile: -------------------------------------------------------------------------------- 1 | this is super secret key file that noone will ever figureout 2 | -------------------------------------------------------------------------------- /tests/utils/masterslave.inc: -------------------------------------------------------------------------------- 1 | getMasterSlaveConfig(); 7 | if (isset($needs)) { 8 | $needsOp = isset($needsOp) ? $needsOp : '>='; 9 | $serverversion = $server->getServerVersion("MASTERSLAVE"); 10 | if ( ! version_compare($serverversion, $needs, $needsOp)) { 11 | throw new Exception("Needs MongoDB $needsOp $needs, but is running $serverversion"); 12 | } 13 | } 14 | $server->close(); 15 | } catch(Exception $e) { 16 | exit("skip " . $e->getMessage()); 17 | } 18 | -------------------------------------------------------------------------------- /tests/utils/replicaset-failover.inc: -------------------------------------------------------------------------------- 1 | getUnixStandaloneConfig(); 7 | if (isset($needs)) { 8 | $needsOp = isset($needsOp) ? $needsOp : '>='; 9 | $serverversion = $server->getServerVersion("STANDALONE"); 10 | if ( ! version_compare($serverversion, $needs, $needsOp)) { 11 | throw new Exception("Needs MongoDB $needsOp $needs, but is running $serverversion"); 12 | } 13 | } 14 | $server->close(); 15 | } catch(Exception $e) { 16 | exit("skip " . $e->getMessage()); 17 | } 18 | --------------------------------------------------------------------------------