summaryrefslogtreecommitdiff
path: root/www/wiki/extensions/SemanticMediaWiki/tests/phpunit/Unit/SQLStore/QueryEngine/DescriptionInterpreters/ThingDescriptionInterpreterTest.php
diff options
context:
space:
mode:
Diffstat (limited to 'www/wiki/extensions/SemanticMediaWiki/tests/phpunit/Unit/SQLStore/QueryEngine/DescriptionInterpreters/ThingDescriptionInterpreterTest.php')
-rw-r--r--www/wiki/extensions/SemanticMediaWiki/tests/phpunit/Unit/SQLStore/QueryEngine/DescriptionInterpreters/ThingDescriptionInterpreterTest.php71
1 files changed, 71 insertions, 0 deletions
diff --git a/www/wiki/extensions/SemanticMediaWiki/tests/phpunit/Unit/SQLStore/QueryEngine/DescriptionInterpreters/ThingDescriptionInterpreterTest.php b/www/wiki/extensions/SemanticMediaWiki/tests/phpunit/Unit/SQLStore/QueryEngine/DescriptionInterpreters/ThingDescriptionInterpreterTest.php
new file mode 100644
index 00000000..5e59430a
--- /dev/null
+++ b/www/wiki/extensions/SemanticMediaWiki/tests/phpunit/Unit/SQLStore/QueryEngine/DescriptionInterpreters/ThingDescriptionInterpreterTest.php
@@ -0,0 +1,71 @@
+<?php
+
+namespace SMW\Tests\SQLStore\QueryEngine\DescriptionInterpreters;
+
+use SMW\SQLStore\QueryEngine\DescriptionInterpreters\ThingDescriptionInterpreter;
+use SMW\SQLStore\QueryEngineFactory;
+use SMW\Tests\TestEnvironment;
+
+/**
+ * @covers \SMW\SQLStore\QueryEngine\DescriptionInterpreters\ThingDescriptionInterpreter
+ * @group semantic-mediawiki
+ *
+ * @license GNU GPL v2+
+ * @since 2.2
+ *
+ * @author mwjames
+ */
+class ThingDescriptionInterpreterTest extends \PHPUnit_Framework_TestCase {
+
+ private $querySegmentValidator;
+
+ protected function setUp() {
+ parent::setUp();
+
+ $testEnvironment = new TestEnvironment();
+ $this->querySegmentValidator = $testEnvironment->getUtilityFactory()->newValidatorFactory()->newQuerySegmentValidator();
+ }
+
+ public function testCanConstruct() {
+
+ $querySegmentListBuilder = $this->getMockBuilder( '\SMW\SQLStore\QueryEngine\QuerySegmentListBuilder' )
+ ->disableOriginalConstructor()
+ ->getMockForAbstractClass();
+
+ $this->assertInstanceOf(
+ '\SMW\SQLStore\QueryEngine\DescriptionInterpreters\ThingDescriptionInterpreter',
+ new ThingDescriptionInterpreter( $querySegmentListBuilder )
+ );
+ }
+
+ public function testInterpretDescription() {
+
+ $store = $this->getMockBuilder( '\SMW\SQLStore\SQLStore' )
+ ->disableOriginalConstructor()
+ ->getMock();
+
+ $description = $this->getMockBuilder( '\SMW\Query\Language\ThingDescription' )
+ ->disableOriginalConstructor()
+ ->getMockForAbstractClass();
+
+ $expected = new \stdClass;
+ $expected->type = 0;
+ $expected->queryNumber = 0;
+
+ $queryEngineFactory = new QueryEngineFactory( $store );
+
+ $instance = new ThingDescriptionInterpreter(
+ $queryEngineFactory->newQuerySegmentListBuilder()
+ );
+
+ $this->assertTrue(
+ $instance->canInterpretDescription( $description )
+ );
+
+ $this->querySegmentValidator->assertThatContainerHasProperties(
+ $expected,
+ $instance->interpretDescription( $description )
+ );
+ }
+
+}