| 1 |
<?php |
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
use MediaWiki\EditPage\Constraint\IEditConstraint; |
| 22 |
use MediaWiki\EditPage\Constraint\PageSizeConstraint; |
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
class PageSizeConstraintTest extends MediaWikiUnitTestCase { |
| 32 |
use EditConstraintTestTrait; |
| 33 |
|
| 34 |
|
| 35 |
|
| 36 |
|
| 37 |
public function testPass( string $type, int $errorCode ) { |
| 38 |
|
| 39 |
$constraint = new PageSizeConstraint( |
| 40 |
1, |
| 41 |
1023, |
| 42 |
$type |
| 43 |
); |
| 44 |
$this->assertConstraintPassed( $constraint ); |
| 45 |
} |
| 46 |
|
| 47 |
|
| 48 |
|
| 49 |
|
| 50 |
public function testFailure( string $type, int $errorCode ) { |
| 51 |
|
| 52 |
$constraint = new PageSizeConstraint( |
| 53 |
1, |
| 54 |
1025, |
| 55 |
$type |
| 56 |
); |
| 57 |
$this->assertConstraintFailed( $constraint, $errorCode ); |
| 58 |
} |
| 59 |
|
| 60 |
public static function provideCodes() { |
| 61 |
return [ |
| 62 |
'Before merge - CONTENT_TOO_BIG' => [ |
| 63 |
PageSizeConstraint::BEFORE_MERGE, |
| 64 |
IEditConstraint::AS_CONTENT_TOO_BIG |
| 65 |
], |
| 66 |
'After merge - MAX_ARTICLE_SIZE' => [ |
| 67 |
PageSizeConstraint::AFTER_MERGE, |
| 68 |
IEditConstraint::AS_MAX_ARTICLE_SIZE_EXCEEDED |
| 69 |
] |
| 70 |
]; |
| 71 |
} |
| 72 |
|
| 73 |
public function testInvalidType() { |
| 74 |
$this->expectException( InvalidArgumentException::class ); |
| 75 |
new PageSizeConstraint( 1, 1023, 'FooBar' ); |
| 76 |
} |
| 77 |
|
| 78 |
} |