-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from micgro42/extendSyntax
Extend syntax
- Loading branch information
Showing
8 changed files
with
246 additions
and
18 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
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,100 @@ | ||
<?php | ||
|
||
/** | ||
* | ||
* | ||
* @author Michael Große <grosse@cosmocode.de> | ||
* | ||
* @group Michael Große <grosse@cosmocode.de> | ||
* @group plugin_rating | ||
* @group plugins | ||
*/ | ||
|
||
class best_rating_test extends DokuWikiTest { | ||
protected $pluginsEnabled = array('rating'); | ||
|
||
function test_vanilla_syntax_parsing() { | ||
$parser_response = p_get_instructions('{{rating}}')[2]; | ||
$expected_response = array( | ||
0 => 'plugin', | ||
1 => array( | ||
0 => 'rating', | ||
1 => array( | ||
0 => DOKU_LEXER_SPECIAL, | ||
1 => array( | ||
'lang' => '', | ||
'startdate' => '', | ||
) | ||
), | ||
2 => DOKU_LEXER_SPECIAL, | ||
3 => '{{rating}}', | ||
), | ||
2 => 1, | ||
); | ||
$this->assertEquals($expected_response, $parser_response); | ||
} | ||
|
||
function test_date_syntax_parsing() { | ||
$parser_response = p_get_instructions('{{rating|startdate=2015-02-17}}')[2]; | ||
$expected_response = array( | ||
0 => 'plugin', | ||
1 => array( | ||
0 => 'rating', | ||
1 => array( | ||
0 => DOKU_LEXER_SPECIAL, | ||
1 => array( | ||
'lang' => '', | ||
'startdate' => '2015-02-17', | ||
) | ||
), | ||
2 => DOKU_LEXER_SPECIAL, | ||
3 => '{{rating|startdate=2015-02-17}}', | ||
), | ||
2 => 1, | ||
); | ||
$this->assertEquals($expected_response, $parser_response); | ||
} | ||
|
||
function test_lang_syntax_parsing() { | ||
$parser_response = p_get_instructions('{{rating|lang=en}}')[2]; | ||
$expected_response = array( | ||
0 => 'plugin', | ||
1 => array( | ||
0 => 'rating', | ||
1 => array( | ||
0 => DOKU_LEXER_SPECIAL, | ||
1 => array( | ||
'lang' => 'en', | ||
'startdate' => '', | ||
) | ||
), | ||
2 => DOKU_LEXER_SPECIAL, | ||
3 => '{{rating|lang=en}}', | ||
), | ||
2 => 1, | ||
); | ||
$this->assertEquals($expected_response, $parser_response); | ||
} | ||
|
||
function test_datelang_syntax_parsing() { | ||
$parser_response = p_get_instructions('{{rating|startdate=2015-02-17,lang=en}}')[2]; | ||
$expected_response = array( | ||
0 => 'plugin', | ||
1 => array( | ||
0 => 'rating', | ||
1 => array( | ||
0 => DOKU_LEXER_SPECIAL, | ||
1 => array( | ||
'lang' => 'en', | ||
'startdate' => '2015-02-17', | ||
) | ||
), | ||
2 => DOKU_LEXER_SPECIAL, | ||
3 => '{{rating|startdate=2015-02-17,lang=en}}', | ||
), | ||
2 => 1, | ||
); | ||
$this->assertEquals($expected_response, $parser_response); | ||
} | ||
|
||
} |
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,57 @@ | ||
<?php | ||
/** | ||
* General tests for the top plugin | ||
* | ||
* @group plugin_rating | ||
* @group plugins | ||
*/ | ||
class general_plugin_rating_test extends DokuWikiTest { | ||
|
||
/** | ||
* Simple test to make sure the plugin.info.txt is in correct format | ||
*/ | ||
public function test_plugininfo() { | ||
$file = __DIR__.'/../plugin.info.txt'; | ||
$this->assertFileExists($file); | ||
|
||
$info = confToHash($file); | ||
|
||
$this->assertArrayHasKey('base', $info); | ||
$this->assertArrayHasKey('author', $info); | ||
$this->assertArrayHasKey('email', $info); | ||
$this->assertArrayHasKey('date', $info); | ||
$this->assertArrayHasKey('name', $info); | ||
$this->assertArrayHasKey('desc', $info); | ||
$this->assertArrayHasKey('url', $info); | ||
|
||
$this->assertEquals('rating', $info['base']); | ||
$this->assertRegExp('/^https?:\/\//', $info['url']); | ||
$this->assertTrue(mail_isvalid($info['email'])); | ||
$this->assertRegExp('/^\d\d\d\d-\d\d-\d\d$/', $info['date']); | ||
$this->assertTrue(false !== strtotime($info['date'])); | ||
} | ||
|
||
/** | ||
* Test to ensure that every conf['...'] entry in conf/default.php has a corresponding meta['...'] entry in | ||
* conf/metadata.php. | ||
*/ | ||
public function test_plugin_conf() { | ||
$conf_file = __DIR__.'/../conf/default.php'; | ||
if (file_exists($conf_file)){ | ||
include($conf_file); | ||
} | ||
$meta_file = __DIR__.'/../conf/metadata.php'; | ||
if (file_exists($meta_file)) { | ||
include($meta_file); | ||
} | ||
$this->assertEquals(gettype($conf), gettype($meta),'Both ' . DOKU_PLUGIN . 'rating/conf/default.php and ' . DOKU_PLUGIN . 'rating/conf/metadata.php have to exist and contain the same keys.'); | ||
if (gettype($conf) != 'NULL' && gettype($meta) != 'NULL') { | ||
foreach($conf as $key => $value) { | ||
$this->assertArrayHasKey($key, $meta, 'Key $meta[\'' . $key . '\'] missing in ' . DOKU_PLUGIN . 'rating/conf/metadata.php'); | ||
} | ||
foreach($meta as $key => $value) { | ||
$this->assertArrayHasKey($key, $conf, 'Key $conf[\'' . $key . '\'] missing in ' . DOKU_PLUGIN . 'rating/conf/default.php'); | ||
} | ||
} | ||
} | ||
} |
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 +1 @@ | ||
1 | ||
2 |
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,25 @@ | ||
CREATE TEMPORARY TABLE ratingtemp ( | ||
page, | ||
rater, | ||
lang, | ||
date, | ||
value, | ||
PRIMARY KEY(page, rater) | ||
); | ||
|
||
INSERT INTO ratingtemp (page, rater, lang, date, value) SELECT page, rater, '', '', value FROM ratings; | ||
|
||
DROP TABLE ratings; | ||
|
||
CREATE TABLE ratings ( | ||
page, | ||
rater, | ||
lang, | ||
date, | ||
value, | ||
PRIMARY KEY(page, rater) | ||
); | ||
|
||
INSERT INTO ratings (page, rater, lang, date, value) SELECT page, rater, lang, date, value FROM ratingtemp; | ||
|
||
DROP TABLE ratingtemp; |
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 |
---|---|---|
@@ -1,7 +1,7 @@ | ||
base rating | ||
author Andreas Gohr | ||
email gohr@cosmocode.de | ||
date 2014-10-08 | ||
date 2015-02-19 | ||
name rating plugin | ||
desc Allows rating a page | ||
url http://www.cosmocode.de | ||
url https://www.dokuwiki.org/plugin:rating |
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