Passed
Pull Request — master (#12)
by Robbie
04:58 queued 01:01
created

SynonymValidatorTest::tearDown()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 0
dl 0
loc 4
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace CWP\CWP\Tests\Extensions;
4
5
use PHPUnit_Framework_TestCase;
6
7
use CWP\CWP\Extensions\SynonymValidator;
8
9
10
11
class SynonymValidatorTest extends PHPUnit_Framework_TestCase {
12
	/**
13
	 * @var SynonymValidator
14
	 */
15
	protected $validator;
16
17
	/**
18
	 * @inheritdoc
19
	 */
20
	public function setUp() {
21
		parent::setUp();
22
23
		$this->validator = new SynonymValidator(array(
24
			'Synonyms',
25
		));
26
	}
27
28
	/**
29
	 * @inheritdoc
30
	 */
31
	public function tearDown() {
32
		$this->validator = null;
33
34
		parent::tearDown();
35
	}
36
37
	/**
38
	 * @dataProvider validValuesProvider
39
	 */
40
	public function testItAllowsValidValues($value) {
41
		$this->validator->php(array(
42
			'Synonyms' => $value,
43
		));
44
45
		$this->assertEmpty($this->validator->getErrors());
46
	}
47
48
	/**
49
	 * @return array
50
	 */
51
	public function validValuesProvider() {
52
		return array(
53
			array('foo'),
54
			array('foo,bar,baz'),
55
			array('foo, bar, baz'),
56
			array('
57
				foo
58
				bar
59
				baz
60
			'),
61
			array('foo => bar, baz'),
62
			array('
63
				# this is a comment, it should be ignored!
64
65
				foo, bar, baz
66
				foo => bar, baz
67
68
				# ...as should this.
69
			'),
70
		);
71
	}
72
73
	/**
74
	 * @dataProvider invalidValuesProvider
75
	 *
76
	 * @param string $value
77
	 */
78
	public function testItDisallowsInvalidValues($value) {
79
		$this->validator->php(array(
80
			'Synonyms' => $value,
81
		));
82
83
		$this->assertNotEmpty($this->validator->getErrors());
84
	}
85
86
	/**
87
	 * @return array
88
	 */
89
	public function invalidValuesProvider() {
90
		return array(
91
			array('foo, bar baz, qux'),
92
			array('foo => bar baz, qux')
93
		);
94
	}
95
}
96