Skip to content

Commit

Permalink
Append subtitle but hide MW's subpages, refs 46 (#49)
Browse files Browse the repository at this point in the history
  • Loading branch information
mwjames committed Sep 15, 2018
1 parent 9ea3f5f commit 9366d22
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 37 deletions.
4 changes: 4 additions & 0 deletions res/sbl.styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,10 @@
margin: 0.9em 0 1.4em -1em;
}

#contentSub span.subpages {
display: none;
}

/* SBL chameleon */
.skin-chameleon .sbl-breadcrumb-children-list {
margin: .1em 0 0 -1.5em;
Expand Down
2 changes: 1 addition & 1 deletion src/SkinTemplateOutputModifier.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public function modify( OutputPage $output, &$template ) {

// We always assume `subtitle` is available!
// https://github.com/wikimedia/mediawiki/blob/23ea2e4c2966f381eb7fd69b66a8d738bb24cc60/includes/skins/SkinTemplate.php#L292-L296
$template->data['subtitle'] = $this->htmlBreadcrumbLinksBuilder->getHtml();
$template->data['subtitle'] .= $this->htmlBreadcrumbLinksBuilder->getHtml();
}

private function canModifyOutput( OutputPage $output ) {
Expand Down
50 changes: 14 additions & 36 deletions tests/phpunit/Unit/SkinTemplateOutputModifierTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,6 @@ public function testTryPrependHtmlOnSpecialPage() {
->disableOriginalConstructor()
->getMock();

$output->expects( $this->never() )
->method( 'prependHTML' );

$output->expects( $this->atLeastOnce() )
->method( 'getTitle' )
->will( $this->returnValue( $title ) );
Expand All @@ -120,10 +117,6 @@ public function testTryPrependHtmlOnSpecialPage() {

public function PrependHtmlOnNonViewAction() {

$context = new \RequestContext();
$context->setRequest( new \FauxRequest( [ 'action' => 'edit' ], true ) );
$context->setTitle( Title::newFromText( __METHOD__ ) );

$htmlBreadcrumbLinksBuilder = $this->getMockBuilder( '\SBL\HtmlBreadcrumbLinksBuilder' )
->disableOriginalConstructor()
->getMock();
Expand All @@ -148,13 +141,6 @@ public function PrependHtmlOnNonViewAction() {
->disableOriginalConstructor()
->getMock();

$output->expects( $this->never() )
->method( 'prependHTML' );

$output->expects( $this->once() )
->method( 'getContext' )
->will( $this->returnValue( $context ) );

$output->expects( $this->atLeastOnce() )
->method( 'getTitle' )
->will( $this->returnValue( $title ) );
Expand All @@ -172,9 +158,6 @@ public function PrependHtmlOnNonViewAction() {

public function testTryPrependHtmlOnNOBREADCRUMBLINKS() {

$context = new \RequestContext();
$context->setRequest( new \FauxRequest( [ 'action' => 'view' ], true ) );

$htmlBreadcrumbLinksBuilder = $this->getMockBuilder( '\SBL\HtmlBreadcrumbLinksBuilder' )
->disableOriginalConstructor()
->getMock();
Expand All @@ -199,13 +182,6 @@ public function testTryPrependHtmlOnNOBREADCRUMBLINKS() {
->disableOriginalConstructor()
->getMock();

$output->expects( $this->never() )
->method( 'prependHTML' );

$output->expects( $this->any() )
->method( 'getContext' )
->will( $this->returnValue( $context ) );

$output->expects( $this->atLeastOnce() )
->method( 'getTitle' )
->will( $this->returnValue( $title ) );
Expand All @@ -223,10 +199,11 @@ public function testTryPrependHtmlOnNOBREADCRUMBLINKS() {
$instance->modify( $output, $template );
}

public function tesPrependHtmlForViewActionOnly() {
public function testAppendHtml() {

$context = new \RequestContext();
$context->setRequest( new \FauxRequest( [ 'action' => 'view' ], true ) );
$this->namespaceExaminer->expects( $this->once() )
->method( 'isSemanticEnabled' )
->will( $this->returnValue( true ) );

$htmlBreadcrumbLinksBuilder = $this->getMockBuilder( '\SBL\HtmlBreadcrumbLinksBuilder' )
->disableOriginalConstructor()
Expand All @@ -236,6 +213,10 @@ public function tesPrependHtmlForViewActionOnly() {
->method( 'buildBreadcrumbs' )
->will( $this->returnSelf() );

$htmlBreadcrumbLinksBuilder->expects( $this->once() )
->method( 'getHtml' )
->will( $this->returnValue( 'bar' ) );

$language = $this->getMockBuilder( '\Language' )
->disableOriginalConstructor()
->getMock();
Expand Down Expand Up @@ -264,13 +245,6 @@ public function tesPrependHtmlForViewActionOnly() {
->disableOriginalConstructor()
->getMock();

$output->expects( $this->once() )
->method( 'prependHTML' );

$output->expects( $this->once() )
->method( 'getContext' )
->will( $this->returnValue( $context ) );

$output->expects( $this->atLeastOnce() )
->method( 'getTitle' )
->will( $this->returnValue( $title ) );
Expand All @@ -281,11 +255,15 @@ public function tesPrependHtmlForViewActionOnly() {
);

$template = new \stdClass;
$template->data = [];

$template->data = [
'subtitle' => 'Foo'
];

$instance->modify( $output, $template );

$this->assertEmpty(
$this->assertEquals(
'Foobar',
$template->data['subtitle']
);
}
Expand Down

0 comments on commit 9366d22

Please sign in to comment.