mediawiki-extensions-Echo/tests/phpunit/HooksTest.php
David Barratt 6593a0a427 Prevent loading or saving of zeros in the database.
When intval() fails, the function returns a zero. We should remove
the failures from the blacklist.

Bug: T178512
Change-Id: I89ad680a287da16c2fbd6aa4d53a725142429144
2017-11-17 12:34:54 -05:00

34 lines
717 B
PHP

<?php
class EchoHooksTest extends MediaWikiTestCase {
/**
* Test the UserSaveOptions hook implementation.
*/
public function testOnUserSaveOptions() {
$options['echo-notifications-blacklist'] = [
'',
'0',
'abcdef',
'12345',
'54321',
];
EchoHooks::onUserSaveOptions( new User(), $options );
$this->assertSame( "12345\n54321", $options['echo-notifications-blacklist'] );
}
/**
* Test the UserLoadOptions hook implementation.
*/
public function testOnUserLoadOptions() {
$options['echo-notifications-blacklist'] = "12345\n54321";
EchoHooks::onUserLoadOptions( new User(), $options );
$this->assertSame( [ 12345, 54321 ], $options['echo-notifications-blacklist'] );
}
}