示例#1
0
 /**
  * @return int
  */
 public function getSubUnit()
 {
     return Currency::getSubUnit($this->currency);
 }
示例#2
0
 public function testSubUnitsLessThanOneShouldThrowUnexpectedValueException()
 {
     $refl = new \ReflectionClass(Currency::class);
     $property = $refl->getProperty('currencies');
     $property->setAccessible(true);
     $originalCurrencies = $property->getValue();
     $newCurrencies = ['ABC' => ['display_name' => 'ABC fake currency', 'numeric_code' => 123, 'default_fraction_digits' => 2, 'sub_unit' => -1]];
     $property->setValue($newCurrencies);
     try {
         Currency::getSubUnit('ABC');
         $this->fail(UnexpectedValueException::class . ' not thrown');
     } catch (UnexpectedValueException $exc) {
         $this->assertInstanceOf(UnexpectedValueException::class, $exc);
         $this->assertSame(sprintf('The currency sub-units value must be greater than 1; "%s" given', $newCurrencies['ABC']['sub_unit']), $exc->getMessage());
     }
     $property->setValue($originalCurrencies);
     $property->setAccessible(false);
 }