r86218 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r86217‎ | r86218 | r86219 >
Date:16:54, 16 April 2011
Author:raylton.sousa
Status:deferred (Comments)
Tags:
Comment:
Add ParserTest
Modified paths:
  • /trunk/extensions/BookManager/BookManagerParserTests.txt (added) (history)

Diff [purge]

Index: trunk/extensions/BookManager/BookManagerParserTests.txt
@@ -0,0 +1,570 @@
 2+#Define where books are stored
 3+!! article
 4+MediaWiki:Coll-community book prefix
 5+!! text
 6+BookNamespace:
 7+!! endarticle
 8+
 9+# Create a standard book
 10+!! article
 11+BookNamespace:The book
 12+!! text
 13+== The book ==
 14+:[[The book/Introduction]]
 15+:[[The book/First chapter]]
 16+:[[The book/Second chapter]]
 17+:[[The book/Third chapter]]
 18+:[[The book/Chapter ÁÉÍÓÚ]]
 19+:[[The book/References]]
 20+!! endarticle
 21+
 22+#Create some chapters for the standard book
 23+!! article
 24+The book/Introduction
 25+!! text
 26+This is an introduction...
 27+!! endarticle
 28+
 29+!! article
 30+The book/First chapter
 31+!! text
 32+This is the chapter 1...
 33+!! endarticle
 34+
 35+!! article
 36+The book/Second chapter
 37+!! text
 38+This is the chapter 2...
 39+!! endarticle
 40+
 41+!! article
 42+The book/Third chapter
 43+!! text
 44+This is the chapter 3...
 45+!! endarticle
 46+
 47+!! article
 48+The book/Chapter ÁÉÍÓÚ
 49+!! text
 50+This is a page whose title has accented characters...
 51+!! endarticle
 52+
 53+!! article
 54+The book/References
 55+!! text
 56+This is a page for references...
 57+!! endarticle
 58+
 59+
 60+###
 61+### Tests for PREVPAGENAME variable
 62+###
 63+
 64+!!test
 65+Book Manager: PREVPAGENAME, given a chapter in the middle of a book
 66+!!input
 67+{{PREVPAGENAME:The book/Second chapter}}
 68+!!result
 69+<p>The book/First chapter
 70+</p>
 71+!!end
 72+
 73+!!test
 74+Book Manager: PREVPAGENAME, given the first chapter of a book
 75+!!input
 76+{{PREVPAGENAME:The book/Introduction}}
 77+!!result
 78+!!end
 79+
 80+!!test
 81+Book Manager: PREVPAGENAME on middle chapters
 82+!! options
 83+title=[[The book/Second chapter]]
 84+!!input
 85+{{PREVPAGENAME}}
 86+!!result
 87+<p>The book/First chapter
 88+</p>
 89+!!end
 90+
 91+!!test
 92+Book Manager: PREVPAGENAME on first chapter
 93+!! options
 94+title=[[The book/Introduction]]
 95+!!input
 96+{{PREVPAGENAME}}
 97+!!result
 98+!!end
 99+
 100+!!test
 101+Book Manager: PREVPAGENAME with empty parameter
 102+!! options
 103+title=[[The book/Second chapter]]
 104+!!input
 105+{{PREVPAGENAME:}}
 106+!!result
 107+<p>The book/First chapter
 108+</p>
 109+!!end
 110+
 111+
 112+###
 113+### Tests for PREVPAGENAMEE variable
 114+###
 115+
 116+!!test
 117+Book Manager: PREVPAGENAMEE, given a chapter in the middle of a book
 118+!!input
 119+{{PREVPAGENAMEE:The book/Second chapter}}
 120+!!result
 121+<p>The+book/First+chapter
 122+</p>
 123+!!end
 124+
 125+!!test
 126+Book Manager: PREVPAGENAMEE, given the first chapter of a book
 127+!!input
 128+{{PREVPAGENAMEE:The book/Introduction}}
 129+!!result
 130+!!end
 131+
 132+!!test
 133+Book Manager: PREVPAGENAMEE on middle chapters
 134+!! options
 135+title=[[The book/Second chapter]]
 136+!!input
 137+{{PREVPAGENAMEE}}
 138+!!result
 139+<p>The+book/First+chapter
 140+</p>
 141+!!end
 142+
 143+!!test
 144+Book Manager: PREVPAGENAMEE on first chapter
 145+!! options
 146+title=[[The book/Introduction]]
 147+!!input
 148+{{PREVPAGENAMEE}}
 149+!!result
 150+!!end
 151+
 152+!!test
 153+Book Manager: PREVPAGENAMEE with empty parameter
 154+!! options
 155+title=[[The book/Second chapter]]
 156+!!input
 157+{{PREVPAGENAMEE:}}
 158+!!result
 159+<p>The+book/First+chapter
 160+</p>
 161+!!end
 162+
 163+!!test
 164+Book Manager: PREVPAGENAMEE, when the previous chapter has accented letters
 165+!! options
 166+title=[[The book/References]]
 167+!!input
 168+{{PREVPAGENAMEE:}}
 169+!!result
 170+<p>The+book/Chapter+%C3%81%C3%89%C3%8D%C3%93%C3%9A
 171+</p>
 172+!!end
 173+
 174+
 175+###
 176+### Tests for NEXTPAGENAME variable
 177+###
 178+
 179+!!test
 180+Book Manager: NEXTPAGENAME, given a chapter in the middle of a book
 181+!!input
 182+{{NEXTPAGENAME:The book/Second chapter}}
 183+!!result
 184+<p>The book/Third chapter
 185+</p>
 186+!!end
 187+
 188+!!test
 189+Book Manager: NEXTPAGENAME, given the last chapter of a book
 190+!!input
 191+{{NEXTPAGENAME:The book/References}}
 192+!!result
 193+!!end
 194+
 195+!!test
 196+Book Manager: NEXTPAGENAME on middle chapters
 197+!! options
 198+title=[[The book/Second chapter]]
 199+!!input
 200+{{NEXTPAGENAME}}
 201+!!result
 202+<p>The book/Third chapter
 203+</p>
 204+!!end
 205+
 206+!!test
 207+Book Manager: NEXTPAGENAME, on last chapter
 208+!! options
 209+title=[[The book/References]]
 210+!!input
 211+{{NEXTPAGENAME}}
 212+!!result
 213+!!end
 214+
 215+!!test
 216+Book Manager: NEXTPAGENAME with empty parameter
 217+!! options
 218+title=[[The book/Second chapter]]
 219+!!input
 220+{{NEXTPAGENAME:}}
 221+!!result
 222+<p>The book/Third chapter
 223+</p>
 224+!!end
 225+
 226+
 227+###
 228+### Tests for NEXTPAGENAMEE variable
 229+###
 230+
 231+!!test
 232+Book Manager: NEXTPAGENAMEE, given a chapter in the middle of a book
 233+!!input
 234+{{NEXTPAGENAMEE:The book/Second chapter}}
 235+!!result
 236+<p>The+book/Third+chapter
 237+</p>
 238+!!end
 239+
 240+!!test
 241+Book Manager: NEXTPAGENAMEE, given the last chapter of a book
 242+!!input
 243+{{NEXTPAGENAMEE:The book/References}}
 244+!!result
 245+!!end
 246+
 247+!!test
 248+Book Manager: NEXTPAGENAMEE on middle chapters
 249+!! options
 250+title=[[The book/Second chapter]]
 251+!!input
 252+{{NEXTPAGENAMEE}}
 253+!!result
 254+<p>The+book/Third+chapter
 255+</p>
 256+!!end
 257+
 258+!!test
 259+Book Manager: NEXTPAGENAMEE, on last chapter
 260+!! options
 261+title=[[The book/References]]
 262+!!input
 263+{{NEXTPAGENAMEE}}
 264+!!result
 265+!!end
 266+
 267+!!test
 268+Book Manager: NEXTPAGENAMEE with empty parameter
 269+!! options
 270+title=[[The book/Second chapter]]
 271+!!input
 272+{{NEXTPAGENAMEE:}}
 273+!!result
 274+<p>The+book/Third+chapter
 275+</p>
 276+!!end
 277+
 278+!!test
 279+Book Manager: NEXTPAGENAMEE, when the next chapter has accented letters
 280+!! options
 281+title=[[The book/Third chapter]]
 282+!!input
 283+{{NEXTPAGENAMEE:}}
 284+!!result
 285+<p>The+book/Chapter+%C3%81%C3%89%C3%8D%C3%93%C3%9A
 286+</p>
 287+!!end
 288+
 289+
 290+###
 291+### Tests for ROOTPAGENAME variable
 292+###
 293+
 294+!!test
 295+Book Manager: ROOTPAGENAME, given a title without any "/"
 296+!!input
 297+{{ROOTPAGENAME:Some page title without bars}}
 298+!!result
 299+<p>Some page title without bars
 300+</p>
 301+!!end
 302+
 303+!!test
 304+Book Manager: ROOTPAGENAME, given a title with only one "/"
 305+!!input
 306+{{ROOTPAGENAME:Some page title/With one bar}}
 307+!!result
 308+<p>Some page title
 309+</p>
 310+!!end
 311+
 312+!!test
 313+Book Manager: ROOTPAGENAME, given a title with two "/"
 314+!!input
 315+{{ROOTPAGENAME:Some page title/With/Two bars}}
 316+!!result
 317+<p>Some page title
 318+</p>
 319+!!end
 320+
 321+!!test
 322+Book Manager: ROOTPAGENAME, given a title with lots of "/"
 323+!!input
 324+{{ROOTPAGENAME:Some page title/A/B/C/D/E/F/G/H/I/J/K/L/M/N/O/P/Q/R/S/T/U/V/W/X/Y/Z}}
 325+!!result
 326+<p>Some page title
 327+</p>
 328+!!end
 329+
 330+!!test
 331+Book Manager: ROOTPAGENAME, in a page whose title doesn't has any "/"
 332+!! options
 333+title=[[Some page title without bars]]
 334+!!input
 335+{{ROOTPAGENAME}}
 336+!!result
 337+<p>Some page title without bars
 338+</p>
 339+!!end
 340+
 341+!!test
 342+Book Manager: ROOTPAGENAME, in a page whose title has accented letters and lots of "/"
 343+!! options
 344+title=[[Some page title ÁÉÍÓÚ/A/B/C/D/E/F/G/H/I/J/K/L/M/N/O/P/Q/R/S/T/U/V/W/X/Y/Z]]
 345+!!input
 346+{{ROOTPAGENAME}}
 347+!!result
 348+<p>Some page title ÁÉÍÓÚ
 349+</p>
 350+!!end
 351+
 352+
 353+###
 354+### Tests for ROOTPAGENAMEE variable
 355+###
 356+
 357+!!test
 358+Book Manager: ROOTPAGENAMEE, given a title without any "/"
 359+!!input
 360+{{ROOTPAGENAMEE:Some page title without bars}}
 361+!!result
 362+<p>Some+page+title+without+bars
 363+</p>
 364+!!end
 365+
 366+!!test
 367+Book Manager: ROOTPAGENAMEE, given a title with only one "/"
 368+!!input
 369+{{ROOTPAGENAMEE:Some page title/With one bar}}
 370+!!result
 371+<p>Some+page+title
 372+</p>
 373+!!end
 374+
 375+!!test
 376+Book Manager: ROOTPAGENAMEE, given a title with two "/"
 377+!!input
 378+{{ROOTPAGENAMEE:Some page title/With/Two bars}}
 379+!!result
 380+<p>Some+page+title
 381+</p>
 382+!!end
 383+
 384+!!test
 385+Book Manager: ROOTPAGENAMEE, given a title with lots of "/"
 386+!!input
 387+{{ROOTPAGENAMEE:Some page title/A/B/C/D/E/F/G/H/I/J/K/L/M/N/O/P/Q/R/S/T/U/V/W/X/Y/Z}}
 388+!!result
 389+<p>Some+page+title
 390+</p>
 391+!!end
 392+
 393+!!test
 394+Book Manager: ROOTPAGENAMEE, given a title with accented letters and lots of "/"
 395+!!input
 396+{{ROOTPAGENAMEE:Some page title ÁÉÍÓÚ/A/B/C/D/E/F/G/H/I/J/K/L/M/N/O/P/Q/R/S/T/U/V/W/X/Y/Z}}
 397+!!result
 398+<p>Some+page+title+%C3%81%C3%89%C3%8D%C3%93%C3%9A
 399+</p>
 400+!!end
 401+
 402+!!test
 403+Book Manager: ROOTPAGENAMEE, in a page whose title doesn't has any "/"
 404+!! options
 405+title=[[Some page title without bars]]
 406+!!input
 407+{{ROOTPAGENAMEE}}
 408+!!result
 409+<p>Some+page+title+without+bars
 410+</p>
 411+!!end
 412+
 413+!!test
 414+Book Manager: ROOTPAGENAMEE, in a page whose title has accented letters and lots of "/"
 415+!! options
 416+title=[[Some page title ÁÉÍÓÚ/A/B/C/D/E/F/G/H/I/J/K/L/M/N/O/P/Q/R/S/T/U/V/W/X/Y/Z]]
 417+!!input
 418+{{ROOTPAGENAMEE}}
 419+!!result
 420+<p>Some+page+title+%C3%81%C3%89%C3%8D%C3%93%C3%9A
 421+</p>
 422+!!end
 423+
 424+###
 425+### Tests for CHAPTERNAME variable
 426+###
 427+
 428+!!test
 429+Book Manager: CHAPTERNAME, given a title without any "/"
 430+!!input
 431+{{CHAPTERNAME:Some page title without bars}}
 432+!!result
 433+<p>Some page title without bars
 434+</p>
 435+!!end
 436+
 437+!!test
 438+Book Manager: CHAPTERNAME, given a title with only one "/"
 439+!!input
 440+{{CHAPTERNAME:Some page title/With one bar}}
 441+!!result
 442+<p>With one bar
 443+</p>
 444+!!end
 445+
 446+!!test
 447+Book Manager: CHAPTERNAME, given a title with two "/"
 448+!!input
 449+{{CHAPTERNAME:Some page title/With/Two bars}}
 450+!!result
 451+<p>With/Two bars
 452+</p>
 453+!!end
 454+
 455+!!test
 456+Book Manager: CHAPTERNAME, given a title with lots of "/"
 457+!!input
 458+{{CHAPTERNAME:Some page title/A/B/C/D/E/F/G/H/I/J/K/L/M/N/O/P/Q/R/S/T/U/V/W/X/Y/Z}}
 459+!!result
 460+<p>A/B/C/D/E/F/G/H/I/J/K/L/M/N/O/P/Q/R/S/T/U/V/W/X/Y/Z
 461+</p>
 462+!!end
 463+
 464+!!test
 465+Book Manager: CHAPTERNAME, in a page whose title doesn't has any "/"
 466+!! options
 467+title=[[Some page title without bars]]
 468+!!input
 469+{{CHAPTERNAME}}
 470+!!result
 471+<p>Some page title without bars
 472+</p>
 473+!!end
 474+
 475+!!test
 476+Book Manager: CHAPTERNAME, in a page whose title has accented letters and lots of "/"
 477+!! options
 478+title=[[Some page title ÁÉÍÓÚ/A/B/C/D/E/F/G/H/I/J/K/L/M/N/O/P/Q/R/S/T/U/V/W/X/Y/Z]]
 479+!!input
 480+{{CHAPTERNAME}}
 481+!!result
 482+<p>A/B/C/D/E/F/G/H/I/J/K/L/M/N/O/P/Q/R/S/T/U/V/W/X/Y/Z
 483+</p>
 484+!!end
 485+
 486+
 487+###
 488+### Tests for CHAPTERNAMEE variable
 489+###
 490+
 491+!!test
 492+Book Manager: CHAPTERNAMEE, given a title without any "/"
 493+!!input
 494+{{CHAPTERNAMEE:Some page title without bars}}
 495+!!result
 496+<p>Some+page+title+without+bars
 497+</p>
 498+!!end
 499+
 500+!!test
 501+Book Manager: CHAPTERNAMEE, given a title with only one "/"
 502+!!input
 503+{{CHAPTERNAMEE:Some page title/With one bar}}
 504+!!result
 505+<p>With+one+bar
 506+</p>
 507+!!end
 508+
 509+!!test
 510+Book Manager: CHAPTERNAMEE, given a title with two "/"
 511+!!input
 512+{{CHAPTERNAMEE:Some page title/With/Two bars}}
 513+!!result
 514+<p>With/Two+bars
 515+</p>
 516+!!end
 517+
 518+!!test
 519+Book Manager: CHAPTERNAMEE, given a title with lots of "/"
 520+!!input
 521+{{CHAPTERNAMEE:Some page title/A/B/C/D/E/F/G/H/I/J/K/L/M/N/O/P/Q/R/S/T/U/V/W/X/Y/Z}}
 522+!!result
 523+<p>A/B/C/D/E/F/G/H/I/J/K/L/M/N/O/P/Q/R/S/T/U/V/W/X/Y/Z
 524+</p>
 525+!!end
 526+
 527+!!test
 528+Book Manager: CHAPTERNAMEE, given a title with accented letters and lots of "/"
 529+!!input
 530+{{CHAPTERNAMEE:Some page title/ÁÉÍÓÚ/A/B/C/D/E/F/G/H/I/J/K/L/M/N/O/P/Q/R/S/T/U/V/W/X/Y/Z}}
 531+!!result
 532+<p>%C3%81%C3%89%C3%8D%C3%93%C3%9A/A/B/C/D/E/F/G/H/I/J/K/L/M/N/O/P/Q/R/S/T/U/V/W/X/Y/Z
 533+</p>
 534+!!end
 535+
 536+!!test
 537+Book Manager: CHAPTERNAMEE, in a page whose title doesn't has any "/"
 538+!! options
 539+title=[[Some page title without bars]]
 540+!!input
 541+{{CHAPTERNAMEE}}
 542+!!result
 543+<p>Some+page+title+without+bars
 544+</p>
 545+!!end
 546+
 547+!!test
 548+Book Manager: CHAPTERNAMEE, in a page whose title has accented letters and lots of "/"
 549+!! options
 550+title=[[Some page title/ÁÉÍÓÚ/A/B/C/D/E/F/G/H/I/J/K/L/M/N/O/P/Q/R/S/T/U/V/W/X/Y/Z]]
 551+!!input
 552+{{CHAPTERNAMEE}}
 553+!!result
 554+<p>%C3%81%C3%89%C3%8D%C3%93%C3%9A/A/B/C/D/E/F/G/H/I/J/K/L/M/N/O/P/Q/R/S/T/U/V/W/X/Y/Z
 555+</p>
 556+!!end
 557+
 558+
 559+###
 560+### Tests for Special:PrintVersion
 561+###
 562+
 563+!! test
 564+BookManager: Special:PrintVersion is known
 565+!! options
 566+msg
 567+!! input
 568+{{#special:PrintVersion}}
 569+!! result
 570+Special:PrintVersion
 571+!! end
\ No newline at end of file

Follow-up revisions

RevisionCommit summaryAuthorDate
r87682Addraylton.sousa11:16, 8 May 2011

Comments

#Comment by He7d3r (talk | contribs)   12:25, 17 April 2011

It is necessary to add the file to /BookManager.php:

$wgParserTestFiles[] = $dir . "/BookManagerParserTests.txt";
#Comment by Raylton P. Sousa (talk | contribs)   09:32, 15 May 2011

Solve in r87682.

Status & tagging log