summaryrefslogtreecommitdiff
path: root/www/wiki/extensions/SemanticMediaWiki/tests/phpunit/Unit/MediaWiki/Hooks/SpecialSearchResultsPrependTest.php
diff options
context:
space:
mode:
Diffstat (limited to 'www/wiki/extensions/SemanticMediaWiki/tests/phpunit/Unit/MediaWiki/Hooks/SpecialSearchResultsPrependTest.php')
-rw-r--r--www/wiki/extensions/SemanticMediaWiki/tests/phpunit/Unit/MediaWiki/Hooks/SpecialSearchResultsPrependTest.php116
1 files changed, 116 insertions, 0 deletions
diff --git a/www/wiki/extensions/SemanticMediaWiki/tests/phpunit/Unit/MediaWiki/Hooks/SpecialSearchResultsPrependTest.php b/www/wiki/extensions/SemanticMediaWiki/tests/phpunit/Unit/MediaWiki/Hooks/SpecialSearchResultsPrependTest.php
new file mode 100644
index 00000000..fa7d4aa3
--- /dev/null
+++ b/www/wiki/extensions/SemanticMediaWiki/tests/phpunit/Unit/MediaWiki/Hooks/SpecialSearchResultsPrependTest.php
@@ -0,0 +1,116 @@
+<?php
+
+namespace SMW\Tests\MediaWiki\Hooks;
+
+use SMW\MediaWiki\Hooks\SpecialSearchResultsPrepend;
+
+/**
+ * @covers \SMW\MediaWiki\Hooks\SpecialSearchResultsPrepend
+ * @group semantic-mediawiki
+ *
+ * @license GNU GPL v2+
+ * @since 3.0
+ *
+ * @author mwjames
+ */
+class SpecialSearchResultsPrependTest extends \PHPUnit_Framework_TestCase {
+
+ public function testCanConstruct() {
+
+ $specialSearch = $this->getMockBuilder( '\SpecialSearch' )
+ ->disableOriginalConstructor()
+ ->getMock();
+
+ $outputPage = $this->getMockBuilder( '\OutputPage' )
+ ->disableOriginalConstructor()
+ ->getMock();
+
+ $this->assertInstanceOf(
+ SpecialSearchResultsPrepend::class,
+ new SpecialSearchResultsPrepend( $specialSearch, $outputPage )
+ );
+ }
+
+ public function testProcess() {
+
+ $search = $this->getMockBuilder( '\SMWSearch' )
+ ->disableOriginalConstructor()
+ ->getMock();
+
+ $user = $this->getMockBuilder( '\User' )
+ ->disableOriginalConstructor()
+ ->getMock();
+
+ $specialSearch = $this->getMockBuilder( '\SpecialSearch' )
+ ->disableOriginalConstructor()
+ ->getMock();
+
+ $specialSearch->expects( $this->atLeastOnce() )
+ ->method( 'getSearchEngine' )
+ ->will( $this->returnValue( $search ) );
+
+ $outputPage = $this->getMockBuilder( '\OutputPage' )
+ ->disableOriginalConstructor()
+ ->getMock();
+
+ $outputPage->expects( $this->atLeastOnce() )
+ ->method( 'addHtml' );
+
+ $instance = new SpecialSearchResultsPrepend(
+ $specialSearch,
+ $outputPage
+ );
+
+ $instance->setOptions(
+ [
+ 'prefs-suggester-textinput' => true,
+ 'prefs-disable-search-info' => null
+ ]
+ );
+
+ $this->assertTrue(
+ $instance->process( '' )
+ );
+ }
+
+ public function testProcess_DisabledInfo() {
+
+ $search = $this->getMockBuilder( '\SMWSearch' )
+ ->disableOriginalConstructor()
+ ->getMock();
+
+ $user = $this->getMockBuilder( '\User' )
+ ->disableOriginalConstructor()
+ ->getMock();
+
+ $specialSearch = $this->getMockBuilder( '\SpecialSearch' )
+ ->disableOriginalConstructor()
+ ->getMock();
+
+ $specialSearch->expects( $this->atLeastOnce() )
+ ->method( 'getSearchEngine' )
+ ->will( $this->returnValue( $search ) );
+
+ $outputPage = $this->getMockBuilder( '\OutputPage' )
+ ->disableOriginalConstructor()
+ ->getMock();
+
+ $outputPage->expects( $this->never() )
+ ->method( 'addHtml' );
+
+ $instance = new SpecialSearchResultsPrepend(
+ $specialSearch,
+ $outputPage
+ );
+
+ $instance->setOptions(
+ [
+ 'prefs-suggester-textinput' => true,
+ 'prefs-disable-search-info' => true
+ ]
+ );
+
+ $instance->process( '' );
+ }
+
+}