Passed
Push — master ( c6d69a...dbe157 )
by Mr
02:16
created

MoneyTest   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 10
dl 0
loc 23
ccs 13
cts 13
cp 1
rs 10
c 1
b 0
f 0
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A testFromNative() 0 7 1
A testToString() 0 4 1
A testZero() 0 6 1
1
<?php declare(strict_types=1);
2
/**
3
 * This file is part of the daikon-cqrs/value-object project.
4
 *
5
 * For the full copyright and license information, please view the LICENSE
6
 * file that was distributed with this source code.
7
 */
8
9
 namespace Daikon\Tests\Money\ValueObject;
10
11
use Daikon\Money\ValueObject\Money;
12
use InvalidArgumentException;
13
use PHPUnit\Framework\TestCase;
14
15
final class MoneyTest extends TestCase
16
{
17 1
    public function testFromNative(): void
18
    {
19 1
        $this->assertEquals('100USD', Money::fromNative('100usd')->toNative());
20 1
        $this->assertEquals('-100A', Money::fromNative('-100A')->toNative());
21
22 1
        $this->expectException(InvalidArgumentException::class);
23 1
        Money::fromNative('100');
24
    } // @codeCoverageIgnore
25
26 1
    public function testToString(): void
27
    {
28 1
        $this->assertEquals('100USD1', (string)Money::fromNative('100uSd1'));
29 1
        $this->assertEquals('-100A', (string)Money::fromNative('-100A'));
30 1
    }
31
32 1
    public function testZero(): void
33
    {
34 1
        $this->assertEquals('0AB', Money::zero('Ab')->toNative());
35
36 1
        $this->expectException(InvalidArgumentException::class);
37 1
        Money::zero();
38
    } // @codeCoverageIgnore
39
}
40