diff options
Diffstat (limited to 'www/wiki/tests/phpunit/includes/installer')
-rw-r--r-- | www/wiki/tests/phpunit/includes/installer/InstallDocFormatterTest.php | 83 | ||||
-rw-r--r-- | www/wiki/tests/phpunit/includes/installer/OracleInstallerTest.php | 51 |
2 files changed, 134 insertions, 0 deletions
diff --git a/www/wiki/tests/phpunit/includes/installer/InstallDocFormatterTest.php b/www/wiki/tests/phpunit/includes/installer/InstallDocFormatterTest.php new file mode 100644 index 00000000..9584d4b8 --- /dev/null +++ b/www/wiki/tests/phpunit/includes/installer/InstallDocFormatterTest.php @@ -0,0 +1,83 @@ +<?php + +class InstallDocFormatterTest extends MediaWikiTestCase { + /** + * @covers InstallDocFormatter + * @dataProvider provideDocFormattingTests + */ + public function testFormat( $expected, $unformattedText, $message = '' ) { + $this->assertEquals( + $expected, + InstallDocFormatter::format( $unformattedText ), + $message + ); + } + + /** + * Provider for testFormat() + */ + public static function provideDocFormattingTests() { + # Format: (expected string, unformattedText string, optional message) + return [ + # Escape some wikitext + [ 'Install <tag>', 'Install <tag>', 'Escaping <' ], + [ 'Install {{template}}', 'Install {{template}}', 'Escaping [[' ], + [ 'Install [[page]]', 'Install [[page]]', 'Escaping {{' ], + [ 'Install __TOC__', 'Install __TOC__', 'Escaping __' ], + [ 'Install ', "Install \r", 'Removing \r' ], + + # Transform \t{1,2} into :{1,2} + [ ':One indentation', "\tOne indentation", 'Replacing a single \t' ], + [ '::Two indentations', "\t\tTwo indentations", 'Replacing 2 x \t' ], + + # Transform 'T123' links + [ + '<span class="config-plainlink">[https://phabricator.wikimedia.org/T123 T123]</span>', + 'T123', 'Testing T123 links' ], + [ + 'bug <span class="config-plainlink">[https://phabricator.wikimedia.org/T123 T123]</span>', + 'bug T123', 'Testing bug T123 links' ], + [ + '(<span class="config-plainlink">[https://phabricator.wikimedia.org/T987654 T987654]</span>)', + '(T987654)', 'Testing (T987654) links' ], + + # "Tabc" shouldn't work + [ 'Tfoobar', 'Tfoobar', "Don't match T followed by non-digits" ], + [ 'T!!fakefake!!', 'T!!fakefake!!', "Don't match T followed by non-digits" ], + + # Transform 'bug 123' links + [ + '<span class="config-plainlink">[https://bugzilla.wikimedia.org/123 bug 123]</span>', + 'bug 123', 'Testing bug 123 links' ], + [ + '(<span class="config-plainlink">[https://bugzilla.wikimedia.org/987654 bug 987654]</span>)', + '(bug 987654)', 'Testing (bug 987654) links' ], + + # "bug abc" shouldn't work + [ 'bug foobar', 'bug foobar', "Don't match bug followed by non-digits" ], + [ 'bug !!fakefake!!', 'bug !!fakefake!!', "Don't match bug followed by non-digits" ], + + # Transform '$wgFooBar' links + [ + '<span class="config-plainlink">' + . '[https://www.mediawiki.org/wiki/Manual:$wgFooBar $wgFooBar]</span>', + '$wgFooBar', 'Testing basic $wgFooBar' ], + [ + '<span class="config-plainlink">' + . '[https://www.mediawiki.org/wiki/Manual:$wgFooBar45 $wgFooBar45]</span>', + '$wgFooBar45', 'Testing $wgFooBar45 (with numbers)' ], + [ + '<span class="config-plainlink">' + . '[https://www.mediawiki.org/wiki/Manual:$wgFoo_Bar $wgFoo_Bar]</span>', + '$wgFoo_Bar', 'Testing $wgFoo_Bar (with underscore)' ], + + # Icky variables that shouldn't link + [ + '$myAwesomeVariable', + '$myAwesomeVariable', + 'Testing $myAwesomeVariable (not starting with $wg)' + ], + [ '$()not!a&Var', '$()not!a&Var', 'Testing $()not!a&Var (obviously not a variable)' ], + ]; + } +} diff --git a/www/wiki/tests/phpunit/includes/installer/OracleInstallerTest.php b/www/wiki/tests/phpunit/includes/installer/OracleInstallerTest.php new file mode 100644 index 00000000..2811a9cf --- /dev/null +++ b/www/wiki/tests/phpunit/includes/installer/OracleInstallerTest.php @@ -0,0 +1,51 @@ +<?php + +/** + * Tests for OracleInstaller + * + * @group Database + * @group Installer + */ +class OracleInstallerTest extends MediaWikiTestCase { + + /** + * @dataProvider provideOracleConnectStrings + * @covers OracleInstaller::checkConnectStringFormat + */ + public function testCheckConnectStringFormat( $expected, $connectString, $msg = '' ) { + $validity = $expected ? 'should be valid' : 'should NOT be valid'; + $msg = "'$connectString' ($msg) $validity."; + $this->assertEquals( $expected, + OracleInstaller::checkConnectStringFormat( $connectString ), + $msg + ); + } + + /** + * Provider to test OracleInstaller::checkConnectStringFormat() + */ + function provideOracleConnectStrings() { + // expected result, connectString[, message] + return [ + [ true, 'simple_01', 'Simple TNS name' ], + [ true, 'simple_01.world', 'TNS name with domain' ], + [ true, 'simple_01.domain.net', 'TNS name with domain' ], + [ true, 'host123', 'Host only' ], + [ true, 'host123.domain.net', 'FQDN only' ], + [ true, '//host123.domain.net', 'FQDN URL only' ], + [ true, '123.223.213.132', 'Host IP only' ], + [ true, 'host:1521', 'Host and port' ], + [ true, 'host:1521/service', 'Host, port and service' ], + [ true, 'host:1521/service:shared', 'Host, port, service and shared server type' ], + [ true, 'host:1521/service:dedicated', 'Host, port, service and dedicated server type' ], + [ true, 'host:1521/service:pooled', 'Host, port, service and pooled server type' ], + [ + true, + 'host:1521/service:shared/instance1', + 'Host, port, service, server type and instance' + ], + [ true, 'host:1521//instance1', 'Host, port and instance' ], + ]; + } + +} |