Passed
Push — 1.0.0 ( 308939...f58402 )
by Alex
01:34
created

CurrencyTest::dataProvider()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 13
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 11
c 1
b 0
f 0
dl 0
loc 13
rs 9.9
cc 1
nc 1
nop 0
1
<?php
2
3
namespace StraTDeS\VO\Tests;
4
5
use StraTDeS\VO\Currency;
6
use PHPUnit\Framework\TestCase;
7
8
class CurrencyTest extends TestCase
9
{
10
    public function dataProvider(): array
11
    {
12
        return [
13
            ['EUR', true, 978, 2],
14
            ['USD', true, 840, 2],
15
            ['BHD', true, 48, 3],
16
            ['BIF', true, 108, 0],
17
            ['BMD', true, 60, 2],
18
            ['BND', true, 96, 2],
19
            ['AAA', false, null, null],
20
            ['BBB', false, null, null],
21
            ['CCC', false, null, null],
22
            ['DDD', false, null, null],
23
        ];
24
    }
25
26
    /**
27
     * @param string $currency
28
     * @param bool $isValid
29
     * @param int|null $iso
30
     * @param int|null $decimals
31
     * @dataProvider dataProvider
32
     */
33
    public function testGivenACurrencyItIsValidAndHaveAValidConfigOrIsInvalidAndThrowsException(
34
        string $currency, bool $isValid, ?int $iso, ?int $decimals
35
    ): void
36
    {
37
        if(!$isValid) {
38
            $this->expectException(\InvalidArgumentException::class);
39
            $this->expectExceptionMessage("$currency is not an allowed currency");
40
        }
41
42
        $currency = Currency::fromValue($currency);
43
44
        $this->assertEquals($iso, $currency->config()->iso());
45
        $this->assertEquals($decimals, $currency->config()->decimals());
46
    }
47
}
48