Completed
Push — symfony3-fqcn ( 04e8c2...ea8d6b )
by Kamil
18:56
created

ExchangeRateSpec::it_has_target_currency()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 6
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 4
nc 1
nop 1
1
<?php
2
3
/*
4
 * This file is part of the Sylius package.
5
 *
6
 * (c) Paweł Jędrzejewski
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace spec\Sylius\Component\Currency\Model;
13
14
use Sylius\Component\Currency\Model\CurrencyInterface;
15
use Sylius\Component\Currency\Model\ExchangeRate;
16
use PhpSpec\ObjectBehavior;
17
use Sylius\Component\Currency\Model\ExchangeRateInterface;
18
19
/**
20
 * @author Jan Góralski <[email protected]>
21
 */
22
final class ExchangeRateSpec extends ObjectBehavior
23
{
24
    function it_is_initializable()
25
    {
26
        $this->shouldHaveType(ExchangeRate::class);
27
    }
28
29
    function it_implements_exchange_rate_interface()
30
    {
31
        $this->shouldImplement(ExchangeRateInterface::class);
32
    }
33
34
    function it_throws_an_invalid_argument_exception_when_adding_non_float_ratio()
35
    {
36
        $this->shouldThrow(\InvalidArgumentException::class)->during('setRatio', ['1.01']);
37
        $this->shouldThrow(\InvalidArgumentException::class)->during('setRatio', ['asd']);
38
        $this->shouldThrow(\InvalidArgumentException::class)->during('setRatio', [[]]);
39
        $this->shouldThrow(\InvalidArgumentException::class)->during('setRatio', [null]);
40
        $this->shouldThrow(\InvalidArgumentException::class)->during('setRatio', [false]);
41
        $this->shouldThrow(\InvalidArgumentException::class)->during('setRatio', [new \stdClass()]);
42
    }
43
44
    function it_has_a_ratio()
45
    {
46
        $this->getRatio()->shouldReturn(null);
47
        $this->setRatio(1.02);
48
        $this->getRatio()->shouldReturn(1.02);
49
        $this->setRatio(1e-6);
50
        $this->getRatio()->shouldReturn(1e-6);
51
    }
52
53
    function it_has_base_currency(CurrencyInterface $currency)
54
    {
55
        $this->getSourceCurrency()->shouldReturn(null);
56
        $this->setSourceCurrency($currency);
57
        $this->getSourceCurrency()->shouldReturn($currency);
58
    }
59
60
    function it_has_target_currency(CurrencyInterface $currency)
61
    {
62
        $this->getTargetCurrency()->shouldReturn(null);
63
        $this->setTargetCurrency($currency);
64
        $this->getTargetCurrency()->shouldReturn($currency);
65
    }
66
}
67