Passed
Push — master ( 6e37f8...05a985 )
by Jeroen De
02:43
created

ParserTestBase::invalidInputProvider()

Size

Total Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 1
nc 1
1
<?php
2
3
namespace Tests\DataValues\Geo\Parsers;
4
5
use DataValues\DataValue;
6
use ValueParsers\ParseException;
7
use ValueParsers\ValueParser;
8
9
/**
10
 * @deprecated This is a copy of ValueParserTestBase from DataValues Common, temporarily created to
11
 * be able to refactor it away in easy to follow steps.
12
 *
13
 * @license GPL-2.0+
14
 */
15
abstract class ParserTestBase extends \PHPUnit_Framework_TestCase {
16
17
	/**
18
	 * @return ValueParser
19
	 */
20
	abstract protected function getInstance();
21
22
	/**
23
	 * @return array[]
24
	 */
25
	abstract public function validInputProvider();
26
27
	/**
28
	 * @dataProvider validInputProvider
29
	 */
30
	public function testParseWithValidInputs( $value, DataValue $expected ) {
31
		$actual = $this->getInstance()->parse( $value );
32
		$msg = json_encode( $actual->toArray() ) . " should equal\n"
33
			. json_encode( $expected->toArray() );
34
		$this->assertTrue( $expected->equals( $actual ), $msg );
35
	}
36
37
	/**
38
	 * @return array[]
39
	 */
40
	abstract public function invalidInputProvider();
41
42
	/**
43
	 * @dataProvider invalidInputProvider
44
	 */
45
	public function testParseWithInvalidInputs( $value ) {
46
		$this->setExpectedException( ParseException::class );
47
		$this->getInstance()->parse( $value );
48
	}
49
50
}
51