aboutsummaryrefslogtreecommitdiffstats
path: root/tests/phpunit/unit/includes/editpage
diff options
context:
space:
mode:
authorBartosz Dziewoński <matma.rex@gmail.com>2022-07-15 02:46:52 +0200
committerBartosz Dziewoński <matma.rex@gmail.com>2022-07-19 09:56:05 +0000
commit990fd8f0b29f54e583ace8d613bed9d28c0c6485 (patch)
tree5fc73057efebda74501b39a00f9370cb18adf6a9 /tests/phpunit/unit/includes/editpage
parent2d8a15d8d2c11fdfb3de0bae77b9a7247bfbf2e1 (diff)
downloadmediawikicore-990fd8f0b29f54e583ace8d613bed9d28c0c6485.tar.gz
mediawikicore-990fd8f0b29f54e583ace8d613bed9d28c0c6485.zip
EditPage: Disentangle edit summary and section title
Previously, `$this->summary` was used for two different purposes. Usually it was just the summary. But when `$this->section` was 'new', then it was actually the section title most of the time – unless `$this->sectiontitle` was also set (in which case it took priority), and until it was replaced by the real edit summary (near the end of the processing, after copying the section title to the page content and before saving changes). Unsurprisingly some of the code didn't handle this duality correctly, causing T191722 and T311533. Now `$this->summary` is always the summary, and when `$this->section` is 'new', then `$this->sectiontitle` is always the new section title. The only place where this duality remains is in the input attributes and query parameters, where 'wpSummary' is still used for both the summary and the section title inputs (only one of them can appear, depending on whether `$this->section` is 'new'). It would be an unreasonable backwards-compatibility break to change this, and the code handling this is somewhat isolated from the rest of the logic. Bug: T191722 Bug: T311533 Change-Id: I5313ca9a045d112ece390b011a34192220e2abc1
Diffstat (limited to 'tests/phpunit/unit/includes/editpage')
-rw-r--r--tests/phpunit/unit/includes/editpage/Constraint/EditConstraintFactoryTest.php1
-rw-r--r--tests/phpunit/unit/includes/editpage/Constraint/NewSectionMissingSubjectConstraintTest.php (renamed from tests/phpunit/unit/includes/editpage/Constraint/NewSectionMissingSummaryConstraintTest.php)12
-rw-r--r--tests/phpunit/unit/includes/editpage/Constraint/SpamRegexConstraintTest.php2
3 files changed, 6 insertions, 9 deletions
diff --git a/tests/phpunit/unit/includes/editpage/Constraint/EditConstraintFactoryTest.php b/tests/phpunit/unit/includes/editpage/Constraint/EditConstraintFactoryTest.php
index d53aee0fbf39..b0e258a01893 100644
--- a/tests/phpunit/unit/includes/editpage/Constraint/EditConstraintFactoryTest.php
+++ b/tests/phpunit/unit/includes/editpage/Constraint/EditConstraintFactoryTest.php
@@ -92,7 +92,6 @@ class EditConstraintFactoryTest extends MediaWikiUnitTestCase {
SpamRegexConstraint::class,
$factory->newSpamRegexConstraint(
'EditSummary',
- 'new',
'SectionHeading',
'Text',
'RequestIP',
diff --git a/tests/phpunit/unit/includes/editpage/Constraint/NewSectionMissingSummaryConstraintTest.php b/tests/phpunit/unit/includes/editpage/Constraint/NewSectionMissingSubjectConstraintTest.php
index f26b0ee1e0db..ee2082abf19e 100644
--- a/tests/phpunit/unit/includes/editpage/Constraint/NewSectionMissingSummaryConstraintTest.php
+++ b/tests/phpunit/unit/includes/editpage/Constraint/NewSectionMissingSubjectConstraintTest.php
@@ -19,25 +19,25 @@
*/
use MediaWiki\EditPage\Constraint\IEditConstraint;
-use MediaWiki\EditPage\Constraint\NewSectionMissingSummaryConstraint;
+use MediaWiki\EditPage\Constraint\NewSectionMissingSubjectConstraint;
/**
- * Tests the NewSectionMissingSummaryConstraint
+ * Tests the NewSectionMissingSubjectConstraint
*
* @author DannyS712
*
- * @covers \MediaWiki\EditPage\Constraint\NewSectionMissingSummaryConstraint
+ * @covers \MediaWiki\EditPage\Constraint\NewSectionMissingSubjectConstraint
*/
-class NewSectionMissingSummaryConstraintTest extends MediaWikiUnitTestCase {
+class NewSectionMissingSubjectConstraintTest extends MediaWikiUnitTestCase {
use EditConstraintTestTrait;
public function testPass() {
- $constraint = new NewSectionMissingSummaryConstraint( 'Summary', false );
+ $constraint = new NewSectionMissingSubjectConstraint( 'Subject', false );
$this->assertConstraintPassed( $constraint );
}
public function testFailure() {
- $constraint = new NewSectionMissingSummaryConstraint( '', false );
+ $constraint = new NewSectionMissingSubjectConstraint( '', false );
$this->assertConstraintFailed( $constraint, IEditConstraint::AS_SUMMARY_NEEDED );
}
diff --git a/tests/phpunit/unit/includes/editpage/Constraint/SpamRegexConstraintTest.php b/tests/phpunit/unit/includes/editpage/Constraint/SpamRegexConstraintTest.php
index ce39e9869490..b6b3d559624c 100644
--- a/tests/phpunit/unit/includes/editpage/Constraint/SpamRegexConstraintTest.php
+++ b/tests/phpunit/unit/includes/editpage/Constraint/SpamRegexConstraintTest.php
@@ -62,7 +62,6 @@ class SpamRegexConstraintTest extends MediaWikiUnitTestCase {
$logger,
$spamChecker,
$summary,
- 'new',
$sectionHeading,
$text,
'Request-IP',
@@ -95,7 +94,6 @@ class SpamRegexConstraintTest extends MediaWikiUnitTestCase {
$logger,
$spamChecker,
$summary,
- '',
$sectionHeading,
$text,
'Request-IP',