Completed
Push — master ( 4fff23...13399c )
by Kamil
30:31
created

it_implements_context_interface()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 1 Features 0
Metric Value
c 1
b 1
f 0
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 0
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\Behat\Context\Transform;
13
14
use Behat\Behat\Context\Context;
15
use PhpSpec\ObjectBehavior;
16
17
/**
18
 * @author Mateusz Zalewski <[email protected]>
19
 */
20
class LexicalContextSpec extends ObjectBehavior
21
{
22
    function let()
23
    {
24
        $this->beConstructedWith();
25
    }
26
27
    function it_is_initializable()
28
    {
29
        $this->shouldHaveType('Sylius\Behat\Context\Transform\LexicalContext');
30
    }
31
32
    function it_implements_context_interface()
33
    {
34
        $this->shouldImplement(Context::class);
35
    }
36
37
    function it_transforms_price_string_to_integer()
38
    {
39
        $this->getPriceFromString('10.00')->shouldReturn(1000);
40
        $this->getPriceFromString('0.30')->shouldReturn(30);
41
    }
42
43
    function it_throws_exception_if_price_string_is_invalid()
44
    {
45
        $this
46
            ->shouldThrow(new \InvalidArgumentException('Price string should not have more than 2 decimal digits.'))
47
            ->during('getPriceFromString', ['0.1345'])
48
        ;
49
    }
50
51
    function it_transforms_percentage_string_to_float()
52
    {
53
        $this->getPercentageFromString('10')->shouldReturn(0.1);
54
    }
55
}
56