EraParserTest   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 79
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

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

4 Methods

Rating   Name   Duplication   Size   Complexity  
A getInstance() 0 3 1
A requireDataValue() 0 3 1
A validInputProvider() 0 37 1
A invalidInputProvider() 0 13 1
1
<?php
2
3
namespace ValueParsers\Test;
4
5
use ValueParsers\EraParser;
6
7
/**
8
 * @covers ValueParsers\EraParser
9
 *
10
 * @group DataValue
11
 * @group DataValueExtensions
12
 * @group TimeParsers
13
 * @group ValueParsers
14
 *
15
 * @license GPL-2.0+
16
 * @author Addshore
17
 * @author Thiemo Kreuz
18
 */
19
class EraParserTest extends StringValueParserTest {
20
21
	/**
22
	 * @see ValueParserTestBase::getInstance
23
	 *
24
	 * @return EraParser
25
	 */
26
	protected function getInstance() {
27
		return new EraParser();
28
	}
29
30
	/**
31
	 * @see ValueParserTestBase::requireDataValue
32
	 *
33
	 * @return bool
34
	 */
35
	protected function requireDataValue() {
36
		return false;
37
	}
38
39
	/**
40
	 * @see ValueParserTestBase::validInputProvider
41
	 */
42
	public function validInputProvider() {
43
		return array(
44
			// Strings with no explicit era should be echoed
45
			array( '1', array( '+', '1' ) ),
46
			array( '1 000 000', array( '+', '1 000 000' ) ),
47
			array( 'non-matching string', array( '+', 'non-matching string' ) ),
48
49
			// Strings with an era that should be split of
50
			array( '+100', array( '+', '100' ) ),
51
			array( '-100', array( '-', '100' ) ),
52
			array( '   -100', array( '-', '100' ) ),
53
			array( '100BC', array( '-', '100' ) ),
54
			array( '100 BC', array( '-', '100' ) ),
55
			array( '100 BCE', array( '-', '100' ) ),
56
			array( '100 AD', array( '+', '100' ) ),
57
			array( '100 A. D.', array( '+', '100' ) ),
58
			array( '   100   B.   C.   ', array( '-', '100' ) ),
59
			array( '   100   Common   Era   ', array( '+', '100' ) ),
60
			array( '100 CE', array( '+', '100' ) ),
61
			array( '100CE', array( '+', '100' ) ),
62
			array( '+100', array( '+', '100' ) ),
63
			array( '100 Common Era', array( '+', '100' ) ),
64
			array( '100 Current Era', array( '+', '100' ) ),
65
			array( '100 Christian Era', array( '+', '100' ) ),
66
			array( '100Common Era', array( '+', '100' ) ),
67
			array( '100 Before Common Era', array( '-', '100' ) ),
68
			array( '100 Before Current Era', array( '-', '100' ) ),
69
			array( '100 Before Christian Era', array( '-', '100' ) ),
70
			array( '1 July 2013 Before Common Era', array( '-', '1 July 2013' ) ),
71
			array( 'June 2013 Before Common Era', array( '-', 'June 2013' ) ),
72
			array( '10-10-10 Before Common Era', array( '-', '10-10-10' ) ),
73
			array( 'FooBefore Common Era', array( '-', 'Foo' ) ),
74
			array( 'Foo Before Common Era', array( '-', 'Foo' ) ),
75
			array( '-1 000 000', array( '-', '1 000 000' ) ),
76
			array( '1 000 000 B.C.', array( '-', '1 000 000' ) ),
77
		);
78
	}
79
80
	/**
81
	 * @see StringValueParserTest::invalidInputProvider
82
	 */
83
	public function invalidInputProvider() {
84
		return array(
85
			// Reject strings with two eras, no matter if conflicting or not
86
			array( '-100BC' ),
87
			array( '-100AD' ),
88
			array( '-100CE' ),
89
			array( '+100BC' ),
90
			array( '+100AD' ),
91
			array( '+100CE' ),
92
			array( '+100 Before Common Era' ),
93
			array( '+100 Common Era' ),
94
		);
95
	}
96
97
}
98