Commit 629003e3 authored by catch's avatar catch

Issue #2454669 by amateescu: SQLite: Fix tests in migrate_drupal test group

parent a336347b
......@@ -359,4 +359,14 @@ public function nextId($existing_id = 0) {
return $this->query('SELECT value FROM {sequences}')->fetchField();
}
/**
* {@inheritdoc}
*/
public function getFullQualifiedTableName($table) {
$prefix = $this->tablePrefix($table);
// Don't include the SQLite database file name as part of the table name.
return $prefix . $table;
}
}
......@@ -130,6 +130,11 @@ protected function processField($field) {
else {
$map = $this->getFieldTypeMap();
$field['sqlite_type'] = $map[$field['type'] . ':' . $field['size']];
// Numeric fields with a specified scale have to be stored as floats.
if ($field['sqlite_type'] === 'NUMERIC' && isset($field['scale'])) {
$field['sqlite_type'] = 'FLOAT';
}
}
if (isset($field['type']) && $field['type'] == 'serial') {
......
......@@ -56,6 +56,9 @@ protected function setUp() {
// Simpletest uses 7 character prefixes at most so this can't cause
// collisions.
'default' => $value['prefix']['default'] . '0',
// Add the original simpletest prefix so SQLite can attach its database.
// @see \Drupal\Core\Database\Driver\sqlite\Connection::init()
$value['prefix']['default'] => $value['prefix']['default'],
);
}
Database::addConnectionInfo('migrate', 'default', $connection_info['default']);
......
......@@ -27,9 +27,10 @@ public function load() {
),
'fields' => array(
'vid' => array(
'type' => 'serial',
'type' => 'int',
'not null' => TRUE,
'length' => '10',
'default' => '0',
'unsigned' => TRUE,
),
'nid' => array(
......
This diff is collapsed.
......@@ -7,6 +7,7 @@
namespace Drupal\migrate_drupal\Tests\d6;
use Drupal\Core\Database\Database;
use Drupal\migrate\MigrateExecutable;
use Drupal\node\Entity\Node;
......@@ -190,8 +191,17 @@ public function testCckFields() {
$this->assertIdentical('5', $node->field_test_filefield->target_id);
$planet_node = Node::load(3);
$this->assertIdentical('33.00', $planet_node->field_multivalue->value);
$this->assertIdentical('44.00', $planet_node->field_multivalue[1]->value);
$value_1 = $planet_node->field_multivalue->value;
$value_2 = $planet_node->field_multivalue[1]->value;
// SQLite does not support scales for float data types so we need to convert
// the value manually.
if ($this->container->get('database')->driver() == 'sqlite') {
$value_1 = sprintf('%01.2f', $value_1);
$value_2 = sprintf('%01.2f', $value_2);
}
$this->assertIdentical('33.00', $value_1);
$this->assertIdentical('44.00', $value_2);
}
}
......@@ -125,4 +125,17 @@ function testLikeBackslash() {
->fetchField();
$this->assertIdentical($num_matches, '1', 'Found 1 record.');
}
/**
* Tests \Drupal\Core\Database\Connection::getFullQualifiedTableName().
*/
public function testGetFullQualifiedTableName() {
$database = \Drupal::database();
$num_matches = $database->select($database->getFullQualifiedTableName('test'), 't')
->countQuery()
->execute()
->fetchField();
$this->assertIdentical($num_matches, '4', 'Found 4 records.');
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment