forked from moneyphp/money
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathNumberSpec.php
39 lines (30 loc) · 878 Bytes
/
NumberSpec.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
<?php
namespace spec\Money;
use Money\Number;
use PhpSpec\ObjectBehavior;
final class NumberSpec extends ObjectBehavior
{
function let()
{
$this->beConstructedWith('1');
}
function it_is_initializable()
{
$this->shouldHaveType(Number::class);
}
function it_throws_an_exception_when_number_is_invalid()
{
$this->beConstructedWith('ONE');
$this->shouldThrow(\InvalidArgumentException::class)->duringInstantiation();
}
function it_creates_a_number_from_float()
{
$number = $this->fromFloat(1.1);
$number->shouldHaveType(Number::class);
$number->__toString()->shouldReturn('1.1');
}
function it_throws_an_exception_when_number_is_not_float_during_creation_from_float()
{
$this->shouldThrow(\InvalidArgumentException::class)->duringFromFloat(1);
}
}