Jeroen De Dauw has submitted this change and it was merged.

Change subject: Expand integration test to use DefinitionReader
......................................................................


Expand integration test to use DefinitionReader

The previous TableCreationAndDeletion test now also
uses a TableDefinitionReader in its execution making
sure the defintion that is read is equal to that
that was initially created

This change also fixes various small issues through
both the MySql and SQLite classes

Change-Id: I10808c074a39a28a906f668a4260ca9abbafa25b
---
M src/MediaWiki/MediaWikiQueryInterface.php
M src/MediaWiki/MediaWikiTableBuilder.php
M src/MySQL/MySQLTableDefinitionReader.php
M src/MySQL/MySQLTableSqlBuilder.php
M src/SQLite/SQLiteFieldSqlBuilder.php
M src/SQLite/SQLiteSchemaSqlBuilder.php
M src/SQLite/SQLiteTableDefinitionReader.php
M src/SQLite/SQLiteTableSqlBuilder.php
R tests/integration/MediaWiki/Schema/TableCreateReadDeleteTest.php
M tests/phpunit/MySQL/MySQLTableDefinitionReaderTest.php
M tests/phpunit/MySQL/MySQLTableSqlBuilderTest.php
M tests/phpunit/SQLite/SQLiteSchemaSqlBuilderTest.php
M tests/phpunit/SQLite/SQLiteTableDefinitionReaderTest.php
M tests/phpunit/SQLite/SQLiteTableSqlBuilderTest.php
14 files changed, 120 insertions(+), 76 deletions(-)

Approvals:
  Jeroen De Dauw: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/src/MediaWiki/MediaWikiQueryInterface.php 
b/src/MediaWiki/MediaWikiQueryInterface.php
index bea4790..6976173 100644
--- a/src/MediaWiki/MediaWikiQueryInterface.php
+++ b/src/MediaWiki/MediaWikiQueryInterface.php
@@ -150,7 +150,7 @@
        public function select( $tableName, array $fields, array $conditions, 
array $options = array() ) {
                $selectionResult = $this->getDB()->select(
                        $tableName,
-                        $fields,
+                       $fields,
                        $conditions,
                        __METHOD__,
                        $options
diff --git a/src/MediaWiki/MediaWikiTableBuilder.php 
b/src/MediaWiki/MediaWikiTableBuilder.php
index 5b6a030..c5fcf6c 100644
--- a/src/MediaWiki/MediaWikiTableBuilder.php
+++ b/src/MediaWiki/MediaWikiTableBuilder.php
@@ -71,11 +71,14 @@
        public function createTable( TableDefinition $table ) {
                $sql = $this->tableSqlBuilder->getCreateTableSql( $table );
 
-               $success = $this->getDB()->query( $sql );
+               foreach( explode( PHP_EOL, $sql ) as $query ){
+                       $success = $this->getDB()->query( $query );
 
-               if ( $success === false ) {
-                       throw new TableCreationFailedException( $table, 
$this->getDB()->lastError() );
+                       if ( $success === false ) {
+                               throw new TableCreationFailedException( $table, 
$this->getDB()->lastError() );
+                       }
                }
+
        }
 
        /**
diff --git a/src/MySQL/MySQLTableDefinitionReader.php 
b/src/MySQL/MySQLTableDefinitionReader.php
index 22afbae..20ba608 100644
--- a/src/MySQL/MySQLTableDefinitionReader.php
+++ b/src/MySQL/MySQLTableDefinitionReader.php
@@ -50,23 +50,23 @@
         */
        private function getFields( $tableName ) {
                $results = $this->queryInterface->select(
-                       'information_schema.COLUMNS',
+                       'INFORMATION_SCHEMA.COLUMNS',
                        array(
                                'name' => 'COLUMN_NAME',
                                'cannull' => 'IS_NULLABLE',
                                'type' => 'DATA_TYPE',
-                               'default' => 'COLUMN_DEFAULT' ),
-                       array( 'TABLE_SCHEMA' => $tableName )
+                               'defaultvalue' => 'COLUMN_DEFAULT', ),
+                       array( 'TABLE_NAME' => $tableName )
                );
 
                $fields = array();
                foreach( $results as $field ){
 
                        $fields[] = new FieldDefinition(
-                               $field['name'],
-                               $this->getDataType( $field['type'] ),
-                               $this->getNullable( $field['cannull'] ),
-                               $field['default'] );
+                               $field->name,
+                               $this->getDataType( $field->type ),
+                               $this->getNullable( $field->cannull ),
+                               $field->defaultvalue );
                }
 
                return $fields;
@@ -82,7 +82,7 @@
                $indexes = array();
 
                $constraintsResult = $this->queryInterface->select(
-                       'information_schema.table_constraints',
+                       'INFORMATION_SCHEMA.TABLE_CONSTRAINTS',
                        array(
                                'name' => 'CONSTRAINT_NAME',
                                'type' => 'CONSTRAINT_TYPE',
@@ -90,40 +90,44 @@
                        array( 'TABLE_NAME' => $tableName )
                );
 
+               //TODO FIXME the below check for constraints will never work as 
$constraint->columns is undefined...
+               //TODO check unit tests and write an integration test...
                foreach( $constraintsResult as $constraint ) {
-                       if( $constraint['type'] === 'PRIMARY KEY' ) {
+                       if( $constraint->type === 'PRIMARY KEY' ) {
                                $type = IndexDefinition::TYPE_PRIMARY;
-                       } else if( $constraint['type'] === 'UNIQUE' ) {
+                       } else if( $constraint->type === 'UNIQUE' ) {
                                $type = IndexDefinition::TYPE_UNIQUE;
                        } else {
                                throw new QueryInterfaceException(
                                        'Unknown Constraint when reading 
definition ' .
-                                       $constraint['name'] . ', ' . 
$constraint['type'] );
+                                       $constraint->name . ', ' . 
$constraint->type );
                        }
-                       $indexes[] = new IndexDefinition( $constraint['name'] , 
$constraint['columns'] , $type );
+                       $indexes[] = new IndexDefinition( $constraint->name , 
$constraint->columns , $type );
                }
 
                $indexesResult = $this->queryInterface->select(
-                       'information_schema.statistics',
+                       'INFORMATION_SCHEMA.STATISTICS',
                        array(
-                               'name' => 'index_name',
-                               'columns' => 'GROUP_CONCAT(column_name ORDER BY 
seq_in_index)' ),
+                               'COLUMN_NAME',
+                               'SEQ_IN_INDEX',
+                               'name' => 'INDEX_NAME',
+                               'columns' => 'GROUP_CONCAT(COLUMN_NAME ORDER BY 
SEQ_IN_INDEX)' ),
                        array( 'TABLE_NAME' => $tableName ),
-                       array( 'GROUP BY' => '1,2' )
+                       array( 'GROUP BY' => 'name' )
                );
 
                foreach( $indexesResult as $index ){
                        //ignore any indexes we already have (primary and 
unique)
                        foreach( $constraintsResult as $constraint ){
-                               if( $constraint['name'] === $index['name'] ){
+                               if( $constraint->name === $index->name ){
                                        continue 2;
                                }
                        }
                        $cols = array();
-                       foreach( explode( ',', $index['columns'] ) as $col ){
+                       foreach( explode( ',', $index->columns ) as $col ){
                                $cols[ $col ] = 0;
                        }
-                       $indexes[] = new IndexDefinition( $index['name'], $cols 
, IndexDefinition::TYPE_INDEX );
+                       $indexes[] = new IndexDefinition( $index->name, $cols , 
IndexDefinition::TYPE_INDEX );
                }
 
                return $indexes;
@@ -138,7 +142,7 @@
                if( stristr( $dataType, 'blob' ) ){
                        return FieldDefinition::TYPE_TEXT;
                } else if ( stristr( $dataType, 'tinyint' ) ){
-                       return FieldDefinition::TYPE_INTEGER;
+                       return FieldDefinition::TYPE_BOOLEAN;
                } else if ( stristr( $dataType, 'int' ) ){
                        return FieldDefinition::TYPE_INTEGER;
                } else if ( stristr( $dataType, 'float' ) ){
diff --git a/src/MySQL/MySQLTableSqlBuilder.php 
b/src/MySQL/MySQLTableSqlBuilder.php
index d0bc8e0..20316d5 100644
--- a/src/MySQL/MySQLTableSqlBuilder.php
+++ b/src/MySQL/MySQLTableSqlBuilder.php
@@ -62,7 +62,7 @@
 
                $sql .= implode( ', ', $queryParts );
 
-               $sql .= ') ' . 'ENGINE=InnoDB, DEFAULT CHARSET=binary';
+               $sql .= ') ' . 'ENGINE=InnoDB, DEFAULT CHARSET=binary;';
 
                return $sql;
        }
diff --git a/src/SQLite/SQLiteFieldSqlBuilder.php 
b/src/SQLite/SQLiteFieldSqlBuilder.php
index 13eba45..3a3d048 100644
--- a/src/SQLite/SQLiteFieldSqlBuilder.php
+++ b/src/SQLite/SQLiteFieldSqlBuilder.php
@@ -28,15 +28,19 @@
 
                $sql .= $this->getFieldType( $field->getType() );
 
-               $sql .= $this->getDefault( $field->getDefault() );
+               $sql .= $this->getDefault( $field->getDefault(), 
$field->getType() );
 
                $sql .= $this->getNull( $field->allowsNull() );
 
                return $sql;
        }
 
-       protected function getDefault( $default ) {
+       protected function getDefault( $default, $type ) {
                if ( $default !== null ) {
+                       //TODO ints shouldn't have quotes added to them so we 
can not use the escaper used for strings below???
+                       if( $type === FieldDefinition::TYPE_INTEGER ){
+                               return ' DEFAULT ' . $default;
+                       }
                        return ' DEFAULT ' . $this->escaper->getEscapedValue( 
$default );
                }
 
diff --git a/src/SQLite/SQLiteSchemaSqlBuilder.php 
b/src/SQLite/SQLiteSchemaSqlBuilder.php
index e97f10d..b8bf44c 100644
--- a/src/SQLite/SQLiteSchemaSqlBuilder.php
+++ b/src/SQLite/SQLiteSchemaSqlBuilder.php
@@ -44,13 +44,13 @@
                $definition = $this->tableDefinitionReader->readDefinition( 
$tableName );
                $tableName = $this->tableNameFormatter->formatTableName( 
$tableName );
                $tmpTableName = $this->tableNameFormatter->formatTableName( 
$tableName . '_tmp' );
-               $sql = "ALTER TABLE {$tableName} RENAME TO {$tmpTableName};";
+               $sql = "ALTER TABLE {$tableName} RENAME TO {$tmpTableName};" . 
PHP_EOL;
 
                $definition = $definition->mutateFieldAway( $fieldName );
-               $sql .= $this->tableSqlBuilder->getCreateTableSql( $definition 
);
+               $sql .= $this->tableSqlBuilder->getCreateTableSql( $definition 
) . PHP_EOL;
 
                $fieldsSql = $this->getFieldsSql( $definition->getFields() );
-               $sql .= "INSERT INTO {$tableName}({$fieldsSql}) SELECT 
{$fieldsSql} FROM {$tmpTableName};";
+               $sql .= "INSERT INTO {$tableName}({$fieldsSql}) SELECT 
{$fieldsSql} FROM {$tmpTableName};" . PHP_EOL;
                $sql .= "DROP TABLE {$tmpTableName};";
 
                return $sql;
diff --git a/src/SQLite/SQLiteTableDefinitionReader.php 
b/src/SQLite/SQLiteTableDefinitionReader.php
index 57f9280..e783da3 100644
--- a/src/SQLite/SQLiteTableDefinitionReader.php
+++ b/src/SQLite/SQLiteTableDefinitionReader.php
@@ -2,6 +2,7 @@
 
 namespace Wikibase\Database\SQLite;
 
+use RuntimeException;
 use Wikibase\Database\QueryInterface\QueryInterface;
 use Wikibase\Database\QueryInterface\QueryInterfaceException;
 use Wikibase\Database\Schema\Definitions\FieldDefinition;
@@ -48,9 +49,8 @@
        private function getFields( $tableName ) {
                $results = $this->queryInterface->select(
                        'sqlite_master',
-                       array( 'name', 'sql' ),
-                       array( 'type' => 'table', 'tbl_name' => $tableName )
-               );
+                       array( 'sql' ),
+                       array( 'type' => 'table', 'tbl_name' => $tableName ) );
 
                if( iterator_count( $results ) > 1 ){
                        throw new QueryInterfaceException( "More than one set 
of fields returned for {$tableName}" );
@@ -58,7 +58,7 @@
                $fields = array();
 
                foreach( $results as $result ){
-                       preg_match( '/CREATE TABLE ([^ ]+) \(([^\)]+)\)/', 
$result['sql'], $createParts );
+                       preg_match( '/CREATE TABLE ([^ ]+) \(([^\)]+)\)/', 
$result->sql, $createParts );
                        /** 1 => tableName, 2 => fieldParts (fields, keys, 
etc.) */
 
                        foreach( explode( ',', $createParts[2] ) as $fieldSql ){
@@ -66,21 +66,7 @@
                                        $fieldParts[0] !== 'PRIMARY KEY' ){
                                        /** 1 => column, 2 => type, 4 => 
default, 6 => NotNull */
 
-                                       $type = $fieldParts[2];
-                                       switch ( $type ) {
-                                               case 'BOOL':
-                                                       $type = 'bool';
-                                                       break;
-                                               case 'BLOB':
-                                                       $type = 'str';
-                                                       break;
-                                               case 'INT':
-                                                       $type = 'int';
-                                                       break;
-                                               case 'FLOAT':
-                                                       $type = 'float';
-                                                       break;
-                                       }
+                                       $type = $this->getFieldType( 
$fieldParts[2] );
 
                                        if( !empty( $fieldParts[4] ) ){
                                                $default = $fieldParts[4];
@@ -105,13 +91,13 @@
        private function getIndexes( $tableName ) {
                $results = $this->queryInterface->select(
                        'sqlite_master',
-                       array( 'name', 'sql' ),
+                       array( 'sql' ),
                        array( 'type' => 'index', 'tbl_name' => $tableName )
                );
                $indexes = array();
 
                foreach( $results as $result ){
-                       preg_match( '/CREATE ([^ ]+) ([^ ]+) ON ([^ ]+) 
\((.+)\)\z/', $result['sql'], $createParts );
+                       preg_match( '/CREATE ([^ ]+) ([^ ]+) ON ([^ ]+) 
\((.+)\)\z/', $result->sql, $createParts );
                        $parsedColumns = explode( ',', $createParts[4] );
                        $columns = array();
                        foreach( $parsedColumns as $columnName ){
@@ -128,12 +114,12 @@
                $keys = array();
                $results = $this->queryInterface->select(
                        'sqlite_master',
-                       array( 'name', 'sql' ),
-                       array( 'type' => 'table', 'tbl_name' => $tableName, 
"instr(sql, 'PRIMARY KEY') > 0" )
+                       array( 'sql' ),
+                       array( 'type' => 'table', 'tbl_name' => $tableName, 
"sql LIKE '%PRIMARY KEY%'" )
                );
 
                foreach( $results as $result ){
-                       if( preg_match( '/PRIMARY KEY \(([^\)]+)\)/', 
$result['sql'], $createParts ) ){
+                       if( preg_match( '/PRIMARY KEY \(([^\)]+)\)/', 
$result->sql, $createParts ) ){
                                /**  0 => PRIMARY KEY (column1, column2), 1 => 
column1, column2 */
                                $parsedColumns = explode( ',', $createParts[1] 
);
                                $columns = array();
@@ -148,4 +134,24 @@
                return $keys;
        }
 
+       private function getFieldType( $type ) {
+               switch ( $type ) {
+                       case 'TINYINT':
+                               return 'bool';
+                               break;
+                       case 'BLOB':
+                               return 'str';
+                               break;
+                       case 'INT':
+                               return 'int';
+                               break;
+                       case 'FLOAT':
+                               return 'float';
+                               break;
+                       default:
+                               throw new RuntimeException( __CLASS__ . ' does 
not support db fields of type ' . $type );
+               }
+
+       }
+
 }
diff --git a/src/SQLite/SQLiteTableSqlBuilder.php 
b/src/SQLite/SQLiteTableSqlBuilder.php
index 83510e5..44079ca 100644
--- a/src/SQLite/SQLiteTableSqlBuilder.php
+++ b/src/SQLite/SQLiteTableSqlBuilder.php
@@ -60,7 +60,7 @@
                $sql .= ');';
 
                foreach ( $table->getIndexes() as $index ){
-                       $sql .= $this->indexSqlBuilder->getIndexSQL( $index, 
$table->getName() );
+                       $sql .= PHP_EOL . $this->indexSqlBuilder->getIndexSQL( 
$index, $table->getName() );
                }
 
                return $sql;
diff --git 
a/tests/integration/MediaWiki/Schema/TableCreationAndDeletionTest.php 
b/tests/integration/MediaWiki/Schema/TableCreateReadDeleteTest.php
similarity index 74%
rename from tests/integration/MediaWiki/Schema/TableCreationAndDeletionTest.php
rename to tests/integration/MediaWiki/Schema/TableCreateReadDeleteTest.php
index 5fc3a1f..f2d051d 100644
--- a/tests/integration/MediaWiki/Schema/TableCreationAndDeletionTest.php
+++ b/tests/integration/MediaWiki/Schema/TableCreateReadDeleteTest.php
@@ -2,25 +2,25 @@
 
 namespace Wikibase\Database\Tests;
 
+use Wikibase\Database\MediaWiki\MediaWikiQueryInterface;
 use Wikibase\Database\MediaWiki\MWTableBuilderBuilder;
+use Wikibase\Database\MediaWiki\MWTableDefinitionReaderBuilder;
 use Wikibase\Database\Schema\Definitions\FieldDefinition;
 use Wikibase\Database\Schema\Definitions\IndexDefinition;
 use Wikibase\Database\LazyDBConnectionProvider;
 use Wikibase\Database\Schema\Definitions\TableDefinition;
 
 /**
- * @file
  * @since 0.1
- *
- * @ingroup WikibaseDatabaseTest
  *
  * @group Wikibase
  * @group WikibaseDatabase
  *
  * @licence GNU GPL v2+
  * @author Jeroen De Dauw < jeroended...@gmail.com >
+ * @author Adam Shorland
  */
-class TableCreationAndDeletionTest extends \PHPUnit_Framework_TestCase {
+class TableCreateReadDeleteTest extends \PHPUnit_Framework_TestCase {
 
        protected function tearDown() {
                parent::tearDown();
@@ -43,6 +43,19 @@
 
                $tbBuilder = new MWTableBuilderBuilder();
                return $tbBuilder->setConnection( $connectionProvider 
)->getTableBuilder();
+       }
+
+       protected function newTableReader() {
+               $connectionProvider = new LazyDBConnectionProvider( DB_MASTER );
+
+               $trBuilder = new MWTableDefinitionReaderBuilder();
+               return $trBuilder->setConnection( $connectionProvider 
)->getTableDefinitionReader( $this->newQueryInterface() );
+       }
+
+       protected function newQueryInterface() {
+               $connectionProvider = new LazyDBConnectionProvider( DB_MASTER );
+
+               return new MediaWikiQueryInterface( $connectionProvider );
        }
 
        public function tableProvider() {
@@ -70,9 +83,9 @@
                ) );
 
                $tables[] = new TableDefinition( 'default_field_values', array(
-                       new FieldDefinition( 'intfield', 
FieldDefinition::TYPE_INTEGER, false ),
-                       new FieldDefinition( 'floatfield', 
FieldDefinition::TYPE_FLOAT, false ),
-                       new FieldDefinition( 'boolfield', 
FieldDefinition::TYPE_BOOLEAN, false ),
+                               new FieldDefinition( 'intfield', 
FieldDefinition::TYPE_INTEGER, false ),
+                               new FieldDefinition( 'floatfield', 
FieldDefinition::TYPE_FLOAT, false ),
+                               new FieldDefinition( 'boolfield', 
FieldDefinition::TYPE_BOOLEAN, false ),
                        ),
                        array( new IndexDefinition( 'somename', array( 
'intfield' => 0, 'floatfield' => 0 ) ) )
                );
@@ -106,6 +119,13 @@
                        'Table "' . $table->getName() . '" exists after 
creation'
                );
 
+               $tableReader = $this->newTableReader();
+
+               $this->assertEquals(
+                       $table,
+                       $tableReader->readDefinition( $table->getName() )
+               );
+
                $tableBuilder->dropTable( $table->getName() );
 
                $this->assertFalse(
diff --git a/tests/phpunit/MySQL/MySQLTableDefinitionReaderTest.php 
b/tests/phpunit/MySQL/MySQLTableDefinitionReaderTest.php
index 876c239..6a09747 100644
--- a/tests/phpunit/MySQL/MySQLTableDefinitionReaderTest.php
+++ b/tests/phpunit/MySQL/MySQLTableDefinitionReaderTest.php
@@ -54,13 +54,13 @@
                $argLists[] = array(
                        array(
                                array(
-                                       array( 'name' => 'primaryField', 'type' 
=> 'INT', 'cannull' => 'NO', 'default' => null ),
-                                       array( 'name' => 'textField', 'type' => 
'BLOB', 'cannull' => 'YES', 'default' => null ),
-                                       array( 'name' => 'intField', 'type' => 
'INT', 'cannull' => 'NO', 'default' => 42 ),
+                                       (object)array( 'name' => 
'primaryField', 'type' => 'INT', 'cannull' => 'NO', 'defaultvalue' => null ),
+                                       (object)array( 'name' => 'textField', 
'type' => 'BLOB', 'cannull' => 'YES', 'defaultvalue' => null ),
+                                       (object)array( 'name' => 'intField', 
'type' => 'INT', 'cannull' => 'NO', 'defaultvalue' => 42 ),
                                ),
                                //TODO test UNIQUE and PRIMARY keys
-                               array( array( ) ),
-                               array( array( 'name' => 'indexName', 'columns' 
=> 'intField,textField' ) )
+                               array( null ),
+                               array( (object)array( 'name' => 'indexName', 
'columns' => 'intField,textField' ) )
                        ),
                        new TableDefinition(
                                'dbNametableName',
diff --git a/tests/phpunit/MySQL/MySQLTableSqlBuilderTest.php 
b/tests/phpunit/MySQL/MySQLTableSqlBuilderTest.php
index 52cd4a8..67032ab 100644
--- a/tests/phpunit/MySQL/MySQLTableSqlBuilderTest.php
+++ b/tests/phpunit/MySQL/MySQLTableSqlBuilderTest.php
@@ -67,7 +67,7 @@
                                        new FieldDefinition( 'fieldName', 
FieldDefinition::TYPE_INTEGER )
                                )
                        ),
-                       'CREATE TABLE `dbName`.tableName (fieldName INT NULL) 
ENGINE=InnoDB, DEFAULT CHARSET=binary'
+                       'CREATE TABLE `dbName`.tableName (fieldName INT NULL) 
ENGINE=InnoDB, DEFAULT CHARSET=binary;'
                );
 
                $argLists[] = array(
@@ -85,7 +85,7 @@
                                        ),
                                )
                        ),
-                       'CREATE TABLE `dbName`.tableName (primaryField INT NOT 
NULL, textField BLOB NULL, intField INT DEFAULT 42 NOT NULL) ENGINE=InnoDB, 
DEFAULT CHARSET=binary'
+                       'CREATE TABLE `dbName`.tableName (primaryField INT NOT 
NULL, textField BLOB NULL, intField INT DEFAULT 42 NOT NULL) ENGINE=InnoDB, 
DEFAULT CHARSET=binary;'
                );
 
 
@@ -106,7 +106,7 @@
                                        ),
                                )
                        ),
-                       'CREATE TABLE `dbName`.tableName (textField BLOB NULL, 
intField INT DEFAULT 42 NOT NULL, INDEX `indexName` (`textField`,`intField`)) 
ENGINE=InnoDB, DEFAULT CHARSET=binary'
+                       'CREATE TABLE `dbName`.tableName (textField BLOB NULL, 
intField INT DEFAULT 42 NOT NULL, INDEX `indexName` (`textField`,`intField`)) 
ENGINE=InnoDB, DEFAULT CHARSET=binary;'
                );
 
                $argLists[] = array(
@@ -132,7 +132,7 @@
                                        ),
                                )
                        ),
-                       'CREATE TABLE `dbName`.tableName (textField BLOB NULL, 
intField INT DEFAULT 42 NOT NULL, textField2 BLOB NULL, INDEX `indexName` 
(`intField`), UNIQUE INDEX `uniqueIndexName` (`textField2`)) ENGINE=InnoDB, 
DEFAULT CHARSET=binary'
+                       'CREATE TABLE `dbName`.tableName (textField BLOB NULL, 
intField INT DEFAULT 42 NOT NULL, textField2 BLOB NULL, INDEX `indexName` 
(`intField`), UNIQUE INDEX `uniqueIndexName` (`textField2`)) ENGINE=InnoDB, 
DEFAULT CHARSET=binary;'
                );
 
                return $argLists;
diff --git a/tests/phpunit/SQLite/SQLiteSchemaSqlBuilderTest.php 
b/tests/phpunit/SQLite/SQLiteSchemaSqlBuilderTest.php
index a301f1e..b13e7da 100644
--- a/tests/phpunit/SQLite/SQLiteSchemaSqlBuilderTest.php
+++ b/tests/phpunit/SQLite/SQLiteSchemaSqlBuilderTest.php
@@ -67,7 +67,13 @@
 
                $instance = $this->newInstance( $existingDefinition );
                $sql = $instance->getRemoveFieldSql( 'tableName', 'textField' );
-               $this->assertEquals( 'ALTER TABLE tableName RENAME TO 
tableName_tmp;CREATE TABLE tableName (primaryField INT NOT NULL, intField INT 
DEFAULT 42 NOT NULL);CREATE INDEX INDEX ON tableName 
(intField,primaryField);INSERT INTO tableName(primaryField, intField) SELECT 
primaryField, intField FROM tableName_tmp;DROP TABLE tableName_tmp;', $sql );
+               $this->assertEquals(
+                       'ALTER TABLE tableName RENAME TO tableName_tmp;' . 
PHP_EOL
+                       . 'CREATE TABLE tableName (primaryField INT NOT NULL, 
intField INT DEFAULT 42 NOT NULL);' . PHP_EOL
+                       . 'CREATE INDEX INDEX ON tableName 
(intField,primaryField);' . PHP_EOL
+                       . 'INSERT INTO tableName(primaryField, intField) SELECT 
primaryField, intField FROM tableName_tmp;' . PHP_EOL
+                       . 'DROP TABLE tableName_tmp;' ,
+                       $sql );
        }
 
        public function testGetAddFieldSql(){
diff --git a/tests/phpunit/SQLite/SQLiteTableDefinitionReaderTest.php 
b/tests/phpunit/SQLite/SQLiteTableDefinitionReaderTest.php
index 7fc8731..9e080cb 100644
--- a/tests/phpunit/SQLite/SQLiteTableDefinitionReaderTest.php
+++ b/tests/phpunit/SQLite/SQLiteTableDefinitionReaderTest.php
@@ -53,9 +53,9 @@
 
                $argLists[] = array(
                        array(
-                               array( array( 'sql' => 'CREATE TABLE 
dbNametableName (primaryField INT NOT NULL, textField BLOB NULL, intField INT 
DEFAULT 42 NOT NULL, PRIMARY KEY (textField, primaryField))' ) ),
-                               array( array( 'sql' => 'CREATE INDEX indexName 
ON dbNametableName (intField,textField)' ) ),
-                               array( array( 'sql' => 'CREATE TABLE 
dbNametableName (primaryField INT NOT NULL, textField BLOB NULL, intField INT 
DEFAULT 42 NOT NULL, PRIMARY KEY (textField, primaryField))' ) ),
+                               array( (object)array( 'sql' => 'CREATE TABLE 
dbNametableName (primaryField INT NOT NULL, textField BLOB NULL, intField INT 
DEFAULT 42 NOT NULL, PRIMARY KEY (textField, primaryField))' ) ),
+                               array( (object)array( 'sql' => 'CREATE INDEX 
indexName ON dbNametableName (intField,textField)' ) ),
+                               array( (object)array( 'sql' => 'CREATE TABLE 
dbNametableName (primaryField INT NOT NULL, textField BLOB NULL, intField INT 
DEFAULT 42 NOT NULL, PRIMARY KEY (textField, primaryField))' ) ),
                        ),
                        new TableDefinition(
                                'dbNametableName',
diff --git a/tests/phpunit/SQLite/SQLiteTableSqlBuilderTest.php 
b/tests/phpunit/SQLite/SQLiteTableSqlBuilderTest.php
index a8b3ac1..725698b 100644
--- a/tests/phpunit/SQLite/SQLiteTableSqlBuilderTest.php
+++ b/tests/phpunit/SQLite/SQLiteTableSqlBuilderTest.php
@@ -121,7 +121,8 @@
                                        ),
                                )
                        ),
-                       'CREATE TABLE tableName (primaryField INT NOT NULL, 
textField BLOB NULL, intField INT DEFAULT 42 NOT NULL);CREATE INDEX indexName 
ON tableName (intField,textField);'
+                       'CREATE TABLE tableName (primaryField INT NOT NULL, 
textField BLOB NULL, intField INT DEFAULT 42 NOT NULL);' . PHP_EOL
+                       . 'CREATE INDEX indexName ON tableName 
(intField,textField);'
                );
 
                return $argLists;

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I10808c074a39a28a906f668a4260ca9abbafa25b
Gerrit-PatchSet: 6
Gerrit-Project: mediawiki/extensions/WikibaseDatabase
Gerrit-Branch: master
Gerrit-Owner: Addshore <addshorew...@gmail.com>
Gerrit-Reviewer: Jeroen De Dauw <jeroended...@gmail.com>
Gerrit-Reviewer: jenkins-bot

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to