Archive: Namaste PHP AMQP framework v1.0 (2017-2020)

952 days continuous production uptime, 40k+ tp/s single node.
Original corpo Bitbucket history not included — clean archive commit.
This commit is contained in:
2026-04-05 09:49:30 -07:00
commit 373ebc8c93
1284 changed files with 409372 additions and 0 deletions

584
stubs/testMongo.php Normal file
View File

@@ -0,0 +1,584 @@
<?php
/**
* testMongo.php -- class-level test stub to validate mongo CRUD operations
*
* NOTE:
* -----
* as of 3-11-19, you have to process the meta-data payload through validateMetaData() in functions.php before
* submitting the payload to a class CRUD method, such as _fetchRecords().
*
*/
require_once(dirname(__DIR__) . '/config/sneakerstrap.inc');
// operations supported in this test script:
const OP_CREATE = 1;
const OP_FETCH = 2;
const OP_UPDATE = 3;
const OP_DELETE = 4;
const OP_SUBC_PUSH = 5;
const OP_SUBC_DEL = 6;
const OP_FETCH_LIMIT = 7;
const OP_FETCH_ALL = 8;
const OP_FETCH_BY_GUID = 9;
const OP_AUDIT_ROLLBACK = 10;
const OP_BAD_UPDATE = 11;
const OP_UPDATE_MANY = 12;
const OP_UPDATE_IN = 13;
const OP_SUBC_FETCH = 14;
const OP_TOK_UPD = 15; // token update
const OP_SMAX_CLIENT = 16; // smax client instantiation simulation
$thisOperation = OP_CREATE;
// instantiate
$meta = [
META_TEMPLATE => TEMPLATE_CLASS_TEST_MONGO,
META_CLIENT => CLIENT_CLIENT,
META_CLIENT_IP => STRING_SESSION_HOME,
META_EVENT_GUID => guid(), // simulate a broker event by generating the event guid
];
echo 'Event GUID: ' . $meta[META_EVENT_GUID] . PHP_EOL;
$jayne = "Ten percent of nothin' is ... let me do the math here ... nothin' into nothin' ... carry the nothin' ... ";
$errors = array();
// turn off mongo option
// gasConfig::$settings[CONFIG_DATABASE][CONFIG_DATABASE_MONGODB][CONFIG_DATABASE_MONGODB_ENABLED] = 0;
$objTest = new gacFactory($meta, FACTORY_EVENT_NEW_CLASS, '', $errors);
if (!$objTest->status) {
var_export($objTest);
exit;
}
/** @var gatTestMongo $objMongoTest->template */
/** @var gacMongoDB $objMongoTest */
$objMongoTest = $objTest->widget;
$objTest->__destruct();
unset($objTest);
//$objMongoTest->logger->info(basename(__FILE__) . AT . __LINE__);
//$objMongoTest->logger->warn('this is a test message');
// ok - now we have a native class object (widget) and we can do CRUD stuff..
// invoke the template method to generate a new data set of test data
switch ($thisOperation) {
case OP_CREATE :
$targetNumber = 1; // adjust this value to test with differing amounts of records
$testData = $objMongoTest->template->buildTestData($targetNumber);
$meta[META_DO_CACHE] = false;
// insert a bogus sub-collection field
$testData[0][CM_TST_FIELD_TEST_SUBC][STRING_WH_SETTINGS] = 'you should not see this value stored in the record ever';
$brokerPayload = [
BROKER_REQUEST => BROKER_REQUEST_FETCH,
BROKER_DATA => $testData,
BROKER_META_DATA => $meta
];
if (!validateMetaData($brokerPayload, $errors))
exit('meta data validation failed');
$objMongoTest->_createRecord($brokerPayload[BROKER_DATA]);
if ($objMongoTest->status) {
if (gasCache::mapOutboundPayload($objMongoTest, $errors)) {
var_export($objMongoTest->getCK());
echo $eos;
} else {
var_export($objMongoTest->eventMessages);
echo $eos;
}
} else {
var_export($objMongoTest->eventMessages);
echo $eos . ERROR_NOSQL_CREATE . $eos;
}
break;
case OP_SMAX_CLIENT :
// use the GA client which should already be in the SMAXAPI collection
$clientToken = '79344859-5403-1556-7663-4E34D6B4CBE4'; // ga token
$clientToken = '136EA67A-B1E2-0A4B-2BD8-EE34D39DFDE1'; // pl token
$meta[CLIENT_AUTH_TOKEN] = $clientToken;
$meta[META_CLIENT] = CLIENT_API_USER;
$meta[META_TEMPLATE] = TEMPLATE_PL_DONORS;
$obj = new gacFactory($meta, FACTORY_EVENT_NEW_CLASS, '', $errors);
if (!$obj->status) exit(ERROR_FACTORY_LOAD_BROKER . basename(__FILE__));
exit('successful instantiation of a priceline class by a priceline client');
break;
case OP_FETCH :
// let's do a fetch of records now - we want records where the string field hasn't been set to $jayne
// set the number of records to fetch...
$targetNumber = 5;
$objMongoTest->addMeta(META_LIMIT, $targetNumber);
// let's also set the skip meta value to ensure that skip is working correctly
$objMongoTest->addMeta(META_SKIP, 5);
// disable cache for testing:
$objMongoTest->addMeta(META_DONUT_FILTER, 1);
// set-up the query to fetch records where the string is not set to $jayne
// and sort in descending (LIFO) order of the created-date
$query = [ CM_TST_FIELD_TEST_STRING => [ OPERAND_NULL => [ OPERATOR_DNE => [$jayne] ] ] ];
$sort = [ CM_TST_FIELD_TEST_CDATE => STRING_SORT_DESC ];
// enable the next line to test projection filtering
// $projection = [ CM_TST_FIELD_TEST_DOUBLE ];
// build the request payload
$request = [ STRING_QUERY_DATA => $query, STRING_SORT_DATA => $sort ];
// $request = [ STRING_QUERY_DATA => $query, STRING_SORT_DATA => $sort, STRING_RETURN_DATA => $projection ];
$brokerPayload = [
BROKER_REQUEST => BROKER_REQUEST_FETCH,
STRING_SERVICE => ENV_APPSERVER,
BROKER_DATA => $request,
BROKER_META_DATA => $meta
];
if (!validateMetaData($brokerPayload, $errors)) exit('meta data validation failed');
$objMongoTest->_fetchRecords($request);
// cacheMap the outbound payload
$errors = [];
if (gasCache::mapOutboundPayload($objMongoTest, $errors)) {
var_export($objMongoTest->getCK());
echo $eos;
} else {
var_export(array_merge($objMongoTest->eventMessages, $errors));
echo $eos;
exit;
}
break;
case OP_UPDATE_IN :
$updateString = 'Saw your dork mobile in the parking lot - what does it get, like four miles to the gallon?';
// first, fetch the first 10 records with an active status
$query = [
CM_TST_FIELD_TEST_STATUS => [ OPERAND_NULL => [ OPERATOR_EQ => [ STATUS_ACTIVE ]]],
CM_TST_FIELD_TEST_STRING => [ OPERAND_NULL => [ OPERATOR_DNE => [ $updateString ]]],
OPERAND_AND => null
];
$objMongoTest->addMeta(META_LIMIT, 5);
$payload = [
BROKER_REQUEST => BROKER_REQUEST_FETCH,
BROKER_DATA => [ STRING_QUERY_DATA => $query, STRING_RETURN_DATA => [ CM_TST_TOKEN ]],
BROKER_META_DATA => $objMongoTest->getMetaDataPayload()
];
if (!validateMetaData($payload, $errors)) exit(ERROR_META_VALIDATION_SECOND_PASS);
@$objMongoTest->addMeta(META_DO_CACHE, false);
$objMongoTest->_fetchRecords($payload[BROKER_DATA]);
// we're testing the cache-bypass feature here in this next call
if (!gasCache::mapOutboundPayload($objMongoTest, $errors)) {
exit(ERROR_CACHE_MAP_FAIL . ' outbound payload');
}
if (!$objMongoTest->status) {
var_export($objMongoTest->eventMessages);
exit;
}
$data = $objMongoTest->getData();
$inData = null;
foreach ($data as $record)
foreach ($record as $k => $v)
$inData[] = $v;
// now that have the list of 10 records to update...generate the update command
$query = [ CM_TST_TOKEN => [ OPERAND_NULL => [ OPERATOR_IN => [ $inData ]]]];
$payload = [
BROKER_REQUEST => BROKER_REQUEST_UPDATE,
BROKER_DATA => [
STRING_QUERY_DATA => $query,
STRING_UPDATE_DATA => [ CM_TST_FIELD_TEST_STRING => $updateString ]
],
BROKER_META_DATA => $objMongoTest->getMetaDataPayload()
];
if (!validateMetaData($payload, $errors)) exit(ERROR_META_VALIDATION_SECOND_PASS);
$objMongoTest->_updateRecord($payload[BROKER_DATA]);
echo ($objMongoTest->status) ? 'success' : 'fail' . PHP_EOL;
break;
case OP_FETCH_BY_GUID :
// for this, you need to provide the GUID string of the record you wish to fetch
// this section is provided to test for loading a record via instantiation
$guid = '93241A58-B375-A31C-1429-2F185AFFD01A';
if (empty($guid) or !validateGUID($guid)) {
echo 'Missing or invalid guid for fetch by guid test' . $eos;
exit;
}
// delete the pre-existing object and re-create so we can instantiate with a guid
if (is_object($objMongoTest)) {
$objMongoTest->__destruct();
unset($objMongoTest);
$objTest = new gacFactory($meta, FACTORY_EVENT_NEW_CLASS, $guid, $errors);
if (!$objTest->status) {
var_export($objTest);
exit;
}
/** @var gatTestMongo $objMongoTest->template */
/** @var gacMongoDB $objMongoTest */
$objMongoTest = $objTest->widget;
$objTest->__destruct();
unset($objTest);
}
$query = [ CM_TST_TOKEN => [ OPERAND_NULL => [ OPERATOR_EQ => [ $guid ]]]];
$request = [ STRING_QUERY_DATA => $query ];
$brokerPayload = [
BROKER_REQUEST => BROKER_REQUEST_FETCH,
BROKER_DATA => $request,
BROKER_META_DATA => $meta
];
validateMetaData($brokerPayload, $errors);
$objMongoTest->_fetchRecords($brokerPayload[BROKER_DATA]);
if (!$objMongoTest->status) {
var_export($objMongoTest->eventMessages);
echo $eos;
exit;
}
$queryResults = gasCache::mapOutboundPayload($objMongoTest, $errors);
var_export($objMongoTest->getData());
exit;
break;
case OP_AUDIT_ROLLBACK :
$query = null;
$errors = [];
$retData = [];
if (is_object($objMongoTest)) $objMongoTest->__destruct();
unset($objMongoTest);
// pre-determined DB_TOKEN of targeted audit record
$queryData = [ STRING_KEY => "4AF69A2C-DD4D-CE27-D692-6CA845B2380D" ];
$meta[META_USER_INFO] = basename(__FILE__);
$meta[META_SYSTEM_NOTES] = 'testing journal recovery';
$meta[META_TEMPLATE] = TEMPLATE_CLASS_AUDIT;
// instantiate the audit record
$objFactory = new gacFactory($meta, FACTORY_EVENT_NEW_CLASS, $queryData[STRING_KEY], $errors);
if (!$objFactory->status) {
echo ERROR_FACTORY_LOAD_BROKER . TEMPLATE_CLASS_AUDIT . $eos;
var_export($objFactory->eventMessages);
exit;
}
$objAudit = $objFactory->widget;
if (is_object($objFactory)) $objFactory->__destruct();
unset($objFactory);
// launch the audit process
$startTime = gasStatic::doingTime();
$rc = $objAudit->restoreAuditRecord($retData);
$totalTime = gasStatic::doingTime($startTime);
if ($rc === true) echo 'Audit record recovered in: ' . (string) $totalTime . ' seconds' . $eos;
elseif (is_null($rc)) echo 'Audit method returned null' . $eos;
else echo 'Audit request failed';
if (!is_null($rc))
var_export($rc);
else
var_export($objAudit->eventMessages);
exit;
break;
case OP_FETCH_LIMIT :
$query = null;
$objMongoTest->addMeta(META_LIMIT, 1);
$request = [ BROKER_REQUEST => BROKER_REQUEST_FETCH, STRING_QUERY_DATA => $query, BROKER_META_DATA => $meta ];
$objMongoTest->_fetchRecords($request);
if ($objMongoTest->status) {
echo $objMongoTest->strQuery . $eos;
} else {
var_export($objMongoTest->eventMessages);
echo $eos;
exit;
}
break;
case OP_FETCH_ALL :
$query = null;
if (isset($meta[META_LIMIT])) unset($meta[META_LIMIT]);
$request = [ BROKER_REQUEST => BROKER_REQUEST_FETCH, STRING_QUERY_DATA => $query, BROKER_META_DATA => $meta ];
$objMongoTest->_fetchRecords($request);
if ($objMongoTest->status) {
echo $objMongoTest->strQuery . $eos;
} else {
var_export($objMongoTest->eventMessages);
echo $eos;
exit;
}
break;
case OP_TOK_UPD :
$token = '6CEA2DA3-F39E-873E-0F74-73C930159156';
$badToken = '6CEA2DA3-F39E-873E-0F74-73C930159150';
$badField = 'argle';
$badValue = 123;
$uMeta = $meta;
$uMeta[META_TEMPLATE] = TEMPLATE_CLASS_SMAXAPI;
$uMeta[META_CLIENT] = CLIENT_API;
$errors = [];
$widget = new gacFactory($uMeta, FACTORY_EVENT_NEW_CLASS, '', $errors);
if ($widget->status) {
/** @var gacMongoDB $objToken */
$objToken = $widget->widget;
} else {
exit(ERROR_TEMPLATE_INSTANTIATE . TEMPLATE_CLASS_SMAXAPI);
}
$data = [
STRING_QUERY_DATA => [ STRING_KEY => [ OPERAND_NULL => [ OPERATOR_EQ => [ $badToken ]]]],
STRING_UPDATE_DATA => [ 'givva_employee_name' => 'Scott Everson' ]
];
$objToken->_updateRecord($data);
var_export($objToken->eventMessages);
if (is_object($widget)) $widget->__destruct();
if (is_object($objToken)) $objToken->__destruct();
unset($objToken, $widget);
break;
case OP_UPDATE :
// if you want to test update using a cached class, but not using the cachemap variables, then provide a valid
// token GUID for the record to be updated here -- use $query2 and $update2 as your payload parameters.
$token = '5074D1E8-C4B6-559B-92A6-09C945FC4A4A';
$newString = "Ten percent of nothin' is ... let me do the math here ... nothin' into nothin' ... carry the nothin' ... ";
// plan here is to fetch the first active record, nothing fancy:
$recordLimit = 1; // adjust this value to set the number of records that will be updated
// fetch query looking for active records who's string field has not been updated
$query = [
CM_TST_FIELD_TEST_STATUS => [ OPERAND_NULL => [ OPERATOR_EQ => [ STATUS_ACTIVE ] ] ],
CM_TST_FIELD_TEST_STRING => [ OPERAND_NULL => [ OPERATOR_DNE => [ $newString ]] ],
OPERAND_AND => null
];
// update query using actual column names
$query2 = [
DB_TOKEN => [ OPERAND_NULL => [ OPERATOR_EQ => [ $token ]]],
OPERAND_AND => null
];
// let's limit the number of records returned to 10 -- normally, this query returns about a 100 records
// using the current data set...
$objMongoTest->addMeta(META_LIMIT, $recordLimit);
$request = [ STRING_QUERY_DATA => $query ];
$update = [ CM_TST_FIELD_TEST_STRING => $newString, CM_TST_FIELD_TEST_INT => intval(mt_rand(1,100)) ];
$update2 = [ DB_STATUS => STATUS_DELETED ];
// next field should generate an error b/c we can't update a protected field
// $update = [ CM_TST_FIELD_TEST_CDATE => intval(mt_rand(1,100)) ];
// use either $query/$update or $query2/$update2 in the payload
// $request = [ STRING_QUERY_DATA => $query, STRING_UPDATE_DATA => $update];
$request = [ STRING_QUERY_DATA => $query, STRING_UPDATE_DATA => $update];
$objMongoTest->addMeta(META_LIMIT, 1);
// enable the following line if you want to skip caching of the return payload
$objMongoTest->addMeta(META_DO_CACHE, false);
$payload = [
BROKER_REQUEST => BROKER_REQUEST_UPDATE,
BROKER_DATA => $request,
BROKER_META_DATA => $objMongoTest->getMetaDataPayload()
];
if (!validateMetaData($payload, $errors)) {
echo ERROR_META_VALIDATION_SECOND_PASS;
exit;
}
$objMongoTest->_updateRecord($payload[BROKER_DATA]);
if ($objMongoTest->status) {
$queryResults = gasCache::mapOutboundPayload($objMongoTest, $errors);
if ($objMongoTest->useCache) {
var_export($objMongoTest->getCK());
echo $eos;
} else {
var_export($objMongoTest->getData());
echo $eos;
}
} else {
var_export($objMongoTest->eventMessages);
echo $eos;
}
break;
case OP_UPDATE_MANY:
// replicate the unit-test query -- where we're just updating the first X active records
$query = [
CM_TST_FIELD_TEST_INT => [ OPERAND_NULL => [ OPERATOR_EQ => [ 4 ]]],
CM_TST_FIELD_TEST_BOOL => [ OPERAND_NULL => [ OPERATOR_EQ => [ false ]]],
OPERAND_AND => null
];
if (isset($meta[META_LIMIT])) unset($meta[META_LIMIT]);
$newString = "Dwight Schrute's Gym for Muscles";
$updateData = [ CM_TST_FIELD_TEST_STRING => $newString ];
$payload = [
BROKER_REQUEST => BROKER_REQUEST_UPDATE,
BROKER_DATA => [
STRING_QUERY_DATA => $query,
STRING_UPDATE_DATA => $updateData
],
BROKER_META_DATA => $meta
];
if (!validateMetaData($payload, $errors)) {
echo ERROR_META_VALIDATION_SECOND_PASS;
exit;
}
$objMongoTest->addMeta(META_LIMIT, 10);
$objMongoTest->_updateRecord($payload[BROKER_DATA]);
$errors = null;
$queryResults = gasCache::mapOutboundPayload($objMongoTest, $errors);
$x = 1;
break;
case OP_BAD_UPDATE:
$errors = array();
// first, fetch any active record
$query = [ CM_TST_FIELD_TEST_STATUS => [ OPERAND_NULL => [ OPERATOR_EQ => [ STATUS_ACTIVE ]]]];
$objMongoTest->addMeta(META_LIMIT, 1);
$payload = [
BROKER_REQUEST => BROKER_REQUEST_FETCH,
BROKER_DATA => [ STRING_QUERY_DATA => $query, STRING_RETURN_DATA => [ CM_TST_TOKEN ] ],
BROKER_META_DATA => $objMongoTest->getMetaDataPayload()
];
if (!validateMetaData($payload, $errors)) exit('meta data validation failed for fetch');
$objMongoTest->_fetchRecords($payload[BROKER_DATA]);
@$objMongoTest->removeMeta(META_LIMIT);
// now that we have our record...first, get the token...
if (!$objMongoTest->status) exit('failed to fetch record for update');
$token = $objMongoTest->getColumn(DB_TOKEN);
// build the update query using the token as the search discriminant
$query = [ CM_TST_TOKEN => [ OPERAND_NULL => [ OPERATOR_EQ => [ $token ]]]];
// build the update query using a protected field -- doesn't matter since it should be rejected/dropped
$update = [ CM_TST_FIELD_TEST_CDATE => STRING_DATA ];
$request = [
STRING_QUERY_DATA => $query,
STRING_UPDATE_DATA => $update
];
$payload = [
BROKER_REQUEST => BROKER_REQUEST_UPDATE,
BROKER_DATA => $request,
BROKER_META_DATA => $objMongoTest->getMetaDataPayload()
];
if (!validateMetaData($payload, $errors)) exit('meta data validation failed for update');
$objMongoTest->_updateRecord($payload[BROKER_DATA]);
$x = 1;
break;
case OP_DELETE :
$originalMeta = $objMongoTest->getMetaDataPayload();
// target any record where the test-string is set to $jayne
$query = [ CM_TST_FIELD_TEST_STRING => [ OPERAND_NULL => [ OPERATOR_EQ => [$jayne]]]];
$query = [ CM_TOKEN => [ OPERAND_NULL => [ OPERATOR_EQ => [ '362C8565-8D39-C619-7800-DDB025292AC2' ]]]];
// delete only one record
$objMongoTest->addMeta(META_LIMIT, 1);
// $objMongoTest->useDeletes = true; // turn on hard deletes
$objMongoTest->_deleteRecord([STRING_QUERY_DATA => $query]);
if ($objMongoTest->status) {
$queryResults = gasCache::mapOutboundPayload($objMongoTest, $errors);
if ($objMongoTest->useCache) {
var_export($objMongoTest->getCK());
echo $eos;
} else {
var_export($objMongoTest->getData());
echo $eos;
}
} else {
var_export($objMongoTest->eventMessages);
echo $eos;
}
break;
case OP_SUBC_PUSH :
// set the following variable to true if you want to mimic the unit test: testNegativeSubCollectionInsert()
// this tests exceeding the max_record count on sub-collection inserts...
$negativeTest = false;
// first, fetch any active record
$query = [ CM_TST_FIELD_TEST_STATUS => [ OPERAND_NULL => [ OPERATOR_EQ => [ STATUS_ACTIVE ]]]];
$objMongoTest->addMeta(META_LIMIT, 1);
$payload = [
BROKER_REQUEST => BROKER_REQUEST_FETCH,
BROKER_DATA => [ STRING_QUERY_DATA => $query, STRING_RETURN_DATA => [ CM_TST_TOKEN ] ],
BROKER_META_DATA => $objMongoTest->getMetaDataPayload()
];
if (!validateMetaData($payload, $errors)) exit('meta data validation failed for fetch');
$objMongoTest->_fetchRecords($payload[BROKER_DATA]);
@$objMongoTest->removeMeta(META_LIMIT);
// now that we have our record...first, get the token...
if (!$objMongoTest->status) exit('failed to fetch record for update');
$pkey = $objMongoTest->getColumn(DB_TOKEN);
$field = CM_TST_FIELD_TEST_SUBC; // the cache-mapped name of the field
$newSubCRecord = [
CM_TST_FIELD_TEST_INT => 22,
CM_TST_FIELD_TEST_DOUBLE => 22.22,
CM_TST_FIELD_TEST_STRING => 'twenty-two',
CM_TST_FIELD_TEST_BOOL => true
];
// if we're negative-testing, then load-up the $records array with more records than max allowed
if ($negativeTest) {
$qrl = intval(gasConfig::$settings[CONFIG_DATABASE][CONFIG_DATABASE_QUERY_RECORD_LIMIT]);
$recCount = 1 + $qrl;
for ($index = 0; $index < $recCount; $index++) $records[] = $newSubCRecord;
} else {
$records = [$newSubCRecord];
}
$requestPayload = [ STRING_GUID_KEY => $pkey, STRING_SUBC_FIELD => $field, STRING_DATA => $records ];
// what we would normally submit to a broker (for validation purposes here)
$payload = [
BROKER_REQUEST => BROKER_REQUEST_SUBC_CREATE,
BROKER_DATA => $requestPayload,
BROKER_META_DATA => $meta
];
if (!validateMetaData($payload, $errors)) {
var_export($errors);
exit;
}
$objMongoTest->pushSubCollectionEvent($payload[BROKER_DATA]);
var_export($objMongoTest);
echo $eos;
break;
case OP_SUBC_DEL :
$recordToken = '62294EBC-FD37-4923-64F0-1E4324EE365A';
$subCToken = '85DFED9D-B5E8-A3B6-6A3D-DA51D690F0FB';
$request = [
STRING_GUID_KEY => $recordToken,
STRING_SUBC_GUID => $subCToken,
STRING_SUBC_FIELD => CM_TST_FIELD_TEST_SUBC
];
$payload = [
BROKER_REQUEST => BROKER_REQUEST_SUBC_DELETE,
BROKER_DATA => $request,
BROKER_META_DATA => $meta
];
if (!validateMetaData($payload, $errors))
exit (ERROR_META_VALIDATION_SECOND_PASS);
$objMongoTest->popSubCollection($payload[BROKER_DATA]);
echo 'State: ' . $objMongoTest->state . $eos;
var_export($objMongoTest->strQuery);
echo $eos;
break;
case OP_SUBC_FETCH :
$meta[META_LIMIT] = 1;
$objMongoTest->addMeta(META_LIMIT, 1);
// complex query (two sub-collection fields)
$payload1 = [
BROKER_REQUEST => BROKER_REQUEST_SUBC_FETCH,
BROKER_DATA => [
STRING_SUBC_COL => CM_TST_FIELD_TEST_SUBC,
STRING_SUBC_DATA => [
CM_TST_FIELD_TEST_INT => 7,
CM_TST_FIELD_TEST_BOOL => false
],
],
BROKER_META_DATA => $meta
];
// simple query (one sub-collection field)
$payload2 = [
BROKER_REQUEST => BROKER_REQUEST_SUBC_FETCH,
BROKER_DATA => [
STRING_SUBC_COL => CM_TST_FIELD_TEST_SUBC,
STRING_SUBC_DATA => [ CM_TST_FIELD_TEST_INT => 7]
],
BROKER_META_DATA => $meta
];
$payload = $payload1;
if (!validateMetaData($payload, $errors)) {
var_export($errors);
echo $eos;
exit(ERROR_META_VALIDATION_SECOND_PASS);
}
$objMongoTest->fetchSubCollectionRecord($payload[BROKER_DATA]);
echo $eos . 'State: ' . $objMongoTest->state . $eos;
if ($objMongoTest->status) {
echo $objMongoTest->strQuery . $eos;
var_export($objMongoTest->getData());
} else {
echo $eos;
var_export($objMongoTest->eventMessages);
echo $eos;
}
break;
}