Completed
Pull Request — master (#47)
by no
17:11 queued 15:26
created

StringFormatterTest::invalidProvider()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 7
rs 9.4285
cc 1
eloc 5
nc 1
nop 0
1
<?php
2
3
namespace ValueFormatters\Test;
4
5
use DataValues\StringValue;
6
use ValueFormatters\FormatterOptions;
7
use ValueFormatters\StringFormatter;
8
9
/**
10
 * @covers ValueFormatters\StringFormatter
11
 *
12
 * @group ValueFormatters
13
 * @group DataValueExtensions
14
 *
15
 * @license GPL-2.0+
16
 * @author Katie Filbert < [email protected] >
17
 */
18
class StringFormatterTest extends ValueFormatterTestBase {
19
20
	/**
21
	 * @deprecated since DataValues Interfaces 0.2, just use getInstance.
22
	 */
23
	protected function getFormatterClass() {
24
		throw new \LogicException( 'Should not be called, use getInstance' );
25
	}
26
27
	/**
28
	 * @see ValueFormatterTestBase::getInstance
29
	 *
30
	 * @param FormatterOptions|null $options
31
	 *
32
	 * @return StringFormatter
33
	 */
34
	protected function getInstance( FormatterOptions $options = null ) {
35
		return new StringFormatter( $options );
36
	}
37
38
	/**
39
	 * @see ValueFormatterTestBase::validProvider
40
	 */
41
	public function validProvider() {
42
		return [
43
			[ new StringValue( 'ice cream' ), 'ice cream' ],
44
			[ new StringValue( 'cake' ), 'cake' ],
45
			[ new StringValue( '' ), '' ],
46
			[ new StringValue( ' a ' ), ' a ' ],
47
			[ new StringValue( '  ' ), '  ' ],
48
		];
49
	}
50
51
	/**
52
	 * @dataProvider invalidProvider
53
	 */
54
	public function testInvalidFormat( $value ) {
55
		$formatter = new StringFormatter();
56
		$this->setExpectedException( 'InvalidArgumentException' );
57
		$formatter->format( $value );
58
	}
59
60
	public function invalidProvider() {
61
		return [
62
			[ null ],
63
			[ 0 ],
64
			[ '' ],
65
		];
66
	}
67
68
}
69