Passed
Push — 1.0.0 ( f58402...681a4e )
by Alex
01:36
created

testGivenValidDataItReturnsAValidMoneyVO()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 16
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 6
c 1
b 0
f 0
dl 0
loc 16
rs 10
cc 1
nc 1
nop 4
1
<?php
2
3
namespace StraTDeS\VO\Tests;
4
5
use StraTDeS\VO\Currency;
6
use StraTDeS\VO\Money;
7
use PHPUnit\Framework\TestCase;
8
9
class MoneyTest extends TestCase
10
{
11
    public function dataProvider(): array
12
    {
13
        return [
14
            [12456, 124.56, Currency::fromValue(Currency::EUR), 'EUR 124.56'],
15
            [2346656, 23466.56, Currency::fromValue(Currency::USD), 'USD 23,466.56'],
16
            [536435345, 53643.5345, Currency::fromValue(Currency::UYW), 'UYW 53,643.5345'],
17
        ];
18
    }
19
20
    /**
21
     * @dataProvider dataProvider
22
     * @param int $amount
23
     * @param float $amountFloat
24
     * @param Currency $currency
25
     * @param string $formatted
26
     */
27
    public function testGivenValidDataItReturnsAValidMoneyVO(
28
        int $amount,
29
        float $amountFloat,
30
        Currency $currency,
31
        string $formatted
32
    ): void
33
    {
34
        // Act
35
        $money = Money::create($amount, $currency);
36
37
        // Assert
38
        $this->assertInstanceOf(Money::class, $money);
39
        $this->assertEquals($amount, $money->amount());
40
        $this->assertEquals($currency, $money->currency());
41
        $this->assertEquals($amountFloat, $money->amountFloat());
42
        $this->assertEquals($formatted, $money->formatted());
43
    }
44
}
45