Total Complexity | 6 |
Total Lines | 82 |
Duplicated Lines | 0 % |
Changes | 0 |
1 | <?php |
||
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() { |
||
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() { |
||
93 | ); |
||
94 | } |
||
95 | } |
||
96 |