Passed
Push — master ( 8ff373...315bd9 )
by adam
01:44
created

NullStringNormalizerTest::stringProvider()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 7
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
declare( strict_types = 1 );
4
5
namespace ValueParsers\Tests\Normalizers;
6
7
use DataValues\StringValue;
8
use InvalidArgumentException;
9
use PHPUnit\Framework\TestCase;
10
use ValueParsers\Normalizers\NullStringNormalizer;
11
12
/**
13
 * @covers \ValueParsers\Normalizers\NullStringNormalizer
14
 *
15
 * @group ValueParsers
16
 * @group DataValueExtensions
17
 *
18
 * @license GPL-2.0-or-later
19
 * @author Thiemo Kreuz
20
 */
21
class NullStringNormalizerTest extends TestCase {
22
23
	/**
24
	 * @dataProvider stringProvider
25
	 */
26
	public function testNormalize( $value ) {
27
		$normalizer = new NullStringNormalizer();
28
		$this->assertSame( $value, $normalizer->normalize( $value ) );
29
	}
30
31
	public function stringProvider() {
32
		return [
33
			[ '' ],
34
			[ 'a' ],
35
			[ ' a ' ],
36
		];
37
	}
38
39
	/**
40
	 * @dataProvider invalidValueProvider
41
	 */
42
	public function testNormalizeException( $value ) {
43
		$normalizer = new NullStringNormalizer();
44
		$this->expectException( InvalidArgumentException::class );
45
		$normalizer->normalize( $value );
46
	}
47
48
	public function invalidValueProvider() {
49
		return [
50
			[ null ],
51
			[ true ],
52
			[ 1 ],
53
			[ new StringValue( '' ) ],
54
		];
55
	}
56
57
}
58