Completed
Pull Request — master (#3)
by Jeroen De
03:52
created

testGivenNegativeAmount_constructorThrowsException()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 7
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 5
nc 1
nop 0
1
<?php
2
3
declare( strict_types = 1 );
4
5
namespace WMDE\Euro\Tests\Unit;
6
7
use Eris\Generator;
8
use Eris\TestTrait;
9
use PHPUnit\Framework\TestCase;
10
use WMDE\Euro\Euro;
11
12
/**
13
 * @covers \WMDE\Euro\Euro
14
 *
15
 * @license GNU GPL v2+
16
 * @author Jeroen De Dauw < [email protected] >
17
 */
18
class EuroErisTest extends TestCase {
19
	use TestTrait;
20
21
	public function testGivenNegativeAmount_constructorThrowsException() {
22
		$this->forAll( Generator\neg() )
23
			->then( function( int $negativeInteger ) {
24
				$this->expectException( \InvalidArgumentException::class );
25
				Euro::newFromCents( $negativeInteger );
26
			} );
27
	}
28
29
	public function testGetCentsReturnsConstructorArgument() {
30
		$this->forAll( Generator\pos() )
31
			->then( function( int $unsignedInteger ) {
32
				$amount = Euro::newFromCents( $unsignedInteger );
33
				$this->assertSame( $unsignedInteger, $amount->getEuroCents() );
34
			} );
35
	}
36
37
	public function testEquality() {
38
		$this->forAll( Generator\pos() )
39
			->then( function( int $unsignedInteger ) {
40
				$amount = Euro::newFromCents( $unsignedInteger );
41
				$this->assertTrue( $amount->equals( Euro::newFromCents( $unsignedInteger ) ) );
42
			} );
43
	}
44
45
}
46