/**
  * @covers OpenBuildings\Monetary\Monetary::instance
  * @covers OpenBuildings\Monetary\Monetary::default_currency
  */
 public function test_same_instance_with_currency()
 {
     $monetary = M\Monetary::instance('same_instance_with_currency');
     $this->assertSame($monetary, M\Monetary::instance('same_instance_with_currency'));
     $monetary->default_currency('EUR');
     $this->assertSame($monetary, M\Monetary::instance('same_instance_with_currency'));
     $this->assertSame($monetary->default_currency(), M\Monetary::instance('same_instance_with_currency')->default_currency());
     $this->assertSame('EUR', M\Monetary::instance('same_instance_with_currency')->default_currency());
 }
 /**
  * @covers Model_Purchase::monetary
  */
 public function test_monetary()
 {
     $purchase = Jam::build('purchase');
     $this->assertSame(Monetary::instance(), $purchase->monetary());
     $purchase = Jam::find('purchase', 1);
     $monetary = $purchase->monetary();
     $this->assertInstanceOf('Openbuildings\\Monetary\\Monetary', $monetary);
     $this->assertNotSame(Monetary::instance(), $monetary);
     $this->assertSame($monetary, $purchase->monetary());
     $this->assertEquals(7.4867110878191, $monetary->convert(10, 'USD', 'EUR'));
 }
 /**
  * @covers OpenBuildings\Monetary\Monetary::source
  */
 public function test_source()
 {
     $monetary = new M\Monetary();
     $this->assertInstanceOf('OpenBuildings\\Monetary\\Sourceable', $monetary->source());
     $this->assertInstanceOf('OpenBuildings\\Monetary\\Source_ECB', $monetary->source());
     $source = new M\Source_Static();
     $monetary->source($source);
     $this->assertInstanceOf('OpenBuildings\\Monetary\\Sourceable', $monetary->source());
     $this->assertInstanceOf('OpenBuildings\\Monetary\\Source_Static', $monetary->source());
 }
Exemple #4
0
 /**
  * implement Serializable
  * @param string $data 
  */
 public function unserialize($data)
 {
     $data = unserialize($data);
     $this->amount($data[0]);
     $this->currency($data[1]);
     $this->display_currency($data[2]);
     $this->ceil_on_convert($data[3]);
     $this->monetary(Monetary::instance());
 }
Exemple #5
0
 /**
  * Return Monetary::instance() if not frozen.
  * Freezable field.
  *
  * @return OpenBuildings\Monetary\Monetary
  */
 public function monetary()
 {
     return $this->isFrozen() ? $this->monetary : Monetary::instance();
 }
Exemple #6
0
 public function monetary()
 {
     return Monetary::instance();
 }