diff options
author | DannyS712 <DannyS712.enwiki@gmail.com> | 2020-12-01 23:05:06 +0000 |
---|---|---|
committer | DannyS712 <DannyS712.enwiki@gmail.com> | 2020-12-01 23:08:47 +0000 |
commit | f75f3c75ead98bf1578ef8fcde3d6e68b2522e01 (patch) | |
tree | 4d1e545e9970a5ba94e1cc4d814faa431a3b697f /tests/phpunit/unit/includes/editpage | |
parent | c02ba2a6d047fdfb9bbd5f2e2fadc991567419fa (diff) | |
download | mediawikicore-f75f3c75ead98bf1578ef8fcde3d6e68b2522e01.tar.gz mediawikicore-f75f3c75ead98bf1578ef8fcde3d6e68b2522e01.zip |
UserRateLimitConstraint: move detection of content model change to constraint
A step towards a more common interface between the different
constraints, detect whether the content model changes within the
UserRateLimitConstraint rather than relying on EditPage to inject
the answer
Bug: T157658
Change-Id: Ifa35cbabe74df458784a10b3d2815a1e8e7dcdf8
Diffstat (limited to 'tests/phpunit/unit/includes/editpage')
-rw-r--r-- | tests/phpunit/unit/includes/editpage/Constraint/UserRateLimitConstraintTest.php | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/tests/phpunit/unit/includes/editpage/Constraint/UserRateLimitConstraintTest.php b/tests/phpunit/unit/includes/editpage/Constraint/UserRateLimitConstraintTest.php index 8106289cad4d..5c92ecfe9f29 100644 --- a/tests/phpunit/unit/includes/editpage/Constraint/UserRateLimitConstraintTest.php +++ b/tests/phpunit/unit/includes/editpage/Constraint/UserRateLimitConstraintTest.php @@ -62,8 +62,12 @@ class UserRateLimitConstraintTest extends MediaWikiUnitTestCase { ) ); - // true = also check for rate limit of editing content model - $constraint = new UserRateLimitConstraint( $user, true ); + $title = $this->createMock( Title::class ); + $title->expects( $this->once() ) + ->method( 'getContentModel' ) + ->willReturn( 'OldContentModel' ); + + $constraint = new UserRateLimitConstraint( $user, $title, 'NewContentModel' ); $this->assertConstraintPassed( $constraint ); } @@ -98,8 +102,12 @@ class UserRateLimitConstraintTest extends MediaWikiUnitTestCase { ) ); - // true = also check for rate limit of editing content model - $constraint = new UserRateLimitConstraint( $user, true ); + $title = $this->createMock( Title::class ); + $title->expects( $this->once() ) + ->method( 'getContentModel' ) + ->willReturn( 'OldContentModel' ); + + $constraint = new UserRateLimitConstraint( $user, $title, 'NewContentModel' ); $this->assertConstraintFailed( $constraint, IEditConstraint::AS_RATE_LIMITED ); } |