summaryrefslogtreecommitdiff
path: root/www/wiki/extensions/SemanticMediaWiki/tests/phpunit/Unit/MediaWiki/Specials/Ask/HtmlFormTest.php
diff options
context:
space:
mode:
Diffstat (limited to 'www/wiki/extensions/SemanticMediaWiki/tests/phpunit/Unit/MediaWiki/Specials/Ask/HtmlFormTest.php')
-rw-r--r--www/wiki/extensions/SemanticMediaWiki/tests/phpunit/Unit/MediaWiki/Specials/Ask/HtmlFormTest.php72
1 files changed, 72 insertions, 0 deletions
diff --git a/www/wiki/extensions/SemanticMediaWiki/tests/phpunit/Unit/MediaWiki/Specials/Ask/HtmlFormTest.php b/www/wiki/extensions/SemanticMediaWiki/tests/phpunit/Unit/MediaWiki/Specials/Ask/HtmlFormTest.php
new file mode 100644
index 00000000..eaa85204
--- /dev/null
+++ b/www/wiki/extensions/SemanticMediaWiki/tests/phpunit/Unit/MediaWiki/Specials/Ask/HtmlFormTest.php
@@ -0,0 +1,72 @@
+<?php
+
+namespace SMW\Tests\MediaWiki\Specials\Ask;
+
+use SMW\MediaWiki\Specials\Ask\HtmlForm;
+use SMW\Tests\TestEnvironment;
+
+/**
+ * @covers \SMW\MediaWiki\Specials\Ask\HtmlForm
+ * @group semantic-mediawiki
+ *
+ * @license GNU GPL v2+
+ * @since 3.0
+ *
+ * @author mwjames
+ */
+class HtmlFormTest extends \PHPUnit_Framework_TestCase {
+
+ public function testCanConstruct() {
+
+ $title = $this->getMockBuilder( '\Title' )
+ ->disableOriginalConstructor()
+ ->getMock();
+
+ $this->assertInstanceOf(
+ HtmlForm::class,
+ new HtmlForm( $title )
+ );
+ }
+
+ public function testGetForm_IsEditMode() {
+
+ $title = $this->getMockBuilder( '\Title' )
+ ->disableOriginalConstructor()
+ ->getMock();
+
+ $urlArgs = $this->getMockBuilder( '\SMW\MediaWiki\Specials\Ask\UrlArgs' )
+ ->disableOriginalConstructor()
+ ->getMock();
+
+ $query = $this->getMockBuilder( '\SMWQuery' )
+ ->disableOriginalConstructor()
+ ->getMock();
+
+ $query->expects( $this->once() )
+ ->method( 'getExtraPrintouts' )
+ ->will( $this->returnValue( [] ) );
+
+ $query->expects( $this->once() )
+ ->method( 'getSortKeys' )
+ ->will( $this->returnValue( [] ) );
+
+ $queryResult = $this->getMockBuilder( '\SMWQueryResult' )
+ ->disableOriginalConstructor()
+ ->getMock();
+
+ $queryResult->expects( $this->atLeastOnce() )
+ ->method( 'getQuery' )
+ ->will( $this->returnValue( $query ) );
+
+ $instance = new HtmlForm( $title );
+ $instance->isEditMode( true );
+
+ $text = '';
+
+ $this->assertInternalType(
+ 'string',
+ $instance->getForm( $urlArgs, $queryResult, $text )
+ );
+ }
+
+}