13 'wgCaptchaTriggers' => [
14 $action => $expectedResult,
17 $this->assertEquals( $expectedResult, $captcha->triggersCaptcha( $action ) );
22 $captchaTriggers =
new ReflectionClass( CaptchaTriggers::class );
23 $constants = $captchaTriggers->getConstants();
24 foreach ( $constants as $const ) {
25 $data[] = [ $const,
true ];
26 $data[] = [ $const,
false ];
37 'wgCaptchaTriggers' => [
38 $trigger => !$expected,
40 'wgCaptchaTriggersOnNamespace' => [
42 $trigger => $expected,
46 $title = Title::newFromText(
'Main' );
47 $this->assertEquals( $expected, $captcha->triggersCaptcha( $trigger, $title ) );
64 'CaptchaTriggers' => [
68 'autoloaderPaths' => []
71 $class =
new ReflectionClass(
'ExtensionRegistry' );
72 $instanceProperty = $class->getProperty(
'instance' );
73 $instanceProperty->setAccessible(
true );
74 $instanceProperty->setValue( $registry );
75 $method = $class->getMethod(
'exportExtractedData' );
76 $method->setAccessible(
true );
77 $method->invokeArgs( $registry, [ $info ] );
86 $this->assertEquals(
$value, $captcha->triggersCaptcha( $trigger ) );
101 'wgCaptchaTriggers' => [
102 $trigger => $expected
107 $this->assertEquals( $expected, $captcha->triggersCaptcha( $trigger ) );
122 $user = $this->getMock( User::class );
123 $user->method(
'isAllowed' )->willReturn( $userIsAllowed );
125 $actual = $testObject->canSkipCaptcha( $user, RequestContext::getMain()->getConfig() );
127 $this->assertEquals( $expected, $actual );
145 $userIsMailConfirmed, $expected ) {
147 $user = $this->getMock( User::class );
148 $user->method(
'isEmailConfirmed' )->willReturn( $userIsMailConfirmed );
149 $config = $this->getMock( Config::class );
150 $config->method(
'get' )->willReturn( $allowUserConfirmEmail );
152 $actual = $testObject->canSkipCaptcha( $user, $config );
154 $this->assertEquals( $expected, $actual );
159 [
false,
false,
false ],
160 [
false,
true,
false ],
161 [
true,
false,
false ],
162 [
true,
true,
true ],
175 $config = $this->getMock( Config::class );
176 $request = $this->getMock( WebRequest::class );
177 $request->method(
'getIP' )->willReturn( $requestIP );
181 'wgCaptchaWhitelistIP' => $IPWhitelist
184 $actual = $testObject->canSkipCaptcha( RequestContext::getMain()->getUser(), $config );
186 $this->assertEquals( $expected, $actual );
191 [
'127.0.0.1', [
'127.0.0.1',
'127.0.0.2' ],
true ],
192 [
'127.0.0.1', [],
false ]
testNamespaceTriggersOverwrite( $trigger, $expected)
provideNamespaceOverwrites
provideNamespaceOverwrites()
provideCanSkipCaptchaIPWhitelisted()
testCaptchaTriggersAttributeGetsOverwritten( $trigger, $expected)
provideAttributeOverwritten
provideCanSkipCaptchaUserright()
testCanSkipCaptchaUserright( $userIsAllowed, $expected)
provideCanSkipCaptchaUserright
testCanSkipCaptchaMailconfirmed( $allowUserConfirmEmail, $userIsMailConfirmed, $expected)
setCaptchaTriggersAttribute( $trigger, $value)
testTriggersCaptcha( $action, $expectedResult)
provideSimpleTriggersCaptcha
provideAttributeOverwritten()
provideCanSkipCaptchaMailconfirmed()
provideSimpleTriggersCaptcha()
testCanSkipCaptchaIPWhitelisted( $requestIP, $IPWhitelist, $expected)
testCaptchaTriggersAttributeSetTrue( $trigger, $value)
provideAttributeSet
Demo CAPTCHA (not for production usage) and base class for real CAPTCHAs.
do that in ParserLimitReportFormat instead use this to modify the parameters of the image all existing parser cache entries will be invalid To avoid you ll need to handle that somehow(e.g. with the RejectParserCacheValue hook) because MediaWiki won 't do it for you. & $defaults also a ContextSource after deleting those rows but within the same transaction you ll probably need to make sure the header is varied on $request
null means default in associative array with keys and values unescaped Should be merged with default with a value of false meaning to suppress the attribute in associative array with keys and values unescaped noclasses just before the function returns a value If you return true
processing should stop and the error should be shown to the user * false