/** * @depends testCreateCurrency */ public function testCreate() { $cur1 = new Currency('foo'); $cur2 = new Currency('bar'); $provider = new ArrayCurrencyProvider([$cur1, $cur2]); $factory = new MoneyFactory($provider); $obj1 = new Money($cur1, 10); $obj2 = new Money($cur2, 10); $this->assertTrue($obj1->equals($factory->create('foo', 10))); $this->assertTrue($obj2->equals($factory->create('bar', 10))); $this->assertFalse($obj1->equals($factory->create('bar', 10))); $this->assertFalse($obj2->equals($factory->create('foo', 10))); $this->assertFalse($obj1->equals($factory->create('foo', 0))); }
/** * @depends testCompare */ public function testChecks() { $cur = new Currency('tst', 0); $obj1 = new Money($cur, -10); $obj2 = new Money($cur, 0); $obj3 = new Money($cur, +10); $this->assertTrue($obj2->isZero()); $this->assertFalse($obj1->isZero()); $this->assertTrue($obj2->isPositive()); $this->assertTrue($obj3->isPositive()); $this->assertFalse($obj1->isPositive()); $this->assertFalse($obj2->isNegative()); $this->assertFalse($obj3->isNegative()); $this->assertTrue($obj1->isNegative()); }