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