Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into feature-replacement-functions
- Loading branch information
Showing
40 changed files
with
1,469 additions
and
605 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,12 @@ | ||
language: php | ||
php: | ||
- "7.3" | ||
- "7.2" | ||
- "7.1" | ||
- "7.0" | ||
- "5.6" | ||
before_install: wget https://raw.github.com/splitbrain/dokuwiki-travis/master/travis.sh | ||
install: sh travis.sh | ||
script: cd _test && phpunit --stderr --group plugin_bureaucracy | ||
script: | ||
- cd _test | ||
- ./phpunit.phar --group plugin_bureaucracy |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
<?php | ||
|
||
namespace dokuwiki\plugin\bureaucracy\test; | ||
|
||
use \Doku_Form; | ||
|
||
/** | ||
* @group plugin_bureaucracy | ||
* @group plugins | ||
*/ | ||
class bureaucracy_field_date_test extends BureaucracyTest | ||
{ | ||
|
||
public function dataProvider() | ||
{ | ||
return [ | ||
[ | ||
'Date:@@dateLabel@@', | ||
'date "dateLabel"', | ||
'2018-05-15', | ||
'Date:2018-05-15', | ||
[], | ||
'valid date', | ||
], | ||
[ | ||
'Date:@@dateLabel@@', | ||
'date "dateLabel"', | ||
'2018.05.15', | ||
null, | ||
['dateLabel'], | ||
'invalid date', | ||
], | ||
[ | ||
'Date: @DATE(@@dateLabel@@)@', | ||
'date "dateLabel"', | ||
'2018-02-15', | ||
'Date: 2018/02/15 00:00', | ||
[], | ||
'formatted date with $conf[\'dformat\'] format', | ||
], | ||
[ | ||
'Month: @DATE(@@dateLabel@@,%%m)@', | ||
'date "dateLabel"', | ||
'2018-02-15', | ||
'Month: 02', | ||
[], | ||
'formatted date with custom format', | ||
], | ||
]; | ||
} | ||
|
||
/** | ||
* @dataProvider dataProvider | ||
* | ||
* @param string $templateSyntax | ||
* @param string $formSyntax | ||
* @param string $postedValue | ||
* @param string $expectedWikiText | ||
* @param string $expectedValidationErrors | ||
* @param string $msg | ||
* | ||
*/ | ||
public function test_field_date_submit( | ||
$templateSyntax, | ||
$formSyntax, | ||
$postedValue, | ||
$expectedWikiText, | ||
$expectedValidationErrors, | ||
$msg | ||
) { | ||
$actualValidationErrors = []; | ||
|
||
$actualWikiText = parent::send_form_action_template( | ||
$formSyntax, | ||
$templateSyntax, | ||
$actualValidationErrors, | ||
$postedValue | ||
); | ||
|
||
if (empty($expectedValidationErrors)) { | ||
$this->assertEquals($expectedWikiText, $actualWikiText, $msg); | ||
} | ||
$this->assertEquals($expectedValidationErrors, $actualValidationErrors, $msg); | ||
} | ||
|
||
public function test_field_date_render() | ||
{ | ||
$formSyntax = 'date "dateLabel"'; | ||
$instr = p_get_instructions("<form>\n$formSyntax\n</form>"); | ||
|
||
$actualHTML = p_render('xhtml', $instr, $info); | ||
|
||
$expectedFieldHTML = '<label><span>dateLabel <sup>*</sup></span> <input type="text" name="bureaucracy[0]" class="datepicker edit required" maxlength="10" required="required" /></label>'; | ||
$expectedHTML = self::FORM_PREFIX_HTML . "\n$expectedFieldHTML\n" . self::FORM_SUFFIX_HTML; | ||
$this->assertEquals(trim($expectedHTML), trim($actualHTML)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
<?php | ||
|
||
namespace dokuwiki\plugin\bureaucracy\test; | ||
|
||
use \Doku_Form; | ||
|
||
/** | ||
* @group plugin_bureaucracy | ||
* @group plugins | ||
*/ | ||
class bureaucracy_field_email_test extends BureaucracyTest | ||
{ | ||
|
||
public function dataProvider() | ||
{ | ||
return [ | ||
[ | ||
'Mail: @@emailLabel@@', | ||
'valid@example.com', | ||
'Mail: valid@example.com', | ||
[], | ||
'valid email', | ||
], | ||
[ | ||
'Mail: @@emailLabel@@', | ||
'@MAIL@', | ||
'Mail: @MAIL@', | ||
[], | ||
'@MAIL@ placeholder for user\'s email adress', | ||
], | ||
[ | ||
'Mail: @@emailLabel@@', | ||
'invalid@example', | ||
'Mail: invalid@example', | ||
[], | ||
'local email addresses are allowed', | ||
], | ||
[ | ||
'Mail: @@emailLabel@@', | ||
'invalid[at]example.com', | ||
null, | ||
['emailLabel'], | ||
'invalid email', | ||
], | ||
]; | ||
} | ||
|
||
/** | ||
* @dataProvider dataProvider | ||
* | ||
* @param string $templateSyntax | ||
* @param $postedValue | ||
* @param string $expectedWikiText | ||
* @param string $expectedValidationErrors | ||
* @param string $msg | ||
* | ||
*/ | ||
public function test_field_email_submit( | ||
$templateSyntax, | ||
$postedValue, | ||
$expectedWikiText, | ||
$expectedValidationErrors, | ||
$msg | ||
) { | ||
$actualValidationErrors = []; | ||
|
||
$label = 'emailLabel'; | ||
$actualWikiText = parent::send_form_action_template( | ||
"email \"$label\"", | ||
$templateSyntax, | ||
$actualValidationErrors, | ||
$postedValue | ||
); | ||
|
||
if (empty($expectedValidationErrors)) { | ||
$this->assertEquals($expectedWikiText, $actualWikiText, $msg); | ||
} | ||
$this->assertEquals($expectedValidationErrors, $actualValidationErrors, $msg); | ||
} | ||
|
||
public function test_field_email_render() | ||
{ | ||
$formSyntax = 'email emailLabel'; | ||
$instr = p_get_instructions("<form>\n$formSyntax\n</form>"); | ||
|
||
$actualHTML = p_render('xhtml', $instr, $info); | ||
|
||
$expectedFieldHTML = '<label><span>emailLabel <sup>*</sup></span> <input type="text" name="bureaucracy[0]" class="edit required" required="required" /></label>'; | ||
$expectedHTML = self::FORM_PREFIX_HTML . "\n$expectedFieldHTML\n" . self::FORM_SUFFIX_HTML; | ||
$this->assertEquals(trim($expectedHTML), trim($actualHTML)); | ||
} | ||
} |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
<?php | ||
|
||
namespace dokuwiki\plugin\bureaucracy\test; | ||
|
||
use \Doku_Form; | ||
|
||
/** | ||
* @group plugin_bureaucracy | ||
* @group plugins | ||
*/ | ||
class bureaucracy_field_hidden_test extends BureaucracyTest | ||
{ | ||
|
||
public function dataProvider() | ||
{ | ||
return [ | ||
[ | ||
'hidden:@@hiddenLabel@@', | ||
'default value of the hidden field', | ||
'default value of the hidden field', | ||
'hidden:default value of the hidden field', | ||
[], | ||
'valid hidden', | ||
], | ||
]; | ||
} | ||
|
||
/** | ||
* @dataProvider dataProvider | ||
* | ||
* @param string $templateSyntax | ||
* @param $postedValue | ||
* @param string $expectedWikiText | ||
* @param string $expectedValidationErrors | ||
* @param string $msg | ||
* | ||
*/ | ||
public function test_field_hidden_submit( | ||
$templateSyntax, | ||
$defaultValue, | ||
$postedValue, | ||
$expectedWikiText, | ||
$expectedValidationErrors, | ||
$msg | ||
) { | ||
$actualValidationErrors = []; | ||
|
||
$label = 'hiddenLabel'; | ||
$actualWikiText = parent::send_form_action_template( | ||
"hidden \"$label\" \"=$defaultValue\"", | ||
$templateSyntax, | ||
$actualValidationErrors, | ||
$postedValue | ||
); | ||
|
||
if (empty($expectedValidationErrors)) { | ||
$this->assertEquals($expectedWikiText, $actualWikiText, $msg); | ||
} | ||
$this->assertEquals($expectedValidationErrors, $actualValidationErrors, $msg); | ||
} | ||
|
||
public function test_field_time_render() | ||
{ | ||
$formSyntax = 'hidden hiddenLabel "=default value of the hidden field"'; | ||
$instr = p_get_instructions("<form>\n$formSyntax\n</form>"); | ||
|
||
$actualHTML = p_render('xhtml', $instr, $info); | ||
|
||
$hiddenFormPrefix = '<form class="bureaucracy__plugin" id="bureaucracy__plugin1" enctype="multipart/form-data" method="post" action="" accept-charset="utf-8"><div class="no"> | ||
<input type="hidden" name="sectok" value="" /><input type="hidden" name="bureaucracy[$$id]" value="1" />'; | ||
$expectedFieldHTML = '<input type="hidden" name="bureaucracy[0]" value="default value of the hidden field" />'; | ||
$hiddenFormSuffix = '</div></form>'; | ||
$expectedHTML = "$hiddenFormPrefix$expectedFieldHTML$hiddenFormSuffix"; | ||
|
||
$this->assertEquals(trim($expectedHTML), trim($actualHTML)); | ||
} | ||
} |
Oops, something went wrong.