1<?php
2
3namespace dokuwiki\plugin\struct\test;
4
5use dokuwiki\plugin\struct\meta\Schema;
6use dokuwiki\plugin\struct\meta\ValidationException;
7use dokuwiki\plugin\struct\types\Color;
8use dokuwiki\plugin\struct\types\Date;
9use dokuwiki\plugin\struct\types\Tag;
10
11/**
12 * @group plugin_struct
13 * @group plugins
14 */
15class Type_Color_struct_test extends StructTest {
16
17    /**
18     * DataProvider for successful validations
19     */
20    public function validate_success() {
21        return array(
22            array('#123abc', '#123abc'),
23            array('#123abc ', '#123abc'),
24            array(' #123abc', '#123abc'),
25            array(' #123abc ', '#123abc'),
26
27            array('#123EDF', '#123edf'),
28            array('#123EDF ', '#123edf'),
29            array(' #123EDF', '#123edf'),
30            array(' #123EDF ', '#123edf'),
31
32            array('#ffffff', ''),
33            array(' #ffffff', ''),
34            array('#ffffff ', ''),
35            array(' #ffffff ', ''),
36        );
37    }
38
39    /**
40     * @dataProvider validate_success
41     */
42    public function test_validation_success($input, $expect) {
43        $date = new Color();
44
45        $this->assertEquals($expect, $date->validate($input));
46    }
47
48
49    /**
50     * DataProvider for failed validations
51     */
52    public function validate_fail() {
53        return array(
54            array('ffffff'),
55            array('foo bar'),
56            array('#ccc'),
57        );
58    }
59
60    /**
61     * @dataProvider validate_fail
62     * @expectedException \dokuwiki\plugin\struct\meta\ValidationException
63     */
64    public function test_validation_fail($input) {
65        $date = new Color();
66
67        $date->validate($input);
68    }
69}
70