1*504c13e8SAndreas Gohr<?php 2*504c13e8SAndreas Gohr 3*504c13e8SAndreas Gohrnamespace dokuwiki\test\Parsing\ParserMode; 4*504c13e8SAndreas Gohr 5*504c13e8SAndreas Gohruse dokuwiki\Parsing\ParserMode\Code; 6*504c13e8SAndreas Gohr 7*504c13e8SAndreas Gohr/** 8*504c13e8SAndreas Gohr * Tests to ensure functionality of the <code> syntax tag. 9*504c13e8SAndreas Gohr * 10*504c13e8SAndreas Gohr * @group parser_code 11*504c13e8SAndreas Gohr */ 12*504c13e8SAndreas Gohrclass CodeTest extends ParserTestBase 13*504c13e8SAndreas Gohr{ 14*504c13e8SAndreas Gohr 15*504c13e8SAndreas Gohr function setUp() : void { 16*504c13e8SAndreas Gohr parent::setUp(); 17*504c13e8SAndreas Gohr $this->P->addMode('code',new Code()); 18*504c13e8SAndreas Gohr } 19*504c13e8SAndreas Gohr 20*504c13e8SAndreas Gohr function testCode() { 21*504c13e8SAndreas Gohr $this->P->parse('Foo <code>Test</code> Bar'); 22*504c13e8SAndreas Gohr $calls = [ 23*504c13e8SAndreas Gohr ['document_start',[]], 24*504c13e8SAndreas Gohr ['p_open',[]], 25*504c13e8SAndreas Gohr ['cdata',["\n".'Foo ']], 26*504c13e8SAndreas Gohr ['p_close',[]], 27*504c13e8SAndreas Gohr ['code',['Test',null,null]], 28*504c13e8SAndreas Gohr ['p_open',[]], 29*504c13e8SAndreas Gohr ['cdata',[' Bar']], 30*504c13e8SAndreas Gohr ['p_close',[]], 31*504c13e8SAndreas Gohr ['document_end',[]], 32*504c13e8SAndreas Gohr ]; 33*504c13e8SAndreas Gohr $this->assertCalls($calls, $this->H->calls); 34*504c13e8SAndreas Gohr } 35*504c13e8SAndreas Gohr 36*504c13e8SAndreas Gohr function testCodeBash() { 37*504c13e8SAndreas Gohr $this->P->parse('Foo <code bash>Test</code> Bar'); 38*504c13e8SAndreas Gohr $calls = [ 39*504c13e8SAndreas Gohr ['document_start',[]], 40*504c13e8SAndreas Gohr ['p_open',[]], 41*504c13e8SAndreas Gohr ['cdata',["\n".'Foo ']], 42*504c13e8SAndreas Gohr ['p_close',[]], 43*504c13e8SAndreas Gohr ['code',['Test','bash',null]], 44*504c13e8SAndreas Gohr ['p_open',[]], 45*504c13e8SAndreas Gohr ['cdata',[' Bar']], 46*504c13e8SAndreas Gohr ['p_close',[]], 47*504c13e8SAndreas Gohr ['document_end',[]], 48*504c13e8SAndreas Gohr ]; 49*504c13e8SAndreas Gohr $this->assertCalls($calls, $this->H->calls); 50*504c13e8SAndreas Gohr } 51*504c13e8SAndreas Gohr 52*504c13e8SAndreas Gohr function testCodeDownload() { 53*504c13e8SAndreas Gohr $this->P->parse('Foo <code bash script.sh>Test</code> Bar'); 54*504c13e8SAndreas Gohr $calls = [ 55*504c13e8SAndreas Gohr ['document_start',[]], 56*504c13e8SAndreas Gohr ['p_open',[]], 57*504c13e8SAndreas Gohr ['cdata',["\n".'Foo ']], 58*504c13e8SAndreas Gohr ['p_close',[]], 59*504c13e8SAndreas Gohr ['code',['Test','bash','script.sh']], 60*504c13e8SAndreas Gohr ['p_open',[]], 61*504c13e8SAndreas Gohr ['cdata',[' Bar']], 62*504c13e8SAndreas Gohr ['p_close',[]], 63*504c13e8SAndreas Gohr ['document_end',[]], 64*504c13e8SAndreas Gohr ]; 65*504c13e8SAndreas Gohr $this->assertCalls($calls, $this->H->calls); 66*504c13e8SAndreas Gohr } 67*504c13e8SAndreas Gohr 68*504c13e8SAndreas Gohr function testCodeToken() { 69*504c13e8SAndreas Gohr $this->P->parse('Foo <code2>Bar</code2><code>Test</code>'); 70*504c13e8SAndreas Gohr $calls = [ 71*504c13e8SAndreas Gohr ['document_start',[]], 72*504c13e8SAndreas Gohr ['p_open',[]], 73*504c13e8SAndreas Gohr ['cdata',["\n".'Foo <code2>Bar</code2>']], 74*504c13e8SAndreas Gohr ['p_close',[]], 75*504c13e8SAndreas Gohr ['code',['Test',null,null]], 76*504c13e8SAndreas Gohr ['document_end',[]], 77*504c13e8SAndreas Gohr ]; 78*504c13e8SAndreas Gohr $this->assertCalls($calls, $this->H->calls); 79*504c13e8SAndreas Gohr } 80*504c13e8SAndreas Gohr 81*504c13e8SAndreas Gohr function testCodeOptionsArray_OneOption() { 82*504c13e8SAndreas Gohr $this->P->parse('Foo <code C [enable_line_numbers]>Test</code> Bar'); 83*504c13e8SAndreas Gohr $calls = [ 84*504c13e8SAndreas Gohr ['document_start',[]], 85*504c13e8SAndreas Gohr ['p_open',[]], 86*504c13e8SAndreas Gohr ['cdata',["\n".'Foo ']], 87*504c13e8SAndreas Gohr ['p_close',[]], 88*504c13e8SAndreas Gohr ['code',['Test','C', null, 89*504c13e8SAndreas Gohr ['enable_line_numbers' => 1] 90*504c13e8SAndreas Gohr ]], 91*504c13e8SAndreas Gohr ['p_open',[]], 92*504c13e8SAndreas Gohr ['cdata',[' Bar']], 93*504c13e8SAndreas Gohr ['p_close',[]], 94*504c13e8SAndreas Gohr ['document_end',[]], 95*504c13e8SAndreas Gohr ]; 96*504c13e8SAndreas Gohr $this->assertCalls($calls, $this->H->calls); 97*504c13e8SAndreas Gohr } 98*504c13e8SAndreas Gohr 99*504c13e8SAndreas Gohr function testCodeOptionsArray_TwoOptions() { 100*504c13e8SAndreas Gohr $this->P->parse('Foo <code C [enable_line_numbers highlight_lines_extra="3"]>Test</code> Bar'); 101*504c13e8SAndreas Gohr $calls = [ 102*504c13e8SAndreas Gohr ['document_start',[]], 103*504c13e8SAndreas Gohr ['p_open',[]], 104*504c13e8SAndreas Gohr ['cdata',["\n".'Foo ']], 105*504c13e8SAndreas Gohr ['p_close',[]], 106*504c13e8SAndreas Gohr ['code',['Test','C', null, 107*504c13e8SAndreas Gohr ['enable_line_numbers' => true, 108*504c13e8SAndreas Gohr 'highlight_lines_extra' => [3] 109*504c13e8SAndreas Gohr ]]], 110*504c13e8SAndreas Gohr ['p_open',[]], 111*504c13e8SAndreas Gohr ['cdata',[' Bar']], 112*504c13e8SAndreas Gohr ['p_close',[]], 113*504c13e8SAndreas Gohr ['document_end',[]], 114*504c13e8SAndreas Gohr ]; 115*504c13e8SAndreas Gohr $this->assertCalls($calls, $this->H->calls); 116*504c13e8SAndreas Gohr } 117*504c13e8SAndreas Gohr 118*504c13e8SAndreas Gohr function testCodeOptionsArray_UnknownOption() { 119*504c13e8SAndreas Gohr $this->P->parse('Foo <code C [unknown="I will be deleted/ignored!"]>Test</code> Bar'); 120*504c13e8SAndreas Gohr $calls = [ 121*504c13e8SAndreas Gohr ['document_start',[]], 122*504c13e8SAndreas Gohr ['p_open',[]], 123*504c13e8SAndreas Gohr ['cdata',["\n".'Foo ']], 124*504c13e8SAndreas Gohr ['p_close',[]], 125*504c13e8SAndreas Gohr ['code',['Test','C', null, null]], 126*504c13e8SAndreas Gohr ['p_open',[]], 127*504c13e8SAndreas Gohr ['cdata',[' Bar']], 128*504c13e8SAndreas Gohr ['p_close',[]], 129*504c13e8SAndreas Gohr ['document_end',[]], 130*504c13e8SAndreas Gohr ]; 131*504c13e8SAndreas Gohr $this->assertCalls($calls, $this->H->calls); 132*504c13e8SAndreas Gohr } 133*504c13e8SAndreas Gohr 134*504c13e8SAndreas Gohr function testCodeOptionsArray_EnableLineNumbers1() { 135*504c13e8SAndreas Gohr $this->P->parse('Foo <code C [enable_line_numbers]>Test</code> Bar'); 136*504c13e8SAndreas Gohr $calls = [ 137*504c13e8SAndreas Gohr ['document_start',[]], 138*504c13e8SAndreas Gohr ['p_open',[]], 139*504c13e8SAndreas Gohr ['cdata',["\n".'Foo ']], 140*504c13e8SAndreas Gohr ['p_close',[]], 141*504c13e8SAndreas Gohr ['code',['Test','C', null, 142*504c13e8SAndreas Gohr ['enable_line_numbers' => true] 143*504c13e8SAndreas Gohr ]], 144*504c13e8SAndreas Gohr ['p_open',[]], 145*504c13e8SAndreas Gohr ['cdata',[' Bar']], 146*504c13e8SAndreas Gohr ['p_close',[]], 147*504c13e8SAndreas Gohr ['document_end',[]], 148*504c13e8SAndreas Gohr ]; 149*504c13e8SAndreas Gohr $this->assertCalls($calls, $this->H->calls); 150*504c13e8SAndreas Gohr } 151*504c13e8SAndreas Gohr 152*504c13e8SAndreas Gohr function testCodeOptionsArray_EnableLineNumbers2() { 153*504c13e8SAndreas Gohr $this->P->parse('Foo <code C [enable_line_numbers="1"]>Test</code> Bar'); 154*504c13e8SAndreas Gohr $calls = [ 155*504c13e8SAndreas Gohr ['document_start',[]], 156*504c13e8SAndreas Gohr ['p_open',[]], 157*504c13e8SAndreas Gohr ['cdata',["\n".'Foo ']], 158*504c13e8SAndreas Gohr ['p_close',[]], 159*504c13e8SAndreas Gohr ['code',['Test','C', null, 160*504c13e8SAndreas Gohr ['enable_line_numbers' => true] 161*504c13e8SAndreas Gohr ]], 162*504c13e8SAndreas Gohr ['p_open',[]], 163*504c13e8SAndreas Gohr ['cdata',[' Bar']], 164*504c13e8SAndreas Gohr ['p_close',[]], 165*504c13e8SAndreas Gohr ['document_end',[]], 166*504c13e8SAndreas Gohr ]; 167*504c13e8SAndreas Gohr $this->assertCalls($calls, $this->H->calls); 168*504c13e8SAndreas Gohr } 169*504c13e8SAndreas Gohr 170*504c13e8SAndreas Gohr function testCodeOptionsArray_EnableLineNumbers3() { 171*504c13e8SAndreas Gohr $this->P->parse('Foo <code C [enable_line_numbers="0"]>Test</code> Bar'); 172*504c13e8SAndreas Gohr $calls = [ 173*504c13e8SAndreas Gohr ['document_start',[]], 174*504c13e8SAndreas Gohr ['p_open',[]], 175*504c13e8SAndreas Gohr ['cdata',["\n".'Foo ']], 176*504c13e8SAndreas Gohr ['p_close',[]], 177*504c13e8SAndreas Gohr ['code',['Test','C', null, 178*504c13e8SAndreas Gohr ['enable_line_numbers' => false] 179*504c13e8SAndreas Gohr ]], 180*504c13e8SAndreas Gohr ['p_open',[]], 181*504c13e8SAndreas Gohr ['cdata',[' Bar']], 182*504c13e8SAndreas Gohr ['p_close',[]], 183*504c13e8SAndreas Gohr ['document_end',[]], 184*504c13e8SAndreas Gohr ]; 185*504c13e8SAndreas Gohr $this->assertCalls($calls, $this->H->calls); 186*504c13e8SAndreas Gohr } 187*504c13e8SAndreas Gohr 188*504c13e8SAndreas Gohr function testCodeOptionsArray_EnableLineNumbers4() { 189*504c13e8SAndreas Gohr $this->P->parse('Foo <code C [enable_line_numbers=""]>Test</code> Bar'); 190*504c13e8SAndreas Gohr $calls = [ 191*504c13e8SAndreas Gohr ['document_start',[]], 192*504c13e8SAndreas Gohr ['p_open',[]], 193*504c13e8SAndreas Gohr ['cdata',["\n".'Foo ']], 194*504c13e8SAndreas Gohr ['p_close',[]], 195*504c13e8SAndreas Gohr ['code',['Test','C', null, 196*504c13e8SAndreas Gohr ['enable_line_numbers' => true] 197*504c13e8SAndreas Gohr ]], 198*504c13e8SAndreas Gohr ['p_open',[]], 199*504c13e8SAndreas Gohr ['cdata',[' Bar']], 200*504c13e8SAndreas Gohr ['p_close',[]], 201*504c13e8SAndreas Gohr ['document_end',[]], 202*504c13e8SAndreas Gohr ]; 203*504c13e8SAndreas Gohr $this->assertCalls($calls, $this->H->calls); 204*504c13e8SAndreas Gohr } 205*504c13e8SAndreas Gohr 206*504c13e8SAndreas Gohr function testCodeOptionsArray_HighlightLinesExtra1() { 207*504c13e8SAndreas Gohr $this->P->parse('Foo <code C [enable_line_numbers highlight_lines_extra="42, 123, 456, 789"]>Test</code> Bar'); 208*504c13e8SAndreas Gohr $calls = [ 209*504c13e8SAndreas Gohr ['document_start',[]], 210*504c13e8SAndreas Gohr ['p_open',[]], 211*504c13e8SAndreas Gohr ['cdata',["\n".'Foo ']], 212*504c13e8SAndreas Gohr ['p_close',[]], 213*504c13e8SAndreas Gohr ['code',['Test','C', null, 214*504c13e8SAndreas Gohr ['enable_line_numbers' => true, 215*504c13e8SAndreas Gohr 'highlight_lines_extra' => [42, 123, 456, 789] 216*504c13e8SAndreas Gohr ]]], 217*504c13e8SAndreas Gohr ['p_open',[]], 218*504c13e8SAndreas Gohr ['cdata',[' Bar']], 219*504c13e8SAndreas Gohr ['p_close',[]], 220*504c13e8SAndreas Gohr ['document_end',[]], 221*504c13e8SAndreas Gohr ]; 222*504c13e8SAndreas Gohr $this->assertCalls($calls, $this->H->calls); 223*504c13e8SAndreas Gohr } 224*504c13e8SAndreas Gohr 225*504c13e8SAndreas Gohr function testCodeOptionsArray_HighlightLinesExtra2() { 226*504c13e8SAndreas Gohr $this->P->parse('Foo <code C [enable_line_numbers highlight_lines_extra]>Test</code> Bar'); 227*504c13e8SAndreas Gohr $calls = [ 228*504c13e8SAndreas Gohr ['document_start',[]], 229*504c13e8SAndreas Gohr ['p_open',[]], 230*504c13e8SAndreas Gohr ['cdata',["\n".'Foo ']], 231*504c13e8SAndreas Gohr ['p_close',[]], 232*504c13e8SAndreas Gohr ['code',['Test','C', null, 233*504c13e8SAndreas Gohr ['enable_line_numbers' => true, 234*504c13e8SAndreas Gohr 'highlight_lines_extra' => [1]] 235*504c13e8SAndreas Gohr ]], 236*504c13e8SAndreas Gohr ['p_open',[]], 237*504c13e8SAndreas Gohr ['cdata',[' Bar']], 238*504c13e8SAndreas Gohr ['p_close',[]], 239*504c13e8SAndreas Gohr ['document_end',[]], 240*504c13e8SAndreas Gohr ]; 241*504c13e8SAndreas Gohr $this->assertCalls($calls, $this->H->calls); 242*504c13e8SAndreas Gohr } 243*504c13e8SAndreas Gohr 244*504c13e8SAndreas Gohr function testCodeOptionsArray_HighlightLinesExtra3() { 245*504c13e8SAndreas Gohr $this->P->parse('Foo <code C [enable_line_numbers highlight_lines_extra=""]>Test</code> Bar'); 246*504c13e8SAndreas Gohr $calls = [ 247*504c13e8SAndreas Gohr ['document_start',[]], 248*504c13e8SAndreas Gohr ['p_open',[]], 249*504c13e8SAndreas Gohr ['cdata',["\n".'Foo ']], 250*504c13e8SAndreas Gohr ['p_close',[]], 251*504c13e8SAndreas Gohr ['code',['Test','C', null, 252*504c13e8SAndreas Gohr ['enable_line_numbers' => true, 253*504c13e8SAndreas Gohr 'highlight_lines_extra' => [1]] 254*504c13e8SAndreas Gohr ]], 255*504c13e8SAndreas Gohr ['p_open',[]], 256*504c13e8SAndreas Gohr ['cdata',[' Bar']], 257*504c13e8SAndreas Gohr ['p_close',[]], 258*504c13e8SAndreas Gohr ['document_end',[]], 259*504c13e8SAndreas Gohr ]; 260*504c13e8SAndreas Gohr $this->assertCalls($calls, $this->H->calls); 261*504c13e8SAndreas Gohr } 262*504c13e8SAndreas Gohr 263*504c13e8SAndreas Gohr function testCodeOptionsArray_StartLineNumbersAt1() { 264*504c13e8SAndreas Gohr $this->P->parse('Foo <code C [enable_line_numbers [enable_line_numbers start_line_numbers_at="42"]]>Test</code> Bar'); 265*504c13e8SAndreas Gohr $calls = [ 266*504c13e8SAndreas Gohr ['document_start',[]], 267*504c13e8SAndreas Gohr ['p_open',[]], 268*504c13e8SAndreas Gohr ['cdata',["\n".'Foo ']], 269*504c13e8SAndreas Gohr ['p_close',[]], 270*504c13e8SAndreas Gohr ['code',['Test','C', null, 271*504c13e8SAndreas Gohr ['enable_line_numbers' => true, 272*504c13e8SAndreas Gohr 'start_line_numbers_at' => 42] 273*504c13e8SAndreas Gohr ]], 274*504c13e8SAndreas Gohr ['p_open',[]], 275*504c13e8SAndreas Gohr ['cdata',[' Bar']], 276*504c13e8SAndreas Gohr ['p_close',[]], 277*504c13e8SAndreas Gohr ['document_end',[]], 278*504c13e8SAndreas Gohr ]; 279*504c13e8SAndreas Gohr $this->assertCalls($calls, $this->H->calls); 280*504c13e8SAndreas Gohr } 281*504c13e8SAndreas Gohr 282*504c13e8SAndreas Gohr function testCodeOptionsArray_StartLineNumbersAt2() { 283*504c13e8SAndreas Gohr $this->P->parse('Foo <code C [enable_line_numbers [enable_line_numbers start_line_numbers_at]]>Test</code> Bar'); 284*504c13e8SAndreas Gohr $calls = [ 285*504c13e8SAndreas Gohr ['document_start',[]], 286*504c13e8SAndreas Gohr ['p_open',[]], 287*504c13e8SAndreas Gohr ['cdata',["\n".'Foo ']], 288*504c13e8SAndreas Gohr ['p_close',[]], 289*504c13e8SAndreas Gohr ['code',['Test','C', null, 290*504c13e8SAndreas Gohr ['enable_line_numbers' => true, 291*504c13e8SAndreas Gohr 'start_line_numbers_at' => 1] 292*504c13e8SAndreas Gohr ]], 293*504c13e8SAndreas Gohr ['p_open',[]], 294*504c13e8SAndreas Gohr ['cdata',[' Bar']], 295*504c13e8SAndreas Gohr ['p_close',[]], 296*504c13e8SAndreas Gohr ['document_end',[]], 297*504c13e8SAndreas Gohr ]; 298*504c13e8SAndreas Gohr $this->assertCalls($calls, $this->H->calls); 299*504c13e8SAndreas Gohr } 300*504c13e8SAndreas Gohr 301*504c13e8SAndreas Gohr function testCodeOptionsArray_StartLineNumbersAt3() { 302*504c13e8SAndreas Gohr $this->P->parse('Foo <code C [enable_line_numbers [enable_line_numbers start_line_numbers_at=""]]>Test</code> Bar'); 303*504c13e8SAndreas Gohr $calls = [ 304*504c13e8SAndreas Gohr ['document_start',[]], 305*504c13e8SAndreas Gohr ['p_open',[]], 306*504c13e8SAndreas Gohr ['cdata',["\n".'Foo ']], 307*504c13e8SAndreas Gohr ['p_close',[]], 308*504c13e8SAndreas Gohr ['code',['Test','C', null, 309*504c13e8SAndreas Gohr ['enable_line_numbers' => true, 310*504c13e8SAndreas Gohr 'start_line_numbers_at' => 1] 311*504c13e8SAndreas Gohr ]], 312*504c13e8SAndreas Gohr ['p_open',[]], 313*504c13e8SAndreas Gohr ['cdata',[' Bar']], 314*504c13e8SAndreas Gohr ['p_close',[]], 315*504c13e8SAndreas Gohr ['document_end',[]], 316*504c13e8SAndreas Gohr ]; 317*504c13e8SAndreas Gohr $this->assertCalls($calls, $this->H->calls); 318*504c13e8SAndreas Gohr } 319*504c13e8SAndreas Gohr 320*504c13e8SAndreas Gohr function testCodeOptionsArray_EnableKeywordLinks1() { 321*504c13e8SAndreas Gohr $this->P->parse('Foo <code C [enable_keyword_links="false"]>Test</code> Bar'); 322*504c13e8SAndreas Gohr $calls = [ 323*504c13e8SAndreas Gohr ['document_start',[]], 324*504c13e8SAndreas Gohr ['p_open',[]], 325*504c13e8SAndreas Gohr ['cdata',["\n".'Foo ']], 326*504c13e8SAndreas Gohr ['p_close',[]], 327*504c13e8SAndreas Gohr ['code',['Test','C', null, 328*504c13e8SAndreas Gohr ['enable_keyword_links' => false] 329*504c13e8SAndreas Gohr ]], 330*504c13e8SAndreas Gohr ['p_open',[]], 331*504c13e8SAndreas Gohr ['cdata',[' Bar']], 332*504c13e8SAndreas Gohr ['p_close',[]], 333*504c13e8SAndreas Gohr ['document_end',[]], 334*504c13e8SAndreas Gohr ]; 335*504c13e8SAndreas Gohr $this->assertCalls($calls, $this->H->calls); 336*504c13e8SAndreas Gohr } 337*504c13e8SAndreas Gohr 338*504c13e8SAndreas Gohr function testCodeOptionsArray_EnableKeywordLinks2() { 339*504c13e8SAndreas Gohr $this->P->parse('Foo <code C [enable_keyword_links="true"]>Test</code> Bar'); 340*504c13e8SAndreas Gohr $calls = [ 341*504c13e8SAndreas Gohr ['document_start',[]], 342*504c13e8SAndreas Gohr ['p_open',[]], 343*504c13e8SAndreas Gohr ['cdata',["\n".'Foo ']], 344*504c13e8SAndreas Gohr ['p_close',[]], 345*504c13e8SAndreas Gohr ['code',['Test','C', null, 346*504c13e8SAndreas Gohr ['enable_keyword_links' => true] 347*504c13e8SAndreas Gohr ]], 348*504c13e8SAndreas Gohr ['p_open',[]], 349*504c13e8SAndreas Gohr ['cdata',[' Bar']], 350*504c13e8SAndreas Gohr ['p_close',[]], 351*504c13e8SAndreas Gohr ['document_end',[]], 352*504c13e8SAndreas Gohr ]; 353*504c13e8SAndreas Gohr $this->assertCalls($calls, $this->H->calls); 354*504c13e8SAndreas Gohr } 355*504c13e8SAndreas Gohr 356*504c13e8SAndreas Gohr public function highlightOptionsProvider() { 357*504c13e8SAndreas Gohr return [ 358*504c13e8SAndreas Gohr ['', null], 359*504c13e8SAndreas Gohr ['something weird', null], 360*504c13e8SAndreas Gohr ['enable_line_numbers', ['enable_line_numbers' => true]], 361*504c13e8SAndreas Gohr ['enable_line_numbers=1', ['enable_line_numbers' => true]], 362*504c13e8SAndreas Gohr ['enable_line_numbers="1"', ['enable_line_numbers' => true]], 363*504c13e8SAndreas Gohr ['enable_line_numbers=0', ['enable_line_numbers' => false]], 364*504c13e8SAndreas Gohr ['enable_line_numbers="0"', ['enable_line_numbers' => false]], 365*504c13e8SAndreas Gohr ['enable_line_numbers=false', ['enable_line_numbers' => false]], 366*504c13e8SAndreas Gohr ['enable_line_numbers="false"', ['enable_line_numbers' => false]], 367*504c13e8SAndreas Gohr ['highlight_lines_extra', ['highlight_lines_extra' => [1]]], 368*504c13e8SAndreas Gohr ['highlight_lines_extra=17', ['highlight_lines_extra' => [17]]], 369*504c13e8SAndreas Gohr ['highlight_lines_extra=17,19', ['highlight_lines_extra' => [17, 19]]], 370*504c13e8SAndreas Gohr ['highlight_lines_extra="17,19"', ['highlight_lines_extra' => [17, 19]]], 371*504c13e8SAndreas Gohr ['highlight_lines_extra="17,19,17"', ['highlight_lines_extra' => [17, 19]]], 372*504c13e8SAndreas Gohr ['start_line_numbers_at', ['start_line_numbers_at' => 1]], 373*504c13e8SAndreas Gohr ['start_line_numbers_at=12', ['start_line_numbers_at' => 12]], 374*504c13e8SAndreas Gohr ['start_line_numbers_at="12"', ['start_line_numbers_at' => 12]], 375*504c13e8SAndreas Gohr ['enable_keyword_links', ['enable_keyword_links' => true]], 376*504c13e8SAndreas Gohr ['enable_keyword_links=1', ['enable_keyword_links' => true]], 377*504c13e8SAndreas Gohr ['enable_keyword_links="1"', ['enable_keyword_links' => true]], 378*504c13e8SAndreas Gohr ['enable_keyword_links=0', ['enable_keyword_links' => false]], 379*504c13e8SAndreas Gohr ['enable_keyword_links="0"', ['enable_keyword_links' => false]], 380*504c13e8SAndreas Gohr ['enable_keyword_links=false', ['enable_keyword_links' => false]], 381*504c13e8SAndreas Gohr ['enable_keyword_links="false"', ['enable_keyword_links' => false]], 382*504c13e8SAndreas Gohr [ 383*504c13e8SAndreas Gohr 'enable_line_numbers weird nothing highlight_lines_extra=17,19 start_line_numbers_at="12" enable_keyword_links=false', 384*504c13e8SAndreas Gohr [ 385*504c13e8SAndreas Gohr 'enable_line_numbers' => true, 386*504c13e8SAndreas Gohr 'highlight_lines_extra' => [17, 19], 387*504c13e8SAndreas Gohr 'start_line_numbers_at' => 12, 388*504c13e8SAndreas Gohr 'enable_keyword_links' => false 389*504c13e8SAndreas Gohr ] 390*504c13e8SAndreas Gohr ], 391*504c13e8SAndreas Gohr ]; 392*504c13e8SAndreas Gohr } 393*504c13e8SAndreas Gohr 394*504c13e8SAndreas Gohr /** 395*504c13e8SAndreas Gohr * @dataProvider highlightOptionsProvider 396*504c13e8SAndreas Gohr * @param string $input options to parse 397*504c13e8SAndreas Gohr * @param array|null $expect expected outcome 398*504c13e8SAndreas Gohr */ 399*504c13e8SAndreas Gohr public function testHighlightOptionParser($input, $expect) { 400*504c13e8SAndreas Gohr $code = new Code(); 401*504c13e8SAndreas Gohr $output = $this->callInaccessibleMethod($code, 'parseHighlightOptions', [$input]); 402*504c13e8SAndreas Gohr $this->assertEquals($expect, $output); 403*504c13e8SAndreas Gohr } 404*504c13e8SAndreas Gohr} 405