Page MenuHomePhabricator

Impossible to add articles starting with lower case letter during parser tests using "!!article"
Open, NormalPublic

Description

Adding an article during a parser test like:

!! article
Template:test
!! text
Test
!! endarticle

will not create "Template:test" but "Template:Test", even if $wgCapitalLinks was set to false before (using the new 'ParserTestGlobals' hook).

Apparently, since the following change ParserTest::addArticle() temporarily changes the global during parser tests article creation (to work around another issue?):
https://www.mediawiki.org/w/index.php?title=Special:Code/MediaWiki/71511&path=#c33010

Anyhow, it might be nice to be able use:

!! article
Template:test
!! config
wgCapitalLinks=false
!! text
Test
!! endarticle

to create the article with certain globals set to specific values. The code above should create the article with the lower "s" instead of "S". Also, $wgCapitalLinks should not be ignored by ParserTest::addArticle() anymore.

Details

Reference
bz39461

Event Timeline

bzimport raised the priority of this task from to Normal.Nov 22 2014, 12:56 AM
bzimport set Reference to bz39461.
bzimport added a subscriber: Unknown Object (MLST).
Danwe created this task.Aug 17 2012, 6:44 PM

Yes, it would be nice to use
!! config
wgCapitalLinks=false

Although it is creating a strange environment to test in, since the tests are
run with wgCapitalLinks=true...

Danwe added a comment.Aug 18 2012, 2:46 AM

I will submit a patch for this soon.

The environment is only strange if you explicitly long for it, and that's even a real world scenario, isn't it? In most cases you would probably set $wgCapitalLinks=false for the tests using this page. But there could even be tests for core, testing how articles created with the option in one state behave after changing the option.

It looks to me that it should be a different file to be run with different settings. I think that behavior after changing the settings is "undefined" (articles created with initial lowercase will be unavailable until you run a maintenance script, for instance).

Submitted a fix, I611d8086

Extensions use different files than the default parser test file already. Core could do the same and use different files for different groups of tests.

I also introduced a new hook, 'ParserTestGlobals' in an earlier commit recently. I will extend that one to allow for registering a certain set of settings per file rather than always registering them for all tests.
It would also be nice to be able to overwrite settings for a whole file within that file.

(In reply to comment #4)

Extensions use different files than the default parser test file already. Core
could do the same and use different files for different groups of tests.

Yes, that's what I was talking about.

Danwe added a comment.Nov 6 2012, 10:45 AM

This is kind of blocked by 39473. At least it is the reason for I611d8086 failing. It's just a paint to make this work with having the two different ways of running parser tests. I believe the change-set I have submitted was optimized by the non-PHPUnit way of running the tests.

Change 20534 had a related patch set uploaded by Krinkle:
$wgCapitalLinks=false not ignored during article creation in parser tests anymore

https://gerrit.wikimedia.org/r/20534

Krinkle updated the task description. (Show Details)Dec 21 2014, 7:51 AM
Krinkle set Security to None.
Krinkle removed subscribers: Unknown Object (MLST), Krinkle.
Krinkle moved this task from Inbox to PHPUnit on the MediaWiki-Core-Testing board.Jul 7 2017, 5:13 AM