Example #1
0
 public function testSetSecurity()
 {
     $security = $this->getMock('Model\\WealthbotRebalancer\\Security', null);
     $security->setId(4545);
     $this->queueItem->setSecurity($security);
     $this->assertEquals(4545, $this->queueItem->getSecurity()->getId());
 }
 public function save(QueueItem $item)
 {
     if (null === $item->getId()) {
         $sql = "INSERT INTO " . self::TABLE_REBALANCER_QUEUE . " (lot_id, security_id, rebalancer_action_id, quantity, status, system_client_account_id, amount, subclass_id)\n                      VALUES (:lot_id, :security_id, :rebalancer_action_id, :quantity, :status, :account_id, :amount, :subclass_id);\n            ";
         $parameters = array('lot_id' => $item->getLot() ? $item->getLot()->getId() : null, 'security_id' => $item->getSecurity()->getId(), 'rebalancer_action_id' => $item->getRebalancerActionId(), 'quantity' => $item->getQuantity(), 'status' => $item->getStatus(), 'account_id' => $item->getAccount()->getId(), 'amount' => $item->getAmount(), 'subclass_id' => $item->getSubclass()->getId());
     } else {
         $sql = "UPDATE " . self::TABLE_REBALANCER_QUEUE . " SET quantity = :quantity, amount = :amount\n                      WHERE id = :id;\n            ";
         $parameters = array('id' => $item->getId(), 'quantity' => $item->getQuantity(), 'amount' => $item->getAmount());
     }
     $this->db->query($sql, $parameters);
 }