Commit d8b21410 authored by Karamel's avatar Karamel
Browse files

Add a test to check nextTicketId after writing a ticket.

parent d0b9dae9
......@@ -512,4 +512,47 @@ class TicketAPITest extends TestCase
$this->assertEquals($cTop->getId(), $top[0]->getId());
$this->assertEquals($cTop2->getId(), $top[1]->getId());
}
/** @depends testSaveTicket */
public function testUpdateNextTicketId() {
// Write ticket number 1, expect next = 2
$tkt = new Ticket();
$tkt->setCashRegister($this->session->getCashRegister());
$tkt->setSequence($this->session->getSequence());
$tkt->setNumber(1);
$tkt->setDate(new \DateTime('2018-01-01 8:05'));
$tkt->setUser($this->user);
$tkt->setTaxedPrice(11.0);
$tkt->setFinalPrice(10.0); $tkt->setFinalTaxedPrice(11.0);
$this->api->write($tkt);
$read = $this->dao->readSnapshot(CashRegister::class,
$tkt->getCashRegister()->getId());
$this->assertEquals(2, $read->getNextTicketId());
// Write ticket number 5, expect next = 6
$tkt = new Ticket();
$tkt->setCashRegister($this->session->getCashRegister());
$tkt->setSequence($this->session->getSequence());
$tkt->setNumber(5);
$tkt->setDate(new \DateTime('2018-01-01 8:05'));
$tkt->setUser($this->user);
$tkt->setTaxedPrice(11.0);
$tkt->setFinalPrice(10.0); $tkt->setFinalTaxedPrice(11.0);
$this->api->write($tkt);
$read = $this->dao->readSnapshot(CashRegister::class,
$tkt->getCashRegister()->getId());
$this->assertEquals(6, $read->getNextTicketId());
// Write ticket number 2, expect next still = 6
$tkt = new Ticket();
$tkt->setCashRegister($this->session->getCashRegister());
$tkt->setSequence($this->session->getSequence());
$tkt->setNumber(2);
$tkt->setDate(new \DateTime('2018-01-01 8:05'));
$tkt->setUser($this->user);
$tkt->setTaxedPrice(11.0);
$tkt->setFinalPrice(10.0); $tkt->setFinalTaxedPrice(11.0);
$this->api->write($tkt);
$read = $this->dao->readSnapshot(CashRegister::class,
$tkt->getCashRegister()->getId());
$this->assertEquals(6, $read->getNextTicketId());
}
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment