From c248bda1dcbef2068071904057b8410aa1eb0200 Mon Sep 17 00:00:00 2001 From: Christopher Smith Date: Sat, 16 May 2015 17:40:33 +0200 Subject: fix missing language code parameter for admin plugin titles add unit test coverage --- _test/tests/inc/template_include_page.test.php | 77 +++++++++++++++++--------- inc/template.php | 4 +- 2 files changed, 54 insertions(+), 27 deletions(-) diff --git a/_test/tests/inc/template_include_page.test.php b/_test/tests/inc/template_include_page.test.php index 47d4d46f1..580221979 100644 --- a/_test/tests/inc/template_include_page.test.php +++ b/_test/tests/inc/template_include_page.test.php @@ -1,40 +1,67 @@ assertEquals('', $sidebar); + function test_localID() { + global $ID,$ACT; + + + $id = 'foo:bar'; + + $ACT = 'show'; + $this->assertEquals('foo:bar', tpl_pagetitle($id, true)); } - function testExistingSidebars() { - global $ID; + function test_globalID() { + global $ID,$ACT; + - saveWikiText('sidebar', 'topsidebar-test', ''); + $ID = 'foo:bar'; - $ID = 'foo:bar:baz:test'; - $sidebar = tpl_include_page('sidebar', false, true); - $this->assertTrue(strpos($sidebar, 'topsidebar-test') > 0); + $ACT = 'show'; + $this->assertEquals('foo:bar', tpl_pagetitle(null, true)); + } + + function test_adminTitle() { + global $ID,$ACT; - $ID = 'foo'; - $sidebar = tpl_include_page('sidebar', false, true); - $this->assertTrue(strpos($sidebar, 'topsidebar-test') > 0); + $ID = 'foo:bar'; + + $ACT = 'admin'; + $this->assertEquals('Admin', tpl_pagetitle(null, true)); + } - saveWikiText('foo:bar:sidebar', 'bottomsidebar-test', ''); + function test_adminPluginTitle() { + global $ID,$ACT,$INPUT,$conf; - $ID = 'foo:bar:baz:test'; - $sidebar = tpl_include_page('sidebar', false, true); - $this->assertTrue(strpos($sidebar, 'bottomsidebar-test') > 0); + if (!plugin_load('admin','config')) { + $this->markTestSkipped('Plugin Config not found, unable to test admin plugin titles'); + return; + } - $ID = 'foo:bar:test'; - $sidebar = tpl_include_page('sidebar', false, true); - $this->assertTrue(strpos($sidebar, 'bottomsidebar-test') > 0); + $ID = 'foo:bar'; + $ACT = 'admin'; + $conf['lang'] = 'en'; + $INPUT->set('page','config'); - $ID = 'foo'; - $sidebar = tpl_include_page('sidebar', false, true); - $this->assertTrue(strpos($sidebar, 'topsidebar-test') > 0); + $this->assertEquals('Configuration Settings', tpl_pagetitle(null, true)); } + function test_nonPageFunctionTitle() { + global $ID,$ACT; + + $ID = 'foo:bar'; + + $ACT = 'index'; + $this->assertEquals('Sitemap', tpl_pagetitle(null, true)); + } + + function test_pageFunctionTitle() { + global $ID,$ACT; + + $ID = 'foo:bar'; + + $ACT = 'revisions'; + $this->assertEquals('foo:bar - Old revisions', tpl_pagetitle(null, true)); + } } diff --git a/inc/template.php b/inc/template.php index fd8bff11a..39d06e895 100644 --- a/inc/template.php +++ b/inc/template.php @@ -1035,7 +1035,7 @@ function tpl_pageinfo($ret = false) { * @return bool|string */ function tpl_pagetitle($id = null, $ret = false) { - global $ACT, $INPUT, $lang; + global $ACT, $INPUT, $conf, $lang; if(is_null($id)) { global $ID; @@ -1061,7 +1061,7 @@ function tpl_pagetitle($id = null, $ret = false) { // attempt to load the plugin if (($plugin = plugin_load('admin',$page)) !== null){ - $plugin_title = $plugin->getMenuText(); + $plugin_title = $plugin->getMenuText($conf['lang']); $page_title = $plugin_title ? $plugin_title : $page; } } -- cgit v1.2.3