summaryrefslogtreecommitdiff
path: root/www/wiki/extensions/SemanticMediaWiki/tests/phpunit/includes/storage/sqlstore/SQLStoreTest.php
diff options
context:
space:
mode:
Diffstat (limited to 'www/wiki/extensions/SemanticMediaWiki/tests/phpunit/includes/storage/sqlstore/SQLStoreTest.php')
-rw-r--r--www/wiki/extensions/SemanticMediaWiki/tests/phpunit/includes/storage/sqlstore/SQLStoreTest.php170
1 files changed, 170 insertions, 0 deletions
diff --git a/www/wiki/extensions/SemanticMediaWiki/tests/phpunit/includes/storage/sqlstore/SQLStoreTest.php b/www/wiki/extensions/SemanticMediaWiki/tests/phpunit/includes/storage/sqlstore/SQLStoreTest.php
new file mode 100644
index 00000000..d183273c
--- /dev/null
+++ b/www/wiki/extensions/SemanticMediaWiki/tests/phpunit/includes/storage/sqlstore/SQLStoreTest.php
@@ -0,0 +1,170 @@
+<?php
+
+namespace SMW\Test\SQLStore;
+
+use SMW\ApplicationFactory;
+use SMWSQLStore3;
+
+/**
+ * @covers \SMWSQLStore3
+ *
+ * @group semantic-mediawiki
+ *
+ * @license GNU GPL v2+
+ * @since 1.9
+ *
+ * @author mwjames
+ */
+class SQLStoreTest extends \PHPUnit_Framework_TestCase {
+
+ private $store;
+
+ protected function setUp() {
+ parent::setUp();
+
+ $this->store = new SMWSQLStore3();
+
+ $settings = [
+ 'smwgFixedProperties' => [],
+ 'smwgPageSpecialProperties' => []
+ ];
+
+ foreach ( $settings as $key => $value ) {
+ ApplicationFactory::getInstance()->getSettings()->set( $key, $value );
+ }
+ }
+
+ protected function tearDown() {
+ $this->store->clear();
+ ApplicationFactory::getInstance()->clear();
+
+ parent::tearDown();
+ }
+
+ public function testCanConstruct() {
+
+ $this->assertInstanceOf(
+ '\SMWSQLStore3',
+ $this->store
+ );
+
+ $this->assertInstanceOf(
+ '\SMW\SQLStore\SQLStore',
+ $this->store
+ );
+ }
+
+ /**
+ * @depends testCanConstruct
+ */
+ public function testGetPropertyTables() {
+
+ $defaultPropertyTableCount = count( $this->store->getPropertyTables() );
+
+ $this->assertInternalType(
+ 'array',
+ $this->store->getPropertyTables()
+ );
+
+ foreach ( $this->store->getPropertyTables() as $tid => $propTable ) {
+ $this->assertInstanceOf(
+ '\SMW\SQLStore\TableDefinition',
+ $propTable
+ );
+ }
+ }
+
+ /**
+ * @depends testGetPropertyTables
+ */
+ public function testPropertyTablesValidCustomizableProperty() {
+
+ $defaultPropertyTableCount = count( $this->store->getPropertyTables() );
+
+ $settings = [
+ 'smwgFixedProperties' => [],
+ 'smwgPageSpecialProperties' => [ '_MDAT' ]
+ ];
+
+ foreach ( $settings as $key => $value ) {
+ ApplicationFactory::getInstance()->getSettings()->set( $key, $value );
+ }
+
+ $this->store->clear();
+
+ $this->assertCount(
+ $defaultPropertyTableCount + 1,
+ $this->store->getPropertyTables()
+ );
+ }
+
+ /**
+ * @depends testGetPropertyTables
+ */
+ public function testPropertyTablesWithInvalidCustomizableProperty() {
+
+ $defaultPropertyTableCount = count( $this->store->getPropertyTables() );
+
+ $settings = [
+ 'smwgFixedProperties' => [],
+ 'smwgPageSpecialProperties' => [ '_MDAT', 'Foo' ]
+ ];
+
+ foreach ( $settings as $key => $value ) {
+ ApplicationFactory::getInstance()->getSettings()->set( $key, $value );
+ }
+
+ $this->store->clear();
+
+ $this->assertCount(
+ $defaultPropertyTableCount + 1,
+ $this->store->getPropertyTables()
+ );
+ }
+
+ /**
+ * @depends testGetPropertyTables
+ */
+ public function testPropertyTablesWithValidCustomizableProperties() {
+
+ $defaultPropertyTableCount = count( $this->store->getPropertyTables() );
+
+ $settings = [
+ 'smwgFixedProperties' => [],
+ 'smwgPageSpecialProperties' => [ '_MDAT', '_MEDIA' ]
+ ];
+
+ foreach ( $settings as $key => $value ) {
+ ApplicationFactory::getInstance()->getSettings()->set( $key, $value );
+ }
+
+ $this->store->clear();
+
+ $this->assertCount(
+ $defaultPropertyTableCount + 2,
+ $this->store->getPropertyTables()
+ );
+ }
+
+ public function testGetStatisticsTable() {
+
+ $this->assertInternalType(
+ 'string',
+ $this->store->getStatisticsTable()
+ );
+ }
+
+ public function testGetObjectIds() {
+
+ $this->assertInternalType(
+ 'object',
+ $this->store->getObjectIds()
+ );
+
+ $this->assertInternalType(
+ 'string',
+ $this->store->getObjectIds()->getIdTable()
+ );
+ }
+
+}