示例#1
0
 public function testAddItem()
 {
     $dataSell = array('job_id' => 1, 'account' => array('id' => 1), 'security' => array('id' => 1), 'status' => QueueItem::STATUS_SELL, 'lot' => array('id' => 1), 'quantity' => 10, 'amount' => 1000);
     /** @var QueueItem $queueItem */
     $queueItem = new QueueItem();
     $queueItem->loadFromArray($dataSell);
     $this->rebalancerQueue->addItem($queueItem);
     $this->assertCount(1, $this->rebalancerQueue);
     $this->assertEquals(10, $this->rebalancerQueue->first()->getQuantity());
     $this->assertEquals(1000, $this->rebalancerQueue->first()->getAmount());
     $this->rebalancerQueue->addItem($queueItem);
     $this->assertCount(1, $this->rebalancerQueue);
     $this->assertEquals(20, $this->rebalancerQueue->first()->getQuantity());
     $this->assertEquals(2000, $this->rebalancerQueue->first()->getAmount());
     $dataSell2 = array('job_id' => 1, 'account' => array('id' => 1), 'security' => array('id' => 1), 'status' => QueueItem::STATUS_SELL, 'lot' => array('id' => 3), 'quantity' => 15, 'amount' => 150);
     /** @var QueueItem $queueItem */
     $queueItem = new QueueItem();
     $queueItem->loadFromArray($dataSell2);
     $this->rebalancerQueue->addItem($queueItem);
     $this->assertCount(2, $this->rebalancerQueue);
     $this->assertEquals(15, $this->rebalancerQueue->last()->getQuantity());
     $this->assertEquals(150, $this->rebalancerQueue->last()->getAmount());
 }
示例#2
0
 public function setUp()
 {
     $data = array('id' => 43, 'rebalancer_action_id' => 6, 'lot' => array('id' => 13), 'security' => array('id' => 1212), 'account' => array('id' => 3), 'quantity' => 50, 'status' => QueueItem::STATUS_BUY, 'amount' => 11.1, 'subclass' => array('id' => 1313));
     $this->queueItem = $this->getMockBuilder('Model\\WealthbotRebalancer\\QueueItem')->disableOriginalConstructor()->setMethods(null)->getMock();
     $this->queueItem->loadFromArray($data);
 }