Completed
Push — master ( c0f76f...37333c )
by Jeroen De
299:55 queued 234:55
created

ConstraintViolationListMapperTest   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 4

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 1
lcom 0
cbo 4
dl 0
loc 19
rs 10
c 1
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A testMultipleViolations_canByConvertedToArray() 0 16 1
1
<?php
2
3
declare( strict_types = 1 );
4
5
namespace WMDE\Fundraising\Frontend\Tests\Unit\Validation;
6
7
use Symfony\Component\Validator\ConstraintViolation;
8
use Symfony\Component\Validator\ConstraintViolationList;
9
use WMDE\Fundraising\Frontend\Validation\ConstraintViolationListMapper;
10
use PHPUnit\Framework\TestCase;
11
12
/**
13
 * @covers \WMDE\Fundraising\Frontend\Validation\ConstraintViolationListMapper
14
 */
15
class ConstraintViolationListMapperTest extends TestCase {
16
17
	public function testMultipleViolations_canByConvertedToArray(): void {
18
		$mapper = new ConstraintViolationListMapper();
19
20
		$violationOne = new ConstraintViolation( 'not good', null, [], null, '[lorem]', 5 );
21
		$violationTwo = new ConstraintViolation( 'neither', null, [], null, '[lorem]', 7 );
22
		$violationThree = new ConstraintViolation( 'oops', null, [], null, '[ipsum]', 9000 );
23
		$violations = new ConstraintViolationList( [ $violationOne, $violationTwo, $violationThree ] );
24
25
		$this->assertEquals(
26
			[
27
				'lorem' => [ 'not good', 'neither' ],
28
				'ipsum' => [ 'oops' ]
29
			],
30
			$mapper->map( $violations )
31
		);
32
	}
33
}
34