コード例 #1
0
ファイル: MoneyFactoryTest.php プロジェクト: werkint/money
 /**
  * @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)));
 }
コード例 #2
0
ファイル: MoneyTest.php プロジェクト: werkint/money
 /**
  * @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());
 }