summaryrefslogtreecommitdiff
path: root/www/wiki/extensions/SemanticMediaWiki/tests/phpunit/Unit/DataValues/ValueParsers/AllowsPatternValueParserTest.php
diff options
context:
space:
mode:
Diffstat (limited to 'www/wiki/extensions/SemanticMediaWiki/tests/phpunit/Unit/DataValues/ValueParsers/AllowsPatternValueParserTest.php')
-rw-r--r--www/wiki/extensions/SemanticMediaWiki/tests/phpunit/Unit/DataValues/ValueParsers/AllowsPatternValueParserTest.php50
1 files changed, 50 insertions, 0 deletions
diff --git a/www/wiki/extensions/SemanticMediaWiki/tests/phpunit/Unit/DataValues/ValueParsers/AllowsPatternValueParserTest.php b/www/wiki/extensions/SemanticMediaWiki/tests/phpunit/Unit/DataValues/ValueParsers/AllowsPatternValueParserTest.php
new file mode 100644
index 00000000..4c8c23dd
--- /dev/null
+++ b/www/wiki/extensions/SemanticMediaWiki/tests/phpunit/Unit/DataValues/ValueParsers/AllowsPatternValueParserTest.php
@@ -0,0 +1,50 @@
+<?php
+
+namespace SMW\Tests\DataValues\ValueParsers;
+
+use SMW\DataValues\ValueParsers\AllowsPatternValueParser;
+
+/**
+ * @covers \SMW\DataValues\ValueParsers\AllowsPatternValueParser
+ * @group semantic-mediawiki
+ *
+ * @license GNU GPL v2+
+ * @since 2.4
+ *
+ * @author mwjames
+ */
+class AllowsPatternValueParserTest extends \PHPUnit_Framework_TestCase {
+
+ private $mediaWikiNsContentReader;
+
+ protected function setUp() {
+ $this->mediaWikiNsContentReader = $this->getMockBuilder( '\SMW\MediaWiki\MediaWikiNsContentReader' )
+ ->disableOriginalConstructor()
+ ->getMock();
+ }
+
+ public function testCanConstruct() {
+
+ $this->assertInstanceOf(
+ '\SMW\DataValues\ValueParsers\AllowsPatternValueParser',
+ new AllowsPatternValueParser( $this->mediaWikiNsContentReader )
+ );
+ }
+
+ public function testParseAndMatchFromResource() {
+
+ $this->mediaWikiNsContentReader->expects( $this->once() )
+ ->method( 'read' )
+ ->will( $this->returnValue( " \nFoo|^(Bar|Foo bar)$\n Bar|^(ABC|DEF)$\n" ) );
+
+ $instance = new AllowsPatternValueParser(
+ $this->mediaWikiNsContentReader
+ );
+
+ $this->assertEquals(
+ '^(ABC|DEF)$',
+ $instance->parse( 'Bar' )
+ );
+ }
+
+}