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

EuroErisTest   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 3
dl 0
loc 28
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A testGivenNegativeAmount_constructorThrowsException() 0 7 1
A testGetCentsReturnsConstructorArgument() 0 7 1
A testEquality() 0 7 1
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