mirror of
https://github.com/cosmocode/dokuwiki-plugin-struct.git
synced 2025-08-13 13:37:20 +00:00
Added tests for Color
This commit is contained in:
@ -16,6 +16,7 @@ class column_struct_test extends StructTest {
|
||||
|
||||
$expect = array(
|
||||
'Checkbox' => 'dokuwiki\\plugin\\struct\\types\\Checkbox',
|
||||
'Color' => 'dokuwiki\\plugin\\struct\\types\\Color',
|
||||
'Date' => 'dokuwiki\\plugin\\struct\\types\\Date',
|
||||
'DateTime' => 'dokuwiki\\plugin\\struct\\types\\DateTime',
|
||||
'Decimal' => 'dokuwiki\\plugin\\struct\\types\\Decimal',
|
||||
@ -38,6 +39,7 @@ class column_struct_test extends StructTest {
|
||||
|
||||
$expect = array(
|
||||
'Checkbox' => 'dokuwiki\\plugin\\struct\\types\\Checkbox',
|
||||
'Color' => 'dokuwiki\\plugin\\struct\\types\\Color',
|
||||
'Date' => 'dokuwiki\\plugin\\struct\\types\\Date',
|
||||
'DateTime' => 'dokuwiki\\plugin\\struct\\types\\DateTime',
|
||||
'Decimal' => 'dokuwiki\\plugin\\struct\\types\\Decimal',
|
||||
|
69
_test/Type_Color.test.php
Normal file
69
_test/Type_Color.test.php
Normal file
@ -0,0 +1,69 @@
|
||||
<?php
|
||||
|
||||
namespace dokuwiki\plugin\struct\test;
|
||||
|
||||
use dokuwiki\plugin\struct\meta\Schema;
|
||||
use dokuwiki\plugin\struct\meta\ValidationException;
|
||||
use dokuwiki\plugin\struct\types\Color;
|
||||
use dokuwiki\plugin\struct\types\Date;
|
||||
use dokuwiki\plugin\struct\types\Tag;
|
||||
|
||||
/**
|
||||
* @group plugin_struct
|
||||
* @group plugins
|
||||
*/
|
||||
class Type_Color_struct_test extends StructTest {
|
||||
|
||||
/**
|
||||
* DataProvider for successful validations
|
||||
*/
|
||||
public function validate_success() {
|
||||
return array(
|
||||
array('#123abc', '#123abc'),
|
||||
array('#123abc ', '#123abc'),
|
||||
array(' #123abc', '#123abc'),
|
||||
array(' #123abc ', '#123abc'),
|
||||
|
||||
array('#123EDF', '#123edf'),
|
||||
array('#123EDF ', '#123edf'),
|
||||
array(' #123EDF', '#123edf'),
|
||||
array(' #123EDF ', '#123edf'),
|
||||
|
||||
array('#ffffff', ''),
|
||||
array(' #ffffff', ''),
|
||||
array('#ffffff ', ''),
|
||||
array(' #ffffff ', ''),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider validate_success
|
||||
*/
|
||||
public function test_validation_success($input, $expect) {
|
||||
$date = new Color();
|
||||
|
||||
$this->assertEquals($expect, $date->validate($input));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* DataProvider for failed validations
|
||||
*/
|
||||
public function validate_fail() {
|
||||
return array(
|
||||
array('ffffff'),
|
||||
array('foo bar'),
|
||||
array('#ccc'),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider validate_fail
|
||||
* @expectedException \dokuwiki\plugin\struct\meta\ValidationException
|
||||
*/
|
||||
public function test_validation_fail($input) {
|
||||
$date = new Color();
|
||||
|
||||
$date->validate($input);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user