GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Push — master ( 0c8f9f...37376a )
by Nicolas
02:44 queued 59s
created

it_converts_a_value_to_a_standard_unit()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 8
rs 9.4285
cc 1
eloc 6
nc 1
nop 0
1
<?php
2
3
namespace spec\Akeneo\Bundle\MeasureBundle\Convert;
4
5
use Akeneo\Bundle\MeasureBundle\Exception\UnknownFamilyMeasureException;
6
use Akeneo\Bundle\MeasureBundle\Exception\UnknownMeasureException;
7
use Akeneo\Bundle\MeasureBundle\Family\WeightFamilyInterface;
8
use PhpSpec\ObjectBehavior;
9
use Prophecy\Argument;
10
use Symfony\Component\Yaml\Yaml;
11
12
class MeasureConverterSpec extends ObjectBehavior
13
{
14 View Code Duplication
    function let()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
15
    {
16
        $filename = realpath(dirname(__FILE__) .'/../Resources/config/measure-test.yml');
17
        if (!file_exists($filename)) {
18
            throw new \Exception(sprintf('Config file "%s" does not exist', $filename));
19
        }
20
21
        $config = Yaml::parse(file_get_contents($filename));
22
        $this->beConstructedWith($config);
23
    }
24
25
    function it_allows_to_define_the_family()
26
    {
27
        $this->setFamily('Length')->shouldReturnAnInstanceOf('Akeneo\Bundle\MeasureBundle\Convert\MeasureConverter');
28
    }
29
30
    function it_throws_an_exception_if_an_unknown_family_is_set()
31
    {
32
        $this
33
            ->shouldThrow(
34
                new UnknownFamilyMeasureException()
35
            )
36
            ->during('setFamily', array('foo'));
37
    }
38
39
    function it_converts_a_value_from_a_base_unit_to_a_final_unit()
40
    {
41
        $this->setFamily('Weight');
42
        $this->convert(
43
            WeightFamilyInterface::KILOGRAM,
44
            WeightFamilyInterface::MILLIGRAM,
45
            1
46
        )->shouldReturn((double) 1000000);
47
    }
48
49
    function it_converts_a_value_to_a_standard_unit()
50
    {
51
        $this->setFamily('Weight');
52
        $this->convertBaseToStandard(
53
            WeightFamilyInterface::MILLIGRAM,
54
            1000
55
        )->shouldReturn((double) 1);
56
    }
57
58
    function it_converts_a_standard_value_to_a_final_unit()
59
    {
60
        $this->setFamily('Weight');
61
        $this->convertStandardToResult(
62
            WeightFamilyInterface::KILOGRAM,
63
            10
64
        )->shouldReturn((double) 0.01);
65
    }
66
67
    function it_throws_an_exception_if_the_unit_measure_does_not_exist()
68
    {
69
        $this->setFamily('Weight');
70
        $this
71
            ->shouldThrow(
72
                new UnknownMeasureException(
73
                    'Could not find metric unit "foo" in family "Weight"'
74
                )
75
            )
76
            ->during('convertBaseToStandard', array('foo', Argument::any()));
77
78
        $this
79
            ->shouldThrow(
80
                new UnknownMeasureException(
81
                    'Could not find metric unit "foo" in family "Weight"'
82
                )
83
            )
84
            ->during('convertStandardToResult', array('foo', Argument::any()));
85
    }
86
}
87