Jeroen De Dauw has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/75873


Change subject: Fix multiple design issues in this component [DNM]
......................................................................

Fix multiple design issues in this component [DNM]

*
* Added usage and structure docs to README

Change-Id: I0cc82d12e80495d75fd810820c6527ba410affdd
---
M README.md
M WikibaseDatabase.mw.php
A src/Escaper.php
D src/MWDB/ExtendedAbstraction.php
A src/MediaWiki/MWQueryInterfaceBuilder.php
A src/MediaWiki/MediaWikiEscaper.php
R src/MediaWiki/MediaWikiQueryInterface.php
R src/MySQL/MySqlTableSqlBuilder.php
R src/SQLite/SQLiteTableSqlBuilder.php
A src/TableSqlBuilder.php
A tests/phpunit/MediaWiki/MWQueryInterfaceBuilderTest.php
R tests/phpunit/MySQL/MySQLTableSqlBuilderTest.php
R tests/phpunit/SQLite/SQLiteTableSqlBuilderTest.php
R tests/phpunit/TableSqlBuilderTest.php
14 files changed, 317 insertions(+), 146 deletions(-)


  git pull 
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/WikibaseDatabase 
refs/changes/73/75873/1

diff --git a/README.md b/README.md
index 6bb03c6..36b9263 100644
--- a/README.md
+++ b/README.md
@@ -11,7 +11,18 @@
 ## Requirements
 
 * PHP 5.3 or later
-* MediaWiki 1.21 or later, only when using MediaWikiQueryInterface
+* When using MediaWikiQueryInterface: MediaWiki 1.21 or later
+
+## Supported databases
+
+This component currently only comes with one concrete implementation, which is
+MediaWikiQueryInterface. This implementation depends on MediaWiki and currently
+only has support for MySQL and SQLite.
+
+The core of this component has no database specific things in it. You can thus
+create your own implementation of the interfaces as you see fit, and are 
generally
+encouraged to keep these either in your consuming component, or in a dedicated 
one
+in case you have multiple consumers.
 
 ## Installation
 
@@ -39,7 +50,7 @@
 Load all dependencies and the load the Wikibase Database library by including 
its entry point:
 WikibaseDatabase.php.
 
-## Usage
+## Using the abstraction layer
 
 ```php
 $db->select(
@@ -55,12 +66,37 @@
 $db->createTable( new TableDefinition(
     'table_name',
     array(
-        new FieldDefinition( ... ),
-        ...
+        new FieldDefinition( /* ... */ ),
+        /* ... */
     )
 ) );
 ```
 
+## Abstraction layer structure
+
+All classes of this component reside in the Wikibase\Database namespace, which 
is PSR-0 mapped
+onto the src/ directory.
+
+The main interface of this component is QueryInterface. It defines methods for 
interacting with
+a database. These methods include tableExists, createTable, insert, update and 
select. When using
+this component, you will likely be passing around an instance of an 
implementation of this interface.
+
+Classes and interfaces in sub namespaces are generally considered package 
private and should thus
+not be used in any way outside of the package. The exception to this are the 
implementations of
+the QueryInterface interface, and the dependencies those require.
+
+### MediaWiki implementation
+
+Currently only one implementation of QueryInterface is bundled together with 
the abstract part
+of this component. This implementation is the MediaWikiQueryInterface class in 
the
+Wikibase\Database\MediaWiki namespace. All MediaWiki specific code contained 
by this package
+resides in this namespace. (Currently with the exception of 
DBConnectionProvider and
+LazyDBConnectionProvider.)
+
+### Exceptions
+
+TODO
+
 ## Tests
 
 This library comes with a set up PHPUnit tests that cover all non-trivial 
code. You can run these
diff --git a/WikibaseDatabase.mw.php b/WikibaseDatabase.mw.php
index 5b2e82d..a6d1753 100644
--- a/WikibaseDatabase.mw.php
+++ b/WikibaseDatabase.mw.php
@@ -49,7 +49,7 @@
 $wgHooks['UnitTestsList'][]    = function( array &$files ) {
        // @codeCoverageIgnoreStart
        $testFiles = array(
-               'MWDB/ExtendedMySQLAbstraction',
+               'MWDB/MySqlTableSqlBuilder',
 
                'FieldDefinition',
                'MediaWikiQueryInterface',
diff --git a/src/Escaper.php b/src/Escaper.php
new file mode 100644
index 0000000..98e7d7b
--- /dev/null
+++ b/src/Escaper.php
@@ -0,0 +1,26 @@
+<?php
+
+namespace Wikibase\Database;
+
+/**
+ * Base class acting as interface for classes that escape values so they
+ * are suitable for injection in an SQL string.
+ *
+ * @since 0.1
+ *
+ * @file
+ * @ingroup WikibaseDatabase
+ *
+ * @licence GNU GPL v2+
+ * @author Jeroen De Dauw < [email protected] >
+ */
+interface Escaper {
+
+       /**
+        * @param mixed $value
+        *
+        * @return string The escaped value
+        */
+       public function getEscapedValue( $value );
+
+}
diff --git a/src/MWDB/ExtendedAbstraction.php b/src/MWDB/ExtendedAbstraction.php
deleted file mode 100644
index a839279..0000000
--- a/src/MWDB/ExtendedAbstraction.php
+++ /dev/null
@@ -1,84 +0,0 @@
-<?php
-
-namespace Wikibase\Database\MWDB;
-
-use Wikibase\Database\DBConnectionProvider;
-use Wikibase\Database\TableDefinition;
-use InvalidArgumentException;
-use DatabaseBase;
-
-/**
- * Base database abstraction class to put stuff into that is not present
- * in the MW core db abstraction layer.
- *
- * Like to core class DatabaseBase, each deriving class provides support
- * for a specific type of database.
- *
- * Everything implemented in these classes could go into DatabaseBase and
- * deriving classes, though this might take quite some time, hence 
implementation
- * is first done here. If you feel like taking core CR crap and waiting a few
- * months, by all means try to get the functionality into core.
- *
- * @since 0.1
- *
- * @file
- * @ingroup WikibaseDatabase
- *
- * @licence GNU GPL v2+
- * @author Jeroen De Dauw < [email protected] >
- */
-abstract class ExtendedAbstraction {
-
-       /**
-        * @since 0.1
-        *
-        * @var DBConnectionProvider
-        */
-       private $connectionProvider;
-
-       /**
-        * @since 0.1
-        *
-        * @param DBConnectionProvider $connectionProvider
-        */
-       public function __construct( DBConnectionProvider $connectionProvider ) 
{
-               $this->connectionProvider = $connectionProvider;
-       }
-
-       /**
-        * @since 0.1
-        *
-        * @return DatabaseBase
-        * @throws InvalidArgumentException
-        */
-       public function getDB() {
-               $db = $this->connectionProvider->getConnection();
-
-               if ( $db->getType() !== $this->getType() ) {
-                       throw new InvalidArgumentException( 'The DatabaseBase 
class type does not match the type of this ExtendedAbstraction' );
-               }
-
-               return $db;
-       }
-
-       /**
-        * Create the provided table.
-        *
-        * @since 0.1
-        *
-        * @param TableDefinition $table
-        *
-        * @return boolean Success indicator
-        */
-       public abstract function createTable( TableDefinition $table );
-
-       /**
-        * Returns the type of the supported MW DB abstraction class.
-        *
-        * @since 0.1
-        *
-        * @return string
-        */
-       protected abstract function getType();
-
-}
\ No newline at end of file
diff --git a/src/MediaWiki/MWQueryInterfaceBuilder.php 
b/src/MediaWiki/MWQueryInterfaceBuilder.php
new file mode 100644
index 0000000..34eb2f7
--- /dev/null
+++ b/src/MediaWiki/MWQueryInterfaceBuilder.php
@@ -0,0 +1,87 @@
+<?php
+
+namespace Wikibase\Database\MediaWiki;
+
+use DatabaseBase;
+use RuntimeException;
+use SubPageList\LazyDBConnectionProvider;
+use Wikibase\Database\DBConnectionProvider;
+use Wikibase\Database\MySQL\MySqlTableSqlBuilder;
+use Wikibase\Database\QueryInterface;
+use Wikibase\Database\SQLite\SQLiteTableSqlBuilder;
+
+/**
+ * Builder for MediaWikiQueryInterface objects.
+ * Implemented as fluent interface.
+ *
+ * @since 0.1
+ *
+ * @file
+ * @ingroup WikibaseDatabase
+ *
+ * @licence GNU GPL v2+
+ * @author Jeroen De Dauw < [email protected] >
+ */
+class MWQueryInterfaceBuilder {
+
+       /**
+        * @var DBConnectionProvider
+        */
+       protected $dbConnection;
+
+       protected $tablePrefix;
+
+       /**
+        * @param DBConnectionProvider $dbConnection
+        *
+        * @return $this
+        */
+       public function setConnection( DBConnectionProvider $dbConnection ) {
+               $this->dbConnection = $dbConnection;
+               return $this;
+       }
+
+       /**
+        * @return QueryInterface
+        */
+       public function getQueryInterface() {
+               return new MediaWikiQueryInterface(
+                       $this->dbConnection,
+                       $this->getTableSqlBuilder()
+               );
+       }
+
+       protected function getTableSqlBuilder() {
+               $dbType = $this->dbConnection->getConnection()->getType();
+
+               if ( $dbType === 'mysql' ) {
+                       return $this->newMySqlTableSqlBuilder();
+               }
+
+               if ( $dbType === 'sqlite' ) {
+                       return $this->newSQLiteTableSqlBuilder();
+               }
+
+               throw new RuntimeException( "Cannot build a 
MediaWikiQueryInterface for database type '$dbType'." );
+       }
+
+       protected function newMySqlTableSqlBuilder() {
+               return new MySqlTableSqlBuilder(
+                       $this->dbConnection->getConnection()->getDBname(),
+                       $this->dbConnection->getConnection()->tablePrefix(),
+                       $this->newEscaper()
+               );
+       }
+
+       protected function newSQLiteTableSqlBuilder() {
+               return new SQLiteTableSqlBuilder(
+                       $this->dbConnection->getConnection()->tablePrefix(),
+                       $this->newEscaper()
+               );
+       }
+
+       protected function newEscaper() {
+               return new MediaWikiEscaper(); // TODO
+       }
+
+}
diff --git a/src/MediaWiki/MediaWikiEscaper.php 
b/src/MediaWiki/MediaWikiEscaper.php
new file mode 100644
index 0000000..fc79813
--- /dev/null
+++ b/src/MediaWiki/MediaWikiEscaper.php
@@ -0,0 +1,31 @@
+<?php
+
+namespace Wikibase\Database\MediaWiki;
+
+use Wikibase\Database\Escaper;
+
+/**
+ * Adapter for MediaWiki's SQL value escaping functionality.
+ *
+ * @since 0.1
+ *
+ * @file
+ * @ingroup WikibaseDatabase
+ *
+ * @licence GNU GPL v2+
+ * @author Jeroen De Dauw < [email protected] >
+ */
+class MediaWikiEscaper implements Escaper {
+
+       /**
+        * @see Escaper::getEscapedValue
+        *
+        * @param mixed $value
+        *
+        * @return string The escaped value
+        */
+       public function getEscapedValue( $value ) {
+
+       }
+
+}
diff --git a/src/MediaWikiQueryInterface.php 
b/src/MediaWiki/MediaWikiQueryInterface.php
similarity index 83%
rename from src/MediaWikiQueryInterface.php
rename to src/MediaWiki/MediaWikiQueryInterface.php
index 4e78c25..d5b54a0 100644
--- a/src/MediaWikiQueryInterface.php
+++ b/src/MediaWiki/MediaWikiQueryInterface.php
@@ -1,9 +1,17 @@
 <?php
 
-namespace Wikibase\Database;
+namespace Wikibase\Database\MediaWiki;
 
+use Wikibase\Database\DBConnectionProvider;
+use Wikibase\Database\DeleteFailedException;
+use Wikibase\Database\InsertFailedException;
+use Wikibase\Database\QueryInterface;
+use Wikibase\Database\ResultIterator;
+use Wikibase\Database\SelectFailedException;
+use Wikibase\Database\TableCreationFailedException;
 use Wikibase\Database\TableDefinition;
-use Wikibase\Database\MWDB\ExtendedAbstraction;
+use Wikibase\Database\MWDB\TableSqlBuilder;
+use Wikibase\Database\UpdateFailedException;
 
 /**
  * Implementation of the QueryInterface interface using the MediaWiki
@@ -25,19 +33,19 @@
        private $connectionProvider;
 
        /**
-        * @var ExtendedAbstraction
+        * @var TableSqlBuilder
         */
-       private $extendedAbstraction;
+       private $tableSqlBuilder;
 
        /**
         * @since 0.1
         *
         * @param DBConnectionProvider $connectionProvider
-        * @param ExtendedAbstraction $extendedAbstraction
+        * @param TableSqlBuilder $tableSqlBuilder
         */
-       public function __construct( DBConnectionProvider $connectionProvider, 
ExtendedAbstraction $extendedAbstraction ) {
+       public function __construct( DBConnectionProvider $connectionProvider, 
TableSqlBuilder $tableSqlBuilder ) {
                $this->connectionProvider = $connectionProvider;
-               $this->extendedAbstraction = $extendedAbstraction;
+               $this->tableSqlBuilder = $tableSqlBuilder;
        }
 
        /**
@@ -70,7 +78,7 @@
         * @throws TableCreationFailedException
         */
        public function createTable( TableDefinition $table ) {
-               $success = $this->extendedAbstraction->createTable( $table );
+               $success = $this->tableSqlBuilder->getCreateTableSql( $table );
 
                if ( $success !== true ) {
                        throw new TableCreationFailedException( $table );
diff --git a/src/MWDB/ExtendedMySQLAbstraction.php 
b/src/MySQL/MySqlTableSqlBuilder.php
similarity index 73%
rename from src/MWDB/ExtendedMySQLAbstraction.php
rename to src/MySQL/MySqlTableSqlBuilder.php
index a9040e2..8668400 100644
--- a/src/MWDB/ExtendedMySQLAbstraction.php
+++ b/src/MySQL/MySqlTableSqlBuilder.php
@@ -1,13 +1,15 @@
 <?php
 
-namespace Wikibase\Database\MWDB;
+namespace Wikibase\Database\MySQL;
 
+use Wikibase\Database\Escaper;
+use Wikibase\Database\TableSqlBuilder;
 use Wikibase\Database\TableDefinition;
 use Wikibase\Database\FieldDefinition;
 use RuntimeException;
 
 /**
- * MySQL implementation of ExtendedAbstraction.
+ * MySQL implementation of TableSqlBuilder.
  *
  * @since 0.1
  *
@@ -17,17 +19,21 @@
  * @licence GNU GPL v2+
  * @author Jeroen De Dauw < [email protected] >
  */
-class ExtendedMySQLAbstraction extends ExtendedAbstraction {
+class MySqlTableSqlBuilder extends TableSqlBuilder {
+
+       protected $dbName;
+       protected $tablePrefix;
+       protected $escaper;
 
        /**
-        * @see ExtendedAbstraction::getType
-        *
-        * @since 0.1
-        *
-        * @return string
+        * @param string $dbName
+        * @param string $tablePrefix
+        * @param Escaper $fieldValueEscaper
         */
-       protected function getType() {
-               return 'mysql';
+       public function __construct( $dbName, $tablePrefix, Escaper 
$fieldValueEscaper ) {
+               $this->dbName = $dbName;
+               $this->tablePrefix = $tablePrefix;
+               $this->escaper = $fieldValueEscaper;
        }
 
        /**
@@ -37,14 +43,12 @@
         *
         * @param TableDefinition $table
         *
-        * @return boolean Success indicator
+        * @return string
         */
-       public function createTable( TableDefinition $table ) {
-               $db = $this->getDB();
-
+       public function getCreateTableSql( TableDefinition $table ) {
                // TODO: Escape table name?
                // TODO: get rid of global (DatabaseBase currently provides no 
access to its mTablePrefix field)
-               $sql = 'CREATE TABLE `' . $db->getDBname() . '`.' . 
$GLOBALS['wgDBprefix'] . $table->getName() . ' (';
+               $sql = 'CREATE TABLE `' . $this->dbName . '`.' . 
$this->tablePrefix . $table->getName() . ' (';
 
                $fields = array();
 
@@ -57,9 +61,7 @@
                // TODO: table options
                $sql .= ') ' . 'ENGINE=InnoDB, DEFAULT CHARSET=binary';
 
-               $success = $db->query( $sql, __METHOD__ );
-
-               return $success !== false;
+               return $sql;
        }
 
        /**
@@ -77,7 +79,6 @@
 
                $sql .= ' ' . $this->getNull( $field->allowsNull() );
 
-               if($field->getIndex()==FieldDefinition::INDEX_PRIMARY && 
$field->getName()!=='id') {q($field);}
                $sql .= ' ' . $this->getIndexString( $field->getIndex() );
 
                // TODO: add all field stuff relevant here
@@ -87,7 +88,7 @@
 
        protected function getDefault( $default ) {
                if ( $default !== null ) {
-                       return 'DEFAULT ' . $this->getDB()->addQuotes( $default 
);
+                       return 'DEFAULT ' . $this->escaper->getEscapedValue( 
$default );
                }
 
                return '';
diff --git a/src/MWDB/ExtendedSQLiteAbstraction.php 
b/src/SQLite/SQLiteTableSqlBuilder.php
similarity index 73%
rename from src/MWDB/ExtendedSQLiteAbstraction.php
rename to src/SQLite/SQLiteTableSqlBuilder.php
index df6967c..e832776 100644
--- a/src/MWDB/ExtendedSQLiteAbstraction.php
+++ b/src/SQLite/SQLiteTableSqlBuilder.php
@@ -1,13 +1,15 @@
 <?php
 
-namespace Wikibase\Database\MWDB;
+namespace Wikibase\Database\SQLite;
 
+use Wikibase\Database\Escaper;
+use Wikibase\Database\TableSqlBuilder;
 use Wikibase\Database\TableDefinition;
 use Wikibase\Database\FieldDefinition;
 use RuntimeException;
 
 /**
- * SQLite implementation of ExtendedAbstraction.
+ * SQLite implementation of TableSqlBuilder.
  *
  * @since 0.1
  *
@@ -17,17 +19,18 @@
  * @licence GNU GPL v2+
  * @author Jeroen De Dauw < [email protected] >
  */
-class ExtendedSQLiteAbstraction extends ExtendedAbstraction {
+class SQLiteTableSqlBuilder extends TableSqlBuilder {
+
+       protected $escaper;
+       protected $tablePrefix;
 
        /**
-        * @see ExtendedAbstraction::getType
-        *
-        * @since 0.1
-        *
-        * @return string
+        * @param string $tablePrefix
+        * @param Escaper $fieldValueEscaper
         */
-       protected function getType() {
-               return 'sqlite';
+       public function __construct( $tablePrefix, Escaper $fieldValueEscaper ) 
{
+               $this->tablePrefix = $tablePrefix;
+               $this->escaper = $fieldValueEscaper;
        }
 
        /**
@@ -37,14 +40,12 @@
         *
         * @param TableDefinition $table
         *
-        * @return boolean Success indicator
+        * @return string
         */
-       public function createTable( TableDefinition $table ) {
-               $db = $this->getDB();
-
+       public function getCreateTableSql( TableDefinition $table ) {
                // TODO: Escape table name?
                // TODO: get rid of global (DatabaseBase currently provides no 
access to its mTablePrefix field)
-               $sql = 'CREATE TABLE ' . $GLOBALS['wgDBprefix'] . 
$table->getName() . ' (';
+               $sql = 'CREATE TABLE ' . $this->tablePrefix . $table->getName() 
. ' (';
 
                $fields = array();
 
@@ -57,9 +58,7 @@
                // TODO: table options
                $sql .= ');';
 
-               $success = $db->query( $sql, __METHOD__ );
-
-               return $success !== false;
+               return $sql;
        }
 
        /**
@@ -74,7 +73,7 @@
                $sql = $this->getFieldType( $field->getType() );
 
                if ( $field->getDefault() !== null ) {
-                       $sql .= ' DEFAULT ' . $this->getDB()->addQuotes( 
$field->getDefault() );
+                       $sql .= ' DEFAULT ' . $this->escaper->getEscapedValue( 
$field->getDefault() );
                }
 
                // TODO: add all field stuff relevant here
diff --git a/src/TableSqlBuilder.php b/src/TableSqlBuilder.php
new file mode 100644
index 0000000..886604d
--- /dev/null
+++ b/src/TableSqlBuilder.php
@@ -0,0 +1,44 @@
+<?php
+
+namespace Wikibase\Database;
+
+use Wikibase\Database\DBConnectionProvider;
+use Wikibase\Database\Escaper;
+use Wikibase\Database\TableDefinition;
+use InvalidArgumentException;
+use DatabaseBase;
+
+/**
+ * Base database abstraction class to put stuff into that is not present
+ * in the MW core db abstraction layer.
+ *
+ * Like to core class DatabaseBase, each deriving class provides support
+ * for a specific type of database.
+ *
+ * Everything implemented in these classes could go into DatabaseBase and
+ * deriving classes, though this might take quite some time, hence 
implementation
+ * is first done here. If you feel like taking core CR crap and waiting a few
+ * months, by all means try to get the functionality into core.
+ *
+ * @since 0.1
+ *
+ * @file
+ * @ingroup WikibaseDatabase
+ *
+ * @licence GNU GPL v2+
+ * @author Jeroen De Dauw < [email protected] >
+ */
+abstract class TableSqlBuilder {
+
+       /**
+        * Create the provided table.
+        *
+        * @since 0.1
+        *
+        * @param TableDefinition $table
+        *
+        * @return string The SQL for creating the table
+        */
+       public abstract function getCreateTableSql( TableDefinition $table );
+
+}
\ No newline at end of file
diff --git a/tests/phpunit/MediaWiki/MWQueryInterfaceBuilderTest.php 
b/tests/phpunit/MediaWiki/MWQueryInterfaceBuilderTest.php
new file mode 100644
index 0000000..ef949e2
--- /dev/null
+++ b/tests/phpunit/MediaWiki/MWQueryInterfaceBuilderTest.php
@@ -0,0 +1,23 @@
+<?php
+
+namespace Wikibase\Database\Tests\MediaWiki;
+
+/**
+ * @covers Wikibase\Database\MediaWiki\MWQueryInterfaceBuilder
+ *
+ * @file
+ * @since 0.1
+ *
+ * @ingroup WikibaseDatabaseTest
+ *
+ * @group Wikibase
+ * @group WikibaseDatabase
+ *
+ * @licence GNU GPL v2+
+ * @author Jeroen De Dauw < [email protected] >
+ */
+class MWQueryInterfaceBuilderTest extends \PHPUnit_Framework_TestCase {
+
+       // TODO
+
+}
diff --git a/tests/phpunit/MWDB/ExtendedMySQLAbstractionTest.php 
b/tests/phpunit/MySQL/MySQLTableSqlBuilderTest.php
similarity index 81%
rename from tests/phpunit/MWDB/ExtendedMySQLAbstractionTest.php
rename to tests/phpunit/MySQL/MySQLTableSqlBuilderTest.php
index d454e68..4c9ee43 100644
--- a/tests/phpunit/MWDB/ExtendedMySQLAbstractionTest.php
+++ b/tests/phpunit/MySQL/MySQLTableSqlBuilderTest.php
@@ -3,7 +3,7 @@
 namespace Wikibase\Database\Tests\MWDB;
 
 use Wikibase\Database\LazyDBConnectionProvider;
-use Wikibase\Database\MWDB\ExtendedMySQLAbstraction;
+use Wikibase\Database\MySQL\MySqlTableSqlBuilder;
 
 /**
  * @covers Wikibase\Database\MWDB\ExtendedMySQLAbstraction
@@ -33,10 +33,10 @@
        /**
         * @see ExtendedAbstractionTest::newInstance
         *
-        * @return ExtendedMySQLAbstraction
+        * @return MySqlTableSqlBuilder
         */
        protected function newInstance() {
-               return new ExtendedMySQLAbstraction( new 
LazyDBConnectionProvider( DB_MASTER ) );
+               return new MySqlTableSqlBuilder( new LazyDBConnectionProvider( 
DB_MASTER ) );
        }
 
 }
diff --git a/tests/phpunit/MWDB/ExtendedSQLiteAbstractionTest.php 
b/tests/phpunit/SQLite/SQLiteTableSqlBuilderTest.php
similarity index 81%
rename from tests/phpunit/MWDB/ExtendedSQLiteAbstractionTest.php
rename to tests/phpunit/SQLite/SQLiteTableSqlBuilderTest.php
index 969fbc7..5d0224c 100644
--- a/tests/phpunit/MWDB/ExtendedSQLiteAbstractionTest.php
+++ b/tests/phpunit/SQLite/SQLiteTableSqlBuilderTest.php
@@ -3,7 +3,7 @@
 namespace Wikibase\Database\Tests\MWDB;
 
 use Wikibase\Database\LazyDBConnectionProvider;
-use Wikibase\Database\MWDB\ExtendedSQLiteAbstraction;
+use Wikibase\Database\SQLite\SQLiteTableSqlBuilder;
 
 /**
  * @covers Wikibase\Database\MWDB\ExtendedSQLiteAbstraction
@@ -33,10 +33,10 @@
        /**
         * @see ExtendedAbstractionTest::newInstance
         *
-        * @return ExtendedSQLiteAbstraction
+        * @return SQLiteTableSqlBuilder
         */
        protected function newInstance() {
-               return new ExtendedSQLiteAbstraction( new 
LazyDBConnectionProvider( DB_MASTER ) );
+               return new SQLiteTableSqlBuilder( new LazyDBConnectionProvider( 
DB_MASTER ) );
        }
 
 }
diff --git a/tests/phpunit/MWDB/ExtendedAbstractionTest.php 
b/tests/phpunit/TableSqlBuilderTest.php
similarity index 91%
rename from tests/phpunit/MWDB/ExtendedAbstractionTest.php
rename to tests/phpunit/TableSqlBuilderTest.php
index bd70018..21938e7 100644
--- a/tests/phpunit/MWDB/ExtendedAbstractionTest.php
+++ b/tests/phpunit/TableSqlBuilderTest.php
@@ -2,12 +2,12 @@
 
 namespace Wikibase\Database\Tests\MWDB;
 
-use Wikibase\Database\MWDB\ExtendedAbstraction;
+use Wikibase\Database\TableSqlBuilder;
 use Wikibase\Database\TableDefinition;
 use Wikibase\Database\FieldDefinition;
 
 /**
- * Base class with tests for the Wikibase\Database\MWDB\ExtendedAbstraction 
deriving classes.
+ * @covers Wikibase\Database\TableSqlBuilder
  *
  * @file
  * @since 0.1
@@ -20,7 +20,7 @@
 abstract class ExtendedAbstractionTest extends \PHPUnit_Framework_TestCase {
 
        /**
-        * @return ExtendedAbstraction
+        * @return TableSqlBuilder
         */
        protected abstract function newInstance();
 
@@ -81,7 +81,7 @@
                        'Table should not exist before creation'
                );
 
-               $success = $extendedAbstraction->createTable( $table );
+               $success = $extendedAbstraction->getCreateTableSql( $table );
 
                $this->assertTrue(
                        $success,

-- 
To view, visit https://gerrit.wikimedia.org/r/75873
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I0cc82d12e80495d75fd810820c6527ba410affdd
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/WikibaseDatabase
Gerrit-Branch: master
Gerrit-Owner: Jeroen De Dauw <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to