Completed
Push — master ( 00092a...39103d )
by wiese
86:17 queued 21:06
created

DonorNameTest   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 67
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 2
dl 0
loc 67
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A testGivenPersonName_determineFullNameReturnsFullName() 0 10 1
A privatePersonProvider() 0 49 1
1
<?php
2
3
declare( strict_types = 1 );
4
5
namespace WMDE\Fundraising\Frontend\DonationContext\Tests\Unit\Domain\Model;
6
7
use WMDE\Fundraising\Frontend\DonationContext\Domain\Model\DonorName;
8
9
/**
10
 * @covers \WMDE\Fundraising\Frontend\DonationContext\Domain\Model\DonorName
11
 *
12
 * @license GNU GPL v2+
13
 * @author Kai Nissen < [email protected] >
14
 */
15
class DonorNameTest extends \PHPUnit\Framework\TestCase {
16
17
	/**
18
	 * @dataProvider privatePersonProvider
19
	 */
20
	public function testGivenPersonName_determineFullNameReturnsFullName( string $expectedValue, array $data ): void {
21
		$personName = DonorName::newPrivatePersonName();
22
23
		$personName->setCompanyName( $data['company'] );
24
		$personName->setFirstName( $data['firstName'] );
25
		$personName->setLastName( $data['lastName'] );
26
		$personName->setTitle( $data['title'] );
27
28
		$this->assertSame( $expectedValue, $personName->getFullName() );
29
	}
30
31
	public function privatePersonProvider(): array {
32
		return [
33
			[
34
				'Ebenezer Scrooge',
35
				[
36
					'title' => '',
37
					'firstName' => 'Ebenezer',
38
					'lastName' => 'Scrooge',
39
					'company' => ''
40
				]
41
			],
42
			[
43
				'Sir Ebenezer Scrooge',
44
				[
45
					'title' => 'Sir',
46
					'firstName' => 'Ebenezer',
47
					'lastName' => 'Scrooge',
48
					'company' => ''
49
				]
50
			],
51
			[
52
				'Prof. Dr. Friedemann Schulz von Thun',
53
				[
54
					'title' => 'Prof. Dr.',
55
					'firstName' => 'Friedemann',
56
					'lastName' => 'Schulz von Thun',
57
					'company' => ''
58
				]
59
			],
60
			[
61
				'Hank Scorpio, Globex Corp.',
62
				[
63
					'title' => '',
64
					'firstName' => 'Hank',
65
					'lastName' => 'Scorpio',
66
					'company' => 'Globex Corp.'
67
				]
68
			],
69
			[
70
				'Evil Hank Scorpio, Globex Corp.',
71
				[
72
					'title' => 'Evil',
73
					'firstName' => 'Hank',
74
					'lastName' => 'Scorpio',
75
					'company' => 'Globex Corp.'
76
				]
77
			]
78
		];
79
	}
80
81
}