Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 21 additions & 1 deletion tests/Parser/DecimalMoneyParserTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use Money\Currencies;
use Money\Currency;
use Money\Exception\ParserException;
use Money\Money;
use Money\Parser\DecimalMoneyParser;
use PHPUnit\Framework\TestCase;
use Prophecy\Argument;
Expand All @@ -29,6 +30,24 @@ public function it_parses_money($decimal, $currency, $subunit, $result)
$this->assertEquals($result, $parser->parse($decimal, new Currency($currency))->getAmount());
}

/**
* @test
*/
public function it_parses_exponential_number()
{
$currencies = $this->prophesize(Currencies::class);

$currencies->subunitFor(Argument::allOf(
Argument::type(Currency::class),
Argument::which('getCode', 'EUR')
))->willReturn('2');

$parser = new DecimalMoneyParser($currencies->reveal());

$value = 2.8865798640254e-15;
$this->assertInstanceOf(Money::class, $parser->parse((string)$value, new Currency('EUR')));
}

/**
* @dataProvider invalidMoneyExamples
* @test
Expand All @@ -51,7 +70,8 @@ public function it_throws_an_exception_upon_invalid_inputs($input)

/**
* @group legacy
* @expectedDeprecation Passing a currency as string is deprecated since 3.1 and will be removed in 4.0. Please pass a Money\Currency instance instead.
* @expectedDeprecation Passing a currency as string is deprecated since 3.1 and will be removed in 4.0. Please
* pass a Money\Currency instance instead.
* @test
*/
public function it_accepts_only_a_currency_object()
Expand Down