summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'SemanticMediaWiki/tests/phpunit/includes/MediaWiki/Hooks/BeforePageDisplayTest.php')
-rw-r--r--SemanticMediaWiki/tests/phpunit/includes/MediaWiki/Hooks/BeforePageDisplayTest.php134
1 files changed, 0 insertions, 134 deletions
diff --git a/SemanticMediaWiki/tests/phpunit/includes/MediaWiki/Hooks/BeforePageDisplayTest.php b/SemanticMediaWiki/tests/phpunit/includes/MediaWiki/Hooks/BeforePageDisplayTest.php
deleted file mode 100644
index 75acd18c..00000000
--- a/SemanticMediaWiki/tests/phpunit/includes/MediaWiki/Hooks/BeforePageDisplayTest.php
+++ /dev/null
@@ -1,134 +0,0 @@
-<?php
-
-namespace SMW\Tests\MediaWiki\Hooks;
-
-use SMW\Tests\Util\Mock\MockTitle;
-
-use SMW\MediaWiki\Hooks\BeforePageDisplay;
-
-use OutputPage;
-use Language;
-
-/**
- * @covers \SMW\MediaWiki\Hooks\BeforePageDisplay
- *
- * @ingroup Test
- *
- * @group SMW
- * @group SMWExtension
- *
- * @license GNU GPL v2+
- * @since 1.9
- *
- * @author mwjames
- */
-class BeforePageDisplayTest extends \PHPUnit_Framework_TestCase {
-
- public function testCanConstruct() {
-
- $outputPage = $this->getMockBuilder( '\OutputPage' )
- ->disableOriginalConstructor()
- ->getMock();
-
- $skin = $this->getMockBuilder( '\Skin' )
- ->disableOriginalConstructor()
- ->getMock();
-
- $this->assertInstanceOf(
- '\SMW\MediaWiki\Hooks\BeforePageDisplay',
- new BeforePageDisplay( $outputPage, $skin )
- );
- }
-
- /**
- * @dataProvider titleDataProvider
- */
- public function testProcess( $setup, $expected ) {
-
- $skin = $this->getMockBuilder( '\Skin' )
- ->disableOriginalConstructor()
- ->getMock();
-
- $context = new \RequestContext();
- $context->setTitle( $setup['title'] );
- $context->setLanguage( Language::factory( 'en' ) );
-
- $outputPage = new OutputPage( $context );
-
- $instance = new BeforePageDisplay( $outputPage, $skin );
- $result = $instance->process();
-
- $this->assertInternalType( 'boolean', $result );
- $this->assertTrue( $result );
-
- $contains = false;
-
- if ( method_exists( $outputPage, 'getHeadLinksArray' ) ) {
- foreach ( $outputPage->getHeadLinksArray() as $key => $value ) {
- if ( strpos( $value, 'ExportRDF' ) ){
- $contains = true;
- break;
- };
- }
- } else{
- // MW 1.19
- if ( strpos( $outputPage->getHeadLinks(), 'ExportRDF' ) ){
- $contains = true;
- };
- }
-
- $expected['result'] ? $this->assertTrue( $contains ) : $this->assertFalse( $contains );
- }
-
- public function titleDataProvider() {
-
- $language = Language::factory( 'en' );
-
- #0 Standard title
- $title = MockTitle::buildMockForMainNamespace();
-
- $title->expects( $this->atLeastOnce() )
- ->method( 'getPrefixedText' )
- ->will( $this->returnValue( 'Foo' ) );
-
- $title->expects( $this->atLeastOnce() )
- ->method( 'isSpecialPage' )
- ->will( $this->returnValue( false ) );
-
- $title->expects( $this->atLeastOnce() )
- ->method( 'getPageLanguage' )
- ->will( $this->returnValue( $language ) );
-
- $provider[] = array(
- array(
- 'title' => $title
- ),
- array(
- 'result' => true
- )
- );
-
- #1 as SpecialPage
- $title = MockTitle::buildMock();
-
- $title->expects( $this->atLeastOnce() )
- ->method( 'isSpecialPage' )
- ->will( $this->returnValue( true ) );
-
- $title->expects( $this->atLeastOnce() )
- ->method( 'getPageLanguage' )
- ->will( $this->returnValue( $language ) );
-
- $provider[] = array(
- array(
- 'title' => $title
- ),
- array(
- 'result' => false
- )
- );
-
- return $provider;
- }
-
-}