Commit 6e5d5403 authored by Karamel's avatar Karamel
Browse files

Add tests on PaymentMode and fix usesDebt/usesPrepay detection.

parent 2243a414
......@@ -125,10 +125,10 @@ class PaymentMode extends DoctrineModel
public function setType($type) { $this->type = $type; }
public function usesDebt() {
return ($this->type & static::CUST_DEBT) > 0;
return ($this->type & static::CUST_DEBT) == static::CUST_DEBT;
}
public function usesPrepay() {
return ($this->type & static::CUST_PREPAID) > 0;
return ($this->type & static::CUST_PREPAID) == static::CUST_PREPAID;
}
/**
......
......@@ -53,6 +53,30 @@ class PaymentModeTest extends TestCase
$this->dao->commit();
}
public function testUsesPrepay() {
$pm = new PaymentMode();
$pm->setType(PaymentMode::CUST_PREPAID);
$this->assertTrue($pm->usesPrepay());
$pm->setType(PaymentMode::TYPE_DEFAULT);
$this->assertFalse($pm->usesPrepay());
$pm->setType(PaymentMode::CUST_ASSIGNED);
$this->assertFalse($pm->usesPrepay());
$pm->setType(PaymentMode::CUST_DEBT);
$this->assertFalse($pm->usesPrepay());
}
public function testUsesDebt() {
$pm = new PaymentMode();
$pm->setType(PaymentMode::CUST_DEBT);
$this->assertTrue($pm->usesDebt());
$pm->setType(PaymentMode::CUST_PREPAID);
$this->assertFalse($pm->usesDebt());
$pm->setType(PaymentMode::TYPE_DEFAULT);
$this->assertFalse($pm->usesDebt());
$pm->setType(PaymentMode::CUST_ASSIGNED);
$this->assertFalse($pm->usesDebt());
}
public function testToStructEmpty() {
$pm = new PaymentMode();
$pm->setReference('test');
......
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