jenkins-bot has submitted this change and it was merged. Change subject: Test for $wgTimelineFontFile values ......................................................................
Test for $wgTimelineFontFile values Parse wmf-config/timeline.php for potential values given to $wgTimelineFontFile. The file must not end up with '.ttf' which is stripped by ploticus and would cause it to fail finding the file. We have GDFONTPATH pointing to /fonts/ ensure the given filename exists there. Bug: T22825 Change-Id: I2a79931822e687e9463f7e1a76a39d7134b5157c --- A tests/timelineTest.php 1 file changed, 64 insertions(+), 0 deletions(-) Approvals: Hashar: Looks good to me, approved jenkins-bot: Verified diff --git a/tests/timelineTest.php b/tests/timelineTest.php new file mode 100644 index 0000000..f1eb261 --- /dev/null +++ b/tests/timelineTest.php @@ -0,0 +1,64 @@ +<?php + +class timelineTest extends \PHPUnit_Framework_TestCase { + + /** + * Ploticus strip the '.ttf' suffix from the font name and then fails + * to find the .ttf font in /fonts/. Make sure we strip the suffix both + * in the config and in the fonts files. T22825. + * + * @dataProvider wgTimelineFontFileValues + */ + function testTimelinefontfile_does_not_have_ttf_suffix( $filename ) { + $this->assertStringEndsNotWith( '.ttf', $filename ); + } + + + /** + * @dataProvider wgTimelineFontFileValues + */ + function testTimelinefontfile_exists( $filename ) { + $this->assertFileExists( __DIR__ . "/../fonts/" . $filename ); + } + + /** + * Parse wmf-config/timeline.php and find values for $wgTimelineFontFile + */ + public static function wgTimelineFontFileValues() { + + $testCases = []; + $conf = file_get_contents( __DIR__ . '/../wmf-config/timeline.php' ); + $tokens = ( token_get_all( $conf ) ); + + while( $token = each( $tokens )[1] ) { + + # Skip until we find $wgTimelineFontFile + if ( !( + is_array( $token ) + && $token[0] == T_VARIABLE + && $token[1] == '$wgTimelineFontFile' + ) ) { + continue; + } + + while ( $next_token = next($tokens) ) { + # Skip ' = ' to reach the actual value being set + if ( + $next_token == '=' + || is_array( $next_token ) && $next_token[0] == T_WHITESPACE ) { + continue; + } + break; + } + self::assertInternalType( 'array', $next_token ); + self::assertEquals( + T_CONSTANT_ENCAPSED_STRING, + $next_token[0], + 'Test suite expects $wgTimelineFontFile to be set to a string' ); + + $testCases[] = [ trim( $next_token[1], '\'' ) ]; + } + return $testCases; + } + +} -- To view, visit https://gerrit.wikimedia.org/r/321558 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: I2a79931822e687e9463f7e1a76a39d7134b5157c Gerrit-PatchSet: 6 Gerrit-Project: operations/mediawiki-config Gerrit-Branch: master Gerrit-Owner: Hashar <has...@free.fr> Gerrit-Reviewer: Hashar <has...@free.fr> Gerrit-Reviewer: jenkins-bot <> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits