1<?php 2 3/** 4 * 5 * 6 * @author Michael Große <grosse@cosmocode.de> 7 * 8 * @group Michael Große <grosse@cosmocode.de> 9 * @group plugin_rating 10 * @group plugins 11 */ 12 13class best_rating_test extends DokuWikiTest { 14 protected $pluginsEnabled = array('rating'); 15 16 function test_vanilla_syntax_parsing() { 17 $parser_response = p_get_instructions('{{rating}}')[2]; 18 $expected_response = array( 19 0 => 'plugin', 20 1 => array( 21 0 => 'rating', 22 1 => array( 23 0 => DOKU_LEXER_SPECIAL, 24 1 => array( 25 'lang' => '', 26 'startdate' => '', 27 'tag' => 'ul', 28 'score' => 'false', 29 ) 30 ), 31 2 => DOKU_LEXER_SPECIAL, 32 3 => '{{rating}}', 33 ), 34 2 => 1, 35 ); 36 $this->assertEquals($expected_response, $parser_response); 37 } 38 39 function test_ol_syntax_parsing() { 40 $parser_response = p_get_instructions('{{rating|tag=ol}}')[2]; 41 $expected_response = array( 42 0 => 'plugin', 43 1 => array( 44 0 => 'rating', 45 1 => array( 46 0 => DOKU_LEXER_SPECIAL, 47 1 => array( 48 'lang' => '', 49 'startdate' => '', 50 'tag' => 'ol', 51 'score' => 'false', 52 ) 53 ), 54 2 => DOKU_LEXER_SPECIAL, 55 3 => '{{rating|tag=ol}}', 56 ), 57 2 => 1, 58 ); 59 $this->assertEquals($expected_response, $parser_response); 60 } 61 62 function test_score_syntax_parsing() { 63 $parser_response = p_get_instructions('{{rating|score=true}}')[2]; 64 $expected_response = array( 65 0 => 'plugin', 66 1 => array( 67 0 => 'rating', 68 1 => array( 69 0 => DOKU_LEXER_SPECIAL, 70 1 => array( 71 'lang' => '', 72 'startdate' => '', 73 'tag' => 'ul', 74 'score' => 'true', 75 ) 76 ), 77 2 => DOKU_LEXER_SPECIAL, 78 3 => '{{rating|score=true}}', 79 ), 80 2 => 1, 81 ); 82 $this->assertEquals($expected_response, $parser_response); 83 } 84 85 function test_date_syntax_parsing() { 86 $parser_response = p_get_instructions('{{rating|startdate=2015-02-17}}')[2]; 87 $expected_response = array( 88 0 => 'plugin', 89 1 => array( 90 0 => 'rating', 91 1 => array( 92 0 => DOKU_LEXER_SPECIAL, 93 1 => array( 94 'lang' => '', 95 'startdate' => '2015-02-17', 96 'tag' => 'ul', 97 'score' => 'false', 98 ) 99 ), 100 2 => DOKU_LEXER_SPECIAL, 101 3 => '{{rating|startdate=2015-02-17}}', 102 ), 103 2 => 1, 104 ); 105 $this->assertEquals($expected_response, $parser_response); 106 } 107 108 function test_lang_syntax_parsing() { 109 $parser_response = p_get_instructions('{{rating|lang=en}}')[2]; 110 $expected_response = array( 111 0 => 'plugin', 112 1 => array( 113 0 => 'rating', 114 1 => array( 115 0 => DOKU_LEXER_SPECIAL, 116 1 => array( 117 'lang' => 'en', 118 'startdate' => '', 119 'tag' => 'ul', 120 'score' => 'false', 121 ) 122 ), 123 2 => DOKU_LEXER_SPECIAL, 124 3 => '{{rating|lang=en}}', 125 ), 126 2 => 1, 127 ); 128 $this->assertEquals($expected_response, $parser_response); 129 } 130 131 function test_datelang_syntax_parsing() { 132 $parser_response = p_get_instructions('{{rating|startdate=2015-02-17,lang=en}}')[2]; 133 $expected_response = array( 134 0 => 'plugin', 135 1 => array( 136 0 => 'rating', 137 1 => array( 138 0 => DOKU_LEXER_SPECIAL, 139 1 => array( 140 'lang' => 'en', 141 'startdate' => '2015-02-17', 142 'tag' => 'ul', 143 'score' => 'false', 144 ) 145 ), 146 2 => DOKU_LEXER_SPECIAL, 147 3 => '{{rating|startdate=2015-02-17,lang=en}}', 148 ), 149 2 => 1, 150 ); 151 $this->assertEquals($expected_response, $parser_response); 152 } 153 154} 155