Example #1
0
 /**
  * @dataProvider providerBadResponse
  */
 public function testBadResponse($json, $truthRes)
 {
     $responseModel = new ResponseModel($json);
     $this->assertEquals($truthRes, $responseModel->getValid());
 }
Example #2
0
 * config file
 */
include 'config.php';
/**
 * create connection with RabbitAMQP
 */
$connection = new AMQPStreamConnection(AMQP_HOST, AMQP_PORT, AMQP_USER, AMQP_PASS);
$channel = $connection->channel();
echo ' [*] Waiting for logs. To exit press CTRL+C', "\n";
$interestQueue = new InterestQueue();
/**
 * @param $msg
 *
 */
$callback = function ($msg) use($channel, $interestQueue) {
    $responseModel = new ResponseModel($msg->body);
    if ($responseModel->getValid()) {
        /**
         * For each message it calculates the "interest" and total sum
         */
        $interest = $interestQueue->getInterests($responseModel->getSum(), $responseModel->getDays());
        $data = json_encode($interest);
        $msgReply = new AMQPMessage($data, array('delivery_mode' => 2, 'content_type' => 'application/json'));
        /**
         * Broadcasting the new message
         */
        $channel->basic_publish($msgReply, '', SOLVED_INTEREST_QUEUE);
        echo $data . "\n";
    }
};
/**