Passed
Push — master ( 54e3cc...a9003e )
by Dmitry
14:11
created

MultipliedMoneyTest   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 2
eloc 15
c 1
b 0
f 0
dl 0
loc 26
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A moneyParsingProvider() 0 11 1
A testMultipliedMoneyParsing() 0 7 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace hiqdev\php\billing\tests\unit\Money;
6
7
use Generator;
8
use hiqdev\php\billing\Money\MultipliedMoney;
9
use PHPUnit\Framework\TestCase;
10
11
/**
12
 * Class MultipliedMoneyTest
13
 *
14
 * @author Dmytro Naumenko <[email protected]>
15
 */
16
class MultipliedMoneyTest extends TestCase
17
{
18
    /**
19
     * @param numeric-string $amountCents
0 ignored issues
show
Documentation Bug introduced by
The doc comment numeric-string at position 0 could not be parsed: Unknown type name 'numeric-string' at position 0 in numeric-string.
Loading history...
20
     * @dataProvider moneyParsingProvider
21
     */
22
    public function testMultipliedMoneyParsing(string $amountCents, string $expectedCents, int $expectedMultiplier): void
23
    {
24
        $currencyCode = 'USD';
25
        $multipliedMoney = MultipliedMoney::create($amountCents, $currencyCode);
26
        $this->assertSame($currencyCode, $multipliedMoney->getCurrency()->getCode());
0 ignored issues
show
Bug introduced by
The method assertSame() does not exist on hiqdev\php\billing\tests...ney\MultipliedMoneyTest. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

26
        $this->/** @scrutinizer ignore-call */ 
27
               assertSame($currencyCode, $multipliedMoney->getCurrency()->getCode());

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
27
        $this->assertSame($expectedCents, $multipliedMoney->getAmount());
28
        $this->assertSame($expectedMultiplier, $multipliedMoney->multiplier());
29
    }
30
31
    public function moneyParsingProvider(): Generator
32
    {
33
        yield ['0', '0', 1];
34
        yield ['1', '100', 1];
35
        yield ['103', '10300', 1];
36
        yield ['1.32', '13200', 100];
37
        yield ['0.01', '100', 100];
38
        yield ['0.001', '100', 1000];
39
        yield ['0.0001', '100', 10000];
40
        yield ['2.1', '2100', 10];
41
        yield ['-2.234', '-223400', 1000];
42
    }
43
}
44