summaryrefslogtreecommitdiff
path: root/www/wiki/extensions/SemanticMediaWiki/tests/phpunit/Unit/MediaWiki/Specials/SpecialBrowseTest.php
diff options
context:
space:
mode:
Diffstat (limited to 'www/wiki/extensions/SemanticMediaWiki/tests/phpunit/Unit/MediaWiki/Specials/SpecialBrowseTest.php')
-rw-r--r--www/wiki/extensions/SemanticMediaWiki/tests/phpunit/Unit/MediaWiki/Specials/SpecialBrowseTest.php97
1 files changed, 97 insertions, 0 deletions
diff --git a/www/wiki/extensions/SemanticMediaWiki/tests/phpunit/Unit/MediaWiki/Specials/SpecialBrowseTest.php b/www/wiki/extensions/SemanticMediaWiki/tests/phpunit/Unit/MediaWiki/Specials/SpecialBrowseTest.php
new file mode 100644
index 00000000..e12cad78
--- /dev/null
+++ b/www/wiki/extensions/SemanticMediaWiki/tests/phpunit/Unit/MediaWiki/Specials/SpecialBrowseTest.php
@@ -0,0 +1,97 @@
+<?php
+
+namespace SMW\Tests\MediaWiki\Specials;
+
+use SMW\MediaWiki\Specials\SpecialBrowse;
+use SMW\Tests\TestEnvironment;
+use Title;
+
+/**
+ * @covers \SMW\MediaWiki\Specials\SpecialBrowse
+ * @group semantic-mediawiki
+ *
+ * @license GNU GPL v2+
+ * @since 2.1
+ *
+ * @author mwjames
+ */
+class SpecialBrowseTest extends \PHPUnit_Framework_TestCase {
+
+ private $testEnvironment;
+ private $stringValidator;
+
+ protected function setUp() {
+ parent::setUp();
+
+ $this->testEnvironment = new TestEnvironment( [
+ 'smwgBrowseFeatures' => SMW_BROWSE_SHOW_INCOMING | SMW_BROWSE_USE_API
+ ] );
+
+ $store = $this->getMockBuilder( '\SMW\Store' )
+ ->disableOriginalConstructor()
+ ->getMockForAbstractClass();
+
+ $this->testEnvironment->registerObject( 'Store', $store );
+ $this->stringValidator = $this->testEnvironment->getUtilityFactory()->newValidatorFactory()->newStringValidator();
+ }
+
+ protected function tearDown() {
+ $this->testEnvironment->tearDown();
+ parent::tearDown();
+ }
+
+ /**
+ * @dataProvider queryParameterProvider
+ */
+ public function testQueryParameter( $query, $expected ) {
+
+ $instance = new SpecialBrowse();
+
+ $instance->getContext()->setTitle(
+ Title::newFromText( 'SpecialBrowse' )
+ );
+
+ $instance->execute( $query );
+
+ $this->stringValidator->assertThatStringContains(
+ $expected,
+ $instance->getOutput()->getHtml()
+ );
+ }
+
+ public function queryParameterProvider() {
+
+ #0
+ $provider[] = [
+ '',
+ [ 'smw-callout smw-callout-error' ]
+ ];
+
+ #1
+ $provider[] = [
+ ':Has-20foo/http:-2F-2Fexample.org-2Fid-2FCurly-2520Brackets-257B-257D',
+ [ 'smw-callout smw-callout-error' ]
+ ];
+
+ #2
+ $provider[] = [
+ 'Foo/Bar',
+ [
+ 'data-subject="Foo/Bar#0##"',
+ 'data-options="{&quot;dir&quot;:null,&quot;group&quot;:null,&quot;printable&quot;:null,&quot;offset&quot;:null,&quot;including&quot;:null,&quot;showInverse&quot;:false,&quot;showAll&quot;:true,&quot;showGroup&quot;:false,&quot;showSort&quot;:false,&quot;api&quot;:true,&quot;valuelistlimit.out&quot;:&quot;200&quot;,&quot;valuelistlimit.in&quot;:&quot;20&quot;}"'
+ ]
+ ];
+
+ #3
+ $provider[] = [
+ ':Main-20Page-23_QUERY140d50d705e9566904fc4a877c755964',
+ [
+ 'data-subject="Main_Page#0##_QUERY140d50d705e9566904fc4a877c755964"',
+ 'data-options="{&quot;dir&quot;:null,&quot;group&quot;:null,&quot;printable&quot;:null,&quot;offset&quot;:null,&quot;including&quot;:null,&quot;showInverse&quot;:false,&quot;showAll&quot;:true,&quot;showGroup&quot;:false,&quot;showSort&quot;:false,&quot;api&quot;:true,&quot;valuelistlimit.out&quot;:&quot;200&quot;,&quot;valuelistlimit.in&quot;:&quot;20&quot;}"'
+ ]
+ ];
+
+ return $provider;
+ }
+
+}