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

MoneyTest::testZero()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 3
nc 1
nop 0
dl 0
loc 6
ccs 4
cts 4
cp 1
crap 1
rs 10
c 1
b 0
f 0
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