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:
49
stubs/testClone.php
Normal file
49
stubs/testClone.php
Normal file
@@ -0,0 +1,49 @@
|
||||
<?php
|
||||
/**
|
||||
* test stub for testing the clone function
|
||||
*
|
||||
*/
|
||||
// load the namaste environment
|
||||
require_once(dirname(__DIR__) . '/config/sneakerstrap.inc');
|
||||
|
||||
// using the gacFactory, build a test object for cloning
|
||||
$meta = [
|
||||
META_TEMPLATE => TEMPLATE_CLASS_TEST_MONGO,
|
||||
META_CLIENT => CLIENT_SYSTEM,
|
||||
META_CLIENT_IP => STRING_SESSION_HOME,
|
||||
META_EVENT_GUID => guid() // simulate a broker event by generating the event guid
|
||||
];
|
||||
$payload1 = [
|
||||
BROKER_REQUEST => BROKER_REQUEST_FETCH,
|
||||
BROKER_DATA => [ STRING_QUERY_DATA => null],
|
||||
BROKER_META_DATA => $meta
|
||||
];
|
||||
$errors = [];
|
||||
$ret = validateMetaData($payload1, $errors);
|
||||
$obj = new gacFactory($meta, FACTORY_EVENT_NEW_CLASS, '', $errors);
|
||||
/** @var gacMongoDB $widget */
|
||||
$widget = $obj->widget;
|
||||
if (is_object($obj)) $obj->__destruct();
|
||||
unset($obj);
|
||||
|
||||
// clone the widget
|
||||
$clone = clone $widget;
|
||||
|
||||
// make a query with the original object
|
||||
$widget->_fetchRecords($payload1[BROKER_DATA]);
|
||||
if (!$widget->count) exit('query failed on object 1');
|
||||
|
||||
$payload2 = [
|
||||
BROKER_REQUEST => BROKER_REQUEST_FETCH,
|
||||
BROKER_DATA => [ STRING_QUERY_DATA =>
|
||||
[ CM_TST_FIELD_TEST_STATUS => [ OPERAND_NULL => [ OPERATOR_EQ => [ STATUS_DELETED ]]]]],
|
||||
BROKER_META_DATA => $meta
|
||||
];
|
||||
$clone->_fetchRecords($payload2[BROKER_DATA]);
|
||||
if (!$clone->count) exit('query failed on object 2');
|
||||
|
||||
if ($clone->count != $widget->count)
|
||||
echo 'count is different - success!';
|
||||
else
|
||||
echo 'count is the same - fail';
|
||||
|
||||
Reference in New Issue
Block a user