Commit 56ace1cb authored by catch's avatar catch
Browse files

Issue #2225473 by mcjim: Move database fakes out of migrate module so they can...

Issue #2225473 by mcjim: Move database fakes out of migrate module so they can be used in non-migrate tests.
parent ef650e72
...@@ -2,11 +2,11 @@ ...@@ -2,11 +2,11 @@
/** /**
* @file * @file
* Contains \Drupal\migrate\Tests\ConditionResolver. * Contains Drupal\Core\Database\Driver\fake\ConditionResolver.
*/ */
namespace Drupal\migrate\Tests; namespace Drupal\Core\Database\Driver\fake;
use Drupal\Core\Database\Query\Condition; use Drupal\Core\Database\Query\Condition;
...@@ -15,7 +15,7 @@ class ConditionResolver { ...@@ -15,7 +15,7 @@ class ConditionResolver {
/** /**
* Match a row against a group of conditions. * Match a row against a group of conditions.
* *
* @param \Drupal\migrate\tests\DatabaseRowInterface $row * @param \Drupal\Core\Database\Driver\fake\DatabaseRowInterface $row
* The database row object. * The database row object.
* @param \Drupal\Core\Database\Query\Condition $condition_group * @param \Drupal\Core\Database\Query\Condition $condition_group
* The condition group object. * The condition group object.
......
...@@ -2,10 +2,10 @@ ...@@ -2,10 +2,10 @@
/** /**
* @file * @file
* Contains \Drupal\migrate\Tests\DatabaseRow. * Contains Drupal\Core\Database\Driver\fake\DatabaseRow.
*/ */
namespace Drupal\migrate\Tests; namespace Drupal\Core\Database\Driver\fake;
class DatabaseRow implements DatabaseRowInterface { class DatabaseRow implements DatabaseRowInterface {
......
...@@ -2,10 +2,10 @@ ...@@ -2,10 +2,10 @@
/** /**
* @file * @file
* Contains \Drupal\migrate\Tests\DatabaseRowInterface. * Contains Drupal\Core\Database\Driver\fake\DatabaseRowInterface.
*/ */
namespace Drupal\migrate\Tests; namespace Drupal\Core\Database\Driver\fake;
interface DatabaseRowInterface { interface DatabaseRowInterface {
......
...@@ -2,10 +2,10 @@ ...@@ -2,10 +2,10 @@
/** /**
* @file * @file
* Contains \Drupal\migrate\Tests\DatabaseRowSelect. * Contains Drupal\Core\Database\Driver\fake\DatabaseRowSelect.
*/ */
namespace Drupal\migrate\Tests; namespace Drupal\Core\Database\Driver\fake;
class DatabaseRowSelect extends DatabaseRow { class DatabaseRowSelect extends DatabaseRow {
......
...@@ -2,10 +2,10 @@ ...@@ -2,10 +2,10 @@
/** /**
* @file * @file
* Contains \Drupal\migrate\Tests\FakeConnection. * Contains Drupal\Core\Database\Driver\fake\FakeConnection.
*/ */
namespace Drupal\migrate\Tests; namespace Drupal\Core\Database\Driver\fake;
use Drupal\Core\Database\Connection; use Drupal\Core\Database\Connection;
......
...@@ -2,10 +2,10 @@ ...@@ -2,10 +2,10 @@
/** /**
* @file * @file
* Contains \Drupal\migrate\Tests\FakeDatabaseSchema. * Contains Drupal\Core\Database\Driver\fake\FakeDatabaseSchema.
*/ */
namespace Drupal\migrate\Tests; namespace Drupal\Core\Database\Driver\fake;
use Drupal\Core\Database\Schema; use Drupal\Core\Database\Schema;
......
...@@ -2,10 +2,10 @@ ...@@ -2,10 +2,10 @@
/** /**
* @file * @file
* Contains \Drupal\migrate\Tests\FakeInsert. * Contains Drupal\Core\Database\Driver\fake\FakeInsert.
*/ */
namespace Drupal\migrate\Tests; namespace Drupal\Core\Database\Driver\fake;
use Drupal\Core\Database\Query\Insert; use Drupal\Core\Database\Query\Insert;
use Drupal\Core\Database\Query\SelectInterface; use Drupal\Core\Database\Query\SelectInterface;
......
...@@ -2,10 +2,10 @@ ...@@ -2,10 +2,10 @@
/** /**
* @file * @file
* Contains \Drupal\migrate\Tests\FakeMerge. * Contains Drupal\Core\Database\Driver\fake\FakeMerge.
*/ */
namespace Drupal\migrate\Tests; namespace Drupal\Core\Database\Driver\fake;
use Drupal\Core\Database\Query\Condition; use Drupal\Core\Database\Query\Condition;
use Drupal\Core\Database\Query\InvalidMergeQueryException; use Drupal\Core\Database\Query\InvalidMergeQueryException;
......
...@@ -2,10 +2,10 @@ ...@@ -2,10 +2,10 @@
/** /**
* @file * @file
* Contains \Drupal\migrate\Tests\FakeSelect. * Contains Drupal\Core\Database\Driver\fake\FakeSelect.
*/ */
namespace Drupal\migrate\Tests; namespace Drupal\Core\Database\Driver\fake;
use Drupal\Component\Utility\String; use Drupal\Component\Utility\String;
use Drupal\Core\Database\Connection; use Drupal\Core\Database\Connection;
...@@ -302,7 +302,7 @@ protected function sortCallback($a, $b) { ...@@ -302,7 +302,7 @@ protected function sortCallback($a, $b) {
* @param array $rows * @param array $rows
* An array of rows excluding non-matching rows. * An array of rows excluding non-matching rows.
* *
* @return \Drupal\migrate\Tests\ConditionResolver * @return \Drupal\Core\Database\Driver\fake\ConditionResolver
* The condition resolver object. * The condition resolver object.
*/ */
protected function resolveConditions(Condition $condition_group, array &$rows) { protected function resolveConditions(Condition $condition_group, array &$rows) {
......
...@@ -2,10 +2,10 @@ ...@@ -2,10 +2,10 @@
/** /**
* @file * @file
* Contains \Drupal\migrate\Tests\FakeStatement. * Contains Drupal\Core\Database\Driver\fake\FakeStatement.
*/ */
namespace Drupal\migrate\Tests; namespace Drupal\Core\Database\Driver\fake;
use Drupal\Core\Database\RowCountException; use Drupal\Core\Database\RowCountException;
use Drupal\Core\Database\StatementInterface; use Drupal\Core\Database\StatementInterface;
......
...@@ -2,10 +2,10 @@ ...@@ -2,10 +2,10 @@
/** /**
* @file * @file
* Contains \Drupal\migrate\Tests\FakeTruncate. * Contains Drupal\Core\Database\Driver\fake\FakeTruncate.
*/ */
namespace Drupal\migrate\Tests; namespace Drupal\Core\Database\Driver\fake;
/** /**
* Defines FakeTruncate for use in database tests. * Defines FakeTruncate for use in database tests.
......
...@@ -2,10 +2,10 @@ ...@@ -2,10 +2,10 @@
/** /**
* @file * @file
* Contains \Drupal\migrate\Tests\FakeUpdate. * Contains Drupal\Core\Database\Driver\fake\FakeUpdate.
*/ */
namespace Drupal\migrate\Tests; namespace Drupal\Core\Database\Driver\fake;
use Drupal\Core\Database\Query\Condition; use Drupal\Core\Database\Query\Condition;
use Drupal\Core\Database\Query\SelectInterface; use Drupal\Core\Database\Query\SelectInterface;
......
<?php
/**
* @file
* Definition of Drupal\Core\Database\Driver\fake\Install\Tasks
*/
namespace Drupal\Core\Database\Driver\fake\Install;
use Drupal\Core\Database\Install\Tasks as InstallTasks;
use Drupal\Core\Database\Database;
use Drupal\Core\Database\Driver\mysql\Connection;
use Drupal\Core\Database\DatabaseNotFoundException;
/**
* Usually used to specify installation tasks but here we're only interested
* in setting $error to TRUE.
*/
class Tasks extends InstallTasks {
/**
* Prevent the installer from recognising this as a potential database driver.
* @TODO Looks like this is needed only if we define $pdoDriver to something valid e.g. mysql.
* Not sure we need to do that. We may not need this file at all?
*
* @var boolean
*/
protected $error = TRUE;
/**
* {@inheritdoc}
*/
public function name() {
return t('Fake database connection for use in unit tests');
}
}
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
namespace Drupal\migrate\Tests; namespace Drupal\migrate\Tests;
use Drupal\Tests\UnitTestCase; use Drupal\Tests\UnitTestCase;
use Drupal\Core\Database\Driver\fake\FakeConnection;
/** /**
* Provides setup and helper methods for Migrate module tests. * Provides setup and helper methods for Migrate module tests.
...@@ -62,7 +63,7 @@ protected function getMigration() { ...@@ -62,7 +63,7 @@ protected function getMigration() {
* @param string $prefix * @param string $prefix
* (optional) The table prefix on the database. * (optional) The table prefix on the database.
* *
* @return \Drupal\migrate\Tests\FakeConnection * @return \Drupal\Core\Database\Driver\fake\FakeConnection
* The database connection. * The database connection.
*/ */
protected function getDatabase(array $database_contents, $connection_options = array(), $prefix = '') { protected function getDatabase(array $database_contents, $connection_options = array(), $prefix = '') {
......
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